162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Shared Atheros AR9170 Header
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * EEPROM layout
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
962306a36Sopenharmony_ci * it under the terms of the GNU General Public License as published by
1062306a36Sopenharmony_ci * the Free Software Foundation; either version 2 of the License, or
1162306a36Sopenharmony_ci * (at your option) any later version.
1262306a36Sopenharmony_ci *
1362306a36Sopenharmony_ci * This program is distributed in the hope that it will be useful,
1462306a36Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
1562306a36Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1662306a36Sopenharmony_ci * GNU General Public License for more details.
1762306a36Sopenharmony_ci *
1862306a36Sopenharmony_ci * You should have received a copy of the GNU General Public License
1962306a36Sopenharmony_ci * along with this program; see the file COPYING.  If not, see
2062306a36Sopenharmony_ci * http://www.gnu.org/licenses/.
2162306a36Sopenharmony_ci *
2262306a36Sopenharmony_ci * This file incorporates work covered by the following copyright and
2362306a36Sopenharmony_ci * permission notice:
2462306a36Sopenharmony_ci *    Copyright (c) 2007-2008 Atheros Communications, Inc.
2562306a36Sopenharmony_ci *
2662306a36Sopenharmony_ci *    Permission to use, copy, modify, and/or distribute this software for any
2762306a36Sopenharmony_ci *    purpose with or without fee is hereby granted, provided that the above
2862306a36Sopenharmony_ci *    copyright notice and this permission notice appear in all copies.
2962306a36Sopenharmony_ci *
3062306a36Sopenharmony_ci *    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3162306a36Sopenharmony_ci *    WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3262306a36Sopenharmony_ci *    MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3362306a36Sopenharmony_ci *    ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3462306a36Sopenharmony_ci *    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3562306a36Sopenharmony_ci *    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3662306a36Sopenharmony_ci *    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3762306a36Sopenharmony_ci */
3862306a36Sopenharmony_ci#ifndef __CARL9170_SHARED_EEPROM_H
3962306a36Sopenharmony_ci#define __CARL9170_SHARED_EEPROM_H
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#define AR9170_EEPROM_START		0x1600
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#define AR5416_MAX_CHAINS		2
4462306a36Sopenharmony_ci#define AR5416_MODAL_SPURS		5
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_cistruct ar9170_eeprom_modal {
4762306a36Sopenharmony_ci	__le32	antCtrlChain[AR5416_MAX_CHAINS];
4862306a36Sopenharmony_ci	__le32	antCtrlCommon;
4962306a36Sopenharmony_ci	s8	antennaGainCh[AR5416_MAX_CHAINS];
5062306a36Sopenharmony_ci	u8	switchSettling;
5162306a36Sopenharmony_ci	u8	txRxAttenCh[AR5416_MAX_CHAINS];
5262306a36Sopenharmony_ci	u8	rxTxMarginCh[AR5416_MAX_CHAINS];
5362306a36Sopenharmony_ci	s8	adcDesiredSize;
5462306a36Sopenharmony_ci	s8	pgaDesiredSize;
5562306a36Sopenharmony_ci	u8	xlnaGainCh[AR5416_MAX_CHAINS];
5662306a36Sopenharmony_ci	u8	txEndToXpaOff;
5762306a36Sopenharmony_ci	u8	txEndToRxOn;
5862306a36Sopenharmony_ci	u8	txFrameToXpaOn;
5962306a36Sopenharmony_ci	u8	thresh62;
6062306a36Sopenharmony_ci	s8	noiseFloorThreshCh[AR5416_MAX_CHAINS];
6162306a36Sopenharmony_ci	u8	xpdGain;
6262306a36Sopenharmony_ci	u8	xpd;
6362306a36Sopenharmony_ci	s8	iqCalICh[AR5416_MAX_CHAINS];
6462306a36Sopenharmony_ci	s8	iqCalQCh[AR5416_MAX_CHAINS];
6562306a36Sopenharmony_ci	u8	pdGainOverlap;
6662306a36Sopenharmony_ci	u8	ob;
6762306a36Sopenharmony_ci	u8	db;
6862306a36Sopenharmony_ci	u8	xpaBiasLvl;
6962306a36Sopenharmony_ci	u8	pwrDecreaseFor2Chain;
7062306a36Sopenharmony_ci	u8	pwrDecreaseFor3Chain;
7162306a36Sopenharmony_ci	u8	txFrameToDataStart;
7262306a36Sopenharmony_ci	u8	txFrameToPaOn;
7362306a36Sopenharmony_ci	u8	ht40PowerIncForPdadc;
7462306a36Sopenharmony_ci	u8	bswAtten[AR5416_MAX_CHAINS];
7562306a36Sopenharmony_ci	u8	bswMargin[AR5416_MAX_CHAINS];
7662306a36Sopenharmony_ci	u8	swSettleHt40;
7762306a36Sopenharmony_ci	u8	reserved[22];
7862306a36Sopenharmony_ci	struct spur_channel {
7962306a36Sopenharmony_ci		__le16 spurChan;
8062306a36Sopenharmony_ci		u8	spurRangeLow;
8162306a36Sopenharmony_ci		u8	spurRangeHigh;
8262306a36Sopenharmony_ci	} __packed spur_channels[AR5416_MODAL_SPURS];
8362306a36Sopenharmony_ci} __packed;
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci#define AR5416_NUM_PD_GAINS		4
8662306a36Sopenharmony_ci#define AR5416_PD_GAIN_ICEPTS		5
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_cistruct ar9170_calibration_data_per_freq {
8962306a36Sopenharmony_ci	u8	pwr_pdg[AR5416_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
9062306a36Sopenharmony_ci	u8	vpd_pdg[AR5416_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
9162306a36Sopenharmony_ci} __packed;
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci#define AR5416_NUM_5G_CAL_PIERS		8
9462306a36Sopenharmony_ci#define AR5416_NUM_2G_CAL_PIERS		4
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci#define AR5416_NUM_5G_TARGET_PWRS	8
9762306a36Sopenharmony_ci#define AR5416_NUM_2G_CCK_TARGET_PWRS	3
9862306a36Sopenharmony_ci#define AR5416_NUM_2G_OFDM_TARGET_PWRS	4
9962306a36Sopenharmony_ci#define AR5416_MAX_NUM_TGT_PWRS		8
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_cistruct ar9170_calibration_target_power_legacy {
10262306a36Sopenharmony_ci	u8	freq;
10362306a36Sopenharmony_ci	u8	power[4];
10462306a36Sopenharmony_ci} __packed;
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_cistruct ar9170_calibration_target_power_ht {
10762306a36Sopenharmony_ci	u8	freq;
10862306a36Sopenharmony_ci	u8	power[8];
10962306a36Sopenharmony_ci} __packed;
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci#define AR5416_NUM_CTLS			24
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_cistruct ar9170_calctl_edges {
11462306a36Sopenharmony_ci	u8	channel;
11562306a36Sopenharmony_ci#define AR9170_CALCTL_EDGE_FLAGS	0xC0
11662306a36Sopenharmony_ci	u8	power_flags;
11762306a36Sopenharmony_ci} __packed;
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci#define AR5416_NUM_BAND_EDGES		8
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_cistruct ar9170_calctl_data {
12262306a36Sopenharmony_ci	struct ar9170_calctl_edges
12362306a36Sopenharmony_ci		control_edges[AR5416_MAX_CHAINS][AR5416_NUM_BAND_EDGES];
12462306a36Sopenharmony_ci} __packed;
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_cistruct ar9170_eeprom {
12762306a36Sopenharmony_ci	__le16	length;
12862306a36Sopenharmony_ci	__le16	checksum;
12962306a36Sopenharmony_ci	__le16	version;
13062306a36Sopenharmony_ci	u8	operating_flags;
13162306a36Sopenharmony_ci#define AR9170_OPFLAG_5GHZ		1
13262306a36Sopenharmony_ci#define AR9170_OPFLAG_2GHZ		2
13362306a36Sopenharmony_ci	u8	misc;
13462306a36Sopenharmony_ci	__le16	reg_domain[2];
13562306a36Sopenharmony_ci	u8	mac_address[6];
13662306a36Sopenharmony_ci	u8	rx_mask;
13762306a36Sopenharmony_ci	u8	tx_mask;
13862306a36Sopenharmony_ci	__le16	rf_silent;
13962306a36Sopenharmony_ci	__le16	bluetooth_options;
14062306a36Sopenharmony_ci	__le16	device_capabilities;
14162306a36Sopenharmony_ci	__le32	build_number;
14262306a36Sopenharmony_ci	u8	deviceType;
14362306a36Sopenharmony_ci	u8	reserved[33];
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci	u8	customer_data[64];
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_ci	struct ar9170_eeprom_modal
14862306a36Sopenharmony_ci		modal_header[2];
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci	u8	cal_freq_pier_5G[AR5416_NUM_5G_CAL_PIERS];
15162306a36Sopenharmony_ci	u8	cal_freq_pier_2G[AR5416_NUM_2G_CAL_PIERS];
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci	struct ar9170_calibration_data_per_freq
15462306a36Sopenharmony_ci		cal_pier_data_5G[AR5416_MAX_CHAINS][AR5416_NUM_5G_CAL_PIERS],
15562306a36Sopenharmony_ci		cal_pier_data_2G[AR5416_MAX_CHAINS][AR5416_NUM_2G_CAL_PIERS];
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ci	/* power calibration data */
15862306a36Sopenharmony_ci	struct ar9170_calibration_target_power_legacy
15962306a36Sopenharmony_ci		cal_tgt_pwr_5G[AR5416_NUM_5G_TARGET_PWRS];
16062306a36Sopenharmony_ci	struct ar9170_calibration_target_power_ht
16162306a36Sopenharmony_ci		cal_tgt_pwr_5G_ht20[AR5416_NUM_5G_TARGET_PWRS],
16262306a36Sopenharmony_ci		cal_tgt_pwr_5G_ht40[AR5416_NUM_5G_TARGET_PWRS];
16362306a36Sopenharmony_ci
16462306a36Sopenharmony_ci	struct ar9170_calibration_target_power_legacy
16562306a36Sopenharmony_ci		cal_tgt_pwr_2G_cck[AR5416_NUM_2G_CCK_TARGET_PWRS],
16662306a36Sopenharmony_ci		cal_tgt_pwr_2G_ofdm[AR5416_NUM_2G_OFDM_TARGET_PWRS];
16762306a36Sopenharmony_ci	struct ar9170_calibration_target_power_ht
16862306a36Sopenharmony_ci		cal_tgt_pwr_2G_ht20[AR5416_NUM_2G_OFDM_TARGET_PWRS],
16962306a36Sopenharmony_ci		cal_tgt_pwr_2G_ht40[AR5416_NUM_2G_OFDM_TARGET_PWRS];
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_ci	/* conformance testing limits */
17262306a36Sopenharmony_ci	u8	ctl_index[AR5416_NUM_CTLS];
17362306a36Sopenharmony_ci	struct ar9170_calctl_data
17462306a36Sopenharmony_ci		ctl_data[AR5416_NUM_CTLS];
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_ci	u8	pad;
17762306a36Sopenharmony_ci	__le16	subsystem_id;
17862306a36Sopenharmony_ci} __packed;
17962306a36Sopenharmony_ci
18062306a36Sopenharmony_ci#define AR9170_LED_MODE_POWER_ON		0x0001
18162306a36Sopenharmony_ci#define AR9170_LED_MODE_RESERVED		0x0002
18262306a36Sopenharmony_ci#define AR9170_LED_MODE_DISABLE_STATE		0x0004
18362306a36Sopenharmony_ci#define AR9170_LED_MODE_OFF_IN_PSM		0x0008
18462306a36Sopenharmony_ci
18562306a36Sopenharmony_ci/* AR9170_LED_MODE BIT is set */
18662306a36Sopenharmony_ci#define AR9170_LED_MODE_FREQUENCY_S		4
18762306a36Sopenharmony_ci#define AR9170_LED_MODE_FREQUENCY		0x0030
18862306a36Sopenharmony_ci#define AR9170_LED_MODE_FREQUENCY_1HZ		0x0000
18962306a36Sopenharmony_ci#define AR9170_LED_MODE_FREQUENCY_0_5HZ		0x0010
19062306a36Sopenharmony_ci#define AR9170_LED_MODE_FREQUENCY_0_25HZ	0x0020
19162306a36Sopenharmony_ci#define AR9170_LED_MODE_FREQUENCY_0_125HZ	0x0030
19262306a36Sopenharmony_ci
19362306a36Sopenharmony_ci/* AR9170_LED_MODE BIT is not set */
19462306a36Sopenharmony_ci#define AR9170_LED_MODE_CONN_STATE_S		4
19562306a36Sopenharmony_ci#define AR9170_LED_MODE_CONN_STATE		0x0030
19662306a36Sopenharmony_ci#define AR9170_LED_MODE_CONN_STATE_FORCE_OFF	0x0000
19762306a36Sopenharmony_ci#define AR9170_LED_MODE_CONN_STATE_FORCE_ON	0x0010
19862306a36Sopenharmony_ci/* Idle off / Active on */
19962306a36Sopenharmony_ci#define AR9170_LED_MODE_CONN_STATE_IOFF_AON	0x0020
20062306a36Sopenharmony_ci/* Idle on / Active off */
20162306a36Sopenharmony_ci#define AR9170_LED_MODE_CONN_STATE_ION_AOFF	0x0010
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_ci#define AR9170_LED_MODE_MODE			0x0040
20462306a36Sopenharmony_ci#define AR9170_LED_MODE_RESERVED2		0x0080
20562306a36Sopenharmony_ci
20662306a36Sopenharmony_ci#define AR9170_LED_MODE_TON_SCAN_S		8
20762306a36Sopenharmony_ci#define AR9170_LED_MODE_TON_SCAN		0x0f00
20862306a36Sopenharmony_ci
20962306a36Sopenharmony_ci#define AR9170_LED_MODE_TOFF_SCAN_S		12
21062306a36Sopenharmony_ci#define AR9170_LED_MODE_TOFF_SCAN		0xf000
21162306a36Sopenharmony_ci
21262306a36Sopenharmony_cistruct ar9170_led_mode {
21362306a36Sopenharmony_ci	__le16 led;
21462306a36Sopenharmony_ci};
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci#endif /* __CARL9170_SHARED_EEPROM_H */
217