Linux Audio

Check our new training course

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