zeus.c 21 KB

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