zeus.c 20 KB

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