zeus.c 18 KB

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