]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - arch/mips/include/asm/mach-au1x00/au1000.h
MIPS: Alchemy: add helpers to access static memory ctrl registers.
[mirror_ubuntu-hirsute-kernel.git] / arch / mips / include / asm / mach-au1x00 / au1000.h
CommitLineData
1da177e4
LT
1/*
2 *
3 * BRIEF MODULE DESCRIPTION
4 * Include file for Alchemy Semiconductor's Au1k CPU.
5 *
01675095
SS
6 * Copyright 2000-2001, 2006-2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. <source@mvista.com>
1da177e4
LT
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
20 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 675 Mass Ave, Cambridge, MA 02139, USA.
28 */
29
30 /*
31 * some definitions add by takuzo@sm.sony.co.jp and sato@sm.sony.co.jp
32 */
33
34#ifndef _AU1000_H_
35#define _AU1000_H_
36
2ef1bb99
ML
37/* SOC Interrupt numbers */
38/* Au1000-style (IC0/1): 2 controllers with 32 sources each */
39#define AU1000_INTC0_INT_BASE (MIPS_CPU_IRQ_BASE + 8)
40#define AU1000_INTC0_INT_LAST (AU1000_INTC0_INT_BASE + 31)
41#define AU1000_INTC1_INT_BASE (AU1000_INTC0_INT_LAST + 1)
42#define AU1000_INTC1_INT_LAST (AU1000_INTC1_INT_BASE + 31)
43#define AU1000_MAX_INTR AU1000_INTC1_INT_LAST
1da177e4 44
2ef1bb99
ML
45/* Au1300-style (GPIC): 1 controller with up to 128 sources */
46#define ALCHEMY_GPIC_INT_BASE (MIPS_CPU_IRQ_BASE + 8)
47#define ALCHEMY_GPIC_INT_NUM 128
48#define ALCHEMY_GPIC_INT_LAST (ALCHEMY_GPIC_INT_BASE + ALCHEMY_GPIC_INT_NUM - 1)
1da177e4 49
9d360ab4 50
2ef1bb99
ML
51/* Au1300 peripheral interrupt numbers */
52#define AU1300_FIRST_INT (ALCHEMY_GPIC_INT_BASE)
53#define AU1300_UART1_INT (AU1300_FIRST_INT + 17)
54#define AU1300_UART2_INT (AU1300_FIRST_INT + 25)
55#define AU1300_UART3_INT (AU1300_FIRST_INT + 27)
56#define AU1300_SD1_INT (AU1300_FIRST_INT + 32)
57#define AU1300_SD2_INT (AU1300_FIRST_INT + 38)
58#define AU1300_PSC0_INT (AU1300_FIRST_INT + 48)
59#define AU1300_PSC1_INT (AU1300_FIRST_INT + 52)
60#define AU1300_PSC2_INT (AU1300_FIRST_INT + 56)
61#define AU1300_PSC3_INT (AU1300_FIRST_INT + 60)
62#define AU1300_NAND_INT (AU1300_FIRST_INT + 62)
63#define AU1300_DDMA_INT (AU1300_FIRST_INT + 75)
64#define AU1300_MMU_INT (AU1300_FIRST_INT + 76)
65#define AU1300_MPU_INT (AU1300_FIRST_INT + 77)
66#define AU1300_GPU_INT (AU1300_FIRST_INT + 78)
67#define AU1300_UDMA_INT (AU1300_FIRST_INT + 79)
68#define AU1300_TOY_INT (AU1300_FIRST_INT + 80)
69#define AU1300_TOY_MATCH0_INT (AU1300_FIRST_INT + 81)
70#define AU1300_TOY_MATCH1_INT (AU1300_FIRST_INT + 82)
71#define AU1300_TOY_MATCH2_INT (AU1300_FIRST_INT + 83)
72#define AU1300_RTC_INT (AU1300_FIRST_INT + 84)
73#define AU1300_RTC_MATCH0_INT (AU1300_FIRST_INT + 85)
74#define AU1300_RTC_MATCH1_INT (AU1300_FIRST_INT + 86)
75#define AU1300_RTC_MATCH2_INT (AU1300_FIRST_INT + 87)
76#define AU1300_UART0_INT (AU1300_FIRST_INT + 88)
77#define AU1300_SD0_INT (AU1300_FIRST_INT + 89)
78#define AU1300_USB_INT (AU1300_FIRST_INT + 90)
79#define AU1300_LCD_INT (AU1300_FIRST_INT + 91)
80#define AU1300_BSA_INT (AU1300_FIRST_INT + 92)
81#define AU1300_MPE_INT (AU1300_FIRST_INT + 93)
82#define AU1300_ITE_INT (AU1300_FIRST_INT + 94)
83#define AU1300_AES_INT (AU1300_FIRST_INT + 95)
84#define AU1300_CIM_INT (AU1300_FIRST_INT + 96)
1da177e4 85
2ef1bb99 86/**********************************************************************/
8ff374b9 87
2ef1bb99
ML
88/*
89 * Physical base addresses for integrated peripherals
90 * 0..au1000 1..au1500 2..au1100 3..au1550 4..au1200 5..au1300
91 */
1da177e4 92
2ef1bb99
ML
93#define AU1000_AC97_PHYS_ADDR 0x10000000 /* 012 */
94#define AU1300_ROM_PHYS_ADDR 0x10000000 /* 5 */
95#define AU1300_OTP_PHYS_ADDR 0x10002000 /* 5 */
96#define AU1300_VSS_PHYS_ADDR 0x10003000 /* 5 */
97#define AU1300_UART0_PHYS_ADDR 0x10100000 /* 5 */
98#define AU1300_UART1_PHYS_ADDR 0x10101000 /* 5 */
99#define AU1300_UART2_PHYS_ADDR 0x10102000 /* 5 */
100#define AU1300_UART3_PHYS_ADDR 0x10103000 /* 5 */
101#define AU1000_USB_OHCI_PHYS_ADDR 0x10100000 /* 012 */
102#define AU1000_USB_UDC_PHYS_ADDR 0x10200000 /* 0123 */
103#define AU1300_GPIC_PHYS_ADDR 0x10200000 /* 5 */
104#define AU1000_IRDA_PHYS_ADDR 0x10300000 /* 02 */
105#define AU1200_AES_PHYS_ADDR 0x10300000 /* 45 */
106#define AU1000_IC0_PHYS_ADDR 0x10400000 /* 01234 */
107#define AU1300_GPU_PHYS_ADDR 0x10500000 /* 5 */
108#define AU1000_MAC0_PHYS_ADDR 0x10500000 /* 023 */
109#define AU1000_MAC1_PHYS_ADDR 0x10510000 /* 023 */
110#define AU1000_MACEN_PHYS_ADDR 0x10520000 /* 023 */
111#define AU1100_SD0_PHYS_ADDR 0x10600000 /* 245 */
112#define AU1300_SD1_PHYS_ADDR 0x10601000 /* 5 */
113#define AU1300_SD2_PHYS_ADDR 0x10602000 /* 5 */
114#define AU1100_SD1_PHYS_ADDR 0x10680000 /* 24 */
115#define AU1300_SYS_PHYS_ADDR 0x10900000 /* 5 */
116#define AU1550_PSC2_PHYS_ADDR 0x10A00000 /* 3 */
117#define AU1550_PSC3_PHYS_ADDR 0x10B00000 /* 3 */
118#define AU1300_PSC0_PHYS_ADDR 0x10A00000 /* 5 */
119#define AU1300_PSC1_PHYS_ADDR 0x10A01000 /* 5 */
120#define AU1300_PSC2_PHYS_ADDR 0x10A02000 /* 5 */
121#define AU1300_PSC3_PHYS_ADDR 0x10A03000 /* 5 */
122#define AU1000_I2S_PHYS_ADDR 0x11000000 /* 02 */
123#define AU1500_MAC0_PHYS_ADDR 0x11500000 /* 1 */
124#define AU1500_MAC1_PHYS_ADDR 0x11510000 /* 1 */
125#define AU1500_MACEN_PHYS_ADDR 0x11520000 /* 1 */
126#define AU1000_UART0_PHYS_ADDR 0x11100000 /* 01234 */
127#define AU1200_SWCNT_PHYS_ADDR 0x1110010C /* 4 */
128#define AU1000_UART1_PHYS_ADDR 0x11200000 /* 0234 */
129#define AU1000_UART2_PHYS_ADDR 0x11300000 /* 0 */
130#define AU1000_UART3_PHYS_ADDR 0x11400000 /* 0123 */
131#define AU1000_SSI0_PHYS_ADDR 0x11600000 /* 02 */
132#define AU1000_SSI1_PHYS_ADDR 0x11680000 /* 02 */
133#define AU1500_GPIO2_PHYS_ADDR 0x11700000 /* 1234 */
134#define AU1000_IC1_PHYS_ADDR 0x11800000 /* 01234 */
135#define AU1000_SYS_PHYS_ADDR 0x11900000 /* 012345 */
136#define AU1550_PSC0_PHYS_ADDR 0x11A00000 /* 34 */
137#define AU1550_PSC1_PHYS_ADDR 0x11B00000 /* 34 */
138#define AU1000_MEM_PHYS_ADDR 0x14000000 /* 01234 */
139#define AU1000_STATIC_MEM_PHYS_ADDR 0x14001000 /* 01234 */
140#define AU1300_UDMA_PHYS_ADDR 0x14001800 /* 5 */
141#define AU1000_DMA_PHYS_ADDR 0x14002000 /* 012 */
142#define AU1550_DBDMA_PHYS_ADDR 0x14002000 /* 345 */
143#define AU1550_DBDMA_CONF_PHYS_ADDR 0x14003000 /* 345 */
144#define AU1000_MACDMA0_PHYS_ADDR 0x14004000 /* 0123 */
145#define AU1000_MACDMA1_PHYS_ADDR 0x14004200 /* 0123 */
146#define AU1200_CIM_PHYS_ADDR 0x14004000 /* 45 */
147#define AU1500_PCI_PHYS_ADDR 0x14005000 /* 13 */
148#define AU1550_PE_PHYS_ADDR 0x14008000 /* 3 */
149#define AU1200_MAEBE_PHYS_ADDR 0x14010000 /* 4 */
150#define AU1200_MAEFE_PHYS_ADDR 0x14012000 /* 4 */
151#define AU1300_MAEITE_PHYS_ADDR 0x14010000 /* 5 */
152#define AU1300_MAEMPE_PHYS_ADDR 0x14014000 /* 5 */
153#define AU1550_USB_OHCI_PHYS_ADDR 0x14020000 /* 3 */
154#define AU1200_USB_CTL_PHYS_ADDR 0x14020000 /* 4 */
155#define AU1200_USB_OTG_PHYS_ADDR 0x14020020 /* 4 */
156#define AU1200_USB_OHCI_PHYS_ADDR 0x14020100 /* 4 */
157#define AU1200_USB_EHCI_PHYS_ADDR 0x14020200 /* 4 */
158#define AU1200_USB_UDC_PHYS_ADDR 0x14022000 /* 4 */
159#define AU1300_USB_EHCI_PHYS_ADDR 0x14020000 /* 5 */
160#define AU1300_USB_OHCI0_PHYS_ADDR 0x14020400 /* 5 */
161#define AU1300_USB_OHCI1_PHYS_ADDR 0x14020800 /* 5 */
162#define AU1300_USB_CTL_PHYS_ADDR 0x14021000 /* 5 */
163#define AU1300_USB_OTG_PHYS_ADDR 0x14022000 /* 5 */
164#define AU1300_MAEBSA_PHYS_ADDR 0x14030000 /* 5 */
165#define AU1100_LCD_PHYS_ADDR 0x15000000 /* 2 */
166#define AU1200_LCD_PHYS_ADDR 0x15000000 /* 45 */
167#define AU1500_PCI_MEM_PHYS_ADDR 0x400000000ULL /* 13 */
168#define AU1500_PCI_IO_PHYS_ADDR 0x500000000ULL /* 13 */
169#define AU1500_PCI_CONFIG0_PHYS_ADDR 0x600000000ULL /* 13 */
170#define AU1500_PCI_CONFIG1_PHYS_ADDR 0x680000000ULL /* 13 */
171#define AU1000_PCMCIA_IO_PHYS_ADDR 0xF00000000ULL /* 012345 */
172#define AU1000_PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL /* 012345 */
173#define AU1000_PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL /* 012345 */
1da177e4 174
2ef1bb99 175/**********************************************************************/
1da177e4 176
1da177e4 177
2ef1bb99
ML
178/*
179 * Au1300 GPIO+INT controller (GPIC) register offsets and bits
180 * Registers are 128bits (0x10 bytes), divided into 4 "banks".
181 */
182#define AU1300_GPIC_PINVAL 0x0000
183#define AU1300_GPIC_PINVALCLR 0x0010
184#define AU1300_GPIC_IPEND 0x0020
185#define AU1300_GPIC_PRIENC 0x0030
186#define AU1300_GPIC_IEN 0x0040 /* int_mask in manual */
187#define AU1300_GPIC_IDIS 0x0050 /* int_maskclr in manual */
188#define AU1300_GPIC_DMASEL 0x0060
189#define AU1300_GPIC_DEVSEL 0x0080
190#define AU1300_GPIC_DEVCLR 0x0090
191#define AU1300_GPIC_RSTVAL 0x00a0
192/* pin configuration space. one 32bit register for up to 128 IRQs */
193#define AU1300_GPIC_PINCFG 0x1000
1da177e4 194
2ef1bb99
ML
195#define GPIC_GPIO_TO_BIT(gpio) \
196 (1 << ((gpio) & 0x1f))
1da177e4 197
2ef1bb99
ML
198#define GPIC_GPIO_BANKOFF(gpio) \
199 (((gpio) >> 5) * 4)
1da177e4 200
2ef1bb99
ML
201/* Pin Control bits: who owns the pin, what does it do */
202#define GPIC_CFG_PC_GPIN 0
203#define GPIC_CFG_PC_DEV 1
204#define GPIC_CFG_PC_GPOLOW 2
205#define GPIC_CFG_PC_GPOHIGH 3
206#define GPIC_CFG_PC_MASK 3
1da177e4 207
2ef1bb99
ML
208/* assign pin to MIPS IRQ line */
209#define GPIC_CFG_IL_SET(x) (((x) & 3) << 2)
210#define GPIC_CFG_IL_MASK (3 << 2)
1da177e4 211
2ef1bb99
ML
212/* pin interrupt type setup */
213#define GPIC_CFG_IC_OFF (0 << 4)
214#define GPIC_CFG_IC_LEVEL_LOW (1 << 4)
215#define GPIC_CFG_IC_LEVEL_HIGH (2 << 4)
216#define GPIC_CFG_IC_EDGE_FALL (5 << 4)
217#define GPIC_CFG_IC_EDGE_RISE (6 << 4)
218#define GPIC_CFG_IC_EDGE_BOTH (7 << 4)
219#define GPIC_CFG_IC_MASK (7 << 4)
074cf656 220
2ef1bb99
ML
221/* allow interrupt to wake cpu from 'wait' */
222#define GPIC_CFG_IDLEWAKE (1 << 7)
1da177e4 223
2ef1bb99 224/***********************************************************************/
93e9cd84 225
2ef1bb99
ML
226/* Au1000 SDRAM memory controller register offsets */
227#define AU1000_MEM_SDMODE0 0x0000
228#define AU1000_MEM_SDMODE1 0x0004
229#define AU1000_MEM_SDMODE2 0x0008
230#define AU1000_MEM_SDADDR0 0x000C
231#define AU1000_MEM_SDADDR1 0x0010
232#define AU1000_MEM_SDADDR2 0x0014
233#define AU1000_MEM_SDREFCFG 0x0018
234#define AU1000_MEM_SDPRECMD 0x001C
235#define AU1000_MEM_SDAUTOREF 0x0020
236#define AU1000_MEM_SDWRMD0 0x0024
237#define AU1000_MEM_SDWRMD1 0x0028
238#define AU1000_MEM_SDWRMD2 0x002C
239#define AU1000_MEM_SDSLEEP 0x0030
240#define AU1000_MEM_SDSMCKE 0x0034
93e9cd84 241
2ef1bb99
ML
242/* MEM_SDMODE register content definitions */
243#define MEM_SDMODE_F (1 << 22)
244#define MEM_SDMODE_SR (1 << 21)
245#define MEM_SDMODE_BS (1 << 20)
246#define MEM_SDMODE_RS (3 << 18)
247#define MEM_SDMODE_CS (7 << 15)
248#define MEM_SDMODE_TRAS (15 << 11)
249#define MEM_SDMODE_TMRD (3 << 9)
250#define MEM_SDMODE_TWR (3 << 7)
251#define MEM_SDMODE_TRP (3 << 5)
252#define MEM_SDMODE_TRCD (3 << 3)
253#define MEM_SDMODE_TCL (7 << 0)
93e9cd84 254
2ef1bb99
ML
255#define MEM_SDMODE_BS_2Bank (0 << 20)
256#define MEM_SDMODE_BS_4Bank (1 << 20)
257#define MEM_SDMODE_RS_11Row (0 << 18)
258#define MEM_SDMODE_RS_12Row (1 << 18)
259#define MEM_SDMODE_RS_13Row (2 << 18)
260#define MEM_SDMODE_RS_N(N) ((N) << 18)
261#define MEM_SDMODE_CS_7Col (0 << 15)
262#define MEM_SDMODE_CS_8Col (1 << 15)
263#define MEM_SDMODE_CS_9Col (2 << 15)
264#define MEM_SDMODE_CS_10Col (3 << 15)
265#define MEM_SDMODE_CS_11Col (4 << 15)
266#define MEM_SDMODE_CS_N(N) ((N) << 15)
267#define MEM_SDMODE_TRAS_N(N) ((N) << 11)
268#define MEM_SDMODE_TMRD_N(N) ((N) << 9)
269#define MEM_SDMODE_TWR_N(N) ((N) << 7)
270#define MEM_SDMODE_TRP_N(N) ((N) << 5)
271#define MEM_SDMODE_TRCD_N(N) ((N) << 3)
272#define MEM_SDMODE_TCL_N(N) ((N) << 0)
80130204 273
2ef1bb99
ML
274/* MEM_SDADDR register contents definitions */
275#define MEM_SDADDR_E (1 << 20)
276#define MEM_SDADDR_CSBA (0x03FF << 10)
277#define MEM_SDADDR_CSMASK (0x03FF << 0)
278#define MEM_SDADDR_CSBA_N(N) ((N) & (0x03FF << 22) >> 12)
279#define MEM_SDADDR_CSMASK_N(N) ((N)&(0x03FF << 22) >> 22)
80130204 280
2ef1bb99
ML
281/* MEM_SDREFCFG register content definitions */
282#define MEM_SDREFCFG_TRC (15 << 28)
283#define MEM_SDREFCFG_TRPM (3 << 26)
284#define MEM_SDREFCFG_E (1 << 25)
285#define MEM_SDREFCFG_RE (0x1ffffff << 0)
286#define MEM_SDREFCFG_TRC_N(N) ((N) << MEM_SDREFCFG_TRC)
287#define MEM_SDREFCFG_TRPM_N(N) ((N) << MEM_SDREFCFG_TRPM)
288#define MEM_SDREFCFG_REF_N(N) (N)
80130204 289
2ef1bb99
ML
290/* Au1550 SDRAM Register Offsets */
291#define AU1550_MEM_SDMODE0 0x0800
292#define AU1550_MEM_SDMODE1 0x0808
293#define AU1550_MEM_SDMODE2 0x0810
294#define AU1550_MEM_SDADDR0 0x0820
295#define AU1550_MEM_SDADDR1 0x0828
296#define AU1550_MEM_SDADDR2 0x0830
297#define AU1550_MEM_SDCONFIGA 0x0840
298#define AU1550_MEM_SDCONFIGB 0x0848
299#define AU1550_MEM_SDSTAT 0x0850
300#define AU1550_MEM_SDERRADDR 0x0858
301#define AU1550_MEM_SDSTRIDE0 0x0860
302#define AU1550_MEM_SDSTRIDE1 0x0868
303#define AU1550_MEM_SDSTRIDE2 0x0870
304#define AU1550_MEM_SDWRMD0 0x0880
305#define AU1550_MEM_SDWRMD1 0x0888
306#define AU1550_MEM_SDWRMD2 0x0890
307#define AU1550_MEM_SDPRECMD 0x08C0
308#define AU1550_MEM_SDAUTOREF 0x08C8
309#define AU1550_MEM_SDSREF 0x08D0
310#define AU1550_MEM_SDSLEEP MEM_SDSREF
80130204 311
9cf12167
ML
312/* Static Bus Controller register offsets */
313#define AU1000_MEM_STCFG0 0x000
314#define AU1000_MEM_STTIME0 0x004
315#define AU1000_MEM_STADDR0 0x008
316#define AU1000_MEM_STCFG1 0x010
317#define AU1000_MEM_STTIME1 0x014
318#define AU1000_MEM_STADDR1 0x018
319#define AU1000_MEM_STCFG2 0x020
320#define AU1000_MEM_STTIME2 0x024
321#define AU1000_MEM_STADDR2 0x028
322#define AU1000_MEM_STCFG3 0x030
323#define AU1000_MEM_STTIME3 0x034
324#define AU1000_MEM_STADDR3 0x038
325#define AU1000_MEM_STNDCTL 0x100
326#define AU1000_MEM_STSTAT 0x104
1da177e4 327
2ef1bb99
ML
328#define MEM_STNAND_CMD 0x0
329#define MEM_STNAND_ADDR 0x4
330#define MEM_STNAND_DATA 0x20
564365b0 331
ce6bc922 332
2ef1bb99 333/* Programmable Counters 0 and 1 */
1d09de7d 334#define AU1000_SYS_CNTRCTRL 0x14
2ef1bb99
ML
335# define SYS_CNTRL_E1S (1 << 23)
336# define SYS_CNTRL_T1S (1 << 20)
337# define SYS_CNTRL_M21 (1 << 19)
338# define SYS_CNTRL_M11 (1 << 18)
339# define SYS_CNTRL_M01 (1 << 17)
340# define SYS_CNTRL_C1S (1 << 16)
341# define SYS_CNTRL_BP (1 << 14)
342# define SYS_CNTRL_EN1 (1 << 13)
343# define SYS_CNTRL_BT1 (1 << 12)
344# define SYS_CNTRL_EN0 (1 << 11)
345# define SYS_CNTRL_BT0 (1 << 10)
346# define SYS_CNTRL_E0 (1 << 8)
347# define SYS_CNTRL_E0S (1 << 7)
348# define SYS_CNTRL_32S (1 << 5)
349# define SYS_CNTRL_T0S (1 << 4)
350# define SYS_CNTRL_M20 (1 << 3)
351# define SYS_CNTRL_M10 (1 << 2)
352# define SYS_CNTRL_M00 (1 << 1)
353# define SYS_CNTRL_C0S (1 << 0)
78814465 354
2ef1bb99 355/* Programmable Counter 0 Registers */
1d09de7d
ML
356#define AU1000_SYS_TOYTRIM 0x00
357#define AU1000_SYS_TOYWRITE 0x04
358#define AU1000_SYS_TOYMATCH0 0x08
359#define AU1000_SYS_TOYMATCH1 0x0c
360#define AU1000_SYS_TOYMATCH2 0x10
361#define AU1000_SYS_TOYREAD 0x40
809f36c6 362
2ef1bb99 363/* Programmable Counter 1 Registers */
1d09de7d
ML
364#define AU1000_SYS_RTCTRIM 0x44
365#define AU1000_SYS_RTCWRITE 0x48
366#define AU1000_SYS_RTCMATCH0 0x4c
367#define AU1000_SYS_RTCMATCH1 0x50
368#define AU1000_SYS_RTCMATCH2 0x54
369#define AU1000_SYS_RTCREAD 0x58
809f36c6 370
809f36c6 371
2ef1bb99 372/* GPIO */
1d09de7d 373#define AU1000_SYS_PINFUNC 0x2C
2ef1bb99
ML
374# define SYS_PF_USB (1 << 15) /* 2nd USB device/host */
375# define SYS_PF_U3 (1 << 14) /* GPIO23/U3TXD */
376# define SYS_PF_U2 (1 << 13) /* GPIO22/U2TXD */
377# define SYS_PF_U1 (1 << 12) /* GPIO21/U1TXD */
378# define SYS_PF_SRC (1 << 11) /* GPIO6/SROMCKE */
379# define SYS_PF_CK5 (1 << 10) /* GPIO3/CLK5 */
380# define SYS_PF_CK4 (1 << 9) /* GPIO2/CLK4 */
381# define SYS_PF_IRF (1 << 8) /* GPIO15/IRFIRSEL */
382# define SYS_PF_UR3 (1 << 7) /* GPIO[14:9]/UART3 */
383# define SYS_PF_I2D (1 << 6) /* GPIO8/I2SDI */
384# define SYS_PF_I2S (1 << 5) /* I2S/GPIO[29:31] */
385# define SYS_PF_NI2 (1 << 4) /* NI2/GPIO[24:28] */
386# define SYS_PF_U0 (1 << 3) /* U0TXD/GPIO20 */
387# define SYS_PF_RD (1 << 2) /* IRTXD/GPIO19 */
388# define SYS_PF_A97 (1 << 1) /* AC97/SSL1 */
389# define SYS_PF_S0 (1 << 0) /* SSI_0/GPIO[16:18] */
78814465 390
2ef1bb99
ML
391/* Au1100 only */
392# define SYS_PF_PC (1 << 18) /* PCMCIA/GPIO[207:204] */
393# define SYS_PF_LCD (1 << 17) /* extern lcd/GPIO[203:200] */
394# define SYS_PF_CS (1 << 16) /* EXTCLK0/32KHz to gpio2 */
395# define SYS_PF_EX0 (1 << 9) /* GPIO2/clock */
78814465 396
2ef1bb99
ML
397/* Au1550 only. Redefines lots of pins */
398# define SYS_PF_PSC2_MASK (7 << 17)
399# define SYS_PF_PSC2_AC97 0
400# define SYS_PF_PSC2_SPI 0
401# define SYS_PF_PSC2_I2S (1 << 17)
402# define SYS_PF_PSC2_SMBUS (3 << 17)
403# define SYS_PF_PSC2_GPIO (7 << 17)
404# define SYS_PF_PSC3_MASK (7 << 20)
405# define SYS_PF_PSC3_AC97 0
406# define SYS_PF_PSC3_SPI 0
407# define SYS_PF_PSC3_I2S (1 << 20)
408# define SYS_PF_PSC3_SMBUS (3 << 20)
409# define SYS_PF_PSC3_GPIO (7 << 20)
410# define SYS_PF_PSC1_S1 (1 << 1)
411# define SYS_PF_MUST_BE_SET ((1 << 5) | (1 << 2))
809f36c6 412
2ef1bb99
ML
413/* Au1200 only */
414#define SYS_PINFUNC_DMA (1 << 31)
415#define SYS_PINFUNC_S0A (1 << 30)
416#define SYS_PINFUNC_S1A (1 << 29)
417#define SYS_PINFUNC_LP0 (1 << 28)
418#define SYS_PINFUNC_LP1 (1 << 27)
419#define SYS_PINFUNC_LD16 (1 << 26)
420#define SYS_PINFUNC_LD8 (1 << 25)
421#define SYS_PINFUNC_LD1 (1 << 24)
422#define SYS_PINFUNC_LD0 (1 << 23)
423#define SYS_PINFUNC_P1A (3 << 21)
424#define SYS_PINFUNC_P1B (1 << 20)
425#define SYS_PINFUNC_FS3 (1 << 19)
426#define SYS_PINFUNC_P0A (3 << 17)
427#define SYS_PINFUNC_CS (1 << 16)
428#define SYS_PINFUNC_CIM (1 << 15)
429#define SYS_PINFUNC_P1C (1 << 14)
430#define SYS_PINFUNC_U1T (1 << 12)
431#define SYS_PINFUNC_U1R (1 << 11)
432#define SYS_PINFUNC_EX1 (1 << 10)
433#define SYS_PINFUNC_EX0 (1 << 9)
434#define SYS_PINFUNC_U0R (1 << 8)
435#define SYS_PINFUNC_MC (1 << 7)
436#define SYS_PINFUNC_S0B (1 << 6)
437#define SYS_PINFUNC_S0C (1 << 5)
438#define SYS_PINFUNC_P0B (1 << 4)
439#define SYS_PINFUNC_U0T (1 << 3)
440#define SYS_PINFUNC_S1B (1 << 2)
78814465 441
2ef1bb99 442/* Power Management */
1d09de7d
ML
443#define AU1000_SYS_SCRATCH0 0x18
444#define AU1000_SYS_SCRATCH1 0x1c
445#define AU1000_SYS_WAKEMSK 0x34
446#define AU1000_SYS_ENDIAN 0x38
447#define AU1000_SYS_POWERCTRL 0x3c
448#define AU1000_SYS_WAKESRC 0x5c
449#define AU1000_SYS_SLPPWR 0x78
450#define AU1000_SYS_SLEEP 0x7c
78814465 451
2ef1bb99
ML
452#define SYS_WAKEMSK_D2 (1 << 9)
453#define SYS_WAKEMSK_M2 (1 << 8)
454#define SYS_WAKEMSK_GPIO(x) (1 << (x))
78814465 455
2ef1bb99 456/* Clock Controller */
1d09de7d 457#define AU1000_SYS_FREQCTRL0 0x20
2ef1bb99
ML
458# define SYS_FC_FRDIV2_BIT 22
459# define SYS_FC_FRDIV2_MASK (0xff << SYS_FC_FRDIV2_BIT)
460# define SYS_FC_FE2 (1 << 21)
461# define SYS_FC_FS2 (1 << 20)
462# define SYS_FC_FRDIV1_BIT 12
463# define SYS_FC_FRDIV1_MASK (0xff << SYS_FC_FRDIV1_BIT)
464# define SYS_FC_FE1 (1 << 11)
465# define SYS_FC_FS1 (1 << 10)
466# define SYS_FC_FRDIV0_BIT 2
467# define SYS_FC_FRDIV0_MASK (0xff << SYS_FC_FRDIV0_BIT)
468# define SYS_FC_FE0 (1 << 1)
469# define SYS_FC_FS0 (1 << 0)
1d09de7d 470#define AU1000_SYS_FREQCTRL1 0x24
2ef1bb99
ML
471# define SYS_FC_FRDIV5_BIT 22
472# define SYS_FC_FRDIV5_MASK (0xff << SYS_FC_FRDIV5_BIT)
473# define SYS_FC_FE5 (1 << 21)
474# define SYS_FC_FS5 (1 << 20)
475# define SYS_FC_FRDIV4_BIT 12
476# define SYS_FC_FRDIV4_MASK (0xff << SYS_FC_FRDIV4_BIT)
477# define SYS_FC_FE4 (1 << 11)
478# define SYS_FC_FS4 (1 << 10)
479# define SYS_FC_FRDIV3_BIT 2
480# define SYS_FC_FRDIV3_MASK (0xff << SYS_FC_FRDIV3_BIT)
481# define SYS_FC_FE3 (1 << 1)
482# define SYS_FC_FS3 (1 << 0)
1d09de7d 483#define AU1000_SYS_CLKSRC 0x28
2ef1bb99
ML
484# define SYS_CS_ME1_BIT 27
485# define SYS_CS_ME1_MASK (0x7 << SYS_CS_ME1_BIT)
486# define SYS_CS_DE1 (1 << 26)
487# define SYS_CS_CE1 (1 << 25)
488# define SYS_CS_ME0_BIT 22
489# define SYS_CS_ME0_MASK (0x7 << SYS_CS_ME0_BIT)
490# define SYS_CS_DE0 (1 << 21)
491# define SYS_CS_CE0 (1 << 20)
492# define SYS_CS_MI2_BIT 17
493# define SYS_CS_MI2_MASK (0x7 << SYS_CS_MI2_BIT)
494# define SYS_CS_DI2 (1 << 16)
495# define SYS_CS_CI2 (1 << 15)
78814465 496
2ef1bb99
ML
497# define SYS_CS_ML_BIT 7
498# define SYS_CS_ML_MASK (0x7 << SYS_CS_ML_BIT)
499# define SYS_CS_DL (1 << 6)
500# define SYS_CS_CL (1 << 5)
78814465 501
2ef1bb99
ML
502# define SYS_CS_MUH_BIT 12
503# define SYS_CS_MUH_MASK (0x7 << SYS_CS_MUH_BIT)
504# define SYS_CS_DUH (1 << 11)
505# define SYS_CS_CUH (1 << 10)
506# define SYS_CS_MUD_BIT 7
507# define SYS_CS_MUD_MASK (0x7 << SYS_CS_MUD_BIT)
508# define SYS_CS_DUD (1 << 6)
509# define SYS_CS_CUD (1 << 5)
78814465 510
2ef1bb99
ML
511# define SYS_CS_MIR_BIT 2
512# define SYS_CS_MIR_MASK (0x7 << SYS_CS_MIR_BIT)
513# define SYS_CS_DIR (1 << 1)
514# define SYS_CS_CIR (1 << 0)
78814465 515
2ef1bb99
ML
516# define SYS_CS_MUX_AUX 0x1
517# define SYS_CS_MUX_FQ0 0x2
518# define SYS_CS_MUX_FQ1 0x3
519# define SYS_CS_MUX_FQ2 0x4
520# define SYS_CS_MUX_FQ3 0x5
521# define SYS_CS_MUX_FQ4 0x6
522# define SYS_CS_MUX_FQ5 0x7
1d09de7d
ML
523
524#define AU1000_SYS_CPUPLL 0x60
525#define AU1000_SYS_AUXPLL 0x64
526
527
528/**********************************************************************/
78814465 529
809f36c6 530
2ef1bb99
ML
531/* The PCI chip selects are outside the 32bit space, and since we can't
532 * just program the 36bit addresses into BARs, we have to take a chunk
533 * out of the 32bit space and reserve it for PCI. When these addresses
534 * are ioremap()ed, they'll be fixed up to the real 36bit address before
535 * being passed to the real ioremap function.
e3ad1c23 536 */
2ef1bb99
ML
537#define ALCHEMY_PCI_MEMWIN_START (AU1500_PCI_MEM_PHYS_ADDR >> 4)
538#define ALCHEMY_PCI_MEMWIN_END (ALCHEMY_PCI_MEMWIN_START + 0x0FFFFFFF)
e3ad1c23 539
2ef1bb99
ML
540/* for PCI IO it's simpler because we get to do the ioremap ourselves and then
541 * adjust the device's resources.
809f36c6 542 */
2ef1bb99
ML
543#define ALCHEMY_PCI_IOWIN_START 0x00001000
544#define ALCHEMY_PCI_IOWIN_END 0x0000FFFF
809f36c6 545
2ef1bb99 546#ifdef CONFIG_PCI
809f36c6 547
2ef1bb99
ML
548#define IOPORT_RESOURCE_START 0x00001000 /* skip legacy probing */
549#define IOPORT_RESOURCE_END 0xffffffff
550#define IOMEM_RESOURCE_START 0x10000000
551#define IOMEM_RESOURCE_END 0xfffffffffULL
809f36c6 552
2ef1bb99 553#else
809f36c6 554
2ef1bb99
ML
555/* Don't allow any legacy ports probing */
556#define IOPORT_RESOURCE_START 0x10000000
557#define IOPORT_RESOURCE_END 0xffffffff
558#define IOMEM_RESOURCE_START 0x10000000
559#define IOMEM_RESOURCE_END 0xfffffffffULL
809f36c6 560
2ef1bb99 561#endif
37663860 562
2ef1bb99
ML
563/* PCI controller block register offsets */
564#define PCI_REG_CMEM 0x0000
565#define PCI_REG_CONFIG 0x0004
566#define PCI_REG_B2BMASK_CCH 0x0008
567#define PCI_REG_B2BBASE0_VID 0x000C
568#define PCI_REG_B2BBASE1_SID 0x0010
569#define PCI_REG_MWMASK_DEV 0x0014
570#define PCI_REG_MWBASE_REV_CCL 0x0018
571#define PCI_REG_ERR_ADDR 0x001C
572#define PCI_REG_SPEC_INTACK 0x0020
573#define PCI_REG_ID 0x0100
574#define PCI_REG_STATCMD 0x0104
575#define PCI_REG_CLASSREV 0x0108
576#define PCI_REG_PARAM 0x010C
577#define PCI_REG_MBAR 0x0110
578#define PCI_REG_TIMEOUT 0x0140
37663860 579
2ef1bb99
ML
580/* PCI controller block register bits */
581#define PCI_CMEM_E (1 << 28) /* enable cacheable memory */
582#define PCI_CMEM_CMBASE(x) (((x) & 0x3fff) << 14)
583#define PCI_CMEM_CMMASK(x) ((x) & 0x3fff)
584#define PCI_CONFIG_ERD (1 << 27) /* pci error during R/W */
585#define PCI_CONFIG_ET (1 << 26) /* error in target mode */
586#define PCI_CONFIG_EF (1 << 25) /* fatal error */
587#define PCI_CONFIG_EP (1 << 24) /* parity error */
588#define PCI_CONFIG_EM (1 << 23) /* multiple errors */
589#define PCI_CONFIG_BM (1 << 22) /* bad master error */
590#define PCI_CONFIG_PD (1 << 20) /* PCI Disable */
591#define PCI_CONFIG_BME (1 << 19) /* Byte Mask Enable for reads */
592#define PCI_CONFIG_NC (1 << 16) /* mark mem access non-coherent */
593#define PCI_CONFIG_IA (1 << 15) /* INTA# enabled (target mode) */
594#define PCI_CONFIG_IP (1 << 13) /* int on PCI_PERR# */
595#define PCI_CONFIG_IS (1 << 12) /* int on PCI_SERR# */
596#define PCI_CONFIG_IMM (1 << 11) /* int on master abort */
597#define PCI_CONFIG_ITM (1 << 10) /* int on target abort (as master) */
598#define PCI_CONFIG_ITT (1 << 9) /* int on target abort (as target) */
599#define PCI_CONFIG_IPB (1 << 8) /* int on PERR# in bus master acc */
600#define PCI_CONFIG_SIC_NO (0 << 6) /* no byte mask changes */
601#define PCI_CONFIG_SIC_BA_ADR (1 << 6) /* on byte/hw acc, invert adr bits */
602#define PCI_CONFIG_SIC_HWA_DAT (2 << 6) /* on halfword acc, swap data */
603#define PCI_CONFIG_SIC_ALL (3 << 6) /* swap data bytes on all accesses */
604#define PCI_CONFIG_ST (1 << 5) /* swap data by target transactions */
605#define PCI_CONFIG_SM (1 << 4) /* swap data from PCI ctl */
606#define PCI_CONFIG_AEN (1 << 3) /* enable internal arbiter */
607#define PCI_CONFIG_R2H (1 << 2) /* REQ2# to hi-prio arbiter */
608#define PCI_CONFIG_R1H (1 << 1) /* REQ1# to hi-prio arbiter */
609#define PCI_CONFIG_CH (1 << 0) /* PCI ctl to hi-prio arbiter */
610#define PCI_B2BMASK_B2BMASK(x) (((x) & 0xffff) << 16)
611#define PCI_B2BMASK_CCH(x) ((x) & 0xffff) /* 16 upper bits of class code */
612#define PCI_B2BBASE0_VID_B0(x) (((x) & 0xffff) << 16)
613#define PCI_B2BBASE0_VID_SV(x) ((x) & 0xffff)
614#define PCI_B2BBASE1_SID_B1(x) (((x) & 0xffff) << 16)
615#define PCI_B2BBASE1_SID_SI(x) ((x) & 0xffff)
616#define PCI_MWMASKDEV_MWMASK(x) (((x) & 0xffff) << 16)
617#define PCI_MWMASKDEV_DEVID(x) ((x) & 0xffff)
618#define PCI_MWBASEREVCCL_BASE(x) (((x) & 0xffff) << 16)
619#define PCI_MWBASEREVCCL_REV(x) (((x) & 0xff) << 8)
620#define PCI_MWBASEREVCCL_CCL(x) ((x) & 0xff)
621#define PCI_ID_DID(x) (((x) & 0xffff) << 16)
622#define PCI_ID_VID(x) ((x) & 0xffff)
623#define PCI_STATCMD_STATUS(x) (((x) & 0xffff) << 16)
624#define PCI_STATCMD_CMD(x) ((x) & 0xffff)
625#define PCI_CLASSREV_CLASS(x) (((x) & 0x00ffffff) << 8)
626#define PCI_CLASSREV_REV(x) ((x) & 0xff)
627#define PCI_PARAM_BIST(x) (((x) & 0xff) << 24)
628#define PCI_PARAM_HT(x) (((x) & 0xff) << 16)
629#define PCI_PARAM_LT(x) (((x) & 0xff) << 8)
630#define PCI_PARAM_CLS(x) ((x) & 0xff)
631#define PCI_TIMEOUT_RETRIES(x) (((x) & 0xff) << 8) /* max retries */
632#define PCI_TIMEOUT_TO(x) ((x) & 0xff) /* target ready timeout */
37663860 633
37663860 634
2ef1bb99 635/**********************************************************************/
1da177e4 636
1da177e4 637
2ef1bb99 638#ifndef _LANGUAGE_ASSEMBLY
1da177e4 639
2ef1bb99
ML
640#include <linux/delay.h>
641#include <linux/types.h>
1da177e4 642
2ef1bb99
ML
643#include <linux/io.h>
644#include <linux/irq.h>
1da177e4 645
2ef1bb99 646#include <asm/cpu.h>
1da177e4 647
2ef1bb99
ML
648/* cpu pipeline flush */
649void static inline au_sync(void)
650{
651 __asm__ volatile ("sync");
652}
0f0d85bc 653
2ef1bb99
ML
654void static inline au_sync_udelay(int us)
655{
656 __asm__ volatile ("sync");
657 udelay(us);
658}
1da177e4 659
2ef1bb99
ML
660void static inline au_sync_delay(int ms)
661{
662 __asm__ volatile ("sync");
663 mdelay(ms);
664}
1da177e4 665
2ef1bb99
ML
666void static inline au_writeb(u8 val, unsigned long reg)
667{
668 *(volatile u8 *)reg = val;
669}
1da177e4 670
2ef1bb99
ML
671void static inline au_writew(u16 val, unsigned long reg)
672{
673 *(volatile u16 *)reg = val;
674}
cd671c16 675
2ef1bb99
ML
676void static inline au_writel(u32 val, unsigned long reg)
677{
678 *(volatile u32 *)reg = val;
679}
cd671c16 680
2ef1bb99
ML
681static inline u8 au_readb(unsigned long reg)
682{
683 return *(volatile u8 *)reg;
684}
cd671c16 685
2ef1bb99
ML
686static inline u16 au_readw(unsigned long reg)
687{
688 return *(volatile u16 *)reg;
689}
1da177e4 690
2ef1bb99
ML
691static inline u32 au_readl(unsigned long reg)
692{
693 return *(volatile u32 *)reg;
694}
ff6814d5 695
1d09de7d
ML
696/* helpers to access the SYS_* registers */
697static inline unsigned long alchemy_rdsys(int regofs)
698{
699 void __iomem *b = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR);
700
701 return __raw_readl(b + regofs);
702}
703
704static inline void alchemy_wrsys(unsigned long v, int regofs)
705{
706 void __iomem *b = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR);
707
708 __raw_writel(v, b + regofs);
709 wmb(); /* drain writebuffer */
710}
711
9cf12167
ML
712/* helpers to access static memctrl registers */
713static inline unsigned long alchemy_rdsmem(int regofs)
714{
715 void __iomem *b = (void __iomem *)KSEG1ADDR(AU1000_STATIC_MEM_PHYS_ADDR);
716
717 return __raw_readl(b + regofs);
718}
719
720static inline void alchemy_wrsmem(unsigned long v, int regofs)
721{
722 void __iomem *b = (void __iomem *)KSEG1ADDR(AU1000_STATIC_MEM_PHYS_ADDR);
723
724 __raw_writel(v, b + regofs);
725 wmb(); /* drain writebuffer */
726}
727
2ef1bb99
ML
728/* Early Au1000 have a write-only SYS_CPUPLL register. */
729static inline int au1xxx_cpu_has_pll_wo(void)
730{
731 switch (read_c0_prid()) {
732 case 0x00030100: /* Au1000 DA */
733 case 0x00030201: /* Au1000 HA */
734 case 0x00030202: /* Au1000 HB */
735 return 1;
736 }
737 return 0;
738}
ff6814d5 739
2ef1bb99
ML
740/* does CPU need CONFIG[OD] set to fix tons of errata? */
741static inline int au1xxx_cpu_needs_config_od(void)
742{
743 /*
744 * c0_config.od (bit 19) was write only (and read as 0) on the
745 * early revisions of Alchemy SOCs. It disables the bus trans-
746 * action overlapping and needs to be set to fix various errata.
747 */
748 switch (read_c0_prid()) {
749 case 0x00030100: /* Au1000 DA */
750 case 0x00030201: /* Au1000 HA */
751 case 0x00030202: /* Au1000 HB */
752 case 0x01030200: /* Au1500 AB */
753 /*
754 * Au1100/Au1200 errata actually keep silence about this bit,
755 * so we set it just in case for those revisions that require
756 * it to be set according to the (now gone) cpu_table.
757 */
758 case 0x02030200: /* Au1100 AB */
759 case 0x02030201: /* Au1100 BA */
760 case 0x02030202: /* Au1100 BC */
761 case 0x04030201: /* Au1200 AC */
762 return 1;
763 }
764 return 0;
765}
ff6814d5 766
2ef1bb99
ML
767#define ALCHEMY_CPU_UNKNOWN -1
768#define ALCHEMY_CPU_AU1000 0
769#define ALCHEMY_CPU_AU1500 1
770#define ALCHEMY_CPU_AU1100 2
771#define ALCHEMY_CPU_AU1550 3
772#define ALCHEMY_CPU_AU1200 4
773#define ALCHEMY_CPU_AU1300 5
e3ad1c23 774
2ef1bb99
ML
775static inline int alchemy_get_cputype(void)
776{
777 switch (read_c0_prid() & (PRID_OPT_MASK | PRID_COMP_MASK)) {
778 case 0x00030000:
779 return ALCHEMY_CPU_AU1000;
780 break;
781 case 0x01030000:
782 return ALCHEMY_CPU_AU1500;
783 break;
784 case 0x02030000:
785 return ALCHEMY_CPU_AU1100;
786 break;
787 case 0x03030000:
788 return ALCHEMY_CPU_AU1550;
789 break;
790 case 0x04030000:
791 case 0x05030000:
792 return ALCHEMY_CPU_AU1200;
793 break;
794 case 0x800c0000:
795 return ALCHEMY_CPU_AU1300;
796 break;
797 }
1da177e4 798
2ef1bb99
ML
799 return ALCHEMY_CPU_UNKNOWN;
800}
61f9c58d 801
2ef1bb99
ML
802/* return number of uarts on a given cputype */
803static inline int alchemy_get_uarts(int type)
804{
805 switch (type) {
806 case ALCHEMY_CPU_AU1000:
807 case ALCHEMY_CPU_AU1300:
808 return 4;
809 case ALCHEMY_CPU_AU1500:
810 case ALCHEMY_CPU_AU1200:
811 return 2;
812 case ALCHEMY_CPU_AU1100:
813 case ALCHEMY_CPU_AU1550:
814 return 3;
815 }
816 return 0;
817}
37663860 818
2ef1bb99
ML
819/* enable an UART block if it isn't already */
820static inline void alchemy_uart_enable(u32 uart_phys)
821{
822 void __iomem *addr = (void __iomem *)KSEG1ADDR(uart_phys);
37663860 823
2ef1bb99
ML
824 /* reset, enable clock, deassert reset */
825 if ((__raw_readl(addr + 0x100) & 3) != 3) {
826 __raw_writel(0, addr + 0x100);
827 wmb(); /* drain writebuffer */
828 __raw_writel(1, addr + 0x100);
829 wmb(); /* drain writebuffer */
830 }
831 __raw_writel(3, addr + 0x100);
832 wmb(); /* drain writebuffer */
833}
37663860 834
2ef1bb99
ML
835static inline void alchemy_uart_disable(u32 uart_phys)
836{
837 void __iomem *addr = (void __iomem *)KSEG1ADDR(uart_phys);
ff6814d5 838
2ef1bb99
ML
839 __raw_writel(0, addr + 0x100); /* UART_MOD_CNTRL */
840 wmb(); /* drain writebuffer */
841}
1da177e4 842
2ef1bb99
ML
843static inline void alchemy_uart_putchar(u32 uart_phys, u8 c)
844{
845 void __iomem *base = (void __iomem *)KSEG1ADDR(uart_phys);
846 int timeout, i;
1da177e4 847
2ef1bb99
ML
848 /* check LSR TX_EMPTY bit */
849 timeout = 0xffffff;
850 do {
851 if (__raw_readl(base + 0x1c) & 0x20)
852 break;
853 /* slow down */
854 for (i = 10000; i; i--)
855 asm volatile ("nop");
856 } while (--timeout);
1da177e4 857
2ef1bb99
ML
858 __raw_writel(c, base + 0x04); /* tx */
859 wmb(); /* drain writebuffer */
860}
dd99d966 861
2ef1bb99
ML
862/* return number of ethernet MACs on a given cputype */
863static inline int alchemy_get_macs(int type)
864{
865 switch (type) {
866 case ALCHEMY_CPU_AU1000:
867 case ALCHEMY_CPU_AU1500:
868 case ALCHEMY_CPU_AU1550:
869 return 2;
870 case ALCHEMY_CPU_AU1100:
871 return 1;
872 }
873 return 0;
874}
1da177e4 875
2ef1bb99
ML
876/* arch/mips/au1000/common/clocks.c */
877extern void set_au1x00_speed(unsigned int new_freq);
878extern unsigned int get_au1x00_speed(void);
879extern void set_au1x00_uart_baud_base(unsigned long new_baud_base);
880extern unsigned long get_au1x00_uart_baud_base(void);
881extern unsigned long au1xxx_calc_clock(void);
1da177e4 882
2ef1bb99
ML
883/* PM: arch/mips/alchemy/common/sleeper.S, power.c, irq.c */
884void alchemy_sleep_au1000(void);
885void alchemy_sleep_au1550(void);
886void alchemy_sleep_au1300(void);
887void au_sleep(void);
1da177e4 888
2ef1bb99
ML
889/* USB: arch/mips/alchemy/common/usb.c */
890enum alchemy_usb_block {
891 ALCHEMY_USB_OHCI0,
892 ALCHEMY_USB_UDC0,
893 ALCHEMY_USB_EHCI0,
894 ALCHEMY_USB_OTG0,
895 ALCHEMY_USB_OHCI1,
896};
897int alchemy_usb_control(int block, int enable);
1da177e4 898
2ef1bb99
ML
899/* PCI controller platform data */
900struct alchemy_pci_platdata {
901 int (*board_map_irq)(const struct pci_dev *d, u8 slot, u8 pin);
902 int (*board_pci_idsel)(unsigned int devsel, int assert);
903 /* bits to set/clear in PCI_CONFIG register */
904 unsigned long pci_cfg_set;
905 unsigned long pci_cfg_clr;
906};
1da177e4 907
2ef1bb99
ML
908/* The IrDA peripheral has an IRFIRSEL pin, but on the DB/PB boards it's
909 * not used to select FIR/SIR mode on the transceiver but as a GPIO.
910 * Instead a CPLD has to be told about the mode. The driver calls the
911 * set_phy_mode() function in addition to driving the IRFIRSEL pin.
912 */
913#define AU1000_IRDA_PHY_MODE_OFF 0
914#define AU1000_IRDA_PHY_MODE_SIR 1
915#define AU1000_IRDA_PHY_MODE_FIR 2
7517de34 916
2ef1bb99
ML
917struct au1k_irda_platform_data {
918 void (*set_phy_mode)(int mode);
919};
920
921
922/* Multifunction pins: Each of these pins can either be assigned to the
923 * GPIO controller or a on-chip peripheral.
924 * Call "au1300_pinfunc_to_dev()" or "au1300_pinfunc_to_gpio()" to
925 * assign one of these to either the GPIO controller or the device.
926 */
927enum au1300_multifunc_pins {
928 /* wake-from-str pins 0-3 */
929 AU1300_PIN_WAKE0 = 0, AU1300_PIN_WAKE1, AU1300_PIN_WAKE2,
930 AU1300_PIN_WAKE3,
931 /* external clock sources for PSCs: 4-5 */
932 AU1300_PIN_EXTCLK0, AU1300_PIN_EXTCLK1,
933 /* 8bit MMC interface on SD0: 6-9 */
934 AU1300_PIN_SD0DAT4, AU1300_PIN_SD0DAT5, AU1300_PIN_SD0DAT6,
935 AU1300_PIN_SD0DAT7,
936 /* aux clk input for freqgen 3: 10 */
937 AU1300_PIN_FG3AUX,
938 /* UART1 pins: 11-18 */
939 AU1300_PIN_U1RI, AU1300_PIN_U1DCD, AU1300_PIN_U1DSR,
940 AU1300_PIN_U1CTS, AU1300_PIN_U1RTS, AU1300_PIN_U1DTR,
941 AU1300_PIN_U1RX, AU1300_PIN_U1TX,
942 /* UART0 pins: 19-24 */
943 AU1300_PIN_U0RI, AU1300_PIN_U0DCD, AU1300_PIN_U0DSR,
944 AU1300_PIN_U0CTS, AU1300_PIN_U0RTS, AU1300_PIN_U0DTR,
945 /* UART2: 25-26 */
946 AU1300_PIN_U2RX, AU1300_PIN_U2TX,
947 /* UART3: 27-28 */
948 AU1300_PIN_U3RX, AU1300_PIN_U3TX,
949 /* LCD controller PWMs, ext pixclock: 29-31 */
950 AU1300_PIN_LCDPWM0, AU1300_PIN_LCDPWM1, AU1300_PIN_LCDCLKIN,
951 /* SD1 interface: 32-37 */
952 AU1300_PIN_SD1DAT0, AU1300_PIN_SD1DAT1, AU1300_PIN_SD1DAT2,
953 AU1300_PIN_SD1DAT3, AU1300_PIN_SD1CMD, AU1300_PIN_SD1CLK,
954 /* SD2 interface: 38-43 */
955 AU1300_PIN_SD2DAT0, AU1300_PIN_SD2DAT1, AU1300_PIN_SD2DAT2,
956 AU1300_PIN_SD2DAT3, AU1300_PIN_SD2CMD, AU1300_PIN_SD2CLK,
957 /* PSC0/1 clocks: 44-45 */
958 AU1300_PIN_PSC0CLK, AU1300_PIN_PSC1CLK,
959 /* PSCs: 46-49/50-53/54-57/58-61 */
960 AU1300_PIN_PSC0SYNC0, AU1300_PIN_PSC0SYNC1, AU1300_PIN_PSC0D0,
961 AU1300_PIN_PSC0D1,
962 AU1300_PIN_PSC1SYNC0, AU1300_PIN_PSC1SYNC1, AU1300_PIN_PSC1D0,
963 AU1300_PIN_PSC1D1,
964 AU1300_PIN_PSC2SYNC0, AU1300_PIN_PSC2SYNC1, AU1300_PIN_PSC2D0,
965 AU1300_PIN_PSC2D1,
966 AU1300_PIN_PSC3SYNC0, AU1300_PIN_PSC3SYNC1, AU1300_PIN_PSC3D0,
967 AU1300_PIN_PSC3D1,
968 /* PCMCIA interface: 62-70 */
969 AU1300_PIN_PCE2, AU1300_PIN_PCE1, AU1300_PIN_PIOS16,
970 AU1300_PIN_PIOR, AU1300_PIN_PWE, AU1300_PIN_PWAIT,
971 AU1300_PIN_PREG, AU1300_PIN_POE, AU1300_PIN_PIOW,
972 /* camera interface H/V sync inputs: 71-72 */
973 AU1300_PIN_CIMLS, AU1300_PIN_CIMFS,
974 /* PSC2/3 clocks: 73-74 */
975 AU1300_PIN_PSC2CLK, AU1300_PIN_PSC3CLK,
976};
977
978/* GPIC (Au1300) pin management: arch/mips/alchemy/common/gpioint.c */
979extern void au1300_pinfunc_to_gpio(enum au1300_multifunc_pins gpio);
980extern void au1300_pinfunc_to_dev(enum au1300_multifunc_pins gpio);
981extern void au1300_set_irq_priority(unsigned int irq, int p);
982extern void au1300_set_dbdma_gpio(int dchan, unsigned int gpio);
983
984/* Au1300 allows to disconnect certain blocks from internal power supply */
985enum au1300_vss_block {
986 AU1300_VSS_MPE = 0,
987 AU1300_VSS_BSA,
988 AU1300_VSS_GPE,
989 AU1300_VSS_MGP,
990};
991
992extern void au1300_vss_block_control(int block, int enable);
993
994enum soc_au1000_ints {
995 AU1000_FIRST_INT = AU1000_INTC0_INT_BASE,
996 AU1000_UART0_INT = AU1000_FIRST_INT,
997 AU1000_UART1_INT,
998 AU1000_UART2_INT,
999 AU1000_UART3_INT,
1000 AU1000_SSI0_INT,
1001 AU1000_SSI1_INT,
1002 AU1000_DMA_INT_BASE,
1003
1004 AU1000_TOY_INT = AU1000_FIRST_INT + 14,
1005 AU1000_TOY_MATCH0_INT,
1006 AU1000_TOY_MATCH1_INT,
1007 AU1000_TOY_MATCH2_INT,
1008 AU1000_RTC_INT,
1009 AU1000_RTC_MATCH0_INT,
1010 AU1000_RTC_MATCH1_INT,
1011 AU1000_RTC_MATCH2_INT,
1012 AU1000_IRDA_TX_INT,
1013 AU1000_IRDA_RX_INT,
1014 AU1000_USB_DEV_REQ_INT,
1015 AU1000_USB_DEV_SUS_INT,
1016 AU1000_USB_HOST_INT,
1017 AU1000_ACSYNC_INT,
1018 AU1000_MAC0_DMA_INT,
1019 AU1000_MAC1_DMA_INT,
1020 AU1000_I2S_UO_INT,
1021 AU1000_AC97C_INT,
1022 AU1000_GPIO0_INT,
1023 AU1000_GPIO1_INT,
1024 AU1000_GPIO2_INT,
1025 AU1000_GPIO3_INT,
1026 AU1000_GPIO4_INT,
1027 AU1000_GPIO5_INT,
1028 AU1000_GPIO6_INT,
1029 AU1000_GPIO7_INT,
1030 AU1000_GPIO8_INT,
1031 AU1000_GPIO9_INT,
1032 AU1000_GPIO10_INT,
1033 AU1000_GPIO11_INT,
1034 AU1000_GPIO12_INT,
1035 AU1000_GPIO13_INT,
1036 AU1000_GPIO14_INT,
1037 AU1000_GPIO15_INT,
1038 AU1000_GPIO16_INT,
1039 AU1000_GPIO17_INT,
1040 AU1000_GPIO18_INT,
1041 AU1000_GPIO19_INT,
1042 AU1000_GPIO20_INT,
1043 AU1000_GPIO21_INT,
1044 AU1000_GPIO22_INT,
1045 AU1000_GPIO23_INT,
1046 AU1000_GPIO24_INT,
1047 AU1000_GPIO25_INT,
1048 AU1000_GPIO26_INT,
1049 AU1000_GPIO27_INT,
1050 AU1000_GPIO28_INT,
1051 AU1000_GPIO29_INT,
1052 AU1000_GPIO30_INT,
1053 AU1000_GPIO31_INT,
1054};
1055
1056enum soc_au1100_ints {
1057 AU1100_FIRST_INT = AU1000_INTC0_INT_BASE,
1058 AU1100_UART0_INT = AU1100_FIRST_INT,
1059 AU1100_UART1_INT,
1060 AU1100_SD_INT,
1061 AU1100_UART3_INT,
1062 AU1100_SSI0_INT,
1063 AU1100_SSI1_INT,
1064 AU1100_DMA_INT_BASE,
1065
1066 AU1100_TOY_INT = AU1100_FIRST_INT + 14,
1067 AU1100_TOY_MATCH0_INT,
1068 AU1100_TOY_MATCH1_INT,
1069 AU1100_TOY_MATCH2_INT,
1070 AU1100_RTC_INT,
1071 AU1100_RTC_MATCH0_INT,
1072 AU1100_RTC_MATCH1_INT,
1073 AU1100_RTC_MATCH2_INT,
1074 AU1100_IRDA_TX_INT,
1075 AU1100_IRDA_RX_INT,
1076 AU1100_USB_DEV_REQ_INT,
1077 AU1100_USB_DEV_SUS_INT,
1078 AU1100_USB_HOST_INT,
1079 AU1100_ACSYNC_INT,
1080 AU1100_MAC0_DMA_INT,
1081 AU1100_GPIO208_215_INT,
1082 AU1100_LCD_INT,
1083 AU1100_AC97C_INT,
1084 AU1100_GPIO0_INT,
1085 AU1100_GPIO1_INT,
1086 AU1100_GPIO2_INT,
1087 AU1100_GPIO3_INT,
1088 AU1100_GPIO4_INT,
1089 AU1100_GPIO5_INT,
1090 AU1100_GPIO6_INT,
1091 AU1100_GPIO7_INT,
1092 AU1100_GPIO8_INT,
1093 AU1100_GPIO9_INT,
1094 AU1100_GPIO10_INT,
1095 AU1100_GPIO11_INT,
1096 AU1100_GPIO12_INT,
1097 AU1100_GPIO13_INT,
1098 AU1100_GPIO14_INT,
1099 AU1100_GPIO15_INT,
1100 AU1100_GPIO16_INT,
1101 AU1100_GPIO17_INT,
1102 AU1100_GPIO18_INT,
1103 AU1100_GPIO19_INT,
1104 AU1100_GPIO20_INT,
1105 AU1100_GPIO21_INT,
1106 AU1100_GPIO22_INT,
1107 AU1100_GPIO23_INT,
1108 AU1100_GPIO24_INT,
1109 AU1100_GPIO25_INT,
1110 AU1100_GPIO26_INT,
1111 AU1100_GPIO27_INT,
1112 AU1100_GPIO28_INT,
1113 AU1100_GPIO29_INT,
1114 AU1100_GPIO30_INT,
1115 AU1100_GPIO31_INT,
1116};
1117
1118enum soc_au1500_ints {
1119 AU1500_FIRST_INT = AU1000_INTC0_INT_BASE,
1120 AU1500_UART0_INT = AU1500_FIRST_INT,
1121 AU1500_PCI_INTA,
1122 AU1500_PCI_INTB,
1123 AU1500_UART3_INT,
1124 AU1500_PCI_INTC,
1125 AU1500_PCI_INTD,
1126 AU1500_DMA_INT_BASE,
1127
1128 AU1500_TOY_INT = AU1500_FIRST_INT + 14,
1129 AU1500_TOY_MATCH0_INT,
1130 AU1500_TOY_MATCH1_INT,
1131 AU1500_TOY_MATCH2_INT,
1132 AU1500_RTC_INT,
1133 AU1500_RTC_MATCH0_INT,
1134 AU1500_RTC_MATCH1_INT,
1135 AU1500_RTC_MATCH2_INT,
1136 AU1500_PCI_ERR_INT,
1137 AU1500_RESERVED_INT,
1138 AU1500_USB_DEV_REQ_INT,
1139 AU1500_USB_DEV_SUS_INT,
1140 AU1500_USB_HOST_INT,
1141 AU1500_ACSYNC_INT,
1142 AU1500_MAC0_DMA_INT,
1143 AU1500_MAC1_DMA_INT,
1144 AU1500_AC97C_INT = AU1500_FIRST_INT + 31,
1145 AU1500_GPIO0_INT,
1146 AU1500_GPIO1_INT,
1147 AU1500_GPIO2_INT,
1148 AU1500_GPIO3_INT,
1149 AU1500_GPIO4_INT,
1150 AU1500_GPIO5_INT,
1151 AU1500_GPIO6_INT,
1152 AU1500_GPIO7_INT,
1153 AU1500_GPIO8_INT,
1154 AU1500_GPIO9_INT,
1155 AU1500_GPIO10_INT,
1156 AU1500_GPIO11_INT,
1157 AU1500_GPIO12_INT,
1158 AU1500_GPIO13_INT,
1159 AU1500_GPIO14_INT,
1160 AU1500_GPIO15_INT,
1161 AU1500_GPIO200_INT,
1162 AU1500_GPIO201_INT,
1163 AU1500_GPIO202_INT,
1164 AU1500_GPIO203_INT,
1165 AU1500_GPIO20_INT,
1166 AU1500_GPIO204_INT,
1167 AU1500_GPIO205_INT,
1168 AU1500_GPIO23_INT,
1169 AU1500_GPIO24_INT,
1170 AU1500_GPIO25_INT,
1171 AU1500_GPIO26_INT,
1172 AU1500_GPIO27_INT,
1173 AU1500_GPIO28_INT,
1174 AU1500_GPIO206_INT,
1175 AU1500_GPIO207_INT,
1176 AU1500_GPIO208_215_INT,
1177};
1178
1179enum soc_au1550_ints {
1180 AU1550_FIRST_INT = AU1000_INTC0_INT_BASE,
1181 AU1550_UART0_INT = AU1550_FIRST_INT,
1182 AU1550_PCI_INTA,
1183 AU1550_PCI_INTB,
1184 AU1550_DDMA_INT,
1185 AU1550_CRYPTO_INT,
1186 AU1550_PCI_INTC,
1187 AU1550_PCI_INTD,
1188 AU1550_PCI_RST_INT,
1189 AU1550_UART1_INT,
1190 AU1550_UART3_INT,
1191 AU1550_PSC0_INT,
1192 AU1550_PSC1_INT,
1193 AU1550_PSC2_INT,
1194 AU1550_PSC3_INT,
1195 AU1550_TOY_INT,
1196 AU1550_TOY_MATCH0_INT,
1197 AU1550_TOY_MATCH1_INT,
1198 AU1550_TOY_MATCH2_INT,
1199 AU1550_RTC_INT,
1200 AU1550_RTC_MATCH0_INT,
1201 AU1550_RTC_MATCH1_INT,
1202 AU1550_RTC_MATCH2_INT,
1203
1204 AU1550_NAND_INT = AU1550_FIRST_INT + 23,
1205 AU1550_USB_DEV_REQ_INT,
1206 AU1550_USB_DEV_SUS_INT,
1207 AU1550_USB_HOST_INT,
1208 AU1550_MAC0_DMA_INT,
1209 AU1550_MAC1_DMA_INT,
1210 AU1550_GPIO0_INT = AU1550_FIRST_INT + 32,
1211 AU1550_GPIO1_INT,
1212 AU1550_GPIO2_INT,
1213 AU1550_GPIO3_INT,
1214 AU1550_GPIO4_INT,
1215 AU1550_GPIO5_INT,
1216 AU1550_GPIO6_INT,
1217 AU1550_GPIO7_INT,
1218 AU1550_GPIO8_INT,
1219 AU1550_GPIO9_INT,
1220 AU1550_GPIO10_INT,
1221 AU1550_GPIO11_INT,
1222 AU1550_GPIO12_INT,
1223 AU1550_GPIO13_INT,
1224 AU1550_GPIO14_INT,
1225 AU1550_GPIO15_INT,
1226 AU1550_GPIO200_INT,
1227 AU1550_GPIO201_205_INT, /* Logical or of GPIO201:205 */
1228 AU1550_GPIO16_INT,
1229 AU1550_GPIO17_INT,
1230 AU1550_GPIO20_INT,
1231 AU1550_GPIO21_INT,
1232 AU1550_GPIO22_INT,
1233 AU1550_GPIO23_INT,
1234 AU1550_GPIO24_INT,
1235 AU1550_GPIO25_INT,
1236 AU1550_GPIO26_INT,
1237 AU1550_GPIO27_INT,
1238 AU1550_GPIO28_INT,
1239 AU1550_GPIO206_INT,
1240 AU1550_GPIO207_INT,
1241 AU1550_GPIO208_215_INT, /* Logical or of GPIO208:215 */
1242};
1243
1244enum soc_au1200_ints {
1245 AU1200_FIRST_INT = AU1000_INTC0_INT_BASE,
1246 AU1200_UART0_INT = AU1200_FIRST_INT,
1247 AU1200_SWT_INT,
1248 AU1200_SD_INT,
1249 AU1200_DDMA_INT,
1250 AU1200_MAE_BE_INT,
1251 AU1200_GPIO200_INT,
1252 AU1200_GPIO201_INT,
1253 AU1200_GPIO202_INT,
1254 AU1200_UART1_INT,
1255 AU1200_MAE_FE_INT,
1256 AU1200_PSC0_INT,
1257 AU1200_PSC1_INT,
1258 AU1200_AES_INT,
1259 AU1200_CAMERA_INT,
1260 AU1200_TOY_INT,
1261 AU1200_TOY_MATCH0_INT,
1262 AU1200_TOY_MATCH1_INT,
1263 AU1200_TOY_MATCH2_INT,
1264 AU1200_RTC_INT,
1265 AU1200_RTC_MATCH0_INT,
1266 AU1200_RTC_MATCH1_INT,
1267 AU1200_RTC_MATCH2_INT,
1268 AU1200_GPIO203_INT,
1269 AU1200_NAND_INT,
1270 AU1200_GPIO204_INT,
1271 AU1200_GPIO205_INT,
1272 AU1200_GPIO206_INT,
1273 AU1200_GPIO207_INT,
1274 AU1200_GPIO208_215_INT, /* Logical OR of 208:215 */
1275 AU1200_USB_INT,
1276 AU1200_LCD_INT,
1277 AU1200_MAE_BOTH_INT,
1278 AU1200_GPIO0_INT,
1279 AU1200_GPIO1_INT,
1280 AU1200_GPIO2_INT,
1281 AU1200_GPIO3_INT,
1282 AU1200_GPIO4_INT,
1283 AU1200_GPIO5_INT,
1284 AU1200_GPIO6_INT,
1285 AU1200_GPIO7_INT,
1286 AU1200_GPIO8_INT,
1287 AU1200_GPIO9_INT,
1288 AU1200_GPIO10_INT,
1289 AU1200_GPIO11_INT,
1290 AU1200_GPIO12_INT,
1291 AU1200_GPIO13_INT,
1292 AU1200_GPIO14_INT,
1293 AU1200_GPIO15_INT,
1294 AU1200_GPIO16_INT,
1295 AU1200_GPIO17_INT,
1296 AU1200_GPIO18_INT,
1297 AU1200_GPIO19_INT,
1298 AU1200_GPIO20_INT,
1299 AU1200_GPIO21_INT,
1300 AU1200_GPIO22_INT,
1301 AU1200_GPIO23_INT,
1302 AU1200_GPIO24_INT,
1303 AU1200_GPIO25_INT,
1304 AU1200_GPIO26_INT,
1305 AU1200_GPIO27_INT,
1306 AU1200_GPIO28_INT,
1307 AU1200_GPIO29_INT,
1308 AU1200_GPIO30_INT,
1309 AU1200_GPIO31_INT,
1310};
1311
1312#endif /* !defined (_LANGUAGE_ASSEMBLY) */
7517de34 1313
e3ad1c23 1314#endif