pdata-quirks.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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/gpio.h>
  12. #include <linux/init.h>
  13. #include <linux/kernel.h>
  14. #include <linux/of_platform.h>
  15. #include <linux/wl12xx.h>
  16. #include <linux/platform_data/pinctrl-single.h>
  17. #include "common.h"
  18. #include "common-board-devices.h"
  19. #include "dss-common.h"
  20. #include "control.h"
  21. struct pdata_init {
  22. const char *compatible;
  23. void (*fn)(void);
  24. };
  25. /*
  26. * Create alias for USB host PHY clock.
  27. * Remove this when clock phandle can be provided via DT
  28. */
  29. static void __init __used legacy_init_ehci_clk(char *clkname)
  30. {
  31. int ret;
  32. ret = clk_add_alias("main_clk", NULL, clkname, NULL);
  33. if (ret)
  34. pr_err("%s:Failed to add main_clk alias to %s :%d\n",
  35. __func__, clkname, ret);
  36. }
  37. #if IS_ENABLED(CONFIG_WL12XX)
  38. static struct wl12xx_platform_data wl12xx __initdata;
  39. static void __init __used legacy_init_wl12xx(unsigned ref_clock,
  40. unsigned tcxo_clock,
  41. int gpio)
  42. {
  43. int res;
  44. wl12xx.board_ref_clock = ref_clock;
  45. wl12xx.board_tcxo_clock = tcxo_clock;
  46. wl12xx.irq = gpio_to_irq(gpio);
  47. res = wl12xx_set_platform_data(&wl12xx);
  48. if (res) {
  49. pr_err("error setting wl12xx data: %d\n", res);
  50. return;
  51. }
  52. }
  53. #else
  54. static inline void legacy_init_wl12xx(unsigned ref_clock,
  55. unsigned tcxo_clock,
  56. int gpio)
  57. {
  58. }
  59. #endif
  60. #ifdef CONFIG_ARCH_OMAP3
  61. static void __init hsmmc2_internal_input_clk(void)
  62. {
  63. u32 reg;
  64. reg = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1);
  65. reg |= OMAP2_MMCSDIO2ADPCLKISEL;
  66. omap_ctrl_writel(reg, OMAP343X_CONTROL_DEVCONF1);
  67. }
  68. static void __init omap3_igep0020_legacy_init(void)
  69. {
  70. omap3_igep2_display_init_of();
  71. }
  72. static void __init omap3_evm_legacy_init(void)
  73. {
  74. legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 149);
  75. }
  76. static void __init omap3_zoom_legacy_init(void)
  77. {
  78. legacy_init_wl12xx(WL12XX_REFCLOCK_26, 0, 162);
  79. }
  80. #endif /* CONFIG_ARCH_OMAP3 */
  81. #ifdef CONFIG_ARCH_OMAP4
  82. static void __init omap4_sdp_legacy_init(void)
  83. {
  84. omap_4430sdp_display_init_of();
  85. legacy_init_wl12xx(WL12XX_REFCLOCK_26,
  86. WL12XX_TCXOCLOCK_26, 53);
  87. }
  88. static void __init omap4_panda_legacy_init(void)
  89. {
  90. omap4_panda_display_init_of();
  91. legacy_init_ehci_clk("auxclk3_ck");
  92. legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 53);
  93. }
  94. #endif
  95. #ifdef CONFIG_SOC_OMAP5
  96. static void __init omap5_uevm_legacy_init(void)
  97. {
  98. legacy_init_ehci_clk("auxclk1_ck");
  99. }
  100. #endif
  101. static struct pcs_pdata pcs_pdata;
  102. void omap_pcs_legacy_init(int irq, void (*rearm)(void))
  103. {
  104. pcs_pdata.irq = irq;
  105. pcs_pdata.rearm = rearm;
  106. }
  107. struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
  108. #ifdef CONFIG_ARCH_OMAP3
  109. OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002030, "48002030.pinmux", &pcs_pdata),
  110. OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002a00, "48002a00.pinmux", &pcs_pdata),
  111. #endif
  112. #ifdef CONFIG_ARCH_OMAP4
  113. OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a100040, "4a100040.pinmux", &pcs_pdata),
  114. OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a31e040, "4a31e040.pinmux", &pcs_pdata),
  115. #endif
  116. { /* sentinel */ },
  117. };
  118. static struct pdata_init pdata_quirks[] __initdata = {
  119. #ifdef CONFIG_ARCH_OMAP3
  120. { "nokia,omap3-n9", hsmmc2_internal_input_clk, },
  121. { "nokia,omap3-n950", hsmmc2_internal_input_clk, },
  122. { "isee,omap3-igep0020", omap3_igep0020_legacy_init, },
  123. { "ti,omap3-evm-37xx", omap3_evm_legacy_init, },
  124. { "ti,omap3-zoom3", omap3_zoom_legacy_init, },
  125. #endif
  126. #ifdef CONFIG_ARCH_OMAP4
  127. { "ti,omap4-sdp", omap4_sdp_legacy_init, },
  128. { "ti,omap4-panda", omap4_panda_legacy_init, },
  129. #endif
  130. #ifdef CONFIG_SOC_OMAP5
  131. { "ti,omap5-uevm", omap5_uevm_legacy_init, },
  132. #endif
  133. { /* sentinel */ },
  134. };
  135. void __init pdata_quirks_init(struct of_device_id *omap_dt_match_table)
  136. {
  137. struct pdata_init *quirks = pdata_quirks;
  138. omap_sdrc_init(NULL, NULL);
  139. of_platform_populate(NULL, omap_dt_match_table,
  140. omap_auxdata_lookup, NULL);
  141. while (quirks->compatible) {
  142. if (of_machine_is_compatible(quirks->compatible)) {
  143. if (quirks->fn)
  144. quirks->fn();
  145. break;
  146. }
  147. quirks++;
  148. }
  149. }