ttc_dkb.c 7.4 KB

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