trizeps4.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. /*
  2. * linux/arch/arm/mach-pxa/trizeps4.c
  3. *
  4. * Support for the Keith und Koep Trizeps4 Module Platform.
  5. *
  6. * Author: Jürgen Schindele
  7. * Created: 20 02, 2006
  8. * Copyright: Jürgen Schindele
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/kernel.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/sysdev.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/sched.h>
  20. #include <linux/bitops.h>
  21. #include <linux/fb.h>
  22. #include <linux/ioport.h>
  23. #include <linux/delay.h>
  24. #include <linux/gpio.h>
  25. #include <linux/dm9000.h>
  26. #include <linux/mtd/physmap.h>
  27. #include <linux/mtd/partitions.h>
  28. #include <asm/types.h>
  29. #include <asm/setup.h>
  30. #include <asm/memory.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/irq.h>
  33. #include <asm/sizes.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/map.h>
  36. #include <asm/mach/irq.h>
  37. #include <asm/mach/flash.h>
  38. #include <mach/pxa27x.h>
  39. #include <mach/pxa2xx_spi.h>
  40. #include <mach/trizeps4.h>
  41. #include <mach/audio.h>
  42. #include <mach/pxafb.h>
  43. #include <mach/mmc.h>
  44. #include <mach/irda.h>
  45. #include <mach/ohci.h>
  46. #include <plat/i2c.h>
  47. #include "generic.h"
  48. #include "devices.h"
  49. /* comment out the following line if you want to use the
  50. * Standard UART from PXA for serial / irda transmission
  51. * and acivate it if you have status leds connected */
  52. #define STATUS_LEDS_ON_STUART_PINS 1
  53. /*****************************************************************************
  54. * MultiFunctionPins of CPU
  55. *****************************************************************************/
  56. static unsigned long trizeps4_pin_config[] __initdata = {
  57. /* Chip Selects */
  58. GPIO15_nCS_1, /* DiskOnChip CS */
  59. GPIO93_GPIO, /* TRIZEPS4_DOC_IRQ */
  60. GPIO94_GPIO, /* DOC lock */
  61. GPIO78_nCS_2, /* DM9000 CS */
  62. GPIO101_GPIO, /* TRIZEPS4_ETH_IRQ */
  63. GPIO79_nCS_3, /* Logic CS */
  64. GPIO0_GPIO | WAKEUP_ON_EDGE_RISE, /* Logic irq */
  65. /* LCD - 16bpp Active TFT */
  66. GPIOxx_LCD_TFT_16BPP,
  67. /* UART */
  68. GPIO9_FFUART_CTS,
  69. GPIO10_FFUART_DCD,
  70. GPIO16_FFUART_TXD,
  71. GPIO33_FFUART_DSR,
  72. GPIO38_FFUART_RI,
  73. GPIO82_FFUART_DTR,
  74. GPIO83_FFUART_RTS,
  75. GPIO96_FFUART_RXD,
  76. GPIO42_BTUART_RXD,
  77. GPIO43_BTUART_TXD,
  78. GPIO44_BTUART_CTS,
  79. GPIO45_BTUART_RTS,
  80. #ifdef STATUS_LEDS_ON_STUART_PINS
  81. GPIO46_GPIO,
  82. GPIO47_GPIO,
  83. #else
  84. GPIO46_STUART_RXD,
  85. GPIO47_STUART_TXD,
  86. #endif
  87. /* PCMCIA */
  88. GPIO11_GPIO, /* TRIZEPS4_CD_IRQ */
  89. GPIO13_GPIO, /* TRIZEPS4_READY_NINT */
  90. GPIO48_nPOE,
  91. GPIO49_nPWE,
  92. GPIO50_nPIOR,
  93. GPIO51_nPIOW,
  94. GPIO54_nPCE_2,
  95. GPIO55_nPREG,
  96. GPIO56_nPWAIT,
  97. GPIO57_nIOIS16,
  98. GPIO102_nPCE_1,
  99. GPIO104_PSKTSEL,
  100. /* MultiMediaCard */
  101. GPIO32_MMC_CLK,
  102. GPIO92_MMC_DAT_0,
  103. GPIO109_MMC_DAT_1,
  104. GPIO110_MMC_DAT_2,
  105. GPIO111_MMC_DAT_3,
  106. GPIO112_MMC_CMD,
  107. GPIO12_GPIO, /* TRIZEPS4_MMC_IRQ */
  108. /* USB OHCI */
  109. GPIO88_USBH1_PWR, /* USBHPWR1 */
  110. GPIO89_USBH1_PEN, /* USBHPEN1 */
  111. /* I2C */
  112. GPIO117_I2C_SCL,
  113. GPIO118_I2C_SDA,
  114. };
  115. static unsigned long trizeps4wl_pin_config[] __initdata = {
  116. /* SSP 2 */
  117. GPIO14_SSP2_SFRM,
  118. GPIO19_SSP2_SCLK,
  119. GPIO53_GPIO, /* TRIZEPS4_SPI_IRQ */
  120. GPIO86_SSP2_RXD,
  121. GPIO87_SSP2_TXD,
  122. };
  123. /****************************************************************************
  124. * ONBOARD FLASH
  125. ****************************************************************************/
  126. static struct mtd_partition trizeps4_partitions[] = {
  127. {
  128. .name = "Bootloader",
  129. .offset = 0x00000000,
  130. .size = 0x00040000,
  131. .mask_flags = MTD_WRITEABLE /* force read-only */
  132. }, {
  133. .name = "Backup",
  134. .offset = 0x00040000,
  135. .size = 0x00040000,
  136. }, {
  137. .name = "Image",
  138. .offset = 0x00080000,
  139. .size = 0x01080000,
  140. }, {
  141. .name = "IPSM",
  142. .offset = 0x01100000,
  143. .size = 0x00e00000,
  144. }, {
  145. .name = "Registry",
  146. .offset = 0x01f00000,
  147. .size = MTDPART_SIZ_FULL,
  148. }
  149. };
  150. static struct physmap_flash_data trizeps4_flash_data[] = {
  151. {
  152. .width = 4, /* bankwidth in bytes */
  153. .parts = trizeps4_partitions,
  154. .nr_parts = ARRAY_SIZE(trizeps4_partitions)
  155. }
  156. };
  157. static struct resource flash_resource = {
  158. .start = PXA_CS0_PHYS,
  159. .end = PXA_CS0_PHYS + SZ_32M - 1,
  160. .flags = IORESOURCE_MEM,
  161. };
  162. static struct platform_device flash_device = {
  163. .name = "physmap-flash",
  164. .id = 0,
  165. .dev = {
  166. .platform_data = trizeps4_flash_data,
  167. },
  168. .resource = &flash_resource,
  169. .num_resources = 1,
  170. };
  171. /****************************************************************************
  172. * DAVICOM DM9000 Ethernet
  173. ****************************************************************************/
  174. static struct resource dm9000_resources[] = {
  175. [0] = {
  176. .start = TRIZEPS4_ETH_PHYS+0x300,
  177. .end = TRIZEPS4_ETH_PHYS+0x400-1,
  178. .flags = IORESOURCE_MEM,
  179. },
  180. [1] = {
  181. .start = TRIZEPS4_ETH_PHYS+0x8300,
  182. .end = TRIZEPS4_ETH_PHYS+0x8400-1,
  183. .flags = IORESOURCE_MEM,
  184. },
  185. [2] = {
  186. .start = TRIZEPS4_ETH_IRQ,
  187. .end = TRIZEPS4_ETH_IRQ,
  188. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  189. },
  190. };
  191. static struct dm9000_plat_data tri_dm9000_platdata = {
  192. .flags = DM9000_PLATF_32BITONLY,
  193. };
  194. static struct platform_device dm9000_device = {
  195. .name = "dm9000",
  196. .id = -1,
  197. .num_resources = ARRAY_SIZE(dm9000_resources),
  198. .resource = dm9000_resources,
  199. .dev = {
  200. .platform_data = &tri_dm9000_platdata,
  201. }
  202. };
  203. /****************************************************************************
  204. * LED's on GPIO pins of PXA
  205. ****************************************************************************/
  206. static struct gpio_led trizeps4_led[] = {
  207. #ifdef STATUS_LEDS_ON_STUART_PINS
  208. {
  209. .name = "led0:orange:heartbeat", /* */
  210. .default_trigger = "heartbeat",
  211. .gpio = GPIO_HEARTBEAT_LED,
  212. .active_low = 1,
  213. },
  214. {
  215. .name = "led1:yellow:cpubusy", /* */
  216. .default_trigger = "cpu-busy",
  217. .gpio = GPIO_SYS_BUSY_LED,
  218. .active_low = 1,
  219. },
  220. #endif
  221. };
  222. static struct gpio_led_platform_data trizeps4_led_data = {
  223. .leds = trizeps4_led,
  224. .num_leds = ARRAY_SIZE(trizeps4_led),
  225. };
  226. static struct platform_device leds_devices = {
  227. .name = "leds-gpio",
  228. .id = -1,
  229. .dev = {
  230. .platform_data = &trizeps4_led_data,
  231. },
  232. };
  233. static struct platform_device *trizeps4_devices[] __initdata = {
  234. &flash_device,
  235. &dm9000_device,
  236. &leds_devices,
  237. };
  238. static struct platform_device *trizeps4wl_devices[] __initdata = {
  239. &flash_device,
  240. &leds_devices,
  241. };
  242. static short trizeps_conxs_bcr;
  243. /* PCCARD power switching supports only 3,3V */
  244. void board_pcmcia_power(int power)
  245. {
  246. if (power) {
  247. /* switch power on, put in reset and enable buffers */
  248. trizeps_conxs_bcr |= power;
  249. trizeps_conxs_bcr |= ConXS_BCR_CF_RESET;
  250. trizeps_conxs_bcr &= ~ConXS_BCR_CF_BUF_EN;
  251. BCR_writew(trizeps_conxs_bcr);
  252. /* wait a little */
  253. udelay(2000);
  254. /* take reset away */
  255. trizeps_conxs_bcr &= ~ConXS_BCR_CF_RESET;
  256. BCR_writew(trizeps_conxs_bcr);
  257. udelay(2000);
  258. } else {
  259. /* put in reset */
  260. trizeps_conxs_bcr |= ConXS_BCR_CF_RESET;
  261. BCR_writew(trizeps_conxs_bcr);
  262. udelay(1000);
  263. /* switch power off */
  264. trizeps_conxs_bcr &= ~0xf;
  265. BCR_writew(trizeps_conxs_bcr);
  266. }
  267. pr_debug("%s: o%s 0x%x\n", __func__, power ? "n" : "ff",
  268. trizeps_conxs_bcr);
  269. }
  270. EXPORT_SYMBOL(board_pcmcia_power);
  271. /* backlight power switching for LCD panel */
  272. static void board_backlight_power(int on)
  273. {
  274. if (on)
  275. trizeps_conxs_bcr |= ConXS_BCR_L_DISP;
  276. else
  277. trizeps_conxs_bcr &= ~ConXS_BCR_L_DISP;
  278. pr_debug("%s: o%s 0x%x\n", __func__, on ? "n" : "ff",
  279. trizeps_conxs_bcr);
  280. BCR_writew(trizeps_conxs_bcr);
  281. }
  282. /* a I2C based RTC is known on CONXS board */
  283. static struct i2c_board_info trizeps4_i2c_devices[] __initdata = {
  284. { I2C_BOARD_INFO("rtc-pcf8593", 0x51) }
  285. };
  286. /****************************************************************************
  287. * MMC card slot external to module
  288. ****************************************************************************/
  289. static int trizeps4_mci_init(struct device *dev, irq_handler_t mci_detect_int,
  290. void *data)
  291. {
  292. int err;
  293. err = request_irq(TRIZEPS4_MMC_IRQ, mci_detect_int,
  294. IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_SAMPLE_RANDOM,
  295. "MMC card detect", data);
  296. if (err) {
  297. printk(KERN_ERR "trizeps4_mci_init: MMC/SD: can't request"
  298. "MMC card detect IRQ\n");
  299. return -1;
  300. }
  301. return 0;
  302. }
  303. static void trizeps4_mci_exit(struct device *dev, void *data)
  304. {
  305. free_irq(TRIZEPS4_MMC_IRQ, data);
  306. }
  307. static struct pxamci_platform_data trizeps4_mci_platform_data = {
  308. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  309. .detect_delay = 1,
  310. .init = trizeps4_mci_init,
  311. .exit = trizeps4_mci_exit,
  312. .get_ro = NULL, /* write-protection not supported */
  313. .setpower = NULL, /* power-switching not supported */
  314. .gpio_card_detect = -1,
  315. .gpio_card_ro = -1,
  316. .gpio_power = -1,
  317. };
  318. /****************************************************************************
  319. * IRDA mode switching on stuart
  320. ****************************************************************************/
  321. #ifndef STATUS_LEDS_ON_STUART_PINS
  322. static short trizeps_conxs_ircr;
  323. static int trizeps4_irda_startup(struct device *dev)
  324. {
  325. trizeps_conxs_ircr &= ~ConXS_IRCR_SD;
  326. IRCR_writew(trizeps_conxs_ircr);
  327. return 0;
  328. }
  329. static void trizeps4_irda_shutdown(struct device *dev)
  330. {
  331. trizeps_conxs_ircr |= ConXS_IRCR_SD;
  332. IRCR_writew(trizeps_conxs_ircr);
  333. }
  334. static void trizeps4_irda_transceiver_mode(struct device *dev, int mode)
  335. {
  336. unsigned long flags;
  337. local_irq_save(flags);
  338. /* Switch mode */
  339. if (mode & IR_SIRMODE)
  340. trizeps_conxs_ircr &= ~ConXS_IRCR_MODE; /* Slow mode */
  341. else if (mode & IR_FIRMODE)
  342. trizeps_conxs_ircr |= ConXS_IRCR_MODE; /* Fast mode */
  343. /* Switch power */
  344. if (mode & IR_OFF)
  345. trizeps_conxs_ircr |= ConXS_IRCR_SD;
  346. else
  347. trizeps_conxs_ircr &= ~ConXS_IRCR_SD;
  348. IRCR_writew(trizeps_conxs_ircr);
  349. local_irq_restore(flags);
  350. pxa2xx_transceiver_mode(dev, mode);
  351. }
  352. static struct pxaficp_platform_data trizeps4_ficp_platform_data = {
  353. .gpio_pwdown = -1,
  354. .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
  355. .transceiver_mode = trizeps4_irda_transceiver_mode,
  356. .startup = trizeps4_irda_startup,
  357. .shutdown = trizeps4_irda_shutdown,
  358. };
  359. #endif
  360. /****************************************************************************
  361. * OHCI USB port
  362. ****************************************************************************/
  363. static struct pxaohci_platform_data trizeps4_ohci_platform_data = {
  364. .port_mode = PMM_PERPORT_MODE,
  365. .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
  366. };
  367. static struct map_desc trizeps4_io_desc[] __initdata = {
  368. { /* ConXS CFSR */
  369. .virtual = TRIZEPS4_CFSR_VIRT,
  370. .pfn = __phys_to_pfn(TRIZEPS4_CFSR_PHYS),
  371. .length = 0x00001000,
  372. .type = MT_DEVICE
  373. },
  374. { /* ConXS BCR */
  375. .virtual = TRIZEPS4_BOCR_VIRT,
  376. .pfn = __phys_to_pfn(TRIZEPS4_BOCR_PHYS),
  377. .length = 0x00001000,
  378. .type = MT_DEVICE
  379. },
  380. { /* ConXS IRCR */
  381. .virtual = TRIZEPS4_IRCR_VIRT,
  382. .pfn = __phys_to_pfn(TRIZEPS4_IRCR_PHYS),
  383. .length = 0x00001000,
  384. .type = MT_DEVICE
  385. },
  386. { /* ConXS DCR */
  387. .virtual = TRIZEPS4_DICR_VIRT,
  388. .pfn = __phys_to_pfn(TRIZEPS4_DICR_PHYS),
  389. .length = 0x00001000,
  390. .type = MT_DEVICE
  391. },
  392. { /* ConXS UPSR */
  393. .virtual = TRIZEPS4_UPSR_VIRT,
  394. .pfn = __phys_to_pfn(TRIZEPS4_UPSR_PHYS),
  395. .length = 0x00001000,
  396. .type = MT_DEVICE
  397. }
  398. };
  399. static struct pxafb_mode_info sharp_lcd_mode = {
  400. .pixclock = 78000,
  401. .xres = 640,
  402. .yres = 480,
  403. .bpp = 8,
  404. .hsync_len = 4,
  405. .left_margin = 4,
  406. .right_margin = 4,
  407. .vsync_len = 2,
  408. .upper_margin = 0,
  409. .lower_margin = 0,
  410. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  411. .cmap_greyscale = 0,
  412. };
  413. static struct pxafb_mach_info sharp_lcd = {
  414. .modes = &sharp_lcd_mode,
  415. .num_modes = 1,
  416. .lcd_conn = LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL,
  417. .cmap_inverse = 0,
  418. .cmap_static = 0,
  419. .pxafb_backlight_power = board_backlight_power,
  420. };
  421. static struct pxafb_mode_info toshiba_lcd_mode = {
  422. .pixclock = 39720,
  423. .xres = 640,
  424. .yres = 480,
  425. .bpp = 8,
  426. .hsync_len = 63,
  427. .left_margin = 12,
  428. .right_margin = 12,
  429. .vsync_len = 4,
  430. .upper_margin = 32,
  431. .lower_margin = 10,
  432. .sync = 0,
  433. .cmap_greyscale = 0,
  434. };
  435. static struct pxafb_mach_info toshiba_lcd = {
  436. .modes = &toshiba_lcd_mode,
  437. .num_modes = 1,
  438. .lcd_conn = (LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL),
  439. .cmap_inverse = 0,
  440. .cmap_static = 0,
  441. .pxafb_backlight_power = board_backlight_power,
  442. };
  443. static void __init trizeps4_init(void)
  444. {
  445. pxa2xx_mfp_config(ARRAY_AND_SIZE(trizeps4_pin_config));
  446. if (machine_is_trizeps4wl()) {
  447. pxa2xx_mfp_config(ARRAY_AND_SIZE(trizeps4wl_pin_config));
  448. platform_add_devices(trizeps4wl_devices,
  449. ARRAY_SIZE(trizeps4wl_devices));
  450. } else {
  451. platform_add_devices(trizeps4_devices,
  452. ARRAY_SIZE(trizeps4_devices));
  453. }
  454. pxa_set_ffuart_info(NULL);
  455. pxa_set_btuart_info(NULL);
  456. pxa_set_stuart_info(NULL);
  457. if (0) /* dont know how to determine LCD */
  458. set_pxa_fb_info(&sharp_lcd);
  459. else
  460. set_pxa_fb_info(&toshiba_lcd);
  461. pxa_set_mci_info(&trizeps4_mci_platform_data);
  462. #ifndef STATUS_LEDS_ON_STUART_PINS
  463. pxa_set_ficp_info(&trizeps4_ficp_platform_data);
  464. #endif
  465. pxa_set_ohci_info(&trizeps4_ohci_platform_data);
  466. pxa_set_ac97_info(NULL);
  467. pxa_set_i2c_info(NULL);
  468. i2c_register_board_info(0, trizeps4_i2c_devices,
  469. ARRAY_SIZE(trizeps4_i2c_devices));
  470. #ifdef CONFIG_IDE_PXA_CF
  471. /* if boot direct from compact flash dont disable power */
  472. trizeps_conxs_bcr = 0x0009;
  473. #else
  474. /* this is the reset value */
  475. trizeps_conxs_bcr = 0x00A0;
  476. #endif
  477. BCR_writew(trizeps_conxs_bcr);
  478. board_backlight_power(1);
  479. }
  480. static void __init trizeps4_map_io(void)
  481. {
  482. pxa_map_io();
  483. iotable_init(trizeps4_io_desc, ARRAY_SIZE(trizeps4_io_desc));
  484. if ((MSC0 & 0x8) && (BOOT_DEF & 0x1)) {
  485. /* if flash is 16 bit wide its a Trizeps4 WL */
  486. __machine_arch_type = MACH_TYPE_TRIZEPS4WL;
  487. trizeps4_flash_data[0].width = 2;
  488. } else {
  489. /* if flash is 32 bit wide its a Trizeps4 */
  490. __machine_arch_type = MACH_TYPE_TRIZEPS4;
  491. trizeps4_flash_data[0].width = 4;
  492. }
  493. }
  494. MACHINE_START(TRIZEPS4, "Keith und Koep Trizeps IV module")
  495. /* MAINTAINER("Jürgen Schindele") */
  496. .phys_io = 0x40000000,
  497. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  498. .boot_params = TRIZEPS4_SDRAM_BASE + 0x100,
  499. .init_machine = trizeps4_init,
  500. .map_io = trizeps4_map_io,
  501. .init_irq = pxa27x_init_irq,
  502. .timer = &pxa_timer,
  503. MACHINE_END
  504. MACHINE_START(TRIZEPS4WL, "Keith und Koep Trizeps IV-WL module")
  505. /* MAINTAINER("Jürgen Schindele") */
  506. .phys_io = 0x40000000,
  507. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  508. .boot_params = TRIZEPS4_SDRAM_BASE + 0x100,
  509. .init_machine = trizeps4_init,
  510. .map_io = trizeps4_map_io,
  511. .init_irq = pxa27x_init_irq,
  512. .timer = &pxa_timer,
  513. MACHINE_END