1185377Ssam/*
2185377Ssam * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
3185377Ssam * Copyright (c) 2002-2008 Atheros Communications, Inc.
4185377Ssam *
5185377Ssam * Permission to use, copy, modify, and/or distribute this software for any
6185377Ssam * purpose with or without fee is hereby granted, provided that the above
7185377Ssam * copyright notice and this permission notice appear in all copies.
8185377Ssam *
9185377Ssam * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10185377Ssam * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11185377Ssam * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12185377Ssam * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13185377Ssam * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14185377Ssam * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15185377Ssam * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16185377Ssam *
17204644Srpaulo * $FreeBSD$
18185377Ssam */
19185377Ssam#ifndef _DEV_ATH_AR5312REG_H_
20185377Ssam#define _DEV_ATH_AR5312REG_H_
21185377Ssam
22185377Ssam#include "ar5212/ar5212reg.h"
23185377Ssam/*
24185377Ssam * Definitions for the Atheros 5312 chipset.
25185377Ssam */
26185377Ssam
27185377Ssam/* Register base addresses for modules which are not wmac modules */
28185377Ssam/* 531X has a fixed memory map */
29185377Ssam
30185377Ssam
31185377Ssam#define REG_WRITE(_reg,_val)		*((volatile uint32_t *)(_reg)) = (_val);
32185377Ssam#define REG_READ(_reg)		*((volatile uint32_t *)(_reg))
33185377Ssam/*
34185377Ssam * PCI-MAC Configuration registers (AR2315+)
35185377Ssam */
36185377Ssam#define AR5315_RSTIMER_BASE 0xb1000000  /* Address for reset/timer registers */
37185377Ssam#define AR5315_GPIO_BASE    0xb1000000  /* Address for GPIO registers */
38185377Ssam#define AR5315_WLAN0            0xb0000000
39185377Ssam
40185377Ssam#define AR5315_RESET   0x0004      /* Offset of reset control register */
41185377Ssam#define AR5315_SREV    0x0014      /* Offset of reset control register */
42185377Ssam#define AR5315_ENDIAN_CTL  0x000c  /* offset of the endian control register */
43185377Ssam#define AR5315_CONFIG_WLAN     0x00000002      /* WLAN byteswap */
44185377Ssam
45185377Ssam#define AR5315_REV_MAJ                     0x00f0
46185377Ssam#define AR5315_REV_MIN                     0x000f
47185377Ssam
48185377Ssam#define AR5315_GPIODIR      0x0098      /* GPIO direction register */
49185377Ssam#define AR5315_GPIODO       0x0090      /* GPIO data output access reg */
50185377Ssam#define AR5315_GPIODI       0x0088      /* GPIO data input access reg*/
51185377Ssam#define AR5315_GPIOINT      0x00a0      /* GPIO interrupt control */
52185377Ssam
53185377Ssam#define AR5315_GPIODIR_M(x) (1 << (x))  /* mask for i/o */
54185377Ssam#define AR5315_GPIODIR_O(x) (1 << (x))  /* output */
55185377Ssam#define AR5315_GPIODIR_I(x) 0           /* input */
56185377Ssam
57185377Ssam#define AR5315_GPIOINT_S    0
58185377Ssam#define AR5315_GPIOINT_M    0x3F
59185377Ssam#define AR5315_GPIOINTLVL_S 6
60185377Ssam#define AR5315_GPIOINTLVL_M (3 << AR5315_GPIOINTLVL_S)
61185377Ssam
62185377Ssam#define AR5315_WREV         (-0xefbfe0)      /* Revision ID register offset */
63185377Ssam#define AR5315_WREV_S       0           /* Shift for WMAC revision info */
64185377Ssam#define AR5315_WREV_ID      0x000000FF  /* Mask for WMAC revision info */
65185377Ssam#define AR5315_WREV_ID_S    4           /* Shift for WMAC Rev ID */
66185377Ssam#define AR5315_WREV_REVISION 0x0000000F /* Mask for WMAN Revsion version */
67185377Ssam
68185377Ssam#define AR5315_RC_BB0_CRES   0x00000002  /* Cold reset to WMAC0 & WBB0 */
69185377Ssam#define AR5315_RC_BB1_CRES   0x00000200  /* Cold reset to WMAC1 & WBB1n */
70185377Ssam#define AR5315_RC_WMAC0_RES  0x00000001  /* Warm reset to WMAC 0 */
71185377Ssam#define AR5315_RC_WBB0_RES  0x00000002  /* Warm reset to WBB0 */
72185377Ssam#define AR5315_RC_WMAC1_RES  0x00020000  /* Warm reset to WMAC1 */
73185377Ssam#define AR5315_RC_WBB1_RES   0x00040000  /* Warm reset to WBB */
74185377Ssam
75185377Ssam/*
76185377Ssam * PCI-MAC Configuration registers (AR5312)
77185377Ssam */
78185377Ssam#define AR5312_RSTIMER_BASE 0xbc003000  /* Address for reset/timer registers */
79185377Ssam#define AR5312_GPIO_BASE    0xbc002000  /* Address for GPIO registers */
80185377Ssam#define AR5312_WLAN0            0xb8000000
81185377Ssam#define AR5312_WLAN1            0xb8500000
82185377Ssam
83185377Ssam#define AR5312_RESET	0x0020      /* Offset of reset control register */
84185377Ssam#define	AR5312_PCICFG	0x00B0	    /* MAC/PCI configuration reg (LEDs) */
85185377Ssam
86185377Ssam#define AR5312_PCICFG_LEDMODE  0x0000001c	/* LED Mode mask */
87185377Ssam#define AR5312_PCICFG_LEDMODE_S  2	/* LED Mode shift */
88185377Ssam#define AR5312_PCICFG_LEDMOD0  0	/* Blnk prop to Tx and filtered Rx */
89185377Ssam#define AR5312_PCICFG_LEDMOD1  1	/* Blnk prop to all Tx and Rx */
90185377Ssam#define AR5312_PCICFG_LEDMOD2  2	/* DEBG flash */
91185377Ssam#define AR5312_PCICFG_LEDMOD3  3	/* BLNK Randomly */
92185377Ssam
93185377Ssam#define	AR5312_PCICFG_LEDSEL   0x000000e0 /* LED Throughput select */
94185377Ssam#define AR5312_PCICFG_LEDSEL_S 5
95185377Ssam#define AR5312_PCICFG_LEDSEL0  0	/* See blink rate table on p. 143 */
96185377Ssam#define AR5312_PCICFG_LEDSEL1  1	/* of AR5212 data sheet */
97185377Ssam#define AR5312_PCICFG_LEDSEL2  2
98185377Ssam#define AR5312_PCICFG_LEDSEL3  3
99185377Ssam#define AR5312_PCICFG_LEDSEL4  4
100185377Ssam#define AR5312_PCICFG_LEDSEL5  5
101185377Ssam#define AR5312_PCICFG_LEDSEL6  6
102185377Ssam#define AR5312_PCICFG_LEDSEL7  7
103185377Ssam
104185377Ssam#define AR5312_PCICFG_LEDSBR   0x00000100 /* Slow blink rate if no
105185377Ssam			   		     activity. 0 = blink @ lowest
106185377Ssam					     rate */
107185377Ssam
108185377Ssam#undef AR_GPIOCR
109185377Ssam#undef AR_GPIODO                    /* Undefine the 5212 defs */
110185377Ssam#undef AR_GPIODI
111185377Ssam
112185377Ssam#define AR5312_GPIOCR       0x0008      /* GPIO Control register */
113185377Ssam#define AR5312_GPIODO       0x0000      /* GPIO data output access reg */
114185377Ssam#define AR5312_GPIODI       0x0004      /* GPIO data input access reg*/
115185377Ssam/* NB: AR5312 uses AR5212 defines for GPIOCR definitions */
116185377Ssam
117185377Ssam#define AR5312_WREV         0x0090      /* Revision ID register offset */
118185377Ssam#define AR5312_WREV_S       8           /* Shift for WMAC revision info */
119185377Ssam#define AR5312_WREV_ID      0x000000FF  /* Mask for WMAC revision info */
120185377Ssam#define AR5312_WREV_ID_S    4           /* Shift for WMAC Rev ID */
121185377Ssam#define AR5312_WREV_REVISION 0x0000000F /* Mask for WMAN Revsion version */
122185377Ssam
123185377Ssam#define AR5312_RC_BB0_CRES   0x00000004  /* Cold reset to WMAC0 & WBB0 */
124185377Ssam#define AR5312_RC_BB1_CRES   0x00000200  /* Cold reset to WMAC1 & WBB1n */
125185377Ssam#define AR5312_RC_WMAC0_RES  0x00002000  /* Warm reset to WMAC 0 */
126185377Ssam#define AR5312_RC_WBB0_RES  0x00004000  /* Warm reset to WBB0 */
127185377Ssam#define AR5312_RC_WMAC1_RES  0x00020000  /* Warm reset to WMAC1 */
128185377Ssam#define AR5312_RC_WBB1_RES   0x00040000  /* Warm reset to WBB */
129185377Ssam
130185377Ssam
131185377Ssam#define AR_RAD2112_SREV_MAJOR   0x40    /* 2112 Major Rev */
132185377Ssam
133185377Ssamenum AR5312PowerMode {
134185377Ssam    AR5312_POWER_MODE_FORCE_SLEEP  = 0,
135185377Ssam    AR5312_POWER_MODE_FORCE_WAKE   = 1,
136185377Ssam    AR5312_POWER_MODE_NORMAL       = 2,
137185377Ssam};
138185377Ssam
139185377Ssam#endif /* _DEV_AR5312REG_H_ */
140