pdata-quirks.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. #endif /* CONFIG_ARCH_OMAP3 */
  73. #ifdef CONFIG_ARCH_OMAP4
  74. static void __init omap4_sdp_legacy_init(void)
  75. {
  76. omap_4430sdp_display_init_of();
  77. legacy_init_wl12xx(WL12XX_REFCLOCK_26,
  78. WL12XX_TCXOCLOCK_26, 53);
  79. }
  80. static void __init omap4_panda_legacy_init(void)
  81. {
  82. omap4_panda_display_init_of();
  83. legacy_init_ehci_clk("auxclk3_ck");
  84. legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 53);
  85. }
  86. #endif
  87. #ifdef CONFIG_SOC_OMAP5
  88. static void __init omap5_uevm_legacy_init(void)
  89. {
  90. legacy_init_ehci_clk("auxclk1_ck");
  91. }
  92. #endif
  93. static struct pcs_pdata pcs_pdata;
  94. void omap_pcs_legacy_init(int irq, void (*rearm)(void))
  95. {
  96. pcs_pdata.irq = irq;
  97. pcs_pdata.rearm = rearm;
  98. }
  99. struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
  100. #ifdef CONFIG_ARCH_OMAP3
  101. OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002030, "48002030.pinmux", &pcs_pdata),
  102. OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002a00, "48002a00.pinmux", &pcs_pdata),
  103. #endif
  104. #ifdef CONFIG_ARCH_OMAP4
  105. OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a100040, "4a100040.pinmux", &pcs_pdata),
  106. OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a31e040, "4a31e040.pinmux", &pcs_pdata),
  107. #endif
  108. { /* sentinel */ },
  109. };
  110. static struct pdata_init pdata_quirks[] __initdata = {
  111. #ifdef CONFIG_ARCH_OMAP3
  112. { "nokia,omap3-n9", hsmmc2_internal_input_clk, },
  113. { "nokia,omap3-n950", hsmmc2_internal_input_clk, },
  114. { "isee,omap3-igep0020", omap3_igep0020_legacy_init, },
  115. #endif
  116. #ifdef CONFIG_ARCH_OMAP4
  117. { "ti,omap4-sdp", omap4_sdp_legacy_init, },
  118. { "ti,omap4-panda", omap4_panda_legacy_init, },
  119. #endif
  120. #ifdef CONFIG_SOC_OMAP5
  121. { "ti,omap5-uevm", omap5_uevm_legacy_init, },
  122. #endif
  123. { /* sentinel */ },
  124. };
  125. void __init pdata_quirks_init(struct of_device_id *omap_dt_match_table)
  126. {
  127. struct pdata_init *quirks = pdata_quirks;
  128. omap_sdrc_init(NULL, NULL);
  129. of_platform_populate(NULL, omap_dt_match_table,
  130. omap_auxdata_lookup, NULL);
  131. while (quirks->compatible) {
  132. if (of_machine_is_compatible(quirks->compatible)) {
  133. if (quirks->fn)
  134. quirks->fn();
  135. break;
  136. }
  137. quirks++;
  138. }
  139. }