zeus.c 20 KB

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