aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-ixp4xx
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-ixp4xx')
-rw-r--r--arch/arm/mach-ixp4xx/Kconfig6
-rw-r--r--arch/arm/mach-ixp4xx/Makefile1
-rw-r--r--arch/arm/mach-ixp4xx/goramo_mlr.c507
-rw-r--r--arch/arm/mach-ixp4xx/include/mach/cpu.h7
-rw-r--r--arch/arm/mach-ixp4xx/include/mach/qmgr.h69
-rw-r--r--arch/arm/mach-ixp4xx/ixp4xx_npe.c9
-rw-r--r--arch/arm/mach-ixp4xx/ixp4xx_qmgr.c135
7 files changed, 687 insertions, 47 deletions
diff --git a/arch/arm/mach-ixp4xx/Kconfig b/arch/arm/mach-ixp4xx/Kconfig
index 2c5a02b8520..264f4d59f89 100644
--- a/arch/arm/mach-ixp4xx/Kconfig
+++ b/arch/arm/mach-ixp4xx/Kconfig
@@ -78,6 +78,12 @@ config MACH_IXDP465
78 IXDP465 Development Platform (Also known as BMP). 78 IXDP465 Development Platform (Also known as BMP).
79 For more information on this platform, see <file:Documentation/arm/IXP4xx>. 79 For more information on this platform, see <file:Documentation/arm/IXP4xx>.
80 80
81config MACH_GORAMO_MLR
82 bool "GORAMO Multi Link Router"
83 help
84 Say 'Y' here if you want your kernel to support GORAMO
85 MultiLink router.
86
81config MACH_KIXRP435 87config MACH_KIXRP435
82 bool "KIXRP435" 88 bool "KIXRP435"
83 help 89 help
diff --git a/arch/arm/mach-ixp4xx/Makefile b/arch/arm/mach-ixp4xx/Makefile
index 2e6bbf927a7..47d1f60d23f 100644
--- a/arch/arm/mach-ixp4xx/Makefile
+++ b/arch/arm/mach-ixp4xx/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o
30obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o 30obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o
31obj-$(CONFIG_MACH_WG302V2) += wg302v2-setup.o 31obj-$(CONFIG_MACH_WG302V2) += wg302v2-setup.o
32obj-$(CONFIG_MACH_FSG) += fsg-setup.o 32obj-$(CONFIG_MACH_FSG) += fsg-setup.o
33obj-$(CONFIG_MACH_GORAMO_MLR) += goramo_mlr.o
33 34
34obj-$(CONFIG_PCI) += $(obj-pci-$(CONFIG_PCI)) common-pci.o 35obj-$(CONFIG_PCI) += $(obj-pci-$(CONFIG_PCI)) common-pci.o
35obj-$(CONFIG_IXP4XX_QMGR) += ixp4xx_qmgr.o 36obj-$(CONFIG_IXP4XX_QMGR) += ixp4xx_qmgr.o
diff --git a/arch/arm/mach-ixp4xx/goramo_mlr.c b/arch/arm/mach-ixp4xx/goramo_mlr.c
new file mode 100644
index 00000000000..a733b8ff3ce
--- /dev/null
+++ b/arch/arm/mach-ixp4xx/goramo_mlr.c
@@ -0,0 +1,507 @@
1/*
2 * Goramo MultiLink router platform code
3 * Copyright (C) 2006-2009 Krzysztof Halasa <khc@pm.waw.pl>
4 */
5
6#include <linux/delay.h>
7#include <linux/hdlc.h>
8#include <linux/i2c-gpio.h>
9#include <linux/io.h>
10#include <linux/irq.h>
11#include <linux/kernel.h>
12#include <linux/pci.h>
13#include <linux/serial_8250.h>
14#include <asm/mach-types.h>
15#include <asm/system.h>
16#include <asm/mach/arch.h>
17#include <asm/mach/flash.h>
18#include <asm/mach/pci.h>
19
20#define xgpio_irq(n) (IRQ_IXP4XX_GPIO ## n)
21#define gpio_irq(n) xgpio_irq(n)
22
23#define SLOT_ETHA 0x0B /* IDSEL = AD21 */
24#define SLOT_ETHB 0x0C /* IDSEL = AD20 */
25#define SLOT_MPCI 0x0D /* IDSEL = AD19 */
26#define SLOT_NEC 0x0E /* IDSEL = AD18 */
27
28#define IRQ_ETHA IRQ_IXP4XX_GPIO4
29#define IRQ_ETHB IRQ_IXP4XX_GPIO5
30#define IRQ_NEC IRQ_IXP4XX_GPIO3
31#define IRQ_MPCI IRQ_IXP4XX_GPIO12
32
33/* GPIO lines */
34#define GPIO_SCL 0
35#define GPIO_SDA 1
36#define GPIO_STR 2
37#define GPIO_HSS0_DCD_N 6
38#define GPIO_HSS1_DCD_N 7
39#define GPIO_HSS0_CTS_N 10
40#define GPIO_HSS1_CTS_N 11
41#define GPIO_HSS1_RTS_N 13
42#define GPIO_HSS0_RTS_N 14
43
44/* Control outputs from 74HC4094 */
45#define CONTROL_HSS0_CLK_INT 0
46#define CONTROL_HSS1_CLK_INT 1
47#define CONTROL_HSS0_DTR_N 2
48#define CONTROL_HSS1_DTR_N 3
49#define CONTROL_EXT 4
50#define CONTROL_AUTO_RESET 5
51#define CONTROL_PCI_RESET_N 6
52#define CONTROL_EEPROM_WC_N 7
53
54/* offsets from start of flash ROM = 0x50000000 */
55#define CFG_ETH0_ADDRESS 0x40 /* 6 bytes */
56#define CFG_ETH1_ADDRESS 0x46 /* 6 bytes */
57#define CFG_REV 0x4C /* u32 */
58#define CFG_SDRAM_SIZE 0x50 /* u32 */
59#define CFG_SDRAM_CONF 0x54 /* u32 */
60#define CFG_SDRAM_MODE 0x58 /* u32 */
61#define CFG_SDRAM_REFRESH 0x5C /* u32 */
62
63#define CFG_HW_BITS 0x60 /* u32 */
64#define CFG_HW_USB_PORTS 0x00000007 /* 0 = no NEC chip, 1-5 = ports # */
65#define CFG_HW_HAS_PCI_SLOT 0x00000008
66#define CFG_HW_HAS_ETH0 0x00000010
67#define CFG_HW_HAS_ETH1 0x00000020
68#define CFG_HW_HAS_HSS0 0x00000040
69#define CFG_HW_HAS_HSS1 0x00000080
70#define CFG_HW_HAS_UART0 0x00000100
71#define CFG_HW_HAS_UART1 0x00000200
72#define CFG_HW_HAS_EEPROM 0x00000400
73
74#define FLASH_CMD_READ_ARRAY 0xFF
75#define FLASH_CMD_READ_ID 0x90
76#define FLASH_SER_OFF 0x102 /* 0x81 in 16-bit mode */
77
78static u32 hw_bits = 0xFFFFFFFD; /* assume all hardware present */;
79static u8 control_value;
80
81static void set_scl(u8 value)
82{
83 gpio_line_set(GPIO_SCL, !!value);
84 udelay(3);
85}
86
87static void set_sda(u8 value)
88{
89 gpio_line_set(GPIO_SDA, !!value);
90 udelay(3);
91}
92
93static void set_str(u8 value)
94{
95 gpio_line_set(GPIO_STR, !!value);
96 udelay(3);
97}
98
99static inline void set_control(int line, int value)
100{
101 if (value)
102 control_value |= (1 << line);
103 else
104 control_value &= ~(1 << line);
105}
106
107
108static void output_control(void)
109{
110 int i;
111
112 gpio_line_config(GPIO_SCL, IXP4XX_GPIO_OUT);
113 gpio_line_config(GPIO_SDA, IXP4XX_GPIO_OUT);
114
115 for (i = 0; i < 8; i++) {
116 set_scl(0);
117 set_sda(control_value & (0x80 >> i)); /* MSB first */
118 set_scl(1); /* active edge */
119 }
120
121 set_str(1);
122 set_str(0);
123
124 set_scl(0);
125 set_sda(1); /* Be ready for START */
126 set_scl(1);
127}
128
129
130static void (*set_carrier_cb_tab[2])(void *pdev, int carrier);
131
132static int hss_set_clock(int port, unsigned int clock_type)
133{
134 int ctrl_int = port ? CONTROL_HSS1_CLK_INT : CONTROL_HSS0_CLK_INT;
135
136 switch (clock_type) {
137 case CLOCK_DEFAULT:
138 case CLOCK_EXT:
139 set_control(ctrl_int, 0);
140 output_control();
141 return CLOCK_EXT;
142
143 case CLOCK_INT:
144 set_control(ctrl_int, 1);
145 output_control();
146 return CLOCK_INT;
147
148 default:
149 return -EINVAL;
150 }
151}
152
153static irqreturn_t hss_dcd_irq(int irq, void *pdev)
154{
155 int i, port = (irq == gpio_irq(GPIO_HSS1_DCD_N));
156 gpio_line_get(port ? GPIO_HSS1_DCD_N : GPIO_HSS0_DCD_N, &i);
157 set_carrier_cb_tab[port](pdev, !i);
158 return IRQ_HANDLED;
159}
160
161
162static int hss_open(int port, void *pdev,
163 void (*set_carrier_cb)(void *pdev, int carrier))
164{
165 int i, irq;
166
167 if (!port)
168 irq = gpio_irq(GPIO_HSS0_DCD_N);
169 else
170 irq = gpio_irq(GPIO_HSS1_DCD_N);
171
172 gpio_line_get(port ? GPIO_HSS1_DCD_N : GPIO_HSS0_DCD_N, &i);
173 set_carrier_cb(pdev, !i);
174
175 set_carrier_cb_tab[!!port] = set_carrier_cb;
176
177 if ((i = request_irq(irq, hss_dcd_irq, 0, "IXP4xx HSS", pdev)) != 0) {
178 printk(KERN_ERR "ixp4xx_hss: failed to request IRQ%i (%i)\n",
179 irq, i);
180 return i;
181 }
182
183 set_control(port ? CONTROL_HSS1_DTR_N : CONTROL_HSS0_DTR_N, 0);
184 output_control();
185 gpio_line_set(port ? GPIO_HSS1_RTS_N : GPIO_HSS0_RTS_N, 0);
186 return 0;
187}
188
189static void hss_close(int port, void *pdev)
190{
191 free_irq(port ? gpio_irq(GPIO_HSS1_DCD_N) : gpio_irq(GPIO_HSS0_DCD_N),
192 pdev);
193 set_carrier_cb_tab[!!port] = NULL; /* catch bugs */
194
195 set_control(port ? CONTROL_HSS1_DTR_N : CONTROL_HSS0_DTR_N, 1);
196 output_control();
197 gpio_line_set(port ? GPIO_HSS1_RTS_N : GPIO_HSS0_RTS_N, 1);
198}
199
200
201/* Flash memory */
202static struct flash_platform_data flash_data = {
203 .map_name = "cfi_probe",
204 .width = 2,
205};
206
207static struct resource flash_resource = {
208 .flags = IORESOURCE_MEM,
209};
210
211static struct platform_device device_flash = {
212 .name = "IXP4XX-Flash",
213 .id = 0,
214 .dev = { .platform_data = &flash_data },
215 .num_resources = 1,
216 .resource = &flash_resource,
217};
218
219
220/* I^2C interface */
221static struct i2c_gpio_platform_data i2c_data = {
222 .sda_pin = GPIO_SDA,
223 .scl_pin = GPIO_SCL,
224};
225
226static struct platform_device device_i2c = {
227 .name = "i2c-gpio",
228 .id = 0,
229 .dev = { .platform_data = &i2c_data },
230};
231
232
233/* IXP425 2 UART ports */
234static struct resource uart_resources[] = {
235 {
236 .start = IXP4XX_UART1_BASE_PHYS,
237 .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
238 .flags = IORESOURCE_MEM,
239 },
240 {
241 .start = IXP4XX_UART2_BASE_PHYS,
242 .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
243 .flags = IORESOURCE_MEM,
244 }
245};
246
247static struct plat_serial8250_port uart_data[] = {
248 {
249 .mapbase = IXP4XX_UART1_BASE_PHYS,
250 .membase = (char __iomem *)IXP4XX_UART1_BASE_VIRT +
251 REG_OFFSET,
252 .irq = IRQ_IXP4XX_UART1,
253 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
254 .iotype = UPIO_MEM,
255 .regshift = 2,
256 .uartclk = IXP4XX_UART_XTAL,
257 },
258 {
259 .mapbase = IXP4XX_UART2_BASE_PHYS,
260 .membase = (char __iomem *)IXP4XX_UART2_BASE_VIRT +
261 REG_OFFSET,
262 .irq = IRQ_IXP4XX_UART2,
263 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
264 .iotype = UPIO_MEM,
265 .regshift = 2,
266 .uartclk = IXP4XX_UART_XTAL,
267 },
268 { },
269};
270
271static struct platform_device device_uarts = {
272 .name = "serial8250",
273 .id = PLAT8250_DEV_PLATFORM,
274 .dev.platform_data = uart_data,
275 .num_resources = 2,
276 .resource = uart_resources,
277};
278
279
280/* Built-in 10/100 Ethernet MAC interfaces */
281static struct eth_plat_info eth_plat[] = {
282 {
283 .phy = 0,
284 .rxq = 3,
285 .txreadyq = 32,
286 }, {
287 .phy = 1,
288 .rxq = 4,
289 .txreadyq = 33,
290 }
291};
292
293static struct platform_device device_eth_tab[] = {
294 {
295 .name = "ixp4xx_eth",
296 .id = IXP4XX_ETH_NPEB,
297 .dev.platform_data = eth_plat,
298 }, {
299 .name = "ixp4xx_eth",
300 .id = IXP4XX_ETH_NPEC,
301 .dev.platform_data = eth_plat + 1,
302 }
303};
304
305
306/* IXP425 2 synchronous serial ports */
307static struct hss_plat_info hss_plat[] = {
308 {
309 .set_clock = hss_set_clock,
310 .open = hss_open,
311 .close = hss_close,
312 .txreadyq = 34,
313 }, {
314 .set_clock = hss_set_clock,
315 .open = hss_open,
316 .close = hss_close,
317 .txreadyq = 35,
318 }
319};
320
321static struct platform_device device_hss_tab[] = {
322 {
323 .name = "ixp4xx_hss",
324 .id = 0,
325 .dev.platform_data = hss_plat,
326 }, {
327 .name = "ixp4xx_hss",
328 .id = 1,
329 .dev.platform_data = hss_plat + 1,
330 }
331};
332
333
334static struct platform_device *device_tab[6] __initdata = {
335 &device_flash, /* index 0 */
336};
337
338static inline u8 __init flash_readb(u8 __iomem *flash, u32 addr)
339{
340#ifdef __ARMEB__
341 return __raw_readb(flash + addr);
342#else
343 return __raw_readb(flash + (addr ^ 3));
344#endif
345}
346
347static inline u16 __init flash_readw(u8 __iomem *flash, u32 addr)
348{
349#ifdef __ARMEB__
350 return __raw_readw(flash + addr);
351#else
352 return __raw_readw(flash + (addr ^ 2));
353#endif
354}
355
356static void __init gmlr_init(void)
357{
358 u8 __iomem *flash;
359 int i, devices = 1; /* flash */
360
361 ixp4xx_sys_init();
362
363 if ((flash = ioremap(IXP4XX_EXP_BUS_BASE_PHYS, 0x80)) == NULL)
364 printk(KERN_ERR "goramo-mlr: unable to access system"
365 " configuration data\n");
366 else {
367 system_rev = __raw_readl(flash + CFG_REV);
368 hw_bits = __raw_readl(flash + CFG_HW_BITS);
369
370 for (i = 0; i < ETH_ALEN; i++) {
371 eth_plat[0].hwaddr[i] =
372 flash_readb(flash, CFG_ETH0_ADDRESS + i);
373 eth_plat[1].hwaddr[i] =
374 flash_readb(flash, CFG_ETH1_ADDRESS + i);
375 }
376
377 __raw_writew(FLASH_CMD_READ_ID, flash);
378 system_serial_high = flash_readw(flash, FLASH_SER_OFF);
379 system_serial_high <<= 16;
380 system_serial_high |= flash_readw(flash, FLASH_SER_OFF + 2);
381 system_serial_low = flash_readw(flash, FLASH_SER_OFF + 4);
382 system_serial_low <<= 16;
383 system_serial_low |= flash_readw(flash, FLASH_SER_OFF + 6);
384 __raw_writew(FLASH_CMD_READ_ARRAY, flash);
385
386 iounmap(flash);
387 }
388
389 switch (hw_bits & (CFG_HW_HAS_UART0 | CFG_HW_HAS_UART1)) {
390 case CFG_HW_HAS_UART0:
391 memset(&uart_data[1], 0, sizeof(uart_data[1]));
392 device_uarts.num_resources = 1;
393 break;
394
395 case CFG_HW_HAS_UART1:
396 device_uarts.dev.platform_data = &uart_data[1];
397 device_uarts.resource = &uart_resources[1];
398 device_uarts.num_resources = 1;
399 break;
400 }
401 if (hw_bits & (CFG_HW_HAS_UART0 | CFG_HW_HAS_UART1))
402 device_tab[devices++] = &device_uarts; /* max index 1 */
403
404 if (hw_bits & CFG_HW_HAS_ETH0)
405 device_tab[devices++] = &device_eth_tab[0]; /* max index 2 */
406 if (hw_bits & CFG_HW_HAS_ETH1)
407 device_tab[devices++] = &device_eth_tab[1]; /* max index 3 */
408
409 if (hw_bits & CFG_HW_HAS_HSS0)
410 device_tab[devices++] = &device_hss_tab[0]; /* max index 4 */
411 if (hw_bits & CFG_HW_HAS_HSS1)
412 device_tab[devices++] = &device_hss_tab[1]; /* max index 5 */
413
414 if (hw_bits & CFG_HW_HAS_EEPROM)
415 device_tab[devices++] = &device_i2c; /* max index 6 */
416
417 gpio_line_config(GPIO_SCL, IXP4XX_GPIO_OUT);
418 gpio_line_config(GPIO_SDA, IXP4XX_GPIO_OUT);
419 gpio_line_config(GPIO_STR, IXP4XX_GPIO_OUT);
420 gpio_line_config(GPIO_HSS0_RTS_N, IXP4XX_GPIO_OUT);
421 gpio_line_config(GPIO_HSS1_RTS_N, IXP4XX_GPIO_OUT);
422 gpio_line_config(GPIO_HSS0_DCD_N, IXP4XX_GPIO_IN);
423 gpio_line_config(GPIO_HSS1_DCD_N, IXP4XX_GPIO_IN);
424 set_irq_type(gpio_irq(GPIO_HSS0_DCD_N), IRQ_TYPE_EDGE_BOTH);
425 set_irq_type(gpio_irq(GPIO_HSS1_DCD_N), IRQ_TYPE_EDGE_BOTH);
426
427 set_control(CONTROL_HSS0_DTR_N, 1);
428 set_control(CONTROL_HSS1_DTR_N, 1);
429 set_control(CONTROL_EEPROM_WC_N, 1);
430 set_control(CONTROL_PCI_RESET_N, 1);
431 output_control();
432
433 msleep(1); /* Wait for PCI devices to initialize */
434
435 flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
436 flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
437
438 platform_add_devices(device_tab, devices);
439}
440
441
442#ifdef CONFIG_PCI
443static void __init gmlr_pci_preinit(void)
444{
445 set_irq_type(IRQ_ETHA, IRQ_TYPE_LEVEL_LOW);
446 set_irq_type(IRQ_ETHB, IRQ_TYPE_LEVEL_LOW);
447 set_irq_type(IRQ_NEC, IRQ_TYPE_LEVEL_LOW);
448 set_irq_type(IRQ_MPCI, IRQ_TYPE_LEVEL_LOW);
449 ixp4xx_pci_preinit();
450}
451
452static void __init gmlr_pci_postinit(void)
453{
454 if ((hw_bits & CFG_HW_USB_PORTS) >= 2 &&
455 (hw_bits & CFG_HW_USB_PORTS) < 5) {
456 /* need to adjust number of USB ports on NEC chip */
457 u32 value, addr = BIT(32 - SLOT_NEC) | 0xE0;
458 if (!ixp4xx_pci_read(addr, NP_CMD_CONFIGREAD, &value)) {
459 value &= ~7;
460 value |= (hw_bits & CFG_HW_USB_PORTS);
461 ixp4xx_pci_write(addr, NP_CMD_CONFIGWRITE, value);
462 }
463 }
464}
465
466static int __init gmlr_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
467{
468 switch(slot) {
469 case SLOT_ETHA: return IRQ_ETHA;
470 case SLOT_ETHB: return IRQ_ETHB;
471 case SLOT_NEC: return IRQ_NEC;
472 default: return IRQ_MPCI;
473 }
474}
475
476static struct hw_pci gmlr_hw_pci __initdata = {
477 .nr_controllers = 1,
478 .preinit = gmlr_pci_preinit,
479 .postinit = gmlr_pci_postinit,
480 .swizzle = pci_std_swizzle,
481 .setup = ixp4xx_setup,
482 .scan = ixp4xx_scan_bus,
483 .map_irq = gmlr_map_irq,
484};
485
486static int __init gmlr_pci_init(void)
487{
488 if (machine_is_goramo_mlr() &&
489 (hw_bits & (CFG_HW_USB_PORTS | CFG_HW_HAS_PCI_SLOT)))
490 pci_common_init(&gmlr_hw_pci);
491 return 0;
492}
493
494subsys_initcall(gmlr_pci_init);
495#endif /* CONFIG_PCI */
496
497
498MACHINE_START(GORAMO_MLR, "MultiLink")
499 /* Maintainer: Krzysztof Halasa */
500 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
501 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
502 .map_io = ixp4xx_map_io,
503 .init_irq = ixp4xx_init_irq,
504 .timer = &ixp4xx_timer,
505 .boot_params = 0x0100,
506 .init_machine = gmlr_init,
507MACHINE_END
diff --git a/arch/arm/mach-ixp4xx/include/mach/cpu.h b/arch/arm/mach-ixp4xx/include/mach/cpu.h
index def7773be67..b2ef65db0e9 100644
--- a/arch/arm/mach-ixp4xx/include/mach/cpu.h
+++ b/arch/arm/mach-ixp4xx/include/mach/cpu.h
@@ -26,6 +26,8 @@
26#define IXP46X_PROCESSOR_ID_VALUE 0x69054200 /* including IXP455 */ 26#define IXP46X_PROCESSOR_ID_VALUE 0x69054200 /* including IXP455 */
27#define IXP46X_PROCESSOR_ID_MASK 0xfffffff0 27#define IXP46X_PROCESSOR_ID_MASK 0xfffffff0
28 28
29#define cpu_is_ixp42x_rev_a0() ((read_cpuid_id() & (IXP42X_PROCESSOR_ID_MASK | 0xF)) == \
30 IXP42X_PROCESSOR_ID_VALUE)
29#define cpu_is_ixp42x() ((read_cpuid_id() & IXP42X_PROCESSOR_ID_MASK) == \ 31#define cpu_is_ixp42x() ((read_cpuid_id() & IXP42X_PROCESSOR_ID_MASK) == \
30 IXP42X_PROCESSOR_ID_VALUE) 32 IXP42X_PROCESSOR_ID_VALUE)
31#define cpu_is_ixp43x() ((read_cpuid_id() & IXP43X_PROCESSOR_ID_MASK) == \ 33#define cpu_is_ixp43x() ((read_cpuid_id() & IXP43X_PROCESSOR_ID_MASK) == \
@@ -35,8 +37,11 @@
35 37
36static inline u32 ixp4xx_read_feature_bits(void) 38static inline u32 ixp4xx_read_feature_bits(void)
37{ 39{
38 unsigned int val = ~*IXP4XX_EXP_CFG2; 40 u32 val = ~*IXP4XX_EXP_CFG2;
39 41
42 if (cpu_is_ixp42x_rev_a0())
43 return IXP42X_FEATURE_MASK & ~(IXP4XX_FEATURE_RCOMP |
44 IXP4XX_FEATURE_AES);
40 if (cpu_is_ixp42x()) 45 if (cpu_is_ixp42x())
41 return val & IXP42X_FEATURE_MASK; 46 return val & IXP42X_FEATURE_MASK;
42 if (cpu_is_ixp43x()) 47 if (cpu_is_ixp43x())
diff --git a/arch/arm/mach-ixp4xx/include/mach/qmgr.h b/arch/arm/mach-ixp4xx/include/mach/qmgr.h
index 0cbe6ceb67c..9e7cad2d54c 100644
--- a/arch/arm/mach-ixp4xx/include/mach/qmgr.h
+++ b/arch/arm/mach-ixp4xx/include/mach/qmgr.h
@@ -15,7 +15,7 @@
15#define DEBUG_QMGR 0 15#define DEBUG_QMGR 0
16 16
17#define HALF_QUEUES 32 17#define HALF_QUEUES 32
18#define QUEUES 64 /* only 32 lower queues currently supported */ 18#define QUEUES 64
19#define MAX_QUEUE_LENGTH 4 /* in dwords */ 19#define MAX_QUEUE_LENGTH 4 /* in dwords */
20 20
21#define QUEUE_STAT1_EMPTY 1 /* queue status bits */ 21#define QUEUE_STAT1_EMPTY 1 /* queue status bits */
@@ -110,48 +110,95 @@ static inline u32 qmgr_get_entry(unsigned int queue)
110 return val; 110 return val;
111} 111}
112 112
113static inline int qmgr_get_stat1(unsigned int queue) 113static inline int __qmgr_get_stat1(unsigned int queue)
114{ 114{
115 extern struct qmgr_regs __iomem *qmgr_regs; 115 extern struct qmgr_regs __iomem *qmgr_regs;
116 return (__raw_readl(&qmgr_regs->stat1[queue >> 3]) 116 return (__raw_readl(&qmgr_regs->stat1[queue >> 3])
117 >> ((queue & 7) << 2)) & 0xF; 117 >> ((queue & 7) << 2)) & 0xF;
118} 118}
119 119
120static inline int qmgr_get_stat2(unsigned int queue) 120static inline int __qmgr_get_stat2(unsigned int queue)
121{ 121{
122 extern struct qmgr_regs __iomem *qmgr_regs; 122 extern struct qmgr_regs __iomem *qmgr_regs;
123 BUG_ON(queue >= HALF_QUEUES);
123 return (__raw_readl(&qmgr_regs->stat2[queue >> 4]) 124 return (__raw_readl(&qmgr_regs->stat2[queue >> 4])
124 >> ((queue & 0xF) << 1)) & 0x3; 125 >> ((queue & 0xF) << 1)) & 0x3;
125} 126}
126 127
128/**
129 * qmgr_stat_empty() - checks if a hardware queue is empty
130 * @queue: queue number
131 *
132 * Returns non-zero value if the queue is empty.
133 */
127static inline int qmgr_stat_empty(unsigned int queue) 134static inline int qmgr_stat_empty(unsigned int queue)
128{ 135{
129 return !!(qmgr_get_stat1(queue) & QUEUE_STAT1_EMPTY); 136 BUG_ON(queue >= HALF_QUEUES);
137 return __qmgr_get_stat1(queue) & QUEUE_STAT1_EMPTY;
130} 138}
131 139
132static inline int qmgr_stat_nearly_empty(unsigned int queue) 140/**
141 * qmgr_stat_below_low_watermark() - checks if a queue is below low watermark
142 * @queue: queue number
143 *
144 * Returns non-zero value if the queue is below low watermark.
145 */
146static inline int qmgr_stat_below_low_watermark(unsigned int queue)
133{ 147{
134 return !!(qmgr_get_stat1(queue) & QUEUE_STAT1_NEARLY_EMPTY); 148 extern struct qmgr_regs __iomem *qmgr_regs;
149 if (queue >= HALF_QUEUES)
150 return (__raw_readl(&qmgr_regs->statne_h) >>
151 (queue - HALF_QUEUES)) & 0x01;
152 return __qmgr_get_stat1(queue) & QUEUE_STAT1_NEARLY_EMPTY;
135} 153}
136 154
137static inline int qmgr_stat_nearly_full(unsigned int queue) 155/**
156 * qmgr_stat_above_high_watermark() - checks if a queue is above high watermark
157 * @queue: queue number
158 *
159 * Returns non-zero value if the queue is above high watermark
160 */
161static inline int qmgr_stat_above_high_watermark(unsigned int queue)
138{ 162{
139 return !!(qmgr_get_stat1(queue) & QUEUE_STAT1_NEARLY_FULL); 163 BUG_ON(queue >= HALF_QUEUES);
164 return __qmgr_get_stat1(queue) & QUEUE_STAT1_NEARLY_FULL;
140} 165}
141 166
167/**
168 * qmgr_stat_full() - checks if a hardware queue is full
169 * @queue: queue number
170 *
171 * Returns non-zero value if the queue is full.
172 */
142static inline int qmgr_stat_full(unsigned int queue) 173static inline int qmgr_stat_full(unsigned int queue)
143{ 174{
144 return !!(qmgr_get_stat1(queue) & QUEUE_STAT1_FULL); 175 extern struct qmgr_regs __iomem *qmgr_regs;
176 if (queue >= HALF_QUEUES)
177 return (__raw_readl(&qmgr_regs->statf_h) >>
178 (queue - HALF_QUEUES)) & 0x01;
179 return __qmgr_get_stat1(queue) & QUEUE_STAT1_FULL;
145} 180}
146 181
182/**
183 * qmgr_stat_underflow() - checks if a hardware queue experienced underflow
184 * @queue: queue number
185 *
186 * Returns non-zero value if the queue experienced underflow.
187 */
147static inline int qmgr_stat_underflow(unsigned int queue) 188static inline int qmgr_stat_underflow(unsigned int queue)
148{ 189{
149 return !!(qmgr_get_stat2(queue) & QUEUE_STAT2_UNDERFLOW); 190 return __qmgr_get_stat2(queue) & QUEUE_STAT2_UNDERFLOW;
150} 191}
151 192
193/**
194 * qmgr_stat_overflow() - checks if a hardware queue experienced overflow
195 * @queue: queue number
196 *
197 * Returns non-zero value if the queue experienced overflow.
198 */
152static inline int qmgr_stat_overflow(unsigned int queue) 199static inline int qmgr_stat_overflow(unsigned int queue)
153{ 200{
154 return !!(qmgr_get_stat2(queue) & QUEUE_STAT2_OVERFLOW); 201 return __qmgr_get_stat2(queue) & QUEUE_STAT2_OVERFLOW;
155} 202}
156 203
157#endif 204#endif
diff --git a/arch/arm/mach-ixp4xx/ixp4xx_npe.c b/arch/arm/mach-ixp4xx/ixp4xx_npe.c
index 7bb8e778e4b..47ac69c7ec7 100644
--- a/arch/arm/mach-ixp4xx/ixp4xx_npe.c
+++ b/arch/arm/mach-ixp4xx/ixp4xx_npe.c
@@ -386,15 +386,6 @@ static int npe_reset(struct npe *npe)
386 /* reset the NPE */ 386 /* reset the NPE */
387 ixp4xx_write_feature_bits(val & 387 ixp4xx_write_feature_bits(val &
388 ~(IXP4XX_FEATURE_RESET_NPEA << npe->id)); 388 ~(IXP4XX_FEATURE_RESET_NPEA << npe->id));
389 for (i = 0; i < MAX_RETRIES; i++) {
390 if (!(ixp4xx_read_feature_bits() &
391 (IXP4XX_FEATURE_RESET_NPEA << npe->id)))
392 break; /* reset completed */
393 udelay(1);
394 }
395 if (i == MAX_RETRIES)
396 return -ETIMEDOUT;
397
398 /* deassert reset */ 389 /* deassert reset */
399 ixp4xx_write_feature_bits(val | 390 ixp4xx_write_feature_bits(val |
400 (IXP4XX_FEATURE_RESET_NPEA << npe->id)); 391 (IXP4XX_FEATURE_RESET_NPEA << npe->id));
diff --git a/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c b/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
index bfddc73d0a2..bfdbe4b5a3c 100644
--- a/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
+++ b/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
@@ -18,8 +18,8 @@ struct qmgr_regs __iomem *qmgr_regs;
18static struct resource *mem_res; 18static struct resource *mem_res;
19static spinlock_t qmgr_lock; 19static spinlock_t qmgr_lock;
20static u32 used_sram_bitmap[4]; /* 128 16-dword pages */ 20static u32 used_sram_bitmap[4]; /* 128 16-dword pages */
21static void (*irq_handlers[HALF_QUEUES])(void *pdev); 21static void (*irq_handlers[QUEUES])(void *pdev);
22static void *irq_pdevs[HALF_QUEUES]; 22static void *irq_pdevs[QUEUES];
23 23
24#if DEBUG_QMGR 24#if DEBUG_QMGR
25char qmgr_queue_descs[QUEUES][32]; 25char qmgr_queue_descs[QUEUES][32];
@@ -28,51 +28,112 @@ char qmgr_queue_descs[QUEUES][32];
28void qmgr_set_irq(unsigned int queue, int src, 28void qmgr_set_irq(unsigned int queue, int src,
29 void (*handler)(void *pdev), void *pdev) 29 void (*handler)(void *pdev), void *pdev)
30{ 30{
31 u32 __iomem *reg = &qmgr_regs->irqsrc[queue / 8]; /* 8 queues / u32 */
32 int bit = (queue % 8) * 4; /* 3 bits + 1 reserved bit per queue */
33 unsigned long flags; 31 unsigned long flags;
34 32
35 src &= 7;
36 spin_lock_irqsave(&qmgr_lock, flags); 33 spin_lock_irqsave(&qmgr_lock, flags);
37 __raw_writel((__raw_readl(reg) & ~(7 << bit)) | (src << bit), reg); 34 if (queue < HALF_QUEUES) {
35 u32 __iomem *reg;
36 int bit;
37 BUG_ON(src > QUEUE_IRQ_SRC_NOT_FULL);
38 reg = &qmgr_regs->irqsrc[queue >> 3]; /* 8 queues per u32 */
39 bit = (queue % 8) * 4; /* 3 bits + 1 reserved bit per queue */
40 __raw_writel((__raw_readl(reg) & ~(7 << bit)) | (src << bit),
41 reg);
42 } else
43 /* IRQ source for queues 32-63 is fixed */
44 BUG_ON(src != QUEUE_IRQ_SRC_NOT_NEARLY_EMPTY);
45
38 irq_handlers[queue] = handler; 46 irq_handlers[queue] = handler;
39 irq_pdevs[queue] = pdev; 47 irq_pdevs[queue] = pdev;
40 spin_unlock_irqrestore(&qmgr_lock, flags); 48 spin_unlock_irqrestore(&qmgr_lock, flags);
41} 49}
42 50
43 51
44static irqreturn_t qmgr_irq1(int irq, void *pdev) 52static irqreturn_t qmgr_irq1_a0(int irq, void *pdev)
45{ 53{
46 int i; 54 int i, ret = 0;
47 u32 val = __raw_readl(&qmgr_regs->irqstat[0]); 55 u32 en_bitmap, src, stat;
48 __raw_writel(val, &qmgr_regs->irqstat[0]); /* ACK */ 56
49 57 /* ACK - it may clear any bits so don't rely on it */
50 for (i = 0; i < HALF_QUEUES; i++) 58 __raw_writel(0xFFFFFFFF, &qmgr_regs->irqstat[0]);
51 if (val & (1 << i)) 59
60 en_bitmap = qmgr_regs->irqen[0];
61 while (en_bitmap) {
62 i = __fls(en_bitmap); /* number of the last "low" queue */
63 en_bitmap &= ~BIT(i);
64 src = qmgr_regs->irqsrc[i >> 3];
65 stat = qmgr_regs->stat1[i >> 3];
66 if (src & 4) /* the IRQ condition is inverted */
67 stat = ~stat;
68 if (stat & BIT(src & 3)) {
52 irq_handlers[i](irq_pdevs[i]); 69 irq_handlers[i](irq_pdevs[i]);
70 ret = IRQ_HANDLED;
71 }
72 }
73 return ret;
74}
75
76
77static irqreturn_t qmgr_irq2_a0(int irq, void *pdev)
78{
79 int i, ret = 0;
80 u32 req_bitmap;
81
82 /* ACK - it may clear any bits so don't rely on it */
83 __raw_writel(0xFFFFFFFF, &qmgr_regs->irqstat[1]);
84
85 req_bitmap = qmgr_regs->irqen[1] & qmgr_regs->statne_h;
86 while (req_bitmap) {
87 i = __fls(req_bitmap); /* number of the last "high" queue */
88 req_bitmap &= ~BIT(i);
89 irq_handlers[HALF_QUEUES + i](irq_pdevs[HALF_QUEUES + i]);
90 ret = IRQ_HANDLED;
91 }
92 return ret;
93}
53 94
54 return val ? IRQ_HANDLED : 0; 95
96static irqreturn_t qmgr_irq(int irq, void *pdev)
97{
98 int i, half = (irq == IRQ_IXP4XX_QM1 ? 0 : 1);
99 u32 req_bitmap = __raw_readl(&qmgr_regs->irqstat[half]);
100
101 if (!req_bitmap)
102 return 0;
103 __raw_writel(req_bitmap, &qmgr_regs->irqstat[half]); /* ACK */
104
105 while (req_bitmap) {
106 i = __fls(req_bitmap); /* number of the last queue */
107 req_bitmap &= ~BIT(i);
108 i += half * HALF_QUEUES;
109 irq_handlers[i](irq_pdevs[i]);
110 }
111 return IRQ_HANDLED;
55} 112}
56 113
57 114
58void qmgr_enable_irq(unsigned int queue) 115void qmgr_enable_irq(unsigned int queue)
59{ 116{
60 unsigned long flags; 117 unsigned long flags;
118 int half = queue / 32;
119 u32 mask = 1 << (queue & (HALF_QUEUES - 1));
61 120
62 spin_lock_irqsave(&qmgr_lock, flags); 121 spin_lock_irqsave(&qmgr_lock, flags);
63 __raw_writel(__raw_readl(&qmgr_regs->irqen[0]) | (1 << queue), 122 __raw_writel(__raw_readl(&qmgr_regs->irqen[half]) | mask,
64 &qmgr_regs->irqen[0]); 123 &qmgr_regs->irqen[half]);
65 spin_unlock_irqrestore(&qmgr_lock, flags); 124 spin_unlock_irqrestore(&qmgr_lock, flags);
66} 125}
67 126
68void qmgr_disable_irq(unsigned int queue) 127void qmgr_disable_irq(unsigned int queue)
69{ 128{
70 unsigned long flags; 129 unsigned long flags;
130 int half = queue / 32;
131 u32 mask = 1 << (queue & (HALF_QUEUES - 1));
71 132
72 spin_lock_irqsave(&qmgr_lock, flags); 133 spin_lock_irqsave(&qmgr_lock, flags);
73 __raw_writel(__raw_readl(&qmgr_regs->irqen[0]) & ~(1 << queue), 134 __raw_writel(__raw_readl(&qmgr_regs->irqen[half]) & ~mask,
74 &qmgr_regs->irqen[0]); 135 &qmgr_regs->irqen[half]);
75 __raw_writel(1 << queue, &qmgr_regs->irqstat[0]); /* clear */ 136 __raw_writel(mask, &qmgr_regs->irqstat[half]); /* clear */
76 spin_unlock_irqrestore(&qmgr_lock, flags); 137 spin_unlock_irqrestore(&qmgr_lock, flags);
77} 138}
78 139
@@ -98,8 +159,7 @@ int __qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
98 u32 cfg, addr = 0, mask[4]; /* in 16-dwords */ 159 u32 cfg, addr = 0, mask[4]; /* in 16-dwords */
99 int err; 160 int err;
100 161
101 if (queue >= HALF_QUEUES) 162 BUG_ON(queue >= QUEUES);
102 return -ERANGE;
103 163
104 if ((nearly_empty_watermark | nearly_full_watermark) & ~7) 164 if ((nearly_empty_watermark | nearly_full_watermark) & ~7)
105 return -EINVAL; 165 return -EINVAL;
@@ -180,7 +240,7 @@ void qmgr_release_queue(unsigned int queue)
180{ 240{
181 u32 cfg, addr, mask[4]; 241 u32 cfg, addr, mask[4];
182 242
183 BUG_ON(queue >= HALF_QUEUES); /* not in valid range */ 243 BUG_ON(queue >= QUEUES); /* not in valid range */
184 244
185 spin_lock_irq(&qmgr_lock); 245 spin_lock_irq(&qmgr_lock);
186 cfg = __raw_readl(&qmgr_regs->sram[queue]); 246 cfg = __raw_readl(&qmgr_regs->sram[queue]);
@@ -224,6 +284,8 @@ void qmgr_release_queue(unsigned int queue)
224static int qmgr_init(void) 284static int qmgr_init(void)
225{ 285{
226 int i, err; 286 int i, err;
287 irq_handler_t handler1, handler2;
288
227 mem_res = request_mem_region(IXP4XX_QMGR_BASE_PHYS, 289 mem_res = request_mem_region(IXP4XX_QMGR_BASE_PHYS,
228 IXP4XX_QMGR_REGION_SIZE, 290 IXP4XX_QMGR_REGION_SIZE,
229 "IXP4xx Queue Manager"); 291 "IXP4xx Queue Manager");
@@ -247,23 +309,42 @@ static int qmgr_init(void)
247 __raw_writel(0, &qmgr_regs->irqen[i]); 309 __raw_writel(0, &qmgr_regs->irqen[i]);
248 } 310 }
249 311
312 __raw_writel(0xFFFFFFFF, &qmgr_regs->statne_h);
313 __raw_writel(0, &qmgr_regs->statf_h);
314
250 for (i = 0; i < QUEUES; i++) 315 for (i = 0; i < QUEUES; i++)
251 __raw_writel(0, &qmgr_regs->sram[i]); 316 __raw_writel(0, &qmgr_regs->sram[i]);
252 317
253 err = request_irq(IRQ_IXP4XX_QM1, qmgr_irq1, 0, 318 if (cpu_is_ixp42x_rev_a0()) {
254 "IXP4xx Queue Manager", NULL); 319 handler1 = qmgr_irq1_a0;
320 handler2 = qmgr_irq2_a0;
321 } else
322 handler1 = handler2 = qmgr_irq;
323
324 err = request_irq(IRQ_IXP4XX_QM1, handler1, 0, "IXP4xx Queue Manager",
325 NULL);
255 if (err) { 326 if (err) {
256 printk(KERN_ERR "qmgr: failed to request IRQ%i\n", 327 printk(KERN_ERR "qmgr: failed to request IRQ%i (%i)\n",
257 IRQ_IXP4XX_QM1); 328 IRQ_IXP4XX_QM1, err);
258 goto error_irq; 329 goto error_irq;
259 } 330 }
260 331
332 err = request_irq(IRQ_IXP4XX_QM2, handler2, 0, "IXP4xx Queue Manager",
333 NULL);
334 if (err) {
335 printk(KERN_ERR "qmgr: failed to request IRQ%i (%i)\n",
336 IRQ_IXP4XX_QM2, err);
337 goto error_irq2;
338 }
339
261 used_sram_bitmap[0] = 0xF; /* 4 first pages reserved for config */ 340 used_sram_bitmap[0] = 0xF; /* 4 first pages reserved for config */
262 spin_lock_init(&qmgr_lock); 341 spin_lock_init(&qmgr_lock);
263 342
264 printk(KERN_INFO "IXP4xx Queue Manager initialized.\n"); 343 printk(KERN_INFO "IXP4xx Queue Manager initialized.\n");
265 return 0; 344 return 0;
266 345
346error_irq2:
347 free_irq(IRQ_IXP4XX_QM1, NULL);
267error_irq: 348error_irq:
268 iounmap(qmgr_regs); 349 iounmap(qmgr_regs);
269error_map: 350error_map:
@@ -274,7 +355,9 @@ error_map:
274static void qmgr_remove(void) 355static void qmgr_remove(void)
275{ 356{
276 free_irq(IRQ_IXP4XX_QM1, NULL); 357 free_irq(IRQ_IXP4XX_QM1, NULL);
358 free_irq(IRQ_IXP4XX_QM2, NULL);
277 synchronize_irq(IRQ_IXP4XX_QM1); 359 synchronize_irq(IRQ_IXP4XX_QM1);
360 synchronize_irq(IRQ_IXP4XX_QM2);
278 iounmap(qmgr_regs); 361 iounmap(qmgr_regs);
279 release_mem_region(IXP4XX_QMGR_BASE_PHYS, IXP4XX_QMGR_REGION_SIZE); 362 release_mem_region(IXP4XX_QMGR_BASE_PHYS, IXP4XX_QMGR_REGION_SIZE);
280} 363}