ttc_dkb.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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/platform_data/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 "addr-map.h"
  28. #include "mfp-pxa910.h"
  29. #include "pxa910.h"
  30. #include "irqs.h"
  31. #include "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. #if IS_ENABLED(CONFIG_USB_SUPPORT)
  151. #if IS_ENABLED(CONFIG_USB_MV_UDC) || IS_ENABLED(CONFIG_USB_EHCI_MV_U2O)
  152. static struct mv_usb_platform_data ttc_usb_pdata = {
  153. .vbus = NULL,
  154. .mode = MV_USB_MODE_OTG,
  155. .otg_force_a_bus_req = 1,
  156. .phy_init = pxa_usb_phy_init,
  157. .phy_deinit = pxa_usb_phy_deinit,
  158. .set_vbus = NULL,
  159. };
  160. #endif
  161. #endif
  162. #if IS_ENABLED(CONFIG_MTD_NAND_PXA3xx)
  163. static struct pxa3xx_nand_platform_data dkb_nand_info = {
  164. .enable_arbiter = 1,
  165. .num_cs = 1,
  166. };
  167. #endif
  168. #if IS_ENABLED(CONFIG_MMP_DISP)
  169. /* path config */
  170. #define CFG_IOPADMODE(iopad) (iopad) /* 0x0 ~ 0xd */
  171. #define SCLK_SOURCE_SELECT(x) (x << 30) /* 0x0 ~ 0x3 */
  172. /* link config */
  173. #define CFG_DUMBMODE(mode) (mode << 28) /* 0x0 ~ 0x6*/
  174. static struct mmp_mach_path_config dkb_disp_config[] = {
  175. [0] = {
  176. .name = "mmp-parallel",
  177. .overlay_num = 2,
  178. .output_type = PATH_OUT_PARALLEL,
  179. .path_config = CFG_IOPADMODE(0x1)
  180. | SCLK_SOURCE_SELECT(0x1),
  181. .link_config = CFG_DUMBMODE(0x2),
  182. },
  183. };
  184. static struct mmp_mach_plat_info dkb_disp_info = {
  185. .name = "mmp-disp",
  186. .clk_name = "disp0",
  187. .path_num = 1,
  188. .paths = dkb_disp_config,
  189. };
  190. static struct mmp_buffer_driver_mach_info dkb_fb_info = {
  191. .name = "mmp-fb",
  192. .path_name = "mmp-parallel",
  193. .overlay_id = 0,
  194. .dmafetch_id = 1,
  195. .default_pixfmt = PIXFMT_RGB565,
  196. };
  197. static void dkb_tpo_panel_power(int on)
  198. {
  199. int err;
  200. u32 spi_reset = mfp_to_gpio(MFP_PIN_GPIO106);
  201. if (on) {
  202. err = gpio_request(spi_reset, "TPO_LCD_SPI_RESET");
  203. if (err) {
  204. pr_err("failed to request GPIO for TPO LCD RESET\n");
  205. return;
  206. }
  207. gpio_direction_output(spi_reset, 0);
  208. udelay(100);
  209. gpio_set_value(spi_reset, 1);
  210. gpio_free(spi_reset);
  211. } else {
  212. err = gpio_request(spi_reset, "TPO_LCD_SPI_RESET");
  213. if (err) {
  214. pr_err("failed to request LCD RESET gpio\n");
  215. return;
  216. }
  217. gpio_set_value(spi_reset, 0);
  218. gpio_free(spi_reset);
  219. }
  220. }
  221. static struct mmp_mach_panel_info dkb_tpo_panel_info = {
  222. .name = "tpo-hvga",
  223. .plat_path_name = "mmp-parallel",
  224. .plat_set_onoff = dkb_tpo_panel_power,
  225. };
  226. static struct spi_board_info spi_board_info[] __initdata = {
  227. {
  228. .modalias = "tpo-hvga",
  229. .platform_data = &dkb_tpo_panel_info,
  230. .bus_num = 5,
  231. }
  232. };
  233. static void __init add_disp(void)
  234. {
  235. pxa_register_device(&pxa910_device_disp,
  236. &dkb_disp_info, sizeof(dkb_disp_info));
  237. spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
  238. pxa_register_device(&pxa910_device_fb,
  239. &dkb_fb_info, sizeof(dkb_fb_info));
  240. pxa_register_device(&pxa910_device_panel,
  241. &dkb_tpo_panel_info, sizeof(dkb_tpo_panel_info));
  242. }
  243. #endif
  244. static void __init ttc_dkb_init(void)
  245. {
  246. mfp_config(ARRAY_AND_SIZE(ttc_dkb_pin_config));
  247. /* on-chip devices */
  248. pxa910_add_uart(1);
  249. #if IS_ENABLED(CONFIG_MTD_NAND_PXA3xx)
  250. pxa910_add_nand(&dkb_nand_info);
  251. #endif
  252. /* off-chip devices */
  253. pxa910_add_twsi(0, NULL, ARRAY_AND_SIZE(ttc_dkb_i2c_info));
  254. platform_device_add_data(&pxa910_device_gpio, &pxa910_gpio_pdata,
  255. sizeof(struct pxa_gpio_platform_data));
  256. platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices));
  257. #if IS_ENABLED(CONFIG_USB_MV_UDC)
  258. pxa168_device_u2o.dev.platform_data = &ttc_usb_pdata;
  259. platform_device_register(&pxa168_device_u2o);
  260. #endif
  261. #if IS_ENABLED(CONFIG_USB_EHCI_MV_U2O)
  262. pxa168_device_u2oehci.dev.platform_data = &ttc_usb_pdata;
  263. platform_device_register(&pxa168_device_u2oehci);
  264. #endif
  265. #if IS_ENABLED(CONFIG_USB_MV_OTG)
  266. pxa168_device_u2ootg.dev.platform_data = &ttc_usb_pdata;
  267. platform_device_register(&pxa168_device_u2ootg);
  268. #endif
  269. #if IS_ENABLED(CONFIG_MMP_DISP)
  270. add_disp();
  271. #endif
  272. }
  273. MACHINE_START(TTC_DKB, "PXA910-based TTC_DKB Development Platform")
  274. .map_io = mmp_map_io,
  275. .nr_irqs = TTCDKB_NR_IRQS,
  276. .init_irq = pxa910_init_irq,
  277. .init_time = pxa910_timer_init,
  278. .init_machine = ttc_dkb_init,
  279. .restart = mmp_restart,
  280. MACHINE_END