1185380Ssam/*
2185380Ssam * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
3185380Ssam * Copyright (c) 2002-2008 Atheros Communications, Inc.
4185380Ssam *
5185380Ssam * Permission to use, copy, modify, and/or distribute this software for any
6185380Ssam * purpose with or without fee is hereby granted, provided that the above
7185380Ssam * copyright notice and this permission notice appear in all copies.
8185380Ssam *
9185380Ssam * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10185380Ssam * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11185380Ssam * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12185380Ssam * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13185380Ssam * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14185380Ssam * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15185380Ssam * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16185380Ssam *
17204644Srpaulo * $FreeBSD$
18185380Ssam */
19185380Ssam#ifndef _ATH_AH_EEPROM_V1_H_
20185380Ssam#define _ATH_AH_EEPROM_V1_H_
21185380Ssam
22185380Ssam#include "ah_eeprom.h"
23185380Ssam
24185380Ssam/*
25185380Ssam * EEPROM defines for Version 1 Crete EEPROM.
26185380Ssam *
27185380Ssam * The EEPROM is segmented into three sections:
28185380Ssam *
29185380Ssam *    PCI/Cardbus default configuration settings
30185380Ssam *    Cardbus CIS tuples and vendor-specific data
31185380Ssam *    Atheros-specific data
32185380Ssam *
33185380Ssam * EEPROM entries are read 32-bits at a time through the PCI bus
34185380Ssam * interface but are all 16-bit values.
35185380Ssam *
36185380Ssam * Access to the Atheros-specific data is controlled by protection
37185380Ssam * bits and the data is checksum'd.  The driver reads the Atheros
38185380Ssam * data from the EEPROM at attach and caches it in its private state.
39185380Ssam * This data includes the local regulatory domain, channel calibration
40185380Ssam * settings, and phy-related configuration settings.
41185380Ssam */
42185380Ssam#define	AR_EEPROM_MAC(i)	(0x1f-(i))/* MAC address word */
43185380Ssam#define	AR_EEPROM_MAGIC		0x3d	/* magic number */
44185380Ssam#define AR_EEPROM_PROTECT	0x3f	/* Atheros segment protect register */
45185380Ssam#define	AR_EEPROM_PROTOTECT_WP_128_191	0x80
46185380Ssam#define AR_EEPROM_REG_DOMAIN	0xbf	/* Current regulatory domain register */
47185380Ssam#define AR_EEPROM_ATHEROS_BASE	0xc0	/* Base of Atheros-specific data */
48185380Ssam#define AR_EEPROM_ATHEROS_MAX	64	/* 64x2=128 bytes of EEPROM settings */
49185380Ssam#define	AR_EEPROM_ATHEROS(n)	(AR_EEPROM_ATHEROS_BASE+(n))
50185380Ssam#define	AR_EEPROM_VERSION	AR_EEPROM_ATHEROS(1)
51185380Ssam#define AR_EEPROM_ATHEROS_TP_SETTINGS	0x09	/* Transmit power settings */
52185380Ssam#define AR_REG_DOMAINS_MAX	4	/* # of Regulatory Domains */
53185380Ssam#define AR_CHANNELS_MAX		5	/* # of Channel calibration groups */
54185380Ssam#define AR_TP_SETTINGS_SIZE	11	/* # locations/Channel group */
55185380Ssam#define AR_TP_SCALING_ENTRIES	11	/* # entries in transmit power dBm->pcdac */
56185380Ssam
57185380Ssam/*
58185380Ssam * NB: we store the rfsilent select+polarity data packed
59185380Ssam *     with the encoding used in later parts so values
60185380Ssam *     returned to applications are consistent.
61185380Ssam */
62185380Ssam#define AR_EEPROM_RFSILENT_GPIO_SEL	0x001c
63185380Ssam#define AR_EEPROM_RFSILENT_GPIO_SEL_S	2
64185380Ssam#define AR_EEPROM_RFSILENT_POLARITY	0x0002
65185380Ssam#define AR_EEPROM_RFSILENT_POLARITY_S	1
66185380Ssam
67185380Ssam#define AR_I2DBM(x)	((uint8_t)((x * 2) + 3))
68185380Ssam
69185380Ssam/*
70185380Ssam * Transmit power and channel calibration settings.
71185380Ssam */
72185380Ssamstruct tpcMap {
73185380Ssam	uint8_t		pcdac[AR_TP_SCALING_ENTRIES];
74185380Ssam	uint8_t		gainF[AR_TP_SCALING_ENTRIES];
75185380Ssam	uint8_t		rate36;
76185380Ssam	uint8_t		rate48;
77185380Ssam	uint8_t		rate54;
78185380Ssam	uint8_t		regdmn[AR_REG_DOMAINS_MAX];
79185380Ssam};
80185380Ssam
81185380Ssam/*
82185380Ssam * Information retrieved from EEPROM.
83185380Ssam */
84185380Ssamtypedef struct {
85185380Ssam	uint16_t	ee_version;		/* Version field */
86185380Ssam	uint16_t	ee_protect;		/* EEPROM protect field */
87185380Ssam	uint16_t	ee_antenna;		/* Antenna Settings */
88185380Ssam	uint16_t	ee_biasCurrents;	/* OB, DB */
89185380Ssam	uint8_t		ee_thresh62;		/* thresh62 */
90185380Ssam	uint8_t		ee_xlnaOn;		/* External LNA timing */
91185380Ssam	uint8_t		ee_xpaOff;		/* Extern output stage timing */
92185380Ssam	uint8_t		ee_xpaOn;		/* Extern output stage timing */
93185380Ssam	uint8_t		ee_rfKill;		/* Single low bit signalling if RF Kill is implemented */
94185380Ssam	uint8_t		ee_devType;		/* Type: PCI, miniPCI, CB */
95185380Ssam	uint8_t		ee_regDomain[AR_REG_DOMAINS_MAX];
96185380Ssam						/* calibrated reg domains */
97185380Ssam	struct tpcMap	ee_tpc[AR_CHANNELS_MAX];
98185380Ssam} HAL_EEPROM_v1;
99185380Ssam#endif /* _ATH_AH_EEPROM_V1_H_ */
100