pdata-quirks.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. /*
  2. * Legacy platform_data quirks
  3. *
  4. * Copyright (C) 2013 Texas Instruments
  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. * published by the Free Software Foundation.
  9. */
  10. #include <linux/clk.h>
  11. #include <linux/davinci_emac.h>
  12. #include <linux/gpio.h>
  13. #include <linux/init.h>
  14. #include <linux/kernel.h>
  15. #include <linux/of_platform.h>
  16. #include <linux/ti_wilink_st.h>
  17. #include <linux/platform_data/pinctrl-single.h>
  18. #include <linux/platform_data/iommu-omap.h>
  19. #include "common.h"
  20. #include "common-board-devices.h"
  21. #include "dss-common.h"
  22. #include "control.h"
  23. #include "omap_device.h"
  24. #include "omap-secure.h"
  25. #include "soc.h"
  26. struct pdata_init {
  27. const char *compatible;
  28. void (*fn)(void);
  29. };
  30. struct of_dev_auxdata omap_auxdata_lookup[];
  31. static struct twl4030_gpio_platform_data twl_gpio_auxdata;
  32. #ifdef CONFIG_MACH_NOKIA_N8X0
  33. static void __init omap2420_n8x0_legacy_init(void)
  34. {
  35. omap_auxdata_lookup[0].platform_data = n8x0_legacy_init();
  36. }
  37. #else
  38. #define omap2420_n8x0_legacy_init NULL
  39. #endif
  40. #ifdef CONFIG_ARCH_OMAP3
  41. static void __init hsmmc2_internal_input_clk(void)
  42. {
  43. u32 reg;
  44. reg = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1);
  45. reg |= OMAP2_MMCSDIO2ADPCLKISEL;
  46. omap_ctrl_writel(reg, OMAP343X_CONTROL_DEVCONF1);
  47. }
  48. static struct iommu_platform_data omap3_iommu_pdata = {
  49. .reset_name = "mmu",
  50. .assert_reset = omap_device_assert_hardreset,
  51. .deassert_reset = omap_device_deassert_hardreset,
  52. };
  53. static int omap3_sbc_t3730_twl_callback(struct device *dev,
  54. unsigned gpio,
  55. unsigned ngpio)
  56. {
  57. int res;
  58. res = gpio_request_one(gpio + 2, GPIOF_OUT_INIT_HIGH,
  59. "wlan pwr");
  60. if (res)
  61. return res;
  62. gpio_export(gpio, 0);
  63. return 0;
  64. }
  65. static void __init omap3_sbc_t3x_usb_hub_init(int gpio, char *hub_name)
  66. {
  67. int err = gpio_request_one(gpio, GPIOF_OUT_INIT_LOW, hub_name);
  68. if (err) {
  69. pr_err("SBC-T3x: %s reset gpio request failed: %d\n",
  70. hub_name, err);
  71. return;
  72. }
  73. gpio_export(gpio, 0);
  74. udelay(10);
  75. gpio_set_value(gpio, 1);
  76. msleep(1);
  77. }
  78. static void __init omap3_sbc_t3730_twl_init(void)
  79. {
  80. twl_gpio_auxdata.setup = omap3_sbc_t3730_twl_callback;
  81. }
  82. static void __init omap3_sbc_t3730_legacy_init(void)
  83. {
  84. omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub");
  85. }
  86. static void __init omap3_sbc_t3530_legacy_init(void)
  87. {
  88. omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub");
  89. }
  90. struct ti_st_plat_data wilink_pdata = {
  91. .nshutdown_gpio = 137,
  92. .dev_name = "/dev/ttyO1",
  93. .flow_cntrl = 1,
  94. .baud_rate = 300000,
  95. };
  96. static struct platform_device wl18xx_device = {
  97. .name = "kim",
  98. .id = -1,
  99. .dev = {
  100. .platform_data = &wilink_pdata,
  101. }
  102. };
  103. static struct platform_device btwilink_device = {
  104. .name = "btwilink",
  105. .id = -1,
  106. };
  107. static void __init omap3_igep0020_rev_f_legacy_init(void)
  108. {
  109. platform_device_register(&wl18xx_device);
  110. platform_device_register(&btwilink_device);
  111. }
  112. static void __init omap3_igep0030_rev_g_legacy_init(void)
  113. {
  114. platform_device_register(&wl18xx_device);
  115. platform_device_register(&btwilink_device);
  116. }
  117. static void __init omap3_evm_legacy_init(void)
  118. {
  119. hsmmc2_internal_input_clk();
  120. }
  121. static void am35xx_enable_emac_int(void)
  122. {
  123. u32 v;
  124. v = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
  125. v |= (AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR |
  126. AM35XX_CPGMAC_C0_MISC_PULSE_CLR | AM35XX_CPGMAC_C0_RX_THRESH_CLR);
  127. omap_ctrl_writel(v, AM35XX_CONTROL_LVL_INTR_CLEAR);
  128. omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); /* OCP barrier */
  129. }
  130. static void am35xx_disable_emac_int(void)
  131. {
  132. u32 v;
  133. v = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
  134. v |= (AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR);
  135. omap_ctrl_writel(v, AM35XX_CONTROL_LVL_INTR_CLEAR);
  136. omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); /* OCP barrier */
  137. }
  138. static struct emac_platform_data am35xx_emac_pdata = {
  139. .interrupt_enable = am35xx_enable_emac_int,
  140. .interrupt_disable = am35xx_disable_emac_int,
  141. };
  142. static void __init am35xx_emac_reset(void)
  143. {
  144. u32 v;
  145. v = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
  146. v &= ~AM35XX_CPGMACSS_SW_RST;
  147. omap_ctrl_writel(v, AM35XX_CONTROL_IP_SW_RESET);
  148. omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); /* OCP barrier */
  149. }
  150. static struct gpio cm_t3517_wlan_gpios[] __initdata = {
  151. { 56, GPIOF_OUT_INIT_HIGH, "wlan pwr" },
  152. { 4, GPIOF_OUT_INIT_HIGH, "xcvr noe" },
  153. };
  154. static void __init omap3_sbc_t3517_wifi_init(void)
  155. {
  156. int err = gpio_request_array(cm_t3517_wlan_gpios,
  157. ARRAY_SIZE(cm_t3517_wlan_gpios));
  158. if (err) {
  159. pr_err("SBC-T3517: wl12xx gpios request failed: %d\n", err);
  160. return;
  161. }
  162. gpio_export(cm_t3517_wlan_gpios[0].gpio, 0);
  163. gpio_export(cm_t3517_wlan_gpios[1].gpio, 0);
  164. msleep(100);
  165. gpio_set_value(cm_t3517_wlan_gpios[1].gpio, 0);
  166. }
  167. static void __init omap3_sbc_t3517_legacy_init(void)
  168. {
  169. omap3_sbc_t3x_usb_hub_init(152, "cm-t3517 usb hub");
  170. omap3_sbc_t3x_usb_hub_init(98, "sb-t35 usb hub");
  171. am35xx_emac_reset();
  172. hsmmc2_internal_input_clk();
  173. omap3_sbc_t3517_wifi_init();
  174. }
  175. static void __init am3517_evm_legacy_init(void)
  176. {
  177. am35xx_emac_reset();
  178. }
  179. static struct platform_device omap3_rom_rng_device = {
  180. .name = "omap3-rom-rng",
  181. .id = -1,
  182. .dev = {
  183. .platform_data = rx51_secure_rng_call,
  184. },
  185. };
  186. static void __init nokia_n900_legacy_init(void)
  187. {
  188. hsmmc2_internal_input_clk();
  189. if (omap_type() == OMAP2_DEVICE_TYPE_SEC) {
  190. if (IS_ENABLED(CONFIG_ARM_ERRATA_430973)) {
  191. pr_info("RX-51: Enabling ARM errata 430973 workaround\n");
  192. /* set IBE to 1 */
  193. rx51_secure_update_aux_cr(BIT(6), 0);
  194. } else {
  195. pr_warn("RX-51: Not enabling ARM errata 430973 workaround\n");
  196. pr_warn("Thumb binaries may crash randomly without this workaround\n");
  197. }
  198. pr_info("RX-51: Registring OMAP3 HWRNG device\n");
  199. platform_device_register(&omap3_rom_rng_device);
  200. }
  201. }
  202. static void __init omap3_tao3530_legacy_init(void)
  203. {
  204. hsmmc2_internal_input_clk();
  205. }
  206. #endif /* CONFIG_ARCH_OMAP3 */
  207. #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
  208. static struct iommu_platform_data omap4_iommu_pdata = {
  209. .reset_name = "mmu_cache",
  210. .assert_reset = omap_device_assert_hardreset,
  211. .deassert_reset = omap_device_deassert_hardreset,
  212. };
  213. #endif
  214. #ifdef CONFIG_SOC_OMAP5
  215. static void __init omap5_uevm_legacy_init(void)
  216. {
  217. }
  218. #endif
  219. static struct pcs_pdata pcs_pdata;
  220. void omap_pcs_legacy_init(int irq, void (*rearm)(void))
  221. {
  222. pcs_pdata.irq = irq;
  223. pcs_pdata.rearm = rearm;
  224. }
  225. /*
  226. * GPIOs for TWL are initialized by the I2C bus and need custom
  227. * handing until DSS has device tree bindings.
  228. */
  229. void omap_auxdata_legacy_init(struct device *dev)
  230. {
  231. if (dev->platform_data)
  232. return;
  233. if (strcmp("twl4030-gpio", dev_name(dev)))
  234. return;
  235. dev->platform_data = &twl_gpio_auxdata;
  236. }
  237. /*
  238. * Few boards still need auxdata populated before we populate
  239. * the dev entries in of_platform_populate().
  240. */
  241. static struct pdata_init auxdata_quirks[] __initdata = {
  242. #ifdef CONFIG_SOC_OMAP2420
  243. { "nokia,n800", omap2420_n8x0_legacy_init, },
  244. { "nokia,n810", omap2420_n8x0_legacy_init, },
  245. { "nokia,n810-wimax", omap2420_n8x0_legacy_init, },
  246. #endif
  247. #ifdef CONFIG_ARCH_OMAP3
  248. { "compulab,omap3-sbc-t3730", omap3_sbc_t3730_twl_init, },
  249. #endif
  250. { /* sentinel */ },
  251. };
  252. struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
  253. #ifdef CONFIG_MACH_NOKIA_N8X0
  254. OF_DEV_AUXDATA("ti,omap2420-mmc", 0x4809c000, "mmci-omap.0", NULL),
  255. OF_DEV_AUXDATA("menelaus", 0x72, "1-0072", &n8x0_menelaus_platform_data),
  256. OF_DEV_AUXDATA("tlv320aic3x", 0x18, "2-0018", &n810_aic33_data),
  257. #endif
  258. #ifdef CONFIG_ARCH_OMAP3
  259. OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002030, "48002030.pinmux", &pcs_pdata),
  260. OF_DEV_AUXDATA("ti,omap3-padconf", 0x480025a0, "480025a0.pinmux", &pcs_pdata),
  261. OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002a00, "48002a00.pinmux", &pcs_pdata),
  262. OF_DEV_AUXDATA("ti,omap2-iommu", 0x5d000000, "5d000000.mmu",
  263. &omap3_iommu_pdata),
  264. /* Only on am3517 */
  265. OF_DEV_AUXDATA("ti,davinci_mdio", 0x5c030000, "davinci_mdio.0", NULL),
  266. OF_DEV_AUXDATA("ti,am3517-emac", 0x5c000000, "davinci_emac.0",
  267. &am35xx_emac_pdata),
  268. #endif
  269. #ifdef CONFIG_ARCH_OMAP4
  270. OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a100040, "4a100040.pinmux", &pcs_pdata),
  271. OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a31e040, "4a31e040.pinmux", &pcs_pdata),
  272. #endif
  273. #ifdef CONFIG_SOC_OMAP5
  274. OF_DEV_AUXDATA("ti,omap5-padconf", 0x4a002840, "4a002840.pinmux", &pcs_pdata),
  275. OF_DEV_AUXDATA("ti,omap5-padconf", 0x4ae0c840, "4ae0c840.pinmux", &pcs_pdata),
  276. #endif
  277. #ifdef CONFIG_SOC_DRA7XX
  278. OF_DEV_AUXDATA("ti,dra7-padconf", 0x4a003400, "4a003400.pinmux", &pcs_pdata),
  279. #endif
  280. #ifdef CONFIG_SOC_AM43XX
  281. OF_DEV_AUXDATA("ti,am437-padconf", 0x44e10800, "44e10800.pinmux", &pcs_pdata),
  282. #endif
  283. #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
  284. OF_DEV_AUXDATA("ti,omap4-iommu", 0x4a066000, "4a066000.mmu",
  285. &omap4_iommu_pdata),
  286. OF_DEV_AUXDATA("ti,omap4-iommu", 0x55082000, "55082000.mmu",
  287. &omap4_iommu_pdata),
  288. #endif
  289. { /* sentinel */ },
  290. };
  291. /*
  292. * Few boards still need to initialize some legacy devices with
  293. * platform data until the drivers support device tree.
  294. */
  295. static struct pdata_init pdata_quirks[] __initdata = {
  296. #ifdef CONFIG_ARCH_OMAP3
  297. { "compulab,omap3-sbc-t3517", omap3_sbc_t3517_legacy_init, },
  298. { "compulab,omap3-sbc-t3530", omap3_sbc_t3530_legacy_init, },
  299. { "compulab,omap3-sbc-t3730", omap3_sbc_t3730_legacy_init, },
  300. { "nokia,omap3-n900", nokia_n900_legacy_init, },
  301. { "nokia,omap3-n9", hsmmc2_internal_input_clk, },
  302. { "nokia,omap3-n950", hsmmc2_internal_input_clk, },
  303. { "isee,omap3-igep0020-rev-f", omap3_igep0020_rev_f_legacy_init, },
  304. { "isee,omap3-igep0030-rev-g", omap3_igep0030_rev_g_legacy_init, },
  305. { "ti,omap3-evm-37xx", omap3_evm_legacy_init, },
  306. { "ti,am3517-evm", am3517_evm_legacy_init, },
  307. { "technexion,omap3-tao3530", omap3_tao3530_legacy_init, },
  308. #endif
  309. #ifdef CONFIG_SOC_OMAP5
  310. { "ti,omap5-uevm", omap5_uevm_legacy_init, },
  311. #endif
  312. { /* sentinel */ },
  313. };
  314. static void pdata_quirks_check(struct pdata_init *quirks)
  315. {
  316. while (quirks->compatible) {
  317. if (of_machine_is_compatible(quirks->compatible)) {
  318. if (quirks->fn)
  319. quirks->fn();
  320. break;
  321. }
  322. quirks++;
  323. }
  324. }
  325. void __init pdata_quirks_init(const struct of_device_id *omap_dt_match_table)
  326. {
  327. omap_sdrc_init(NULL, NULL);
  328. pdata_quirks_check(auxdata_quirks);
  329. of_platform_populate(NULL, omap_dt_match_table,
  330. omap_auxdata_lookup, NULL);
  331. pdata_quirks_check(pdata_quirks);
  332. }