zeus.c 21 KB

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