xref: /linux/arch/mips/include/asm/mach-ath79/ar71xx_regs.h (revision 6d1c8fde2daa498fa6ddf8916bcfc5aee1bbe51b)
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
237e98aa46SGabor Juhos #define AR71XX_EHCI_BASE	0x1b000000
247e98aa46SGabor Juhos #define AR71XX_EHCI_SIZE	0x1000
257e98aa46SGabor Juhos #define AR71XX_OHCI_BASE	0x1c000000
267e98aa46SGabor Juhos #define AR71XX_OHCI_SIZE	0x1000
2768a1d316SGabor Juhos #define AR71XX_SPI_BASE		0x1f000000
2868a1d316SGabor Juhos #define AR71XX_SPI_SIZE		0x01000000
29d4a67d9dSGabor Juhos 
30d4a67d9dSGabor Juhos #define AR71XX_DDR_CTRL_BASE	(AR71XX_APB_BASE + 0x00000000)
31d4a67d9dSGabor Juhos #define AR71XX_DDR_CTRL_SIZE	0x100
32d4a67d9dSGabor Juhos #define AR71XX_UART_BASE	(AR71XX_APB_BASE + 0x00020000)
33d4a67d9dSGabor Juhos #define AR71XX_UART_SIZE	0x100
347e98aa46SGabor Juhos #define AR71XX_USB_CTRL_BASE	(AR71XX_APB_BASE + 0x00030000)
357e98aa46SGabor Juhos #define AR71XX_USB_CTRL_SIZE	0x100
366eae43c5SGabor Juhos #define AR71XX_GPIO_BASE        (AR71XX_APB_BASE + 0x00040000)
376eae43c5SGabor Juhos #define AR71XX_GPIO_SIZE        0x100
38d4a67d9dSGabor Juhos #define AR71XX_PLL_BASE		(AR71XX_APB_BASE + 0x00050000)
39d4a67d9dSGabor Juhos #define AR71XX_PLL_SIZE		0x100
40d4a67d9dSGabor Juhos #define AR71XX_RESET_BASE	(AR71XX_APB_BASE + 0x00060000)
41d4a67d9dSGabor Juhos #define AR71XX_RESET_SIZE	0x100
42d4a67d9dSGabor Juhos 
437e98aa46SGabor Juhos #define AR7240_USB_CTRL_BASE	(AR71XX_APB_BASE + 0x00030000)
447e98aa46SGabor Juhos #define AR7240_USB_CTRL_SIZE	0x100
457e98aa46SGabor Juhos #define AR7240_OHCI_BASE	0x1b000000
467e98aa46SGabor Juhos #define AR7240_OHCI_SIZE	0x1000
477e98aa46SGabor Juhos 
487e98aa46SGabor Juhos #define AR724X_EHCI_BASE	0x1b000000
497e98aa46SGabor Juhos #define AR724X_EHCI_SIZE	0x1000
507e98aa46SGabor Juhos 
517e98aa46SGabor Juhos #define AR913X_EHCI_BASE	0x1b000000
527e98aa46SGabor Juhos #define AR913X_EHCI_SIZE	0x1000
53f5b35d0bSGabor Juhos #define AR913X_WMAC_BASE	(AR71XX_APB_BASE + 0x000C0000)
54f5b35d0bSGabor Juhos #define AR913X_WMAC_SIZE	0x30000
55f5b35d0bSGabor Juhos 
56d4a67d9dSGabor Juhos /*
57d4a67d9dSGabor Juhos  * DDR_CTRL block
58d4a67d9dSGabor Juhos  */
59d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_PCI_WIN0		0x7c
60d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_PCI_WIN1		0x80
61d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_PCI_WIN2		0x84
62d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_PCI_WIN3		0x88
63d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_PCI_WIN4		0x8c
64d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_PCI_WIN5		0x90
65d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_PCI_WIN6		0x94
66d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_PCI_WIN7		0x98
67d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_FLUSH_GE0	0x9c
68d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_FLUSH_GE1	0xa0
69d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_FLUSH_USB	0xa4
70d4a67d9dSGabor Juhos #define AR71XX_DDR_REG_FLUSH_PCI	0xa8
71d4a67d9dSGabor Juhos 
72d4a67d9dSGabor Juhos #define AR724X_DDR_REG_FLUSH_GE0	0x7c
73d4a67d9dSGabor Juhos #define AR724X_DDR_REG_FLUSH_GE1	0x80
74d4a67d9dSGabor Juhos #define AR724X_DDR_REG_FLUSH_USB	0x84
75d4a67d9dSGabor Juhos #define AR724X_DDR_REG_FLUSH_PCIE	0x88
76d4a67d9dSGabor Juhos 
77d4a67d9dSGabor Juhos #define AR913X_DDR_REG_FLUSH_GE0	0x7c
78d4a67d9dSGabor Juhos #define AR913X_DDR_REG_FLUSH_GE1	0x80
79d4a67d9dSGabor Juhos #define AR913X_DDR_REG_FLUSH_USB	0x84
80d4a67d9dSGabor Juhos #define AR913X_DDR_REG_FLUSH_WMAC	0x88
81d4a67d9dSGabor Juhos 
82d4a67d9dSGabor Juhos /*
83d4a67d9dSGabor Juhos  * PLL block
84d4a67d9dSGabor Juhos  */
85d4a67d9dSGabor Juhos #define AR71XX_PLL_REG_CPU_CONFIG	0x00
86d4a67d9dSGabor Juhos #define AR71XX_PLL_REG_SEC_CONFIG	0x04
87d4a67d9dSGabor Juhos #define AR71XX_PLL_REG_ETH0_INT_CLOCK	0x10
88d4a67d9dSGabor Juhos #define AR71XX_PLL_REG_ETH1_INT_CLOCK	0x14
89d4a67d9dSGabor Juhos 
90d4a67d9dSGabor Juhos #define AR71XX_PLL_DIV_SHIFT		3
91d4a67d9dSGabor Juhos #define AR71XX_PLL_DIV_MASK		0x1f
92d4a67d9dSGabor Juhos #define AR71XX_CPU_DIV_SHIFT		16
93d4a67d9dSGabor Juhos #define AR71XX_CPU_DIV_MASK		0x3
94d4a67d9dSGabor Juhos #define AR71XX_DDR_DIV_SHIFT		18
95d4a67d9dSGabor Juhos #define AR71XX_DDR_DIV_MASK		0x3
96d4a67d9dSGabor Juhos #define AR71XX_AHB_DIV_SHIFT		20
97d4a67d9dSGabor Juhos #define AR71XX_AHB_DIV_MASK		0x7
98d4a67d9dSGabor Juhos 
99d4a67d9dSGabor Juhos #define AR724X_PLL_REG_CPU_CONFIG	0x00
100d4a67d9dSGabor Juhos #define AR724X_PLL_REG_PCIE_CONFIG	0x18
101d4a67d9dSGabor Juhos 
102d4a67d9dSGabor Juhos #define AR724X_PLL_DIV_SHIFT		0
103d4a67d9dSGabor Juhos #define AR724X_PLL_DIV_MASK		0x3ff
104d4a67d9dSGabor Juhos #define AR724X_PLL_REF_DIV_SHIFT	10
105d4a67d9dSGabor Juhos #define AR724X_PLL_REF_DIV_MASK		0xf
106d4a67d9dSGabor Juhos #define AR724X_AHB_DIV_SHIFT		19
107d4a67d9dSGabor Juhos #define AR724X_AHB_DIV_MASK		0x1
108d4a67d9dSGabor Juhos #define AR724X_DDR_DIV_SHIFT		22
109d4a67d9dSGabor Juhos #define AR724X_DDR_DIV_MASK		0x3
110d4a67d9dSGabor Juhos 
111d4a67d9dSGabor Juhos #define AR913X_PLL_REG_CPU_CONFIG	0x00
112d4a67d9dSGabor Juhos #define AR913X_PLL_REG_ETH_CONFIG	0x04
113d4a67d9dSGabor Juhos #define AR913X_PLL_REG_ETH0_INT_CLOCK	0x14
114d4a67d9dSGabor Juhos #define AR913X_PLL_REG_ETH1_INT_CLOCK	0x18
115d4a67d9dSGabor Juhos 
116d4a67d9dSGabor Juhos #define AR913X_PLL_DIV_SHIFT		0
117d4a67d9dSGabor Juhos #define AR913X_PLL_DIV_MASK		0x3ff
118d4a67d9dSGabor Juhos #define AR913X_DDR_DIV_SHIFT		22
119d4a67d9dSGabor Juhos #define AR913X_DDR_DIV_MASK		0x3
120d4a67d9dSGabor Juhos #define AR913X_AHB_DIV_SHIFT		19
121d4a67d9dSGabor Juhos #define AR913X_AHB_DIV_MASK		0x1
122d4a67d9dSGabor Juhos 
123d4a67d9dSGabor Juhos /*
1247e98aa46SGabor Juhos  * USB_CONFIG block
1257e98aa46SGabor Juhos  */
1267e98aa46SGabor Juhos #define AR71XX_USB_CTRL_REG_FLADJ	0x00
1277e98aa46SGabor Juhos #define AR71XX_USB_CTRL_REG_CONFIG	0x04
1287e98aa46SGabor Juhos 
1297e98aa46SGabor Juhos /*
130d4a67d9dSGabor Juhos  * RESET block
131d4a67d9dSGabor Juhos  */
132d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_TIMER			0x00
133d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_TIMER_RELOAD		0x04
134d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_WDOG_CTRL		0x08
135d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_WDOG			0x0c
136d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_MISC_INT_STATUS	0x10
137d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_MISC_INT_ENABLE	0x14
138d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_PCI_INT_STATUS		0x18
139d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_PCI_INT_ENABLE		0x1c
140d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_GLOBAL_INT_STATUS	0x20
141d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_RESET_MODULE		0x24
142d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_PERFC_CTRL		0x2c
143d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_PERFC0			0x30
144d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_PERFC1			0x34
145d4a67d9dSGabor Juhos #define AR71XX_RESET_REG_REV_ID			0x90
146d4a67d9dSGabor Juhos 
147d4a67d9dSGabor Juhos #define AR913X_RESET_REG_GLOBAL_INT_STATUS	0x18
148d4a67d9dSGabor Juhos #define AR913X_RESET_REG_RESET_MODULE		0x1c
149d4a67d9dSGabor Juhos #define AR913X_RESET_REG_PERF_CTRL		0x20
150d4a67d9dSGabor Juhos #define AR913X_RESET_REG_PERFC0			0x24
151d4a67d9dSGabor Juhos #define AR913X_RESET_REG_PERFC1			0x28
152d4a67d9dSGabor Juhos 
153d4a67d9dSGabor Juhos #define AR724X_RESET_REG_RESET_MODULE		0x1c
154d4a67d9dSGabor Juhos 
155d2b4ac1eSGabor Juhos #define MISC_INT_ETHSW			BIT(12)
156d2b4ac1eSGabor Juhos #define MISC_INT_TIMER4			BIT(10)
157d2b4ac1eSGabor Juhos #define MISC_INT_TIMER3			BIT(9)
158d2b4ac1eSGabor Juhos #define MISC_INT_TIMER2			BIT(8)
159d4a67d9dSGabor Juhos #define MISC_INT_DMA			BIT(7)
160d4a67d9dSGabor Juhos #define MISC_INT_OHCI			BIT(6)
161d4a67d9dSGabor Juhos #define MISC_INT_PERFC			BIT(5)
162d4a67d9dSGabor Juhos #define MISC_INT_WDOG			BIT(4)
163d4a67d9dSGabor Juhos #define MISC_INT_UART			BIT(3)
164d4a67d9dSGabor Juhos #define MISC_INT_GPIO			BIT(2)
165d4a67d9dSGabor Juhos #define MISC_INT_ERROR			BIT(1)
166d4a67d9dSGabor Juhos #define MISC_INT_TIMER			BIT(0)
167d4a67d9dSGabor Juhos 
168d4a67d9dSGabor Juhos #define AR71XX_RESET_EXTERNAL		BIT(28)
169d4a67d9dSGabor Juhos #define AR71XX_RESET_FULL_CHIP		BIT(24)
170d4a67d9dSGabor Juhos #define AR71XX_RESET_CPU_NMI		BIT(21)
171d4a67d9dSGabor Juhos #define AR71XX_RESET_CPU_COLD		BIT(20)
172d4a67d9dSGabor Juhos #define AR71XX_RESET_DMA		BIT(19)
173d4a67d9dSGabor Juhos #define AR71XX_RESET_SLIC		BIT(18)
174d4a67d9dSGabor Juhos #define AR71XX_RESET_STEREO		BIT(17)
175d4a67d9dSGabor Juhos #define AR71XX_RESET_DDR		BIT(16)
176d4a67d9dSGabor Juhos #define AR71XX_RESET_GE1_MAC		BIT(13)
177d4a67d9dSGabor Juhos #define AR71XX_RESET_GE1_PHY		BIT(12)
178d4a67d9dSGabor Juhos #define AR71XX_RESET_USBSUS_OVERRIDE	BIT(10)
179d4a67d9dSGabor Juhos #define AR71XX_RESET_GE0_MAC		BIT(9)
180d4a67d9dSGabor Juhos #define AR71XX_RESET_GE0_PHY		BIT(8)
181d4a67d9dSGabor Juhos #define AR71XX_RESET_USB_OHCI_DLL	BIT(6)
182d4a67d9dSGabor Juhos #define AR71XX_RESET_USB_HOST		BIT(5)
183d4a67d9dSGabor Juhos #define AR71XX_RESET_USB_PHY		BIT(4)
184d4a67d9dSGabor Juhos #define AR71XX_RESET_PCI_BUS		BIT(1)
185d4a67d9dSGabor Juhos #define AR71XX_RESET_PCI_CORE		BIT(0)
186d4a67d9dSGabor Juhos 
1877e98aa46SGabor Juhos #define AR7240_RESET_USB_HOST		BIT(5)
1887e98aa46SGabor Juhos #define AR7240_RESET_OHCI_DLL		BIT(3)
1897e98aa46SGabor Juhos 
190d4a67d9dSGabor Juhos #define AR724X_RESET_GE1_MDIO		BIT(23)
191d4a67d9dSGabor Juhos #define AR724X_RESET_GE0_MDIO		BIT(22)
192d4a67d9dSGabor Juhos #define AR724X_RESET_PCIE_PHY_SERIAL	BIT(10)
193d4a67d9dSGabor Juhos #define AR724X_RESET_PCIE_PHY		BIT(7)
194d4a67d9dSGabor Juhos #define AR724X_RESET_PCIE		BIT(6)
1957e98aa46SGabor Juhos #define AR724X_RESET_USB_HOST		BIT(5)
1967e98aa46SGabor Juhos #define AR724X_RESET_USB_PHY		BIT(4)
1977e98aa46SGabor Juhos #define AR724X_RESET_USBSUS_OVERRIDE	BIT(3)
198d4a67d9dSGabor Juhos 
199d4a67d9dSGabor Juhos #define AR913X_RESET_AMBA2WMAC		BIT(22)
2007e98aa46SGabor Juhos #define AR913X_RESET_USBSUS_OVERRIDE	BIT(10)
2017e98aa46SGabor Juhos #define AR913X_RESET_USB_HOST		BIT(5)
2027e98aa46SGabor Juhos #define AR913X_RESET_USB_PHY		BIT(4)
203d4a67d9dSGabor Juhos 
204d4a67d9dSGabor Juhos #define REV_ID_MAJOR_MASK		0xfff0
205d4a67d9dSGabor Juhos #define REV_ID_MAJOR_AR71XX		0x00a0
206d4a67d9dSGabor Juhos #define REV_ID_MAJOR_AR913X		0x00b0
207d4a67d9dSGabor Juhos #define REV_ID_MAJOR_AR7240		0x00c0
208d4a67d9dSGabor Juhos #define REV_ID_MAJOR_AR7241		0x0100
209d4a67d9dSGabor Juhos #define REV_ID_MAJOR_AR7242		0x1100
210*6d1c8fdeSGabor Juhos #define REV_ID_MAJOR_AR9330		0x0110
211*6d1c8fdeSGabor Juhos #define REV_ID_MAJOR_AR9331		0x1110
212d4a67d9dSGabor Juhos 
213d4a67d9dSGabor Juhos #define AR71XX_REV_ID_MINOR_MASK	0x3
214d4a67d9dSGabor Juhos #define AR71XX_REV_ID_MINOR_AR7130	0x0
215d4a67d9dSGabor Juhos #define AR71XX_REV_ID_MINOR_AR7141	0x1
216d4a67d9dSGabor Juhos #define AR71XX_REV_ID_MINOR_AR7161	0x2
217d4a67d9dSGabor Juhos #define AR71XX_REV_ID_REVISION_MASK	0x3
218d4a67d9dSGabor Juhos #define AR71XX_REV_ID_REVISION_SHIFT	2
219d4a67d9dSGabor Juhos 
220d4a67d9dSGabor Juhos #define AR913X_REV_ID_MINOR_MASK	0x3
221d4a67d9dSGabor Juhos #define AR913X_REV_ID_MINOR_AR9130	0x0
222d4a67d9dSGabor Juhos #define AR913X_REV_ID_MINOR_AR9132	0x1
223d4a67d9dSGabor Juhos #define AR913X_REV_ID_REVISION_MASK	0x3
224d4a67d9dSGabor Juhos #define AR913X_REV_ID_REVISION_SHIFT	2
225d4a67d9dSGabor Juhos 
226*6d1c8fdeSGabor Juhos #define AR933X_REV_ID_REVISION_MASK	0x3
227*6d1c8fdeSGabor Juhos 
228d4a67d9dSGabor Juhos #define AR724X_REV_ID_REVISION_MASK	0x3
229d4a67d9dSGabor Juhos 
230d4a67d9dSGabor Juhos /*
231d4a67d9dSGabor Juhos  * SPI block
232d4a67d9dSGabor Juhos  */
233d4a67d9dSGabor Juhos #define AR71XX_SPI_REG_FS	0x00	/* Function Select */
234d4a67d9dSGabor Juhos #define AR71XX_SPI_REG_CTRL	0x04	/* SPI Control */
235d4a67d9dSGabor Juhos #define AR71XX_SPI_REG_IOC	0x08	/* SPI I/O Control */
236d4a67d9dSGabor Juhos #define AR71XX_SPI_REG_RDS	0x0c	/* Read Data Shift */
237d4a67d9dSGabor Juhos 
238d4a67d9dSGabor Juhos #define AR71XX_SPI_FS_GPIO	BIT(0)	/* Enable GPIO mode */
239d4a67d9dSGabor Juhos 
240d4a67d9dSGabor Juhos #define AR71XX_SPI_CTRL_RD	BIT(6)	/* Remap Disable */
241d4a67d9dSGabor Juhos #define AR71XX_SPI_CTRL_DIV_MASK 0x3f
242d4a67d9dSGabor Juhos 
243d4a67d9dSGabor Juhos #define AR71XX_SPI_IOC_DO	BIT(0)	/* Data Out pin */
244d4a67d9dSGabor Juhos #define AR71XX_SPI_IOC_CLK	BIT(8)	/* CLK pin */
245d4a67d9dSGabor Juhos #define AR71XX_SPI_IOC_CS(n)	BIT(16 + (n))
246d4a67d9dSGabor Juhos #define AR71XX_SPI_IOC_CS0	AR71XX_SPI_IOC_CS(0)
247d4a67d9dSGabor Juhos #define AR71XX_SPI_IOC_CS1	AR71XX_SPI_IOC_CS(1)
248d4a67d9dSGabor Juhos #define AR71XX_SPI_IOC_CS2	AR71XX_SPI_IOC_CS(2)
249d4a67d9dSGabor Juhos #define AR71XX_SPI_IOC_CS_ALL	(AR71XX_SPI_IOC_CS0 | AR71XX_SPI_IOC_CS1 | \
250d4a67d9dSGabor Juhos 				 AR71XX_SPI_IOC_CS2)
251d4a67d9dSGabor Juhos 
2526eae43c5SGabor Juhos /*
2536eae43c5SGabor Juhos  * GPIO block
2546eae43c5SGabor Juhos  */
2556eae43c5SGabor Juhos #define AR71XX_GPIO_REG_OE		0x00
2566eae43c5SGabor Juhos #define AR71XX_GPIO_REG_IN		0x04
2576eae43c5SGabor Juhos #define AR71XX_GPIO_REG_OUT		0x08
2586eae43c5SGabor Juhos #define AR71XX_GPIO_REG_SET		0x0c
2596eae43c5SGabor Juhos #define AR71XX_GPIO_REG_CLEAR		0x10
2606eae43c5SGabor Juhos #define AR71XX_GPIO_REG_INT_MODE	0x14
2616eae43c5SGabor Juhos #define AR71XX_GPIO_REG_INT_TYPE	0x18
2626eae43c5SGabor Juhos #define AR71XX_GPIO_REG_INT_POLARITY	0x1c
2636eae43c5SGabor Juhos #define AR71XX_GPIO_REG_INT_PENDING	0x20
2646eae43c5SGabor Juhos #define AR71XX_GPIO_REG_INT_ENABLE	0x24
2656eae43c5SGabor Juhos #define AR71XX_GPIO_REG_FUNC		0x28
2666eae43c5SGabor Juhos 
2676eae43c5SGabor Juhos #define AR71XX_GPIO_COUNT		16
2686eae43c5SGabor Juhos #define AR724X_GPIO_COUNT		18
2696eae43c5SGabor Juhos #define AR913X_GPIO_COUNT		22
2706eae43c5SGabor Juhos 
271d4a67d9dSGabor Juhos #endif /* __ASM_MACH_AR71XX_REGS_H */
272