ttc_dkb.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. /*
  2. * linux/arch/arm/mach-mmp/ttc_dkb.c
  3. *
  4. * Support for the Marvell PXA910-based TTC_DKB Development Platform.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * publishhed by the Free Software Foundation.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/kernel.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/mtd/mtd.h>
  14. #include <linux/mtd/partitions.h>
  15. #include <linux/mtd/onenand.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/i2c/pca953x.h>
  18. #include <linux/gpio.h>
  19. #include <linux/gpio-pxa.h>
  20. #include <linux/mfd/88pm860x.h>
  21. #include <linux/platform_data/mv_usb.h>
  22. #include <linux/spi/spi.h>
  23. #include <linux/delay.h>
  24. #include <asm/mach-types.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach/flash.h>
  27. #include <mach/addr-map.h>
  28. #include <mach/mfp-pxa910.h>
  29. #include <mach/pxa910.h>
  30. #include <mach/irqs.h>
  31. #include <mach/regs-usb.h>
  32. #include "common.h"
  33. #define TTCDKB_GPIO_EXT0(x) (MMP_NR_BUILTIN_GPIO + ((x < 0) ? 0 : \
  34. ((x < 16) ? x : 15)))
  35. #define TTCDKB_GPIO_EXT1(x) (MMP_NR_BUILTIN_GPIO + 16 + ((x < 0) ? 0 : \
  36. ((x < 16) ? x : 15)))
  37. /*
  38. * 16 board interrupts -- MAX7312 GPIO expander
  39. * 16 board interrupts -- PCA9575 GPIO expander
  40. * 24 board interrupts -- 88PM860x PMIC
  41. */
  42. #define TTCDKB_NR_IRQS (MMP_NR_IRQS + 16 + 16 + 24)
  43. static unsigned long ttc_dkb_pin_config[] __initdata = {
  44. /* UART2 */
  45. GPIO47_UART2_RXD,
  46. GPIO48_UART2_TXD,
  47. /* DFI */
  48. DF_IO0_ND_IO0,
  49. DF_IO1_ND_IO1,
  50. DF_IO2_ND_IO2,
  51. DF_IO3_ND_IO3,
  52. DF_IO4_ND_IO4,
  53. DF_IO5_ND_IO5,
  54. DF_IO6_ND_IO6,
  55. DF_IO7_ND_IO7,
  56. DF_IO8_ND_IO8,
  57. DF_IO9_ND_IO9,
  58. DF_IO10_ND_IO10,
  59. DF_IO11_ND_IO11,
  60. DF_IO12_ND_IO12,
  61. DF_IO13_ND_IO13,
  62. DF_IO14_ND_IO14,
  63. DF_IO15_ND_IO15,
  64. DF_nCS0_SM_nCS2_nCS0,
  65. DF_ALE_SM_WEn_ND_ALE,
  66. DF_CLE_SM_OEn_ND_CLE,
  67. DF_WEn_DF_WEn,
  68. DF_REn_DF_REn,
  69. DF_RDY0_DF_RDY0,
  70. };
  71. static struct pxa_gpio_platform_data pxa910_gpio_pdata = {
  72. .irq_base = MMP_GPIO_TO_IRQ(0),
  73. };
  74. static struct mtd_partition ttc_dkb_onenand_partitions[] = {
  75. {
  76. .name = "bootloader",
  77. .offset = 0,
  78. .size = SZ_1M,
  79. .mask_flags = MTD_WRITEABLE,
  80. }, {
  81. .name = "reserved",
  82. .offset = MTDPART_OFS_APPEND,
  83. .size = SZ_128K,
  84. .mask_flags = MTD_WRITEABLE,
  85. }, {
  86. .name = "reserved",
  87. .offset = MTDPART_OFS_APPEND,
  88. .size = SZ_8M,
  89. .mask_flags = MTD_WRITEABLE,
  90. }, {
  91. .name = "kernel",
  92. .offset = MTDPART_OFS_APPEND,
  93. .size = (SZ_2M + SZ_1M),
  94. .mask_flags = 0,
  95. }, {
  96. .name = "filesystem",
  97. .offset = MTDPART_OFS_APPEND,
  98. .size = SZ_32M + SZ_16M,
  99. .mask_flags = 0,
  100. }
  101. };
  102. static struct onenand_platform_data ttc_dkb_onenand_info = {
  103. .parts = ttc_dkb_onenand_partitions,
  104. .nr_parts = ARRAY_SIZE(ttc_dkb_onenand_partitions),
  105. };
  106. static struct resource ttc_dkb_resource_onenand[] = {
  107. [0] = {
  108. .start = SMC_CS0_PHYS_BASE,
  109. .end = SMC_CS0_PHYS_BASE + SZ_1M,
  110. .flags = IORESOURCE_MEM,
  111. },
  112. };
  113. static struct platform_device ttc_dkb_device_onenand = {
  114. .name = "onenand-flash",
  115. .id = -1,
  116. .resource = ttc_dkb_resource_onenand,
  117. .num_resources = ARRAY_SIZE(ttc_dkb_resource_onenand),
  118. .dev = {
  119. .platform_data = &ttc_dkb_onenand_info,
  120. },
  121. };
  122. static struct platform_device *ttc_dkb_devices[] = {
  123. &pxa910_device_gpio,
  124. &pxa910_device_rtc,
  125. &ttc_dkb_device_onenand,
  126. };
  127. static struct pca953x_platform_data max7312_data[] = {
  128. {
  129. .gpio_base = TTCDKB_GPIO_EXT0(0),
  130. .irq_base = MMP_NR_IRQS,
  131. },
  132. };
  133. static struct pm860x_platform_data ttc_dkb_pm8607_info = {
  134. .irq_base = IRQ_BOARD_START,
  135. };
  136. static struct i2c_board_info ttc_dkb_i2c_info[] = {
  137. {
  138. .type = "88PM860x",
  139. .addr = 0x34,
  140. .platform_data = &ttc_dkb_pm8607_info,
  141. .irq = IRQ_PXA910_PMIC_INT,
  142. },
  143. {
  144. .type = "max7312",
  145. .addr = 0x23,
  146. .irq = MMP_GPIO_TO_IRQ(80),
  147. .platform_data = &max7312_data,
  148. },
  149. };
  150. #ifdef CONFIG_USB_SUPPORT
  151. #if defined(CONFIG_USB_MV_UDC) || defined(CONFIG_USB_EHCI_MV_U2O)
  152. static char *pxa910_usb_clock_name[] = {
  153. [0] = "U2OCLK",
  154. };
  155. static struct mv_usb_platform_data ttc_usb_pdata = {
  156. .clknum = 1,
  157. .clkname = pxa910_usb_clock_name,
  158. .vbus = NULL,
  159. .mode = MV_USB_MODE_OTG,
  160. .otg_force_a_bus_req = 1,
  161. .phy_init = pxa_usb_phy_init,
  162. .phy_deinit = pxa_usb_phy_deinit,
  163. .set_vbus = NULL,
  164. };
  165. #endif
  166. #endif
  167. #ifdef CONFIG_MTD_NAND_PXA3xx
  168. static struct pxa3xx_nand_platform_data dkb_nand_info = {
  169. .enable_arbiter = 1,
  170. .num_cs = 1,
  171. };
  172. #endif
  173. #ifdef CONFIG_MMP_DISP
  174. /* path config */
  175. #define CFG_IOPADMODE(iopad) (iopad) /* 0x0 ~ 0xd */
  176. #define SCLK_SOURCE_SELECT(x) (x << 30) /* 0x0 ~ 0x3 */
  177. /* link config */
  178. #define CFG_DUMBMODE(mode) (mode << 28) /* 0x0 ~ 0x6*/
  179. #define CFG_GRA_SWAPRB(x) (x << 0) /* 1: rbswap enabled */
  180. static struct mmp_mach_path_config dkb_disp_config[] = {
  181. [0] = {
  182. .name = "mmp-parallel",
  183. .overlay_num = 2,
  184. .output_type = PATH_OUT_PARALLEL,
  185. .path_config = CFG_IOPADMODE(0x1)
  186. | SCLK_SOURCE_SELECT(0x1),
  187. .link_config = CFG_DUMBMODE(0x2)
  188. | CFG_GRA_SWAPRB(0x1),
  189. },
  190. };
  191. static struct mmp_mach_plat_info dkb_disp_info = {
  192. .name = "mmp-disp",
  193. .clk_name = "disp0",
  194. .path_num = 1,
  195. .paths = dkb_disp_config,
  196. };
  197. static struct mmp_buffer_driver_mach_info dkb_fb_info = {
  198. .name = "mmp-fb",
  199. .path_name = "mmp-parallel",
  200. .overlay_id = 0,
  201. .dmafetch_id = 1,
  202. .default_pixfmt = PIXFMT_RGB565,
  203. };
  204. static void dkb_tpo_panel_power(int on)
  205. {
  206. int err;
  207. u32 spi_reset = mfp_to_gpio(MFP_PIN_GPIO106);
  208. if (on) {
  209. err = gpio_request(spi_reset, "TPO_LCD_SPI_RESET");
  210. if (err) {
  211. pr_err("failed to request GPIO for TPO LCD RESET\n");
  212. return;
  213. }
  214. gpio_direction_output(spi_reset, 0);
  215. udelay(100);
  216. gpio_set_value(spi_reset, 1);
  217. gpio_free(spi_reset);
  218. } else {
  219. err = gpio_request(spi_reset, "TPO_LCD_SPI_RESET");
  220. if (err) {
  221. pr_err("failed to request LCD RESET gpio\n");
  222. return;
  223. }
  224. gpio_set_value(spi_reset, 0);
  225. gpio_free(spi_reset);
  226. }
  227. }
  228. static struct mmp_mach_panel_info dkb_tpo_panel_info = {
  229. .name = "tpo-hvga",
  230. .plat_path_name = "mmp-parallel",
  231. .plat_set_onoff = dkb_tpo_panel_power,
  232. };
  233. static struct spi_board_info spi_board_info[] __initdata = {
  234. {
  235. .modalias = "tpo-hvga",
  236. .platform_data = &dkb_tpo_panel_info,
  237. .bus_num = 5,
  238. }
  239. };
  240. static void __init add_disp(void)
  241. {
  242. pxa_register_device(&pxa910_device_disp,
  243. &dkb_disp_info, sizeof(dkb_disp_info));
  244. spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
  245. pxa_register_device(&pxa910_device_fb,
  246. &dkb_fb_info, sizeof(dkb_fb_info));
  247. pxa_register_device(&pxa910_device_panel,
  248. &dkb_tpo_panel_info, sizeof(dkb_tpo_panel_info));
  249. }
  250. #endif
  251. static void __init ttc_dkb_init(void)
  252. {
  253. mfp_config(ARRAY_AND_SIZE(ttc_dkb_pin_config));
  254. /* on-chip devices */
  255. pxa910_add_uart(1);
  256. #ifdef CONFIG_MTD_NAND_PXA3xx
  257. pxa910_add_nand(&dkb_nand_info);
  258. #endif
  259. /* off-chip devices */
  260. pxa910_add_twsi(0, NULL, ARRAY_AND_SIZE(ttc_dkb_i2c_info));
  261. platform_device_add_data(&pxa910_device_gpio, &pxa910_gpio_pdata,
  262. sizeof(struct pxa_gpio_platform_data));
  263. platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices));
  264. #ifdef CONFIG_USB_MV_UDC
  265. pxa168_device_u2o.dev.platform_data = &ttc_usb_pdata;
  266. platform_device_register(&pxa168_device_u2o);
  267. #endif
  268. #ifdef CONFIG_USB_EHCI_MV_U2O
  269. pxa168_device_u2oehci.dev.platform_data = &ttc_usb_pdata;
  270. platform_device_register(&pxa168_device_u2oehci);
  271. #endif
  272. #ifdef CONFIG_USB_MV_OTG
  273. pxa168_device_u2ootg.dev.platform_data = &ttc_usb_pdata;
  274. platform_device_register(&pxa168_device_u2ootg);
  275. #endif
  276. #ifdef CONFIG_MMP_DISP
  277. add_disp();
  278. #endif
  279. }
  280. MACHINE_START(TTC_DKB, "PXA910-based TTC_DKB Development Platform")
  281. .map_io = mmp_map_io,
  282. .nr_irqs = TTCDKB_NR_IRQS,
  283. .init_irq = pxa910_init_irq,
  284. .init_time = pxa910_timer_init,
  285. .init_machine = ttc_dkb_init,
  286. .restart = mmp_restart,
  287. MACHINE_END