trizeps4.c 14 KB

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