Merge tag 'sound-5.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai...
[linux-2.6-block.git] / arch / arm / mach-pxa / zeus.c
CommitLineData
d2912cb1 1// SPDX-License-Identifier: GPL-2.0-only
e491a11c
MZ
2/*
3 * Support for the Arcom ZEUS.
4 *
5 * Copyright (C) 2006 Arcom Control Systems Ltd.
6 *
7 * Loosely based on Arcom's 2.6.16.28.
8 * Maintained by Marc Zyngier <maz@misterjones.org>
e491a11c
MZ
9 */
10
11#include <linux/cpufreq.h>
12#include <linux/interrupt.h>
40d727a2 13#include <linux/leds.h>
e491a11c
MZ
14#include <linux/irq.h>
15#include <linux/pm.h>
16#include <linux/gpio.h>
efdfeb07 17#include <linux/gpio/machine.h>
e491a11c
MZ
18#include <linux/serial_8250.h>
19#include <linux/dm9000.h>
20#include <linux/mmc/host.h>
21#include <linux/spi/spi.h>
8348c259 22#include <linux/spi/pxa2xx_spi.h>
e491a11c
MZ
23#include <linux/mtd/mtd.h>
24#include <linux/mtd/partitions.h>
25#include <linux/mtd/physmap.h>
26#include <linux/i2c.h>
f15fc9b1 27#include <linux/platform_data/i2c-pxa.h>
5877457a 28#include <linux/platform_data/pca953x.h>
a1916eb0 29#include <linux/apm-emulation.h>
438a22fe 30#include <linux/can/platform/mcp251x.h>
1ddff7da
AS
31#include <linux/regulator/fixed.h>
32#include <linux/regulator/machine.h>
e491a11c
MZ
33
34#include <asm/mach-types.h>
2c74a0ce 35#include <asm/suspend.h>
9f97da78 36#include <asm/system_info.h>
e491a11c
MZ
37#include <asm/mach/arch.h>
38#include <asm/mach/map.h>
39
4c25c5d2 40#include "pxa27x.h"
cb74dc3b 41#include "devices.h"
e491a11c 42#include <mach/regs-uart.h>
293b2da1
AB
43#include <linux/platform_data/usb-ohci-pxa27x.h>
44#include <linux/platform_data/mmc-pxamci.h>
4c25c5d2
AB
45#include "pxa27x-udc.h"
46#include "udc.h"
293b2da1 47#include <linux/platform_data/video-pxafb.h>
4c25c5d2 48#include "pm.h"
e491a11c 49#include <mach/audio.h>
293b2da1 50#include <linux/platform_data/pcmcia-pxa2xx_viper.h>
4c25c5d2 51#include "zeus.h"
ad68bb9f 52#include <mach/smemc.h>
e491a11c
MZ
53
54#include "generic.h"
55
56/*
57 * Interrupt handling
58 */
59
60static unsigned long zeus_irq_enabled_mask;
61static const int zeus_isa_irqs[] = { 3, 4, 5, 6, 7, 10, 11, 12, };
62static const int zeus_isa_irq_map[] = {
63 0, /* ISA irq #0, invalid */
64 0, /* ISA irq #1, invalid */
65 0, /* ISA irq #2, invalid */
66 1 << 0, /* ISA irq #3 */
67 1 << 1, /* ISA irq #4 */
68 1 << 2, /* ISA irq #5 */
69 1 << 3, /* ISA irq #6 */
70 1 << 4, /* ISA irq #7 */
71 0, /* ISA irq #8, invalid */
72 0, /* ISA irq #9, invalid */
73 1 << 5, /* ISA irq #10 */
74 1 << 6, /* ISA irq #11 */
75 1 << 7, /* ISA irq #12 */
76};
77
78static inline int zeus_irq_to_bitmask(unsigned int irq)
79{
80 return zeus_isa_irq_map[irq - PXA_ISA_IRQ(0)];
81}
82
83static inline int zeus_bit_to_irq(int bit)
84{
85 return zeus_isa_irqs[bit] + PXA_ISA_IRQ(0);
86}
87
a3f4c927 88static void zeus_ack_irq(struct irq_data *d)
e491a11c 89{
a3f4c927 90 __raw_writew(zeus_irq_to_bitmask(d->irq), ZEUS_CPLD_ISA_IRQ);
e491a11c
MZ
91}
92
a3f4c927 93static void zeus_mask_irq(struct irq_data *d)
e491a11c 94{
a3f4c927 95 zeus_irq_enabled_mask &= ~(zeus_irq_to_bitmask(d->irq));
e491a11c
MZ
96}
97
a3f4c927 98static void zeus_unmask_irq(struct irq_data *d)
e491a11c 99{
a3f4c927 100 zeus_irq_enabled_mask |= zeus_irq_to_bitmask(d->irq);
e491a11c
MZ
101}
102
103static inline unsigned long zeus_irq_pending(void)
104{
105 return __raw_readw(ZEUS_CPLD_ISA_IRQ) & zeus_irq_enabled_mask;
106}
107
bd0b9ac4 108static void zeus_irq_handler(struct irq_desc *desc)
e491a11c 109{
6947d04a 110 unsigned int irq;
e491a11c
MZ
111 unsigned long pending;
112
113 pending = zeus_irq_pending();
114 do {
115 /* we're in a chained irq handler,
116 * so ack the interrupt by hand */
a3f4c927 117 desc->irq_data.chip->irq_ack(&desc->irq_data);
e491a11c
MZ
118
119 if (likely(pending)) {
120 irq = zeus_bit_to_irq(__ffs(pending));
121 generic_handle_irq(irq);
122 }
123 pending = zeus_irq_pending();
124 } while (pending);
125}
126
127static struct irq_chip zeus_irq_chip = {
a3f4c927
LB
128 .name = "ISA",
129 .irq_ack = zeus_ack_irq,
130 .irq_mask = zeus_mask_irq,
131 .irq_unmask = zeus_unmask_irq,
e491a11c
MZ
132};
133
134static void __init zeus_init_irq(void)
135{
136 int level;
137 int isa_irq;
138
139 pxa27x_init_irq();
140
141 /* Peripheral IRQs. It would be nice to move those inside driver
142 configuration, but it is not supported at the moment. */
6845664a
TG
143 irq_set_irq_type(gpio_to_irq(ZEUS_AC97_GPIO), IRQ_TYPE_EDGE_RISING);
144 irq_set_irq_type(gpio_to_irq(ZEUS_WAKEUP_GPIO), IRQ_TYPE_EDGE_RISING);
145 irq_set_irq_type(gpio_to_irq(ZEUS_PTT_GPIO), IRQ_TYPE_EDGE_RISING);
146 irq_set_irq_type(gpio_to_irq(ZEUS_EXTGPIO_GPIO),
147 IRQ_TYPE_EDGE_FALLING);
148 irq_set_irq_type(gpio_to_irq(ZEUS_CAN_GPIO), IRQ_TYPE_EDGE_FALLING);
e491a11c
MZ
149
150 /* Setup ISA IRQs */
151 for (level = 0; level < ARRAY_SIZE(zeus_isa_irqs); level++) {
152 isa_irq = zeus_bit_to_irq(level);
f38c02f3
TG
153 irq_set_chip_and_handler(isa_irq, &zeus_irq_chip,
154 handle_edge_irq);
e8d36d5d 155 irq_clear_status_flags(isa_irq, IRQ_NOREQUEST | IRQ_NOPROBE);
e491a11c
MZ
156 }
157
6845664a
TG
158 irq_set_irq_type(gpio_to_irq(ZEUS_ISA_GPIO), IRQ_TYPE_EDGE_RISING);
159 irq_set_chained_handler(gpio_to_irq(ZEUS_ISA_GPIO), zeus_irq_handler);
e491a11c
MZ
160}
161
162
163/*
164 * Platform devices
165 */
166
167/* Flash */
168static struct resource zeus_mtd_resources[] = {
169 [0] = { /* NOR Flash (up to 64MB) */
170 .start = ZEUS_FLASH_PHYS,
171 .end = ZEUS_FLASH_PHYS + SZ_64M - 1,
172 .flags = IORESOURCE_MEM,
173 },
174 [1] = { /* SRAM */
175 .start = ZEUS_SRAM_PHYS,
176 .end = ZEUS_SRAM_PHYS + SZ_512K - 1,
177 .flags = IORESOURCE_MEM,
178 },
179};
180
181static struct physmap_flash_data zeus_flash_data[] = {
182 [0] = {
183 .width = 2,
184 .parts = NULL,
185 .nr_parts = 0,
186 },
187};
188
189static struct platform_device zeus_mtd_devices[] = {
190 [0] = {
191 .name = "physmap-flash",
192 .id = 0,
193 .dev = {
194 .platform_data = &zeus_flash_data[0],
195 },
196 .resource = &zeus_mtd_resources[0],
197 .num_resources = 1,
198 },
199};
200
201/* Serial */
202static struct resource zeus_serial_resources[] = {
203 {
204 .start = 0x10000000,
205 .end = 0x1000000f,
206 .flags = IORESOURCE_MEM,
207 },
208 {
209 .start = 0x10800000,
210 .end = 0x1080000f,
211 .flags = IORESOURCE_MEM,
212 },
213 {
214 .start = 0x11000000,
215 .end = 0x1100000f,
216 .flags = IORESOURCE_MEM,
217 },
218 {
219 .start = 0x40100000,
220 .end = 0x4010001f,
221 .flags = IORESOURCE_MEM,
222 },
223 {
224 .start = 0x40200000,
225 .end = 0x4020001f,
226 .flags = IORESOURCE_MEM,
227 },
228 {
229 .start = 0x40700000,
230 .end = 0x4070001f,
231 .flags = IORESOURCE_MEM,
232 },
233};
234
235static struct plat_serial8250_port serial_platform_data[] = {
236 /* External UARTs */
237 /* FIXME: Shared IRQs on COM1-COM4 will not work properly on v1i1 hardware. */
238 { /* COM1 */
239 .mapbase = 0x10000000,
4929f5a8 240 .irq = PXA_GPIO_TO_IRQ(ZEUS_UARTA_GPIO),
e491a11c
MZ
241 .irqflags = IRQF_TRIGGER_RISING,
242 .uartclk = 14745600,
243 .regshift = 1,
244 .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
245 .iotype = UPIO_MEM,
246 },
247 { /* COM2 */
248 .mapbase = 0x10800000,
4929f5a8 249 .irq = PXA_GPIO_TO_IRQ(ZEUS_UARTB_GPIO),
e491a11c
MZ
250 .irqflags = IRQF_TRIGGER_RISING,
251 .uartclk = 14745600,
252 .regshift = 1,
253 .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
254 .iotype = UPIO_MEM,
255 },
256 { /* COM3 */
257 .mapbase = 0x11000000,
4929f5a8 258 .irq = PXA_GPIO_TO_IRQ(ZEUS_UARTC_GPIO),
e491a11c
MZ
259 .irqflags = IRQF_TRIGGER_RISING,
260 .uartclk = 14745600,
261 .regshift = 1,
262 .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
263 .iotype = UPIO_MEM,
264 },
265 { /* COM4 */
266 .mapbase = 0x11800000,
4929f5a8 267 .irq = PXA_GPIO_TO_IRQ(ZEUS_UARTD_GPIO),
e491a11c
MZ
268 .irqflags = IRQF_TRIGGER_RISING,
269 .uartclk = 14745600,
270 .regshift = 1,
271 .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
272 .iotype = UPIO_MEM,
273 },
274 /* Internal UARTs */
275 { /* FFUART */
276 .membase = (void *)&FFUART,
277 .mapbase = __PREG(FFUART),
278 .irq = IRQ_FFUART,
279 .uartclk = 921600 * 16,
280 .regshift = 2,
281 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
282 .iotype = UPIO_MEM,
283 },
284 { /* BTUART */
285 .membase = (void *)&BTUART,
286 .mapbase = __PREG(BTUART),
287 .irq = IRQ_BTUART,
288 .uartclk = 921600 * 16,
289 .regshift = 2,
290 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
291 .iotype = UPIO_MEM,
292 },
293 { /* STUART */
294 .membase = (void *)&STUART,
295 .mapbase = __PREG(STUART),
296 .irq = IRQ_STUART,
297 .uartclk = 921600 * 16,
298 .regshift = 2,
299 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
300 .iotype = UPIO_MEM,
301 },
302 { },
303};
304
305static struct platform_device zeus_serial_device = {
306 .name = "serial8250",
307 .id = PLAT8250_DEV_PLATFORM,
308 .dev = {
309 .platform_data = serial_platform_data,
310 },
311 .num_resources = ARRAY_SIZE(zeus_serial_resources),
312 .resource = zeus_serial_resources,
313};
314
315/* Ethernet */
316static struct resource zeus_dm9k0_resource[] = {
317 [0] = {
318 .start = ZEUS_ETH0_PHYS,
319 .end = ZEUS_ETH0_PHYS + 1,
320 .flags = IORESOURCE_MEM
321 },
322 [1] = {
323 .start = ZEUS_ETH0_PHYS + 2,
324 .end = ZEUS_ETH0_PHYS + 3,
325 .flags = IORESOURCE_MEM
326 },
327 [2] = {
4929f5a8
HZ
328 .start = PXA_GPIO_TO_IRQ(ZEUS_ETH0_GPIO),
329 .end = PXA_GPIO_TO_IRQ(ZEUS_ETH0_GPIO),
e491a11c
MZ
330 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
331 },
332};
333
334static struct resource zeus_dm9k1_resource[] = {
335 [0] = {
336 .start = ZEUS_ETH1_PHYS,
337 .end = ZEUS_ETH1_PHYS + 1,
338 .flags = IORESOURCE_MEM
339 },
340 [1] = {
341 .start = ZEUS_ETH1_PHYS + 2,
342 .end = ZEUS_ETH1_PHYS + 3,
343 .flags = IORESOURCE_MEM,
344 },
345 [2] = {
4929f5a8
HZ
346 .start = PXA_GPIO_TO_IRQ(ZEUS_ETH1_GPIO),
347 .end = PXA_GPIO_TO_IRQ(ZEUS_ETH1_GPIO),
e491a11c
MZ
348 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
349 },
350};
351
352static struct dm9000_plat_data zeus_dm9k_platdata = {
353 .flags = DM9000_PLATF_16BITONLY,
354};
355
356static struct platform_device zeus_dm9k0_device = {
357 .name = "dm9000",
358 .id = 0,
359 .num_resources = ARRAY_SIZE(zeus_dm9k0_resource),
360 .resource = zeus_dm9k0_resource,
361 .dev = {
362 .platform_data = &zeus_dm9k_platdata,
363 }
364};
365
366static struct platform_device zeus_dm9k1_device = {
367 .name = "dm9000",
368 .id = 1,
369 .num_resources = ARRAY_SIZE(zeus_dm9k1_resource),
370 .resource = zeus_dm9k1_resource,
371 .dev = {
372 .platform_data = &zeus_dm9k_platdata,
373 }
374};
375
376/* External SRAM */
377static struct resource zeus_sram_resource = {
378 .start = ZEUS_SRAM_PHYS,
379 .end = ZEUS_SRAM_PHYS + ZEUS_SRAM_SIZE * 2 - 1,
380 .flags = IORESOURCE_MEM,
381};
382
383static struct platform_device zeus_sram_device = {
384 .name = "pxa2xx-8bit-sram",
385 .id = 0,
386 .num_resources = 1,
387 .resource = &zeus_sram_resource,
388};
389
390/* SPI interface on SSP3 */
51eea52d 391static struct pxa2xx_spi_controller pxa2xx_spi_ssp3_master_info = {
e491a11c
MZ
392 .num_chipselect = 1,
393 .enable_dma = 1,
394};
395
438a22fe 396/* CAN bus on SPI */
1ddff7da
AS
397static struct regulator_consumer_supply can_regulator_consumer =
398 REGULATOR_SUPPLY("vdd", "spi3.0");
438a22fe 399
1ddff7da
AS
400static struct regulator_init_data can_regulator_init_data = {
401 .constraints = {
402 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
403 },
404 .consumer_supplies = &can_regulator_consumer,
405 .num_consumer_supplies = 1,
406};
438a22fe 407
1ddff7da
AS
408static struct fixed_voltage_config can_regulator_pdata = {
409 .supply_name = "CAN_SHDN",
410 .microvolts = 3300000,
1ddff7da
AS
411 .init_data = &can_regulator_init_data,
412};
438a22fe 413
1ddff7da 414static struct platform_device can_regulator_device = {
5c0c75d3 415 .name = "reg-fixed-voltage",
541e00ae 416 .id = 0,
1ddff7da
AS
417 .dev = {
418 .platform_data = &can_regulator_pdata,
419 },
420};
438a22fe 421
efdfeb07
LW
422static struct gpiod_lookup_table can_regulator_gpiod_table = {
423 .dev_id = "reg-fixed-voltage.0",
424 .table = {
425 GPIO_LOOKUP("gpio-pxa", ZEUS_CAN_SHDN_GPIO,
01dc79cd 426 NULL, GPIO_ACTIVE_LOW),
efdfeb07
LW
427 { },
428 },
429};
430
438a22fe
MZ
431static struct mcp251x_platform_data zeus_mcp2515_pdata = {
432 .oscillator_frequency = 16*1000*1000,
438a22fe
MZ
433};
434
435static struct spi_board_info zeus_spi_board_info[] = {
436 [0] = {
e446630c 437 .modalias = "mcp2515",
438a22fe 438 .platform_data = &zeus_mcp2515_pdata,
4929f5a8 439 .irq = PXA_GPIO_TO_IRQ(ZEUS_CAN_GPIO),
438a22fe
MZ
440 .max_speed_hz = 1*1000*1000,
441 .bus_num = 3,
442 .mode = SPI_MODE_0,
443 .chip_select = 0,
e491a11c
MZ
444 },
445};
446
447/* Leds */
448static struct gpio_led zeus_leds[] = {
449 [0] = {
450 .name = "zeus:yellow:1",
451 .default_trigger = "heartbeat",
452 .gpio = ZEUS_EXT0_GPIO(3),
453 .active_low = 1,
454 },
455 [1] = {
456 .name = "zeus:yellow:2",
457 .default_trigger = "default-on",
458 .gpio = ZEUS_EXT0_GPIO(4),
459 .active_low = 1,
460 },
461 [2] = {
462 .name = "zeus:yellow:3",
463 .default_trigger = "default-on",
464 .gpio = ZEUS_EXT0_GPIO(5),
465 .active_low = 1,
466 },
467};
468
469static struct gpio_led_platform_data zeus_leds_info = {
470 .leds = zeus_leds,
471 .num_leds = ARRAY_SIZE(zeus_leds),
472};
473
474static struct platform_device zeus_leds_device = {
475 .name = "leds-gpio",
476 .id = -1,
477 .dev = {
478 .platform_data = &zeus_leds_info,
479 },
480};
481
c2de1c38
MZ
482static void zeus_cf_reset(int state)
483{
484 u16 cpld_state = __raw_readw(ZEUS_CPLD_CONTROL);
485
486 if (state)
487 cpld_state |= ZEUS_CPLD_CONTROL_CF_RST;
488 else
489 cpld_state &= ~ZEUS_CPLD_CONTROL_CF_RST;
490
491 __raw_writew(cpld_state, ZEUS_CPLD_CONTROL);
492}
493
494static struct arcom_pcmcia_pdata zeus_pcmcia_info = {
495 .cd_gpio = ZEUS_CF_CD_GPIO,
496 .rdy_gpio = ZEUS_CF_RDY_GPIO,
497 .pwr_gpio = ZEUS_CF_PWEN_GPIO,
498 .reset = zeus_cf_reset,
499};
500
501static struct platform_device zeus_pcmcia_device = {
502 .name = "zeus-pcmcia",
503 .id = -1,
504 .dev = {
505 .platform_data = &zeus_pcmcia_info,
506 },
507};
508
fcfdc67f
MZ
509static struct resource zeus_max6369_resource = {
510 .start = ZEUS_CPLD_EXTWDOG_PHYS,
511 .end = ZEUS_CPLD_EXTWDOG_PHYS,
512 .flags = IORESOURCE_MEM,
513};
514
515struct platform_device zeus_max6369_device = {
516 .name = "max6369_wdt",
517 .id = -1,
518 .resource = &zeus_max6369_resource,
519 .num_resources = 1,
520};
521
e491a11c
MZ
522/* AC'97 */
523static pxa2xx_audio_ops_t zeus_ac97_info = {
524 .reset_gpio = 95,
525};
526
527
528/*
529 * USB host
530 */
531
541e00ae
LP
532static struct regulator_consumer_supply zeus_ohci_regulator_supplies[] = {
533 REGULATOR_SUPPLY("vbus2", "pxa27x-ohci"),
534};
e491a11c 535
541e00ae
LP
536static struct regulator_init_data zeus_ohci_regulator_data = {
537 .constraints = {
538 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
539 },
540 .num_consumer_supplies = ARRAY_SIZE(zeus_ohci_regulator_supplies),
541 .consumer_supplies = zeus_ohci_regulator_supplies,
542};
e491a11c 543
541e00ae
LP
544static struct fixed_voltage_config zeus_ohci_regulator_config = {
545 .supply_name = "vbus2",
546 .microvolts = 5000000, /* 5.0V */
541e00ae
LP
547 .startup_delay = 0,
548 .init_data = &zeus_ohci_regulator_data,
549};
e491a11c 550
541e00ae
LP
551static struct platform_device zeus_ohci_regulator_device = {
552 .name = "reg-fixed-voltage",
553 .id = 1,
554 .dev = {
555 .platform_data = &zeus_ohci_regulator_config,
556 },
557};
e491a11c 558
efdfeb07
LW
559static struct gpiod_lookup_table zeus_ohci_regulator_gpiod_table = {
560 .dev_id = "reg-fixed-voltage.0",
561 .table = {
562 GPIO_LOOKUP("gpio-pxa", ZEUS_USB2_PWREN_GPIO,
563 NULL, GPIO_ACTIVE_HIGH),
564 { },
565 },
566};
567
e491a11c
MZ
568static struct pxaohci_platform_data zeus_ohci_platform_data = {
569 .port_mode = PMM_NPS_MODE,
7ff27dfa
MZ
570 /* Clear Power Control Polarity Low and set Power Sense
571 * Polarity Low. Supply power to USB ports. */
572 .flags = ENABLE_PORT_ALL | POWER_SENSE_LOW,
e491a11c
MZ
573};
574
88af3209 575static void __init zeus_register_ohci(void)
541e00ae
LP
576{
577 /* Port 2 is shared between host and client interface. */
578 UP2OCR = UP2OCR_HXOE | UP2OCR_HXS | UP2OCR_DMPDE | UP2OCR_DPPDE;
579
580 pxa_set_ohci_info(&zeus_ohci_platform_data);
581}
582
e491a11c
MZ
583/*
584 * Flat Panel
585 */
586
587static void zeus_lcd_power(int on, struct fb_var_screeninfo *si)
588{
589 gpio_set_value(ZEUS_LCD_EN_GPIO, on);
590}
591
592static void zeus_backlight_power(int on)
593{
594 gpio_set_value(ZEUS_BKLEN_GPIO, on);
595}
596
597static int zeus_setup_fb_gpios(void)
598{
599 int err;
600
601 if ((err = gpio_request(ZEUS_LCD_EN_GPIO, "LCD_EN")))
602 goto out_err;
603
604 if ((err = gpio_direction_output(ZEUS_LCD_EN_GPIO, 0)))
605 goto out_err_lcd;
606
607 if ((err = gpio_request(ZEUS_BKLEN_GPIO, "BKLEN")))
608 goto out_err_lcd;
609
610 if ((err = gpio_direction_output(ZEUS_BKLEN_GPIO, 0)))
611 goto out_err_bkl;
612
613 return 0;
614
615out_err_bkl:
616 gpio_free(ZEUS_BKLEN_GPIO);
617out_err_lcd:
618 gpio_free(ZEUS_LCD_EN_GPIO);
619out_err:
620 return err;
621}
622
623static struct pxafb_mode_info zeus_fb_mode_info[] = {
624 {
625 .pixclock = 39722,
626
627 .xres = 640,
628 .yres = 480,
629
630 .bpp = 16,
631
632 .hsync_len = 63,
633 .left_margin = 16,
634 .right_margin = 81,
635
636 .vsync_len = 2,
637 .upper_margin = 12,
638 .lower_margin = 31,
639
640 .sync = 0,
641 },
642};
643
644static struct pxafb_mach_info zeus_fb_info = {
645 .modes = zeus_fb_mode_info,
646 .num_modes = 1,
647 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
648 .pxafb_lcd_power = zeus_lcd_power,
649 .pxafb_backlight_power = zeus_backlight_power,
650};
651
652/*
653 * MMC/SD Device
654 *
655 * The card detect interrupt isn't debounced so we delay it by 250ms
656 * to give the card a chance to fully insert/eject.
657 */
658
659static struct pxamci_platform_data zeus_mci_platform_data = {
660 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
f97cab28 661 .detect_delay_ms = 250,
e491a11c 662 .gpio_card_ro_invert = 1,
e491a11c
MZ
663};
664
32d15448
LW
665static struct gpiod_lookup_table zeus_mci_gpio_table = {
666 .dev_id = "pxa2xx-mci.0",
667 .table = {
668 GPIO_LOOKUP("gpio-pxa", ZEUS_MMC_CD_GPIO,
669 "cd", GPIO_ACTIVE_LOW),
670 GPIO_LOOKUP("gpio-pxa", ZEUS_MMC_WP_GPIO,
671 "wp", GPIO_ACTIVE_HIGH),
672 { },
673 },
674};
675
e491a11c
MZ
676/*
677 * USB Device Controller
678 */
679static void zeus_udc_command(int cmd)
680{
681 switch (cmd) {
682 case PXA2XX_UDC_CMD_DISCONNECT:
683 pr_info("zeus: disconnecting USB client\n");
684 UP2OCR = UP2OCR_HXOE | UP2OCR_HXS | UP2OCR_DMPDE | UP2OCR_DPPDE;
685 break;
686
687 case PXA2XX_UDC_CMD_CONNECT:
688 pr_info("zeus: connecting USB client\n");
689 UP2OCR = UP2OCR_HXOE | UP2OCR_DPPUE;
690 break;
691 }
692}
693
694static struct pxa2xx_udc_mach_info zeus_udc_info = {
695 .udc_command = zeus_udc_command,
696};
697
541e00ae
LP
698static struct platform_device *zeus_devices[] __initdata = {
699 &zeus_serial_device,
700 &zeus_mtd_devices[0],
701 &zeus_dm9k0_device,
702 &zeus_dm9k1_device,
703 &zeus_sram_device,
704 &zeus_leds_device,
705 &zeus_pcmcia_device,
706 &zeus_max6369_device,
707 &can_regulator_device,
708 &zeus_ohci_regulator_device,
709};
710
98acdbe4 711#ifdef CONFIG_PM
e491a11c
MZ
712static void zeus_power_off(void)
713{
714 local_irq_disable();
2c74a0ce 715 cpu_suspend(PWRMODE_DEEPSLEEP, pxa27x_finish_suspend);
e491a11c 716}
98acdbe4
SS
717#else
718#define zeus_power_off NULL
719#endif
e491a11c 720
a1916eb0
MZ
721#ifdef CONFIG_APM_EMULATION
722static void zeus_get_power_status(struct apm_power_info *info)
723{
724 /* Power supply is always present */
725 info->ac_line_status = APM_AC_ONLINE;
726 info->battery_status = APM_BATTERY_STATUS_NOT_PRESENT;
727 info->battery_flag = APM_BATTERY_FLAG_NOT_PRESENT;
728}
729
730static inline void zeus_setup_apm(void)
731{
732 apm_get_power_status = zeus_get_power_status;
733}
734#else
735static inline void zeus_setup_apm(void)
736{
737}
738#endif
739
100627b4
MZ
740static int zeus_get_pcb_info(struct i2c_client *client, unsigned gpio,
741 unsigned ngpio, void *context)
e491a11c
MZ
742{
743 int i;
744 u8 pcb_info = 0;
745
746 for (i = 0; i < 8; i++) {
747 int pcb_bit = gpio + i + 8;
748
749 if (gpio_request(pcb_bit, "pcb info")) {
750 dev_err(&client->dev, "Can't request pcb info %d\n", i);
751 continue;
752 }
753
754 if (gpio_direction_input(pcb_bit)) {
755 dev_err(&client->dev, "Can't read pcb info %d\n", i);
756 gpio_free(pcb_bit);
757 continue;
758 }
759
760 pcb_info |= !!gpio_get_value(pcb_bit) << i;
761
762 gpio_free(pcb_bit);
763 }
764
765 dev_info(&client->dev, "Zeus PCB version %d issue %d\n",
766 pcb_info >> 4, pcb_info & 0xf);
767
768 return 0;
769}
770
771static struct pca953x_platform_data zeus_pca953x_pdata[] = {
772 [0] = { .gpio_base = ZEUS_EXT0_GPIO_BASE, },
773 [1] = {
774 .gpio_base = ZEUS_EXT1_GPIO_BASE,
775 .setup = zeus_get_pcb_info,
776 },
777 [2] = { .gpio_base = ZEUS_USER_GPIO_BASE, },
778};
779
780static struct i2c_board_info __initdata zeus_i2c_devices[] = {
781 {
782 I2C_BOARD_INFO("pca9535", 0x21),
783 .platform_data = &zeus_pca953x_pdata[0],
784 },
785 {
786 I2C_BOARD_INFO("pca9535", 0x22),
787 .platform_data = &zeus_pca953x_pdata[1],
788 },
789 {
790 I2C_BOARD_INFO("pca9535", 0x20),
791 .platform_data = &zeus_pca953x_pdata[2],
4929f5a8 792 .irq = PXA_GPIO_TO_IRQ(ZEUS_EXTGPIO_GPIO),
e491a11c
MZ
793 },
794 { I2C_BOARD_INFO("lm75a", 0x48) },
795 { I2C_BOARD_INFO("24c01", 0x50) },
796 { I2C_BOARD_INFO("isl1208", 0x6f) },
797};
798
799static mfp_cfg_t zeus_pin_config[] __initdata = {
c11b6a42
EM
800 /* AC97 */
801 GPIO28_AC97_BITCLK,
802 GPIO29_AC97_SDATA_IN_0,
803 GPIO30_AC97_SDATA_OUT,
804 GPIO31_AC97_SYNC,
805
e491a11c
MZ
806 GPIO15_nCS_1,
807 GPIO78_nCS_2,
808 GPIO80_nCS_4,
809 GPIO33_nCS_5,
810
811 GPIO22_GPIO,
812 GPIO32_MMC_CLK,
813 GPIO92_MMC_DAT_0,
814 GPIO109_MMC_DAT_1,
815 GPIO110_MMC_DAT_2,
816 GPIO111_MMC_DAT_3,
817 GPIO112_MMC_CMD,
818
819 GPIO88_USBH1_PWR,
820 GPIO89_USBH1_PEN,
821 GPIO119_USBH2_PWR,
822 GPIO120_USBH2_PEN,
823
824 GPIO86_LCD_LDD_16,
825 GPIO87_LCD_LDD_17,
826
827 GPIO102_GPIO,
828 GPIO104_CIF_DD_2,
829 GPIO105_CIF_DD_1,
830
438a22fe
MZ
831 GPIO81_SSP3_TXD,
832 GPIO82_SSP3_RXD,
833 GPIO83_SSP3_SFRM,
834 GPIO84_SSP3_SCLK,
835
e491a11c
MZ
836 GPIO48_nPOE,
837 GPIO49_nPWE,
838 GPIO50_nPIOR,
839 GPIO51_nPIOW,
840 GPIO85_nPCE_1,
841 GPIO54_nPCE_2,
842 GPIO79_PSKTSEL,
843 GPIO55_nPREG,
844 GPIO56_nPWAIT,
845 GPIO57_nIOIS16,
846 GPIO36_GPIO, /* CF CD */
847 GPIO97_GPIO, /* CF PWREN */
848 GPIO99_GPIO, /* CF RDY */
849};
850
5f86ceba
MZ
851/*
852 * DM9k MSCx settings: SRAM, 16 bits
853 * 17 cycles delay first access
854 * 5 cycles delay next access
855 * 13 cycles recovery time
856 * faster device
857 */
858#define DM9K_MSC_VALUE 0xe4c9
859
e491a11c
MZ
860static void __init zeus_init(void)
861{
5f86ceba 862 u16 dm9000_msc = DM9K_MSC_VALUE;
ad68bb9f 863 u32 msc0, msc1;
e491a11c
MZ
864
865 system_rev = __raw_readw(ZEUS_CPLD_VERSION);
866 pr_info("Zeus CPLD V%dI%d\n", (system_rev & 0xf0) >> 4, (system_rev & 0x0f));
867
868 /* Fix timings for dm9000s (CS1/CS2)*/
bc3e55c6
MV
869 msc0 = (__raw_readl(MSC0) & 0x0000ffff) | (dm9000_msc << 16);
870 msc1 = (__raw_readl(MSC1) & 0xffff0000) | dm9000_msc;
ad68bb9f
MV
871 __raw_writel(msc0, MSC0);
872 __raw_writel(msc1, MSC1);
e491a11c
MZ
873
874 pm_power_off = zeus_power_off;
a1916eb0 875 zeus_setup_apm();
e491a11c
MZ
876
877 pxa2xx_mfp_config(ARRAY_AND_SIZE(zeus_pin_config));
878
efdfeb07
LW
879 gpiod_add_lookup_table(&can_regulator_gpiod_table);
880 gpiod_add_lookup_table(&zeus_ohci_regulator_gpiod_table);
e491a11c
MZ
881 platform_add_devices(zeus_devices, ARRAY_SIZE(zeus_devices));
882
541e00ae 883 zeus_register_ohci();
e491a11c
MZ
884
885 if (zeus_setup_fb_gpios())
886 pr_err("Failed to setup fb gpios\n");
887 else
4321e1a1 888 pxa_set_fb_info(NULL, &zeus_fb_info);
e491a11c 889
32d15448 890 gpiod_add_lookup_table(&zeus_mci_gpio_table);
e491a11c
MZ
891 pxa_set_mci_info(&zeus_mci_platform_data);
892 pxa_set_udc_info(&zeus_udc_info);
893 pxa_set_ac97_info(&zeus_ac97_info);
894 pxa_set_i2c_info(NULL);
895 i2c_register_board_info(0, ARRAY_AND_SIZE(zeus_i2c_devices));
438a22fe
MZ
896 pxa2xx_set_spi_info(3, &pxa2xx_spi_ssp3_master_info);
897 spi_register_board_info(zeus_spi_board_info, ARRAY_SIZE(zeus_spi_board_info));
a927ef89
RJ
898
899 regulator_has_full_constraints();
e491a11c
MZ
900}
901
902static struct map_desc zeus_io_desc[] __initdata = {
903 {
97b09da4 904 .virtual = (unsigned long)ZEUS_CPLD_VERSION,
e491a11c
MZ
905 .pfn = __phys_to_pfn(ZEUS_CPLD_VERSION_PHYS),
906 .length = 0x1000,
907 .type = MT_DEVICE,
908 },
909 {
97b09da4 910 .virtual = (unsigned long)ZEUS_CPLD_ISA_IRQ,
e491a11c
MZ
911 .pfn = __phys_to_pfn(ZEUS_CPLD_ISA_IRQ_PHYS),
912 .length = 0x1000,
913 .type = MT_DEVICE,
914 },
915 {
97b09da4 916 .virtual = (unsigned long)ZEUS_CPLD_CONTROL,
e491a11c
MZ
917 .pfn = __phys_to_pfn(ZEUS_CPLD_CONTROL_PHYS),
918 .length = 0x1000,
919 .type = MT_DEVICE,
920 },
e491a11c 921 {
97b09da4 922 .virtual = (unsigned long)ZEUS_PC104IO,
e491a11c
MZ
923 .pfn = __phys_to_pfn(ZEUS_PC104IO_PHYS),
924 .length = 0x00800000,
925 .type = MT_DEVICE,
926 },
927};
928
929static void __init zeus_map_io(void)
930{
851982c1 931 pxa27x_map_io();
e491a11c
MZ
932
933 iotable_init(zeus_io_desc, ARRAY_SIZE(zeus_io_desc));
934
935 /* Clear PSPR to ensure a full restart on wake-up. */
936 PMCR = PSPR = 0;
937
938 /* enable internal 32.768Khz oscillator (ignore OSCC_OOK) */
ea7743e2 939 writel(readl(OSCC) | OSCC_OON, OSCC);
e491a11c
MZ
940
941 /* Some clock cycles later (from OSCC_ON), programme PCFR (OPDE...).
942 * float chip selects and PCMCIA */
943 PCFR = PCFR_OPDE | PCFR_DC_EN | PCFR_FS | PCFR_FP;
944}
945
90ac0dfd 946MACHINE_START(ARCOM_ZEUS, "Arcom/Eurotech ZEUS")
e491a11c 947 /* Maintainer: Marc Zyngier <maz@misterjones.org> */
7375aba6 948 .atag_offset = 0x100,
e491a11c 949 .map_io = zeus_map_io,
6ac6b817 950 .nr_irqs = ZEUS_NR_IRQS,
e491a11c 951 .init_irq = zeus_init_irq,
8a97ae2f 952 .handle_irq = pxa27x_handle_irq,
6bb27d73 953 .init_time = pxa_timer_init,
e491a11c 954 .init_machine = zeus_init,
271a74fc 955 .restart = pxa_restart,
e491a11c
MZ
956MACHINE_END
957