ttc_dkb.c 7.2 KB

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