xref: /freebsd/sys/dev/ath/ath_hal/ah_eeprom_v1.h (revision 95ee2897)
16e778a7eSPedro F. Giffuni /*-
26e778a7eSPedro F. Giffuni  * SPDX-License-Identifier: ISC
36e778a7eSPedro F. Giffuni  *
414779705SSam Leffler  * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
514779705SSam Leffler  * Copyright (c) 2002-2008 Atheros Communications, Inc.
614779705SSam Leffler  *
714779705SSam Leffler  * Permission to use, copy, modify, and/or distribute this software for any
814779705SSam Leffler  * purpose with or without fee is hereby granted, provided that the above
914779705SSam Leffler  * copyright notice and this permission notice appear in all copies.
1014779705SSam Leffler  *
1114779705SSam Leffler  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1214779705SSam Leffler  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1314779705SSam Leffler  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1414779705SSam Leffler  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1514779705SSam Leffler  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1614779705SSam Leffler  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1714779705SSam Leffler  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1814779705SSam Leffler  */
1914779705SSam Leffler #ifndef _ATH_AH_EEPROM_V1_H_
2014779705SSam Leffler #define _ATH_AH_EEPROM_V1_H_
2114779705SSam Leffler 
2214779705SSam Leffler #include "ah_eeprom.h"
2314779705SSam Leffler 
2414779705SSam Leffler /*
2514779705SSam Leffler  * EEPROM defines for Version 1 Crete EEPROM.
2614779705SSam Leffler  *
2714779705SSam Leffler  * The EEPROM is segmented into three sections:
2814779705SSam Leffler  *
2914779705SSam Leffler  *    PCI/Cardbus default configuration settings
3014779705SSam Leffler  *    Cardbus CIS tuples and vendor-specific data
3114779705SSam Leffler  *    Atheros-specific data
3214779705SSam Leffler  *
3314779705SSam Leffler  * EEPROM entries are read 32-bits at a time through the PCI bus
3414779705SSam Leffler  * interface but are all 16-bit values.
3514779705SSam Leffler  *
3614779705SSam Leffler  * Access to the Atheros-specific data is controlled by protection
3714779705SSam Leffler  * bits and the data is checksum'd.  The driver reads the Atheros
3814779705SSam Leffler  * data from the EEPROM at attach and caches it in its private state.
3914779705SSam Leffler  * This data includes the local regulatory domain, channel calibration
4014779705SSam Leffler  * settings, and phy-related configuration settings.
4114779705SSam Leffler  */
4214779705SSam Leffler #define	AR_EEPROM_MAC(i)	(0x1f-(i))/* MAC address word */
4314779705SSam Leffler #define	AR_EEPROM_MAGIC		0x3d	/* magic number */
4414779705SSam Leffler #define AR_EEPROM_PROTECT	0x3f	/* Atheros segment protect register */
4514779705SSam Leffler #define	AR_EEPROM_PROTOTECT_WP_128_191	0x80
4614779705SSam Leffler #define AR_EEPROM_REG_DOMAIN	0xbf	/* Current regulatory domain register */
4714779705SSam Leffler #define AR_EEPROM_ATHEROS_BASE	0xc0	/* Base of Atheros-specific data */
4814779705SSam Leffler #define AR_EEPROM_ATHEROS_MAX	64	/* 64x2=128 bytes of EEPROM settings */
4914779705SSam Leffler #define	AR_EEPROM_ATHEROS(n)	(AR_EEPROM_ATHEROS_BASE+(n))
5014779705SSam Leffler #define	AR_EEPROM_VERSION	AR_EEPROM_ATHEROS(1)
5114779705SSam Leffler #define AR_EEPROM_ATHEROS_TP_SETTINGS	0x09	/* Transmit power settings */
5214779705SSam Leffler #define AR_REG_DOMAINS_MAX	4	/* # of Regulatory Domains */
5314779705SSam Leffler #define AR_CHANNELS_MAX		5	/* # of Channel calibration groups */
5414779705SSam Leffler #define AR_TP_SETTINGS_SIZE	11	/* # locations/Channel group */
5514779705SSam Leffler #define AR_TP_SCALING_ENTRIES	11	/* # entries in transmit power dBm->pcdac */
5614779705SSam Leffler 
5714779705SSam Leffler /*
5814779705SSam Leffler  * NB: we store the rfsilent select+polarity data packed
5914779705SSam Leffler  *     with the encoding used in later parts so values
6014779705SSam Leffler  *     returned to applications are consistent.
6114779705SSam Leffler  */
6214779705SSam Leffler #define AR_EEPROM_RFSILENT_GPIO_SEL	0x001c
6314779705SSam Leffler #define AR_EEPROM_RFSILENT_GPIO_SEL_S	2
6414779705SSam Leffler #define AR_EEPROM_RFSILENT_POLARITY	0x0002
6514779705SSam Leffler #define AR_EEPROM_RFSILENT_POLARITY_S	1
6614779705SSam Leffler 
6714779705SSam Leffler #define AR_I2DBM(x)	((uint8_t)((x * 2) + 3))
6814779705SSam Leffler 
6914779705SSam Leffler /*
7014779705SSam Leffler  * Transmit power and channel calibration settings.
7114779705SSam Leffler  */
7214779705SSam Leffler struct tpcMap {
7314779705SSam Leffler 	uint8_t		pcdac[AR_TP_SCALING_ENTRIES];
7414779705SSam Leffler 	uint8_t		gainF[AR_TP_SCALING_ENTRIES];
7514779705SSam Leffler 	uint8_t		rate36;
7614779705SSam Leffler 	uint8_t		rate48;
7714779705SSam Leffler 	uint8_t		rate54;
7814779705SSam Leffler 	uint8_t		regdmn[AR_REG_DOMAINS_MAX];
7914779705SSam Leffler };
8014779705SSam Leffler 
8114779705SSam Leffler /*
8214779705SSam Leffler  * Information retrieved from EEPROM.
8314779705SSam Leffler  */
8414779705SSam Leffler typedef struct {
8514779705SSam Leffler 	uint16_t	ee_version;		/* Version field */
8614779705SSam Leffler 	uint16_t	ee_protect;		/* EEPROM protect field */
8714779705SSam Leffler 	uint16_t	ee_antenna;		/* Antenna Settings */
8814779705SSam Leffler 	uint16_t	ee_biasCurrents;	/* OB, DB */
8914779705SSam Leffler 	uint8_t		ee_thresh62;		/* thresh62 */
9014779705SSam Leffler 	uint8_t		ee_xlnaOn;		/* External LNA timing */
9114779705SSam Leffler 	uint8_t		ee_xpaOff;		/* Extern output stage timing */
9214779705SSam Leffler 	uint8_t		ee_xpaOn;		/* Extern output stage timing */
9314779705SSam Leffler 	uint8_t		ee_rfKill;		/* Single low bit signalling if RF Kill is implemented */
9414779705SSam Leffler 	uint8_t		ee_devType;		/* Type: PCI, miniPCI, CB */
9514779705SSam Leffler 	uint8_t		ee_regDomain[AR_REG_DOMAINS_MAX];
9614779705SSam Leffler 						/* calibrated reg domains */
9714779705SSam Leffler 	struct tpcMap	ee_tpc[AR_CHANNELS_MAX];
9814779705SSam Leffler } HAL_EEPROM_v1;
9914779705SSam Leffler #endif /* _ATH_AH_EEPROM_V1_H_ */
100