trizeps4.c 14 KB

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