trizeps4.c 14 KB

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