trizeps4.c 14 KB

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