xref: /linux/arch/mips/include/asm/mach-ath79/ar71xx_regs.h (revision d2b4ac1e5d34648cc56785f6bd11bfa020ad4f02)
1d4a67d9dSGabor Juhos /*
2d4a67d9dSGabor Juhos  *  Atheros AR71XX/AR724X/AR913X SoC register definitions
3d4a67d9dSGabor Juhos  *
4d4a67d9dSGabor Juhos  *  Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
5d4a67d9dSGabor Juhos  *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6d4a67d9dSGabor Juhos  *
7d4a67d9dSGabor Juhos  *  Parts of this file are based on Atheros' 2.6.15 BSP
8d4a67d9dSGabor Juhos  *
9d4a67d9dSGabor Juhos  *  This program is free software; you can redistribute it and/or modify it
10d4a67d9dSGabor Juhos  *  under the terms of the GNU General Public License version 2 as published
11d4a67d9dSGabor Juhos  *  by the Free Software Foundation.
12d4a67d9dSGabor Juhos  */
13d4a67d9dSGabor Juhos 
14d4a67d9dSGabor Juhos #ifndef __ASM_MACH_AR71XX_REGS_H
15d4a67d9dSGabor Juhos #define __ASM_MACH_AR71XX_REGS_H
16d4a67d9dSGabor Juhos 
17d4a67d9dSGabor Juhos #include <linux/types.h>
18d4a67d9dSGabor Juhos #include <linux/init.h>
19d4a67d9dSGabor Juhos #include <linux/io.h>
20d4a67d9dSGabor Juhos #include <linux/bitops.h>
21d4a67d9dSGabor Juhos 
22d4a67d9dSGabor Juhos #define AR71XX_APB_BASE		0x18000000
2368a1d316SGabor Juhos #define AR71XX_SPI_BASE		0x1f000000
2468a1d316SGabor Juhos #define AR71XX_SPI_SIZE		0x01000000
25d4a67d9dSGabor Juhos 
26d4a67d9dSGabor Juhos #define AR71XX_DDR_CTRL_BASE	(AR71XX_APB_BASE + 0x00000000)
27d4a67d9dSGabor Juhos #define AR71XX_DDR_CTRL_SIZE	0x100
28d4a67d9dSGabor Juhos #define AR71XX_UART_BASE	(AR71XX_APB_BASE + 0x00020000)
29d4a67d9dSGabor Juhos #define AR71XX_UART_SIZE	0x100
306eae43c5SGabor Juhos #define AR71XX_GPIO_BASE        (AR71XX_APB_BASE + 0x00040000)
316eae43c5SGabor Juhos #define AR71XX_GPIO_SIZE        0x100
32d4a67d9dSGabor Juhos #define AR71XX_PLL_BASE		(AR71XX_APB_BASE + 0x00050000)
33d4a67d9dSGabor Juhos #define AR71XX_PLL_SIZE		0x100
34d4a67d9dSGabor Juhos #define AR71XX_RESET_BASE	(AR71XX_APB_BASE + 0x00060000)
35d4a67d9dSGabor Juhos #define AR71XX_RESET_SIZE	0x100
36d4a67d9dSGabor Juhos 
37f5b35d0bSGabor Juhos #define AR913X_WMAC_BASE	(AR71XX_APB_BASE + 0x000C0000)
38f5b35d0bSGabor Juhos #define AR913X_WMAC_SIZE	0x30000
39f5b35d0bSGabor Juhos 
40d4a67d9dSGabor Juhos /*
41d4a67d9dSGabor Juhos  * DDR_CTRL block
42d4a67d9dSGabor Juhos  */
43d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_PCI_WIN0		0x7c
44d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_PCI_WIN1		0x80
45d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_PCI_WIN2		0x84
46d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_PCI_WIN3		0x88
47d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_PCI_WIN4		0x8c
48d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_PCI_WIN5		0x90
49d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_PCI_WIN6		0x94
50d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_PCI_WIN7		0x98
51d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_FLUSH_GE0	0x9c
52d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_FLUSH_GE1	0xa0
53d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_FLUSH_USB	0xa4
54d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_FLUSH_PCI	0xa8
55d4a67d9dSGabor Juhos 
56d4a67d9dSGabor Juhos #define AR724X_DDR_REG_FLUSH_GE0	0x7c
57d4a67d9dSGabor Juhos #define AR724X_DDR_REG_FLUSH_GE1	0x80
58d4a67d9dSGabor Juhos #define AR724X_DDR_REG_FLUSH_USB	0x84
59d4a67d9dSGabor Juhos #define AR724X_DDR_REG_FLUSH_PCIE	0x88
60d4a67d9dSGabor Juhos 
61d4a67d9dSGabor Juhos #define AR913X_DDR_REG_FLUSH_GE0	0x7c
62d4a67d9dSGabor Juhos #define AR913X_DDR_REG_FLUSH_GE1	0x80
63d4a67d9dSGabor Juhos #define AR913X_DDR_REG_FLUSH_USB	0x84
64d4a67d9dSGabor Juhos #define AR913X_DDR_REG_FLUSH_WMAC	0x88
65d4a67d9dSGabor Juhos 
66d4a67d9dSGabor Juhos /*
67d4a67d9dSGabor Juhos  * PLL block
68d4a67d9dSGabor Juhos  */
69d4a67d9dSGabor Juhos #define AR71XX_PLL_REG_CPU_CONFIG	0x00
70d4a67d9dSGabor Juhos #define AR71XX_PLL_REG_SEC_CONFIG	0x04
71d4a67d9dSGabor Juhos #define AR71XX_PLL_REG_ETH0_INT_CLOCK	0x10
72d4a67d9dSGabor Juhos #define AR71XX_PLL_REG_ETH1_INT_CLOCK	0x14
73d4a67d9dSGabor Juhos 
74d4a67d9dSGabor Juhos #define AR71XX_PLL_DIV_SHIFT		3
75d4a67d9dSGabor Juhos #define AR71XX_PLL_DIV_MASK		0x1f
76d4a67d9dSGabor Juhos #define AR71XX_CPU_DIV_SHIFT		16
77d4a67d9dSGabor Juhos #define AR71XX_CPU_DIV_MASK		0x3
78d4a67d9dSGabor Juhos #define AR71XX_DDR_DIV_SHIFT		18
79d4a67d9dSGabor Juhos #define AR71XX_DDR_DIV_MASK		0x3
80d4a67d9dSGabor Juhos #define AR71XX_AHB_DIV_SHIFT		20
81d4a67d9dSGabor Juhos #define AR71XX_AHB_DIV_MASK		0x7
82d4a67d9dSGabor Juhos 
83d4a67d9dSGabor Juhos #define AR724X_PLL_REG_CPU_CONFIG	0x00
84d4a67d9dSGabor Juhos #define AR724X_PLL_REG_PCIE_CONFIG	0x18
85d4a67d9dSGabor Juhos 
86d4a67d9dSGabor Juhos #define AR724X_PLL_DIV_SHIFT		0
87d4a67d9dSGabor Juhos #define AR724X_PLL_DIV_MASK		0x3ff
88d4a67d9dSGabor Juhos #define AR724X_PLL_REF_DIV_SHIFT	10
89d4a67d9dSGabor Juhos #define AR724X_PLL_REF_DIV_MASK		0xf
90d4a67d9dSGabor Juhos #define AR724X_AHB_DIV_SHIFT		19
91d4a67d9dSGabor Juhos #define AR724X_AHB_DIV_MASK		0x1
92d4a67d9dSGabor Juhos #define AR724X_DDR_DIV_SHIFT		22
93d4a67d9dSGabor Juhos #define AR724X_DDR_DIV_MASK		0x3
94d4a67d9dSGabor Juhos 
95d4a67d9dSGabor Juhos #define AR913X_PLL_REG_CPU_CONFIG	0x00
96d4a67d9dSGabor Juhos #define AR913X_PLL_REG_ETH_CONFIG	0x04
97d4a67d9dSGabor Juhos #define AR913X_PLL_REG_ETH0_INT_CLOCK	0x14
98d4a67d9dSGabor Juhos #define AR913X_PLL_REG_ETH1_INT_CLOCK	0x18
99d4a67d9dSGabor Juhos 
100d4a67d9dSGabor Juhos #define AR913X_PLL_DIV_SHIFT		0
101d4a67d9dSGabor Juhos #define AR913X_PLL_DIV_MASK		0x3ff
102d4a67d9dSGabor Juhos #define AR913X_DDR_DIV_SHIFT		22
103d4a67d9dSGabor Juhos #define AR913X_DDR_DIV_MASK		0x3
104d4a67d9dSGabor Juhos #define AR913X_AHB_DIV_SHIFT		19
105d4a67d9dSGabor Juhos #define AR913X_AHB_DIV_MASK		0x1
106d4a67d9dSGabor Juhos 
107d4a67d9dSGabor Juhos /*
108d4a67d9dSGabor Juhos  * RESET block
109d4a67d9dSGabor Juhos  */
110d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_TIMER			0x00
111d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_TIMER_RELOAD		0x04
112d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_WDOG_CTRL		0x08
113d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_WDOG			0x0c
114d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_MISC_INT_STATUS	0x10
115d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_MISC_INT_ENABLE	0x14
116d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_PCI_INT_STATUS		0x18
117d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_PCI_INT_ENABLE		0x1c
118d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_GLOBAL_INT_STATUS	0x20
119d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_RESET_MODULE		0x24
120d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_PERFC_CTRL		0x2c
121d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_PERFC0			0x30
122d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_PERFC1			0x34
123d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_REV_ID			0x90
124d4a67d9dSGabor Juhos 
125d4a67d9dSGabor Juhos #define AR913X_RESET_REG_GLOBAL_INT_STATUS	0x18
126d4a67d9dSGabor Juhos #define AR913X_RESET_REG_RESET_MODULE		0x1c
127d4a67d9dSGabor Juhos #define AR913X_RESET_REG_PERF_CTRL		0x20
128d4a67d9dSGabor Juhos #define AR913X_RESET_REG_PERFC0			0x24
129d4a67d9dSGabor Juhos #define AR913X_RESET_REG_PERFC1			0x28
130d4a67d9dSGabor Juhos 
131d4a67d9dSGabor Juhos #define AR724X_RESET_REG_RESET_MODULE		0x1c
132d4a67d9dSGabor Juhos 
133*d2b4ac1eSGabor Juhos #define MISC_INT_ETHSW			BIT(12)
134*d2b4ac1eSGabor Juhos #define MISC_INT_TIMER4			BIT(10)
135*d2b4ac1eSGabor Juhos #define MISC_INT_TIMER3			BIT(9)
136*d2b4ac1eSGabor Juhos #define MISC_INT_TIMER2			BIT(8)
137d4a67d9dSGabor Juhos #define MISC_INT_DMA			BIT(7)
138d4a67d9dSGabor Juhos #define MISC_INT_OHCI			BIT(6)
139d4a67d9dSGabor Juhos #define MISC_INT_PERFC			BIT(5)
140d4a67d9dSGabor Juhos #define MISC_INT_WDOG			BIT(4)
141d4a67d9dSGabor Juhos #define MISC_INT_UART			BIT(3)
142d4a67d9dSGabor Juhos #define MISC_INT_GPIO			BIT(2)
143d4a67d9dSGabor Juhos #define MISC_INT_ERROR			BIT(1)
144d4a67d9dSGabor Juhos #define MISC_INT_TIMER			BIT(0)
145d4a67d9dSGabor Juhos 
146d4a67d9dSGabor Juhos #define AR71XX_RESET_EXTERNAL		BIT(28)
147d4a67d9dSGabor Juhos #define AR71XX_RESET_FULL_CHIP		BIT(24)
148d4a67d9dSGabor Juhos #define AR71XX_RESET_CPU_NMI		BIT(21)
149d4a67d9dSGabor Juhos #define AR71XX_RESET_CPU_COLD		BIT(20)
150d4a67d9dSGabor Juhos #define AR71XX_RESET_DMA		BIT(19)
151d4a67d9dSGabor Juhos #define AR71XX_RESET_SLIC		BIT(18)
152d4a67d9dSGabor Juhos #define AR71XX_RESET_STEREO		BIT(17)
153d4a67d9dSGabor Juhos #define AR71XX_RESET_DDR		BIT(16)
154d4a67d9dSGabor Juhos #define AR71XX_RESET_GE1_MAC		BIT(13)
155d4a67d9dSGabor Juhos #define AR71XX_RESET_GE1_PHY		BIT(12)
156d4a67d9dSGabor Juhos #define AR71XX_RESET_USBSUS_OVERRIDE	BIT(10)
157d4a67d9dSGabor Juhos #define AR71XX_RESET_GE0_MAC		BIT(9)
158d4a67d9dSGabor Juhos #define AR71XX_RESET_GE0_PHY		BIT(8)
159d4a67d9dSGabor Juhos #define AR71XX_RESET_USB_OHCI_DLL	BIT(6)
160d4a67d9dSGabor Juhos #define AR71XX_RESET_USB_HOST		BIT(5)
161d4a67d9dSGabor Juhos #define AR71XX_RESET_USB_PHY		BIT(4)
162d4a67d9dSGabor Juhos #define AR71XX_RESET_PCI_BUS		BIT(1)
163d4a67d9dSGabor Juhos #define AR71XX_RESET_PCI_CORE		BIT(0)
164d4a67d9dSGabor Juhos 
165d4a67d9dSGabor Juhos #define AR724X_RESET_GE1_MDIO		BIT(23)
166d4a67d9dSGabor Juhos #define AR724X_RESET_GE0_MDIO		BIT(22)
167d4a67d9dSGabor Juhos #define AR724X_RESET_PCIE_PHY_SERIAL	BIT(10)
168d4a67d9dSGabor Juhos #define AR724X_RESET_PCIE_PHY		BIT(7)
169d4a67d9dSGabor Juhos #define AR724X_RESET_PCIE		BIT(6)
170d4a67d9dSGabor Juhos #define AR724X_RESET_OHCI_DLL		BIT(3)
171d4a67d9dSGabor Juhos 
172d4a67d9dSGabor Juhos #define AR913X_RESET_AMBA2WMAC		BIT(22)
173d4a67d9dSGabor Juhos 
174d4a67d9dSGabor Juhos #define REV_ID_MAJOR_MASK		0xfff0
175d4a67d9dSGabor Juhos #define REV_ID_MAJOR_AR71XX		0x00a0
176d4a67d9dSGabor Juhos #define REV_ID_MAJOR_AR913X		0x00b0
177d4a67d9dSGabor Juhos #define REV_ID_MAJOR_AR7240		0x00c0
178d4a67d9dSGabor Juhos #define REV_ID_MAJOR_AR7241		0x0100
179d4a67d9dSGabor Juhos #define REV_ID_MAJOR_AR7242		0x1100
180d4a67d9dSGabor Juhos 
181d4a67d9dSGabor Juhos #define AR71XX_REV_ID_MINOR_MASK	0x3
182d4a67d9dSGabor Juhos #define AR71XX_REV_ID_MINOR_AR7130	0x0
183d4a67d9dSGabor Juhos #define AR71XX_REV_ID_MINOR_AR7141	0x1
184d4a67d9dSGabor Juhos #define AR71XX_REV_ID_MINOR_AR7161	0x2
185d4a67d9dSGabor Juhos #define AR71XX_REV_ID_REVISION_MASK	0x3
186d4a67d9dSGabor Juhos #define AR71XX_REV_ID_REVISION_SHIFT	2
187d4a67d9dSGabor Juhos 
188d4a67d9dSGabor Juhos #define AR913X_REV_ID_MINOR_MASK	0x3
189d4a67d9dSGabor Juhos #define AR913X_REV_ID_MINOR_AR9130	0x0
190d4a67d9dSGabor Juhos #define AR913X_REV_ID_MINOR_AR9132	0x1
191d4a67d9dSGabor Juhos #define AR913X_REV_ID_REVISION_MASK	0x3
192d4a67d9dSGabor Juhos #define AR913X_REV_ID_REVISION_SHIFT	2
193d4a67d9dSGabor Juhos 
194d4a67d9dSGabor Juhos #define AR724X_REV_ID_REVISION_MASK	0x3
195d4a67d9dSGabor Juhos 
196d4a67d9dSGabor Juhos /*
197d4a67d9dSGabor Juhos  * SPI block
198d4a67d9dSGabor Juhos  */
199d4a67d9dSGabor Juhos #define AR71XX_SPI_REG_FS	0x00	/* Function Select */
200d4a67d9dSGabor Juhos #define AR71XX_SPI_REG_CTRL	0x04	/* SPI Control */
201d4a67d9dSGabor Juhos #define AR71XX_SPI_REG_IOC	0x08	/* SPI I/O Control */
202d4a67d9dSGabor Juhos #define AR71XX_SPI_REG_RDS	0x0c	/* Read Data Shift */
203d4a67d9dSGabor Juhos 
204d4a67d9dSGabor Juhos #define AR71XX_SPI_FS_GPIO	BIT(0)	/* Enable GPIO mode */
205d4a67d9dSGabor Juhos 
206d4a67d9dSGabor Juhos #define AR71XX_SPI_CTRL_RD	BIT(6)	/* Remap Disable */
207d4a67d9dSGabor Juhos #define AR71XX_SPI_CTRL_DIV_MASK 0x3f
208d4a67d9dSGabor Juhos 
209d4a67d9dSGabor Juhos #define AR71XX_SPI_IOC_DO	BIT(0)	/* Data Out pin */
210d4a67d9dSGabor Juhos #define AR71XX_SPI_IOC_CLK	BIT(8)	/* CLK pin */
211d4a67d9dSGabor Juhos #define AR71XX_SPI_IOC_CS(n)	BIT(16 + (n))
212d4a67d9dSGabor Juhos #define AR71XX_SPI_IOC_CS0	AR71XX_SPI_IOC_CS(0)
213d4a67d9dSGabor Juhos #define AR71XX_SPI_IOC_CS1	AR71XX_SPI_IOC_CS(1)
214d4a67d9dSGabor Juhos #define AR71XX_SPI_IOC_CS2	AR71XX_SPI_IOC_CS(2)
215d4a67d9dSGabor Juhos #define AR71XX_SPI_IOC_CS_ALL	(AR71XX_SPI_IOC_CS0 | AR71XX_SPI_IOC_CS1 | \
216d4a67d9dSGabor Juhos 				 AR71XX_SPI_IOC_CS2)
217d4a67d9dSGabor Juhos 
2186eae43c5SGabor Juhos /*
2196eae43c5SGabor Juhos  * GPIO block
2206eae43c5SGabor Juhos  */
2216eae43c5SGabor Juhos #define AR71XX_GPIO_REG_OE		0x00
2226eae43c5SGabor Juhos #define AR71XX_GPIO_REG_IN		0x04
2236eae43c5SGabor Juhos #define AR71XX_GPIO_REG_OUT		0x08
2246eae43c5SGabor Juhos #define AR71XX_GPIO_REG_SET		0x0c
2256eae43c5SGabor Juhos #define AR71XX_GPIO_REG_CLEAR		0x10
2266eae43c5SGabor Juhos #define AR71XX_GPIO_REG_INT_MODE	0x14
2276eae43c5SGabor Juhos #define AR71XX_GPIO_REG_INT_TYPE	0x18
2286eae43c5SGabor Juhos #define AR71XX_GPIO_REG_INT_POLARITY	0x1c
2296eae43c5SGabor Juhos #define AR71XX_GPIO_REG_INT_PENDING	0x20
2306eae43c5SGabor Juhos #define AR71XX_GPIO_REG_INT_ENABLE	0x24
2316eae43c5SGabor Juhos #define AR71XX_GPIO_REG_FUNC		0x28
2326eae43c5SGabor Juhos 
2336eae43c5SGabor Juhos #define AR71XX_GPIO_COUNT		16
2346eae43c5SGabor Juhos #define AR724X_GPIO_COUNT		18
2356eae43c5SGabor Juhos #define AR913X_GPIO_COUNT		22
2366eae43c5SGabor Juhos 
237d4a67d9dSGabor Juhos #endif /* __ASM_MACH_AR71XX_REGS_H */
238