aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/alchemy
diff options
context:
space:
mode:
authorManuel Lauss <manuel.lauss@googlemail.com>2011-11-01 15:03:30 -0400
committerRalf Baechle <ralf@linux-mips.org>2011-12-07 17:02:05 -0500
commit809f36c6f4a0568178c909ff1096ca83eae33f7d (patch)
tree6b99b1ac701c0bd581811c39e85856f3bcbda22d /arch/mips/alchemy
parentfb469f084fdf1631e31d87270f5263c20a7f5cd6 (diff)
MIPS: Alchemy: Au1300 SoC support
Add basic support for the Au1300 variant(s): - New GPIO/Interrupt controller - DBDMA ids - USB setup - MMC support - enable various PSC drivers - detection code. Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com> To: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/2866/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/alchemy')
-rw-r--r--arch/mips/alchemy/Kconfig4
-rw-r--r--arch/mips/alchemy/common/Makefile3
-rw-r--r--arch/mips/alchemy/common/dbdma.c46
-rw-r--r--arch/mips/alchemy/common/gpioint.c411
-rw-r--r--arch/mips/alchemy/common/gpiolib.c42
-rw-r--r--arch/mips/alchemy/common/platform.c31
-rw-r--r--arch/mips/alchemy/common/power.c3
-rw-r--r--arch/mips/alchemy/common/sleeper.S73
-rw-r--r--arch/mips/alchemy/common/time.c1
-rw-r--r--arch/mips/alchemy/common/vss.c84
10 files changed, 695 insertions, 3 deletions
diff --git a/arch/mips/alchemy/Kconfig b/arch/mips/alchemy/Kconfig
index 36df5e2c8e07..766badaef3b0 100644
--- a/arch/mips/alchemy/Kconfig
+++ b/arch/mips/alchemy/Kconfig
@@ -2,6 +2,10 @@
2config ALCHEMY_GPIOINT_AU1000 2config ALCHEMY_GPIOINT_AU1000
3 bool 3 bool
4 4
5# au1300-style GPIO/INT controller
6config ALCHEMY_GPIOINT_AU1300
7 bool
8
5# select this in your board config if you don't want to use the gpio 9# select this in your board config if you don't want to use the gpio
6# namespace as documented in the manuals. In this case however you need 10# namespace as documented in the manuals. In this case however you need
7# to create the necessary gpio_* functions in your board code/headers! 11# to create the necessary gpio_* functions in your board code/headers!
diff --git a/arch/mips/alchemy/common/Makefile b/arch/mips/alchemy/common/Makefile
index 811ece7b22e3..d3f5c5137804 100644
--- a/arch/mips/alchemy/common/Makefile
+++ b/arch/mips/alchemy/common/Makefile
@@ -6,9 +6,10 @@
6# 6#
7 7
8obj-y += prom.o time.o clocks.o platform.o power.o setup.o \ 8obj-y += prom.o time.o clocks.o platform.o power.o setup.o \
9 sleeper.o dma.o dbdma.o 9 sleeper.o dma.o dbdma.o vss.o
10 10
11obj-$(CONFIG_ALCHEMY_GPIOINT_AU1000) += irq.o 11obj-$(CONFIG_ALCHEMY_GPIOINT_AU1000) += irq.o
12obj-$(CONFIG_ALCHEMY_GPIOINT_AU1300) += gpioint.o
12 13
13# optional gpiolib support 14# optional gpiolib support
14ifeq ($(CONFIG_ALCHEMY_GPIO_INDIRECT),) 15ifeq ($(CONFIG_ALCHEMY_GPIO_INDIRECT),)
diff --git a/arch/mips/alchemy/common/dbdma.c b/arch/mips/alchemy/common/dbdma.c
index 0e63ee487d6d..c723ec1d3b2c 100644
--- a/arch/mips/alchemy/common/dbdma.c
+++ b/arch/mips/alchemy/common/dbdma.c
@@ -148,6 +148,50 @@ static dbdev_tab_t au1200_dbdev_tab[] __initdata = {
148 { DSCR_CMD0_ALWAYS, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 }, 148 { DSCR_CMD0_ALWAYS, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
149}; 149};
150 150
151static dbdev_tab_t au1300_dbdev_tab[] __initdata = {
152 { AU1300_DSCR_CMD0_UART0_TX, DEV_FLAGS_OUT, 0, 8, 0x10100004, 0, 0 },
153 { AU1300_DSCR_CMD0_UART0_RX, DEV_FLAGS_IN, 0, 8, 0x10100000, 0, 0 },
154 { AU1300_DSCR_CMD0_UART1_TX, DEV_FLAGS_OUT, 0, 8, 0x10101004, 0, 0 },
155 { AU1300_DSCR_CMD0_UART1_RX, DEV_FLAGS_IN, 0, 8, 0x10101000, 0, 0 },
156 { AU1300_DSCR_CMD0_UART2_TX, DEV_FLAGS_OUT, 0, 8, 0x10102004, 0, 0 },
157 { AU1300_DSCR_CMD0_UART2_RX, DEV_FLAGS_IN, 0, 8, 0x10102000, 0, 0 },
158 { AU1300_DSCR_CMD0_UART3_TX, DEV_FLAGS_OUT, 0, 8, 0x10103004, 0, 0 },
159 { AU1300_DSCR_CMD0_UART3_RX, DEV_FLAGS_IN, 0, 8, 0x10103000, 0, 0 },
160
161 { AU1300_DSCR_CMD0_SDMS_TX0, DEV_FLAGS_OUT, 4, 8, 0x10600000, 0, 0 },
162 { AU1300_DSCR_CMD0_SDMS_RX0, DEV_FLAGS_IN, 4, 8, 0x10600004, 0, 0 },
163 { AU1300_DSCR_CMD0_SDMS_TX1, DEV_FLAGS_OUT, 8, 8, 0x10601000, 0, 0 },
164 { AU1300_DSCR_CMD0_SDMS_RX1, DEV_FLAGS_IN, 8, 8, 0x10601004, 0, 0 },
165
166 { AU1300_DSCR_CMD0_AES_RX, DEV_FLAGS_IN , 4, 32, 0x10300008, 0, 0 },
167 { AU1300_DSCR_CMD0_AES_TX, DEV_FLAGS_OUT, 4, 32, 0x10300004, 0, 0 },
168
169 { AU1300_DSCR_CMD0_PSC0_TX, DEV_FLAGS_OUT, 0, 16, 0x10a0001c, 0, 0 },
170 { AU1300_DSCR_CMD0_PSC0_RX, DEV_FLAGS_IN, 0, 16, 0x10a0001c, 0, 0 },
171 { AU1300_DSCR_CMD0_PSC1_TX, DEV_FLAGS_OUT, 0, 16, 0x10a0101c, 0, 0 },
172 { AU1300_DSCR_CMD0_PSC1_RX, DEV_FLAGS_IN, 0, 16, 0x10a0101c, 0, 0 },
173 { AU1300_DSCR_CMD0_PSC2_TX, DEV_FLAGS_OUT, 0, 16, 0x10a0201c, 0, 0 },
174 { AU1300_DSCR_CMD0_PSC2_RX, DEV_FLAGS_IN, 0, 16, 0x10a0201c, 0, 0 },
175 { AU1300_DSCR_CMD0_PSC3_TX, DEV_FLAGS_OUT, 0, 16, 0x10a0301c, 0, 0 },
176 { AU1300_DSCR_CMD0_PSC3_RX, DEV_FLAGS_IN, 0, 16, 0x10a0301c, 0, 0 },
177
178 { AU1300_DSCR_CMD0_LCD, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
179 { AU1300_DSCR_CMD0_NAND_FLASH, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
180
181 { AU1300_DSCR_CMD0_SDMS_TX2, DEV_FLAGS_OUT, 4, 8, 0x10602000, 0, 0 },
182 { AU1300_DSCR_CMD0_SDMS_RX2, DEV_FLAGS_IN, 4, 8, 0x10602004, 0, 0 },
183
184 { AU1300_DSCR_CMD0_CIM_SYNC, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
185
186 { AU1300_DSCR_CMD0_UDMA, DEV_FLAGS_ANYUSE, 0, 32, 0x14001810, 0, 0 },
187
188 { AU1300_DSCR_CMD0_DMA_REQ0, 0, 0, 0, 0x00000000, 0, 0 },
189 { AU1300_DSCR_CMD0_DMA_REQ1, 0, 0, 0, 0x00000000, 0, 0 },
190
191 { DSCR_CMD0_THROTTLE, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
192 { DSCR_CMD0_ALWAYS, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
193};
194
151/* 32 predefined plus 32 custom */ 195/* 32 predefined plus 32 custom */
152#define DBDEV_TAB_SIZE 64 196#define DBDEV_TAB_SIZE 64
153 197
@@ -1038,6 +1082,8 @@ static int __init alchemy_dbdma_init(void)
1038 return dbdma_setup(AU1550_DDMA_INT, au1550_dbdev_tab); 1082 return dbdma_setup(AU1550_DDMA_INT, au1550_dbdev_tab);
1039 case ALCHEMY_CPU_AU1200: 1083 case ALCHEMY_CPU_AU1200:
1040 return dbdma_setup(AU1200_DDMA_INT, au1200_dbdev_tab); 1084 return dbdma_setup(AU1200_DDMA_INT, au1200_dbdev_tab);
1085 case ALCHEMY_CPU_AU1300:
1086 return dbdma_setup(AU1300_DDMA_INT, au1300_dbdev_tab);
1041 } 1087 }
1042 return 0; 1088 return 0;
1043} 1089}
diff --git a/arch/mips/alchemy/common/gpioint.c b/arch/mips/alchemy/common/gpioint.c
new file mode 100644
index 000000000000..b8cd3364ff69
--- /dev/null
+++ b/arch/mips/alchemy/common/gpioint.c
@@ -0,0 +1,411 @@
1/*
2 * gpioint.c - Au1300 GPIO+Interrupt controller (I call it "GPIC") support.
3 *
4 * Copyright (c) 2009-2011 Manuel Lauss <manuel.lauss@googlemail.com>
5 *
6 * licensed under the GPLv2.
7 */
8
9#include <linux/io.h>
10#include <linux/interrupt.h>
11#include <linux/module.h>
12#include <linux/slab.h>
13#include <linux/syscore_ops.h>
14#include <linux/types.h>
15
16#include <asm/irq_cpu.h>
17#include <asm/mach-au1x00/au1000.h>
18#include <asm/mach-au1x00/gpio-au1300.h>
19
20static int au1300_gpic_settype(struct irq_data *d, unsigned int type);
21
22/* setup for known onchip sources */
23struct gpic_devint_data {
24 int irq; /* linux IRQ number */
25 int type; /* IRQ_TYPE_ */
26 int prio; /* irq priority, 0 highest, 3 lowest */
27 int internal; /* internal source (no ext. pin)? */
28};
29
30static const struct gpic_devint_data au1300_devints[] __initdata = {
31 /* multifunction: gpio pin or device */
32 { AU1300_UART1_INT, IRQ_TYPE_LEVEL_HIGH, 1, 0, },
33 { AU1300_UART2_INT, IRQ_TYPE_LEVEL_HIGH, 1, 0, },
34 { AU1300_UART3_INT, IRQ_TYPE_LEVEL_HIGH, 1, 0, },
35 { AU1300_SD1_INT, IRQ_TYPE_LEVEL_HIGH, 1, 0, },
36 { AU1300_SD2_INT, IRQ_TYPE_LEVEL_HIGH, 1, 0, },
37 { AU1300_PSC0_INT, IRQ_TYPE_LEVEL_HIGH, 1, 0, },
38 { AU1300_PSC1_INT, IRQ_TYPE_LEVEL_HIGH, 1, 0, },
39 { AU1300_PSC2_INT, IRQ_TYPE_LEVEL_HIGH, 1, 0, },
40 { AU1300_PSC3_INT, IRQ_TYPE_LEVEL_HIGH, 1, 0, },
41 { AU1300_NAND_INT, IRQ_TYPE_LEVEL_HIGH, 1, 0, },
42 /* au1300 internal */
43 { AU1300_DDMA_INT, IRQ_TYPE_LEVEL_HIGH, 1, 1, },
44 { AU1300_MMU_INT, IRQ_TYPE_LEVEL_HIGH, 1, 1, },
45 { AU1300_MPU_INT, IRQ_TYPE_LEVEL_HIGH, 1, 1, },
46 { AU1300_GPU_INT, IRQ_TYPE_LEVEL_HIGH, 1, 1, },
47 { AU1300_UDMA_INT, IRQ_TYPE_LEVEL_HIGH, 1, 1, },
48 { AU1300_TOY_INT, IRQ_TYPE_EDGE_RISING, 1, 1, },
49 { AU1300_TOY_MATCH0_INT, IRQ_TYPE_EDGE_RISING, 1, 1, },
50 { AU1300_TOY_MATCH1_INT, IRQ_TYPE_EDGE_RISING, 1, 1, },
51 { AU1300_TOY_MATCH2_INT, IRQ_TYPE_EDGE_RISING, 1, 1, },
52 { AU1300_RTC_INT, IRQ_TYPE_EDGE_RISING, 1, 1, },
53 { AU1300_RTC_MATCH0_INT, IRQ_TYPE_EDGE_RISING, 1, 1, },
54 { AU1300_RTC_MATCH1_INT, IRQ_TYPE_EDGE_RISING, 1, 1, },
55 { AU1300_RTC_MATCH2_INT, IRQ_TYPE_EDGE_RISING, 0, 1, },
56 { AU1300_UART0_INT, IRQ_TYPE_LEVEL_HIGH, 1, 1, },
57 { AU1300_SD0_INT, IRQ_TYPE_LEVEL_HIGH, 1, 1, },
58 { AU1300_USB_INT, IRQ_TYPE_LEVEL_HIGH, 1, 1, },
59 { AU1300_LCD_INT, IRQ_TYPE_LEVEL_HIGH, 1, 1, },
60 { AU1300_BSA_INT, IRQ_TYPE_LEVEL_HIGH, 1, 1, },
61 { AU1300_MPE_INT, IRQ_TYPE_EDGE_RISING, 1, 1, },
62 { AU1300_ITE_INT, IRQ_TYPE_LEVEL_HIGH, 1, 1, },
63 { AU1300_AES_INT, IRQ_TYPE_LEVEL_HIGH, 1, 1, },
64 { AU1300_CIM_INT, IRQ_TYPE_LEVEL_HIGH, 1, 1, },
65 { -1, }, /* terminator */
66};
67
68
69/*
70 * au1300_gpic_chgcfg - change PIN configuration.
71 * @gpio: pin to change (0-based GPIO number from datasheet).
72 * @clr: clear all bits set in 'clr'.
73 * @set: set these bits.
74 *
75 * modifies a pins' configuration register, bits set in @clr will
76 * be cleared in the register, bits in @set will be set.
77 */
78static inline void au1300_gpic_chgcfg(unsigned int gpio,
79 unsigned long clr,
80 unsigned long set)
81{
82 void __iomem *r = AU1300_GPIC_ADDR;
83 unsigned long l;
84
85 r += gpio * 4; /* offset into pin config array */
86 l = __raw_readl(r + AU1300_GPIC_PINCFG);
87 l &= ~clr;
88 l |= set;
89 __raw_writel(l, r + AU1300_GPIC_PINCFG);
90 wmb();
91}
92
93/*
94 * au1300_pinfunc_to_gpio - assign a pin as GPIO input (GPIO ctrl).
95 * @pin: pin (0-based GPIO number from datasheet).
96 *
97 * Assigns a GPIO pin to the GPIO controller, so its level can either
98 * be read or set through the generic GPIO functions.
99 * If you need a GPOUT, use au1300_gpio_set_value(pin, 0/1).
100 * REVISIT: is this function really necessary?
101 */
102void au1300_pinfunc_to_gpio(enum au1300_multifunc_pins gpio)
103{
104 au1300_gpio_direction_input(gpio + AU1300_GPIO_BASE);
105}
106EXPORT_SYMBOL_GPL(au1300_pinfunc_to_gpio);
107
108/*
109 * au1300_pinfunc_to_dev - assign a pin to the device function.
110 * @pin: pin (0-based GPIO number from datasheet).
111 *
112 * Assigns a GPIO pin to its associated device function; the pin will be
113 * driven by the device and not through GPIO functions.
114 */
115void au1300_pinfunc_to_dev(enum au1300_multifunc_pins gpio)
116{
117 void __iomem *r = AU1300_GPIC_ADDR;
118 unsigned long bit;
119
120 r += GPIC_GPIO_BANKOFF(gpio);
121 bit = GPIC_GPIO_TO_BIT(gpio);
122 __raw_writel(bit, r + AU1300_GPIC_DEVSEL);
123 wmb();
124}
125EXPORT_SYMBOL_GPL(au1300_pinfunc_to_dev);
126
127/*
128 * au1300_set_irq_priority - set internal priority of IRQ.
129 * @irq: irq to set priority (linux irq number).
130 * @p: priority (0 = highest, 3 = lowest).
131 */
132void au1300_set_irq_priority(unsigned int irq, int p)
133{
134 irq -= ALCHEMY_GPIC_INT_BASE;
135 au1300_gpic_chgcfg(irq, GPIC_CFG_IL_MASK, GPIC_CFG_IL_SET(p));
136}
137EXPORT_SYMBOL_GPL(au1300_set_irq_priority);
138
139/*
140 * au1300_set_dbdma_gpio - assign a gpio to one of the DBDMA triggers.
141 * @dchan: dbdma trigger select (0, 1).
142 * @gpio: pin to assign as trigger.
143 *
144 * DBDMA controller has 2 external trigger sources; this function
145 * assigns a GPIO to the selected trigger.
146 */
147void au1300_set_dbdma_gpio(int dchan, unsigned int gpio)
148{
149 unsigned long r;
150
151 if ((dchan >= 0) && (dchan <= 1)) {
152 r = __raw_readl(AU1300_GPIC_ADDR + AU1300_GPIC_DMASEL);
153 r &= ~(0xff << (8 * dchan));
154 r |= (gpio & 0x7f) << (8 * dchan);
155 __raw_writel(r, AU1300_GPIC_ADDR + AU1300_GPIC_DMASEL);
156 wmb();
157 }
158}
159
160/**********************************************************************/
161
162static inline void gpic_pin_set_idlewake(unsigned int gpio, int allow)
163{
164 au1300_gpic_chgcfg(gpio, GPIC_CFG_IDLEWAKE,
165 allow ? GPIC_CFG_IDLEWAKE : 0);
166}
167
168static void au1300_gpic_mask(struct irq_data *d)
169{
170 void __iomem *r = AU1300_GPIC_ADDR;
171 unsigned long bit, irq = d->irq;
172
173 irq -= ALCHEMY_GPIC_INT_BASE;
174 r += GPIC_GPIO_BANKOFF(irq);
175 bit = GPIC_GPIO_TO_BIT(irq);
176 __raw_writel(bit, r + AU1300_GPIC_IDIS);
177 wmb();
178
179 gpic_pin_set_idlewake(irq, 0);
180}
181
182static void au1300_gpic_unmask(struct irq_data *d)
183{
184 void __iomem *r = AU1300_GPIC_ADDR;
185 unsigned long bit, irq = d->irq;
186
187 irq -= ALCHEMY_GPIC_INT_BASE;
188
189 gpic_pin_set_idlewake(irq, 1);
190
191 r += GPIC_GPIO_BANKOFF(irq);
192 bit = GPIC_GPIO_TO_BIT(irq);
193 __raw_writel(bit, r + AU1300_GPIC_IEN);
194 wmb();
195}
196
197static void au1300_gpic_maskack(struct irq_data *d)
198{
199 void __iomem *r = AU1300_GPIC_ADDR;
200 unsigned long bit, irq = d->irq;
201
202 irq -= ALCHEMY_GPIC_INT_BASE;
203 r += GPIC_GPIO_BANKOFF(irq);
204 bit = GPIC_GPIO_TO_BIT(irq);
205 __raw_writel(bit, r + AU1300_GPIC_IPEND); /* ack */
206 __raw_writel(bit, r + AU1300_GPIC_IDIS); /* mask */
207 wmb();
208
209 gpic_pin_set_idlewake(irq, 0);
210}
211
212static void au1300_gpic_ack(struct irq_data *d)
213{
214 void __iomem *r = AU1300_GPIC_ADDR;
215 unsigned long bit, irq = d->irq;
216
217 irq -= ALCHEMY_GPIC_INT_BASE;
218 r += GPIC_GPIO_BANKOFF(irq);
219 bit = GPIC_GPIO_TO_BIT(irq);
220 __raw_writel(bit, r + AU1300_GPIC_IPEND); /* ack */
221 wmb();
222}
223
224static struct irq_chip au1300_gpic = {
225 .name = "GPIOINT",
226 .irq_ack = au1300_gpic_ack,
227 .irq_mask = au1300_gpic_mask,
228 .irq_mask_ack = au1300_gpic_maskack,
229 .irq_unmask = au1300_gpic_unmask,
230 .irq_set_type = au1300_gpic_settype,
231};
232
233static int au1300_gpic_settype(struct irq_data *d, unsigned int type)
234{
235 unsigned long s;
236 unsigned char *name = NULL;
237 irq_flow_handler_t hdl = NULL;
238
239 switch (type) {
240 case IRQ_TYPE_LEVEL_HIGH:
241 s = GPIC_CFG_IC_LEVEL_HIGH;
242 name = "high";
243 hdl = handle_level_irq;
244 break;
245 case IRQ_TYPE_LEVEL_LOW:
246 s = GPIC_CFG_IC_LEVEL_LOW;
247 name = "low";
248 hdl = handle_level_irq;
249 break;
250 case IRQ_TYPE_EDGE_RISING:
251 s = GPIC_CFG_IC_EDGE_RISE;
252 name = "posedge";
253 hdl = handle_edge_irq;
254 break;
255 case IRQ_TYPE_EDGE_FALLING:
256 s = GPIC_CFG_IC_EDGE_FALL;
257 name = "negedge";
258 hdl = handle_edge_irq;
259 break;
260 case IRQ_TYPE_EDGE_BOTH:
261 s = GPIC_CFG_IC_EDGE_BOTH;
262 name = "bothedge";
263 hdl = handle_edge_irq;
264 break;
265 case IRQ_TYPE_NONE:
266 s = GPIC_CFG_IC_OFF;
267 name = "disabled";
268 hdl = handle_level_irq;
269 break;
270 default:
271 return -EINVAL;
272 }
273
274 __irq_set_chip_handler_name_locked(d->irq, &au1300_gpic, hdl, name);
275
276 au1300_gpic_chgcfg(d->irq - ALCHEMY_GPIC_INT_BASE, GPIC_CFG_IC_MASK, s);
277
278 return 0;
279}
280
281static void __init alchemy_gpic_init_irq(const struct gpic_devint_data *dints)
282{
283 int i;
284 void __iomem *bank_base;
285
286 mips_cpu_irq_init();
287
288 /* disable & ack all possible interrupt sources */
289 for (i = 0; i < 4; i++) {
290 bank_base = AU1300_GPIC_ADDR + (i * 4);
291 __raw_writel(~0UL, bank_base + AU1300_GPIC_IDIS);
292 wmb();
293 __raw_writel(~0UL, bank_base + AU1300_GPIC_IPEND);
294 wmb();
295 }
296
297 /* register an irq_chip for them, with 2nd highest priority */
298 for (i = ALCHEMY_GPIC_INT_BASE; i <= ALCHEMY_GPIC_INT_LAST; i++) {
299 au1300_set_irq_priority(i, 1);
300 au1300_gpic_settype(irq_get_irq_data(i), IRQ_TYPE_NONE);
301 }
302
303 /* setup known on-chip sources */
304 while ((i = dints->irq) != -1) {
305 au1300_gpic_settype(irq_get_irq_data(i), dints->type);
306 au1300_set_irq_priority(i, dints->prio);
307
308 if (dints->internal)
309 au1300_pinfunc_to_dev(i - ALCHEMY_GPIC_INT_BASE);
310
311 dints++;
312 }
313
314 set_c0_status(IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3);
315}
316
317static unsigned long alchemy_gpic_pmdata[ALCHEMY_GPIC_INT_NUM + 6];
318
319static int alchemy_gpic_suspend(void)
320{
321 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1300_GPIC_PHYS_ADDR);
322 int i;
323
324 /* save 4 interrupt mask status registers */
325 alchemy_gpic_pmdata[0] = __raw_readl(base + AU1300_GPIC_IEN + 0x0);
326 alchemy_gpic_pmdata[1] = __raw_readl(base + AU1300_GPIC_IEN + 0x4);
327 alchemy_gpic_pmdata[2] = __raw_readl(base + AU1300_GPIC_IEN + 0x8);
328 alchemy_gpic_pmdata[3] = __raw_readl(base + AU1300_GPIC_IEN + 0xc);
329
330 /* save misc register(s) */
331 alchemy_gpic_pmdata[4] = __raw_readl(base + AU1300_GPIC_DMASEL);
332
333 /* molto silenzioso */
334 __raw_writel(~0UL, base + AU1300_GPIC_IDIS + 0x0);
335 __raw_writel(~0UL, base + AU1300_GPIC_IDIS + 0x4);
336 __raw_writel(~0UL, base + AU1300_GPIC_IDIS + 0x8);
337 __raw_writel(~0UL, base + AU1300_GPIC_IDIS + 0xc);
338 wmb();
339
340 /* save pin/int-type configuration */
341 base += AU1300_GPIC_PINCFG;
342 for (i = 0; i < ALCHEMY_GPIC_INT_NUM; i++)
343 alchemy_gpic_pmdata[i + 5] = __raw_readl(base + (i << 2));
344
345 wmb();
346
347 return 0;
348}
349
350static void alchemy_gpic_resume(void)
351{
352 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1300_GPIC_PHYS_ADDR);
353 int i;
354
355 /* disable all first */
356 __raw_writel(~0UL, base + AU1300_GPIC_IDIS + 0x0);
357 __raw_writel(~0UL, base + AU1300_GPIC_IDIS + 0x4);
358 __raw_writel(~0UL, base + AU1300_GPIC_IDIS + 0x8);
359 __raw_writel(~0UL, base + AU1300_GPIC_IDIS + 0xc);
360 wmb();
361
362 /* restore pin/int-type configurations */
363 base += AU1300_GPIC_PINCFG;
364 for (i = 0; i < ALCHEMY_GPIC_INT_NUM; i++)
365 __raw_writel(alchemy_gpic_pmdata[i + 5], base + (i << 2));
366 wmb();
367
368 /* restore misc register(s) */
369 base = (void __iomem *)KSEG1ADDR(AU1300_GPIC_PHYS_ADDR);
370 __raw_writel(alchemy_gpic_pmdata[4], base + AU1300_GPIC_DMASEL);
371 wmb();
372
373 /* finally restore masks */
374 __raw_writel(alchemy_gpic_pmdata[0], base + AU1300_GPIC_IEN + 0x0);
375 __raw_writel(alchemy_gpic_pmdata[1], base + AU1300_GPIC_IEN + 0x4);
376 __raw_writel(alchemy_gpic_pmdata[2], base + AU1300_GPIC_IEN + 0x8);
377 __raw_writel(alchemy_gpic_pmdata[3], base + AU1300_GPIC_IEN + 0xc);
378 wmb();
379}
380
381static struct syscore_ops alchemy_gpic_pmops = {
382 .suspend = alchemy_gpic_suspend,
383 .resume = alchemy_gpic_resume,
384};
385
386/**********************************************************************/
387
388void __init arch_init_irq(void)
389{
390 switch (alchemy_get_cputype()) {
391 case ALCHEMY_CPU_AU1300:
392 alchemy_gpic_init_irq(&au1300_devints[0]);
393 register_syscore_ops(&alchemy_gpic_pmops);
394 break;
395 }
396}
397
398#define CAUSEF_GPIC (CAUSEF_IP2 | CAUSEF_IP3 | CAUSEF_IP4 | CAUSEF_IP5)
399
400void plat_irq_dispatch(void)
401{
402 unsigned long i, c = read_c0_cause() & read_c0_status();
403
404 if (c & CAUSEF_IP7) /* c0 timer */
405 do_IRQ(MIPS_CPU_IRQ_BASE + 7);
406 else if (likely(c & CAUSEF_GPIC)) {
407 i = __raw_readl(AU1300_GPIC_ADDR + AU1300_GPIC_PRIENC);
408 do_IRQ(i + ALCHEMY_GPIC_INT_BASE);
409 } else
410 spurious_interrupt();
411}
diff --git a/arch/mips/alchemy/common/gpiolib.c b/arch/mips/alchemy/common/gpiolib.c
index 91fb4d9e30fd..f1b50f0c01db 100644
--- a/arch/mips/alchemy/common/gpiolib.c
+++ b/arch/mips/alchemy/common/gpiolib.c
@@ -27,6 +27,7 @@
27 * CONFIG_ALCHEMY_GPIO_INDIRECT=n, otherwise compilation will fail! 27 * CONFIG_ALCHEMY_GPIO_INDIRECT=n, otherwise compilation will fail!
28 * au1000 SoC have only one GPIO block : GPIO1 28 * au1000 SoC have only one GPIO block : GPIO1
29 * Au1100, Au15x0, Au12x0 have a second one : GPIO2 29 * Au1100, Au15x0, Au12x0 have a second one : GPIO2
30 * Au1300 is totally different: 1 block with up to 128 GPIOs
30 */ 31 */
31 32
32#include <linux/init.h> 33#include <linux/init.h>
@@ -35,6 +36,7 @@
35#include <linux/types.h> 36#include <linux/types.h>
36#include <linux/gpio.h> 37#include <linux/gpio.h>
37#include <asm/mach-au1x00/gpio-au1000.h> 38#include <asm/mach-au1x00/gpio-au1000.h>
39#include <asm/mach-au1x00/gpio-au1300.h>
38 40
39static int gpio2_get(struct gpio_chip *chip, unsigned offset) 41static int gpio2_get(struct gpio_chip *chip, unsigned offset)
40{ 42{
@@ -115,6 +117,43 @@ struct gpio_chip alchemy_gpio_chip[] = {
115 }, 117 },
116}; 118};
117 119
120static int alchemy_gpic_get(struct gpio_chip *chip, unsigned int off)
121{
122 return au1300_gpio_get_value(off + AU1300_GPIO_BASE);
123}
124
125static void alchemy_gpic_set(struct gpio_chip *chip, unsigned int off, int v)
126{
127 au1300_gpio_set_value(off + AU1300_GPIO_BASE, v);
128}
129
130static int alchemy_gpic_dir_input(struct gpio_chip *chip, unsigned int off)
131{
132 return au1300_gpio_direction_input(off + AU1300_GPIO_BASE);
133}
134
135static int alchemy_gpic_dir_output(struct gpio_chip *chip, unsigned int off,
136 int v)
137{
138 return au1300_gpio_direction_output(off + AU1300_GPIO_BASE, v);
139}
140
141static int alchemy_gpic_gpio_to_irq(struct gpio_chip *chip, unsigned int off)
142{
143 return au1300_gpio_to_irq(off + AU1300_GPIO_BASE);
144}
145
146static struct gpio_chip au1300_gpiochip = {
147 .label = "alchemy-gpic",
148 .direction_input = alchemy_gpic_dir_input,
149 .direction_output = alchemy_gpic_dir_output,
150 .get = alchemy_gpic_get,
151 .set = alchemy_gpic_set,
152 .to_irq = alchemy_gpic_gpio_to_irq,
153 .base = AU1300_GPIO_BASE,
154 .ngpio = AU1300_GPIO_NUM,
155};
156
118static int __init alchemy_gpiochip_init(void) 157static int __init alchemy_gpiochip_init(void)
119{ 158{
120 int ret = 0; 159 int ret = 0;
@@ -127,6 +166,9 @@ static int __init alchemy_gpiochip_init(void)
127 ret = gpiochip_add(&alchemy_gpio_chip[0]); 166 ret = gpiochip_add(&alchemy_gpio_chip[0]);
128 ret |= gpiochip_add(&alchemy_gpio_chip[1]); 167 ret |= gpiochip_add(&alchemy_gpio_chip[1]);
129 break; 168 break;
169 case ALCHEMY_CPU_AU1300:
170 ret = gpiochip_add(&au1300_gpiochip);
171 break;
130 } 172 }
131 return ret; 173 return ret;
132} 174}
diff --git a/arch/mips/alchemy/common/platform.c b/arch/mips/alchemy/common/platform.c
index c8e5d72a5826..95cb9113b12c 100644
--- a/arch/mips/alchemy/common/platform.c
+++ b/arch/mips/alchemy/common/platform.c
@@ -82,6 +82,12 @@ static struct plat_serial8250_port au1x00_uart_data[][4] __initdata = {
82 PORT(AU1000_UART0_PHYS_ADDR, AU1200_UART0_INT), 82 PORT(AU1000_UART0_PHYS_ADDR, AU1200_UART0_INT),
83 PORT(AU1000_UART1_PHYS_ADDR, AU1200_UART1_INT), 83 PORT(AU1000_UART1_PHYS_ADDR, AU1200_UART1_INT),
84 }, 84 },
85 [ALCHEMY_CPU_AU1300] = {
86 PORT(AU1300_UART0_PHYS_ADDR, AU1300_UART0_INT),
87 PORT(AU1300_UART1_PHYS_ADDR, AU1300_UART1_INT),
88 PORT(AU1300_UART2_PHYS_ADDR, AU1300_UART2_INT),
89 PORT(AU1300_UART3_PHYS_ADDR, AU1300_UART3_INT),
90 },
85}; 91};
86 92
87static struct platform_device au1xx0_uart_device = { 93static struct platform_device au1xx0_uart_device = {
@@ -122,10 +128,12 @@ static unsigned long alchemy_ohci_data[][2] __initdata = {
122 [ALCHEMY_CPU_AU1100] = { AU1000_USB_OHCI_PHYS_ADDR, AU1100_USB_HOST_INT }, 128 [ALCHEMY_CPU_AU1100] = { AU1000_USB_OHCI_PHYS_ADDR, AU1100_USB_HOST_INT },
123 [ALCHEMY_CPU_AU1550] = { AU1550_USB_OHCI_PHYS_ADDR, AU1550_USB_HOST_INT }, 129 [ALCHEMY_CPU_AU1550] = { AU1550_USB_OHCI_PHYS_ADDR, AU1550_USB_HOST_INT },
124 [ALCHEMY_CPU_AU1200] = { AU1200_USB_OHCI_PHYS_ADDR, AU1200_USB_INT }, 130 [ALCHEMY_CPU_AU1200] = { AU1200_USB_OHCI_PHYS_ADDR, AU1200_USB_INT },
131 [ALCHEMY_CPU_AU1300] = { AU1300_USB_OHCI0_PHYS_ADDR, AU1300_USB_INT },
125}; 132};
126 133
127static unsigned long alchemy_ehci_data[][2] __initdata = { 134static unsigned long alchemy_ehci_data[][2] __initdata = {
128 [ALCHEMY_CPU_AU1200] = { AU1200_USB_EHCI_PHYS_ADDR, AU1200_USB_INT }, 135 [ALCHEMY_CPU_AU1200] = { AU1200_USB_EHCI_PHYS_ADDR, AU1200_USB_INT },
136 [ALCHEMY_CPU_AU1300] = { AU1300_USB_EHCI_PHYS_ADDR, AU1300_USB_INT },
129}; 137};
130 138
131static int __init _new_usbres(struct resource **r, struct platform_device **d) 139static int __init _new_usbres(struct resource **r, struct platform_device **d)
@@ -169,8 +177,8 @@ static void __init alchemy_setup_usb(int ctype)
169 printk(KERN_INFO "Alchemy USB: cannot add OHCI0\n"); 177 printk(KERN_INFO "Alchemy USB: cannot add OHCI0\n");
170 178
171 179
172 /* setup EHCI0: Au1200 */ 180 /* setup EHCI0: Au1200/Au1300 */
173 if (ctype == ALCHEMY_CPU_AU1200) { 181 if ((ctype == ALCHEMY_CPU_AU1200) || (ctype == ALCHEMY_CPU_AU1300)) {
174 if (_new_usbres(&res, &pdev)) 182 if (_new_usbres(&res, &pdev))
175 return; 183 return;
176 184
@@ -187,6 +195,25 @@ static void __init alchemy_setup_usb(int ctype)
187 if (platform_device_register(pdev)) 195 if (platform_device_register(pdev))
188 printk(KERN_INFO "Alchemy USB: cannot add EHCI0\n"); 196 printk(KERN_INFO "Alchemy USB: cannot add EHCI0\n");
189 } 197 }
198
199 /* Au1300: OHCI1 */
200 if (ctype == ALCHEMY_CPU_AU1300) {
201 if (_new_usbres(&res, &pdev))
202 return;
203
204 res[0].start = AU1300_USB_OHCI1_PHYS_ADDR;
205 res[0].end = res[0].start + 0x100 - 1;
206 res[0].flags = IORESOURCE_MEM;
207 res[1].start = AU1300_USB_INT;
208 res[1].end = res[1].start;
209 res[1].flags = IORESOURCE_IRQ;
210 pdev->name = "au1xxx-ohci";
211 pdev->id = 1;
212 pdev->dev.dma_mask = &alchemy_ohci_dmamask;
213
214 if (platform_device_register(pdev))
215 printk(KERN_INFO "Alchemy USB: cannot add OHCI1\n");
216 }
190} 217}
191 218
192/* Macro to help defining the Ethernet MAC resources */ 219/* Macro to help defining the Ethernet MAC resources */
diff --git a/arch/mips/alchemy/common/power.c b/arch/mips/alchemy/common/power.c
index bdd6651e9a4f..0c7fce2a3c12 100644
--- a/arch/mips/alchemy/common/power.c
+++ b/arch/mips/alchemy/common/power.c
@@ -126,6 +126,9 @@ void au_sleep(void)
126 case ALCHEMY_CPU_AU1200: 126 case ALCHEMY_CPU_AU1200:
127 alchemy_sleep_au1550(); 127 alchemy_sleep_au1550();
128 break; 128 break;
129 case ALCHEMY_CPU_AU1300:
130 alchemy_sleep_au1300();
131 break;
129 } 132 }
130 133
131 restore_core_regs(); 134 restore_core_regs();
diff --git a/arch/mips/alchemy/common/sleeper.S b/arch/mips/alchemy/common/sleeper.S
index 77f3c743b716..c7bcc7e5c822 100644
--- a/arch/mips/alchemy/common/sleeper.S
+++ b/arch/mips/alchemy/common/sleeper.S
@@ -153,6 +153,79 @@ LEAF(alchemy_sleep_au1550)
153 153
154END(alchemy_sleep_au1550) 154END(alchemy_sleep_au1550)
155 155
156/* sleepcode for Au1300 memory controller type */
157LEAF(alchemy_sleep_au1300)
158
159 SETUP_SLEEP
160
161 /* cache following instructions, as memory gets put to sleep */
162 la t0, 2f
163 la t1, 4f
164 subu t2, t1, t0
165
166 .set mips3
167
1681: cache 0x14, 0(t0)
169 subu t2, t2, 32
170 bgez t2, 1b
171 addu t0, t0, 32
172
173 .set mips0
174
1752: lui a0, 0xb400 /* mem_xxx */
176
177 /* disable all ports in mem_sdportcfga */
178 sw zero, 0x868(a0) /* mem_sdportcfga */
179 sync
180
181 /* disable ODT */
182 li t0, 0x03010000
183 sw t0, 0x08d8(a0) /* mem_sdcmd0 */
184 sw t0, 0x08dc(a0) /* mem_sdcmd1 */
185 sync
186
187 /* precharge */
188 li t0, 0x23000400
189 sw t0, 0x08dc(a0) /* mem_sdcmd1 */
190 sw t0, 0x08d8(a0) /* mem_sdcmd0 */
191 sync
192
193 /* auto refresh */
194 sw zero, 0x08c8(a0) /* mem_sdautoref */
195 sync
196
197 /* block access to the DDR */
198 lw t0, 0x0848(a0) /* mem_sdconfigb */
199 li t1, (1 << 7 | 0x3F)
200 or t0, t0, t1
201 sw t0, 0x0848(a0) /* mem_sdconfigb */
202 sync
203
204 /* issue the Self Refresh command */
205 li t0, 0x10000000
206 sw t0, 0x08dc(a0) /* mem_sdcmd1 */
207 sw t0, 0x08d8(a0) /* mem_sdcmd0 */
208 sync
209
210 /* wait for sdram to enter self-refresh mode */
211 lui t0, 0x0300
2123: lw t1, 0x0850(a0) /* mem_sdstat */
213 and t2, t1, t0
214 bne t2, t0, 3b
215 nop
216
217 /* disable SDRAM clocks */
218 li t0, ~(3<<28)
219 lw t1, 0x0840(a0) /* mem_sdconfiga */
220 and t1, t1, t0 /* clear CE[1:0] */
221 sw t1, 0x0840(a0) /* mem_sdconfiga */
222 sync
223
224 DO_SLEEP
2254:
226
227END(alchemy_sleep_au1300)
228
156 229
157 /* This is where we return upon wakeup. 230 /* This is where we return upon wakeup.
158 * Reload all of the registers and return. 231 * Reload all of the registers and return.
diff --git a/arch/mips/alchemy/common/time.c b/arch/mips/alchemy/common/time.c
index d5da6adbf634..a594a85337d6 100644
--- a/arch/mips/alchemy/common/time.c
+++ b/arch/mips/alchemy/common/time.c
@@ -178,6 +178,7 @@ static int alchemy_m2inttab[] __initdata = {
178 AU1100_RTC_MATCH2_INT, 178 AU1100_RTC_MATCH2_INT,
179 AU1550_RTC_MATCH2_INT, 179 AU1550_RTC_MATCH2_INT,
180 AU1200_RTC_MATCH2_INT, 180 AU1200_RTC_MATCH2_INT,
181 AU1300_RTC_MATCH2_INT,
181}; 182};
182 183
183void __init plat_time_init(void) 184void __init plat_time_init(void)
diff --git a/arch/mips/alchemy/common/vss.c b/arch/mips/alchemy/common/vss.c
new file mode 100644
index 000000000000..d23b1444d365
--- /dev/null
+++ b/arch/mips/alchemy/common/vss.c
@@ -0,0 +1,84 @@
1/*
2 * Au1300 media block power gating (VSS)
3 *
4 * This is a stop-gap solution until I have the clock framework integration
5 * ready. This stuff here really must be handled transparently when clocks
6 * for various media blocks are enabled/disabled.
7 */
8
9#include <linux/module.h>
10#include <linux/spinlock.h>
11#include <asm/mach-au1x00/au1000.h>
12
13#define VSS_GATE 0x00 /* gate wait timers */
14#define VSS_CLKRST 0x04 /* clock/block control */
15#define VSS_FTR 0x08 /* footers */
16
17#define VSS_ADDR(blk) (KSEG1ADDR(AU1300_VSS_PHYS_ADDR) + (blk * 0x0c))
18
19static DEFINE_SPINLOCK(au1300_vss_lock);
20
21/* enable a block as outlined in the databook */
22static inline void __enable_block(int block)
23{
24 void __iomem *base = (void __iomem *)VSS_ADDR(block);
25
26 __raw_writel(3, base + VSS_CLKRST); /* enable clock, assert reset */
27 wmb();
28
29 __raw_writel(0x01fffffe, base + VSS_GATE); /* maximum setup time */
30 wmb();
31
32 /* enable footers in sequence */
33 __raw_writel(0x01, base + VSS_FTR);
34 wmb();
35 __raw_writel(0x03, base + VSS_FTR);
36 wmb();
37 __raw_writel(0x07, base + VSS_FTR);
38 wmb();
39 __raw_writel(0x0f, base + VSS_FTR);
40 wmb();
41
42 __raw_writel(0x01ffffff, base + VSS_GATE); /* start FSM too */
43 wmb();
44
45 __raw_writel(2, base + VSS_CLKRST); /* deassert reset */
46 wmb();
47
48 __raw_writel(0x1f, base + VSS_FTR); /* enable isolation cells */
49 wmb();
50}
51
52/* disable a block as outlined in the databook */
53static inline void __disable_block(int block)
54{
55 void __iomem *base = (void __iomem *)VSS_ADDR(block);
56
57 __raw_writel(0x0f, base + VSS_FTR); /* disable isolation cells */
58 wmb();
59 __raw_writel(0, base + VSS_GATE); /* disable FSM */
60 wmb();
61 __raw_writel(3, base + VSS_CLKRST); /* assert reset */
62 wmb();
63 __raw_writel(1, base + VSS_CLKRST); /* disable clock */
64 wmb();
65 __raw_writel(0, base + VSS_FTR); /* disable all footers */
66 wmb();
67}
68
69void au1300_vss_block_control(int block, int enable)
70{
71 unsigned long flags;
72
73 if (alchemy_get_cputype() != ALCHEMY_CPU_AU1300)
74 return;
75
76 /* only one block at a time */
77 spin_lock_irqsave(&au1300_vss_lock, flags);
78 if (enable)
79 __enable_block(block);
80 else
81 __disable_block(block);
82 spin_unlock_irqrestore(&au1300_vss_lock, flags);
83}
84EXPORT_SYMBOL_GPL(au1300_vss_block_control);