zeus.c 20 KB

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