pdata-quirks.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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/wl12xx.h>
  15. #include "common.h"
  16. #include "common-board-devices.h"
  17. #include "dss-common.h"
  18. #include "control.h"
  19. struct pdata_init {
  20. const char *compatible;
  21. void (*fn)(void);
  22. };
  23. /*
  24. * Create alias for USB host PHY clock.
  25. * Remove this when clock phandle can be provided via DT
  26. */
  27. static void __init __used legacy_init_ehci_clk(char *clkname)
  28. {
  29. int ret;
  30. ret = clk_add_alias("main_clk", NULL, clkname, NULL);
  31. if (ret)
  32. pr_err("%s:Failed to add main_clk alias to %s :%d\n",
  33. __func__, clkname, ret);
  34. }
  35. #if IS_ENABLED(CONFIG_WL12XX)
  36. static struct wl12xx_platform_data wl12xx __initdata;
  37. static void __init __used legacy_init_wl12xx(unsigned ref_clock,
  38. unsigned tcxo_clock,
  39. int gpio)
  40. {
  41. int res;
  42. wl12xx.board_ref_clock = ref_clock;
  43. wl12xx.board_tcxo_clock = tcxo_clock;
  44. wl12xx.irq = gpio_to_irq(gpio);
  45. res = wl12xx_set_platform_data(&wl12xx);
  46. if (res) {
  47. pr_err("error setting wl12xx data: %d\n", res);
  48. return;
  49. }
  50. }
  51. #else
  52. static inline void legacy_init_wl12xx(unsigned ref_clock,
  53. unsigned tcxo_clock,
  54. int gpio)
  55. {
  56. }
  57. #endif
  58. #ifdef CONFIG_ARCH_OMAP3
  59. static void __init hsmmc2_internal_input_clk(void)
  60. {
  61. u32 reg;
  62. reg = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1);
  63. reg |= OMAP2_MMCSDIO2ADPCLKISEL;
  64. omap_ctrl_writel(reg, OMAP343X_CONTROL_DEVCONF1);
  65. }
  66. #endif /* CONFIG_ARCH_OMAP3 */
  67. #ifdef CONFIG_ARCH_OMAP4
  68. static void __init omap4_sdp_legacy_init(void)
  69. {
  70. omap_4430sdp_display_init_of();
  71. legacy_init_wl12xx(WL12XX_REFCLOCK_26,
  72. WL12XX_TCXOCLOCK_26, 53);
  73. }
  74. static void __init omap4_panda_legacy_init(void)
  75. {
  76. omap4_panda_display_init_of();
  77. legacy_init_ehci_clk("auxclk3_ck");
  78. legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 53);
  79. }
  80. #endif
  81. #ifdef CONFIG_SOC_OMAP5
  82. static void __init omap5_uevm_legacy_init(void)
  83. {
  84. legacy_init_ehci_clk("auxclk1_ck");
  85. }
  86. #endif
  87. static struct pdata_init pdata_quirks[] __initdata = {
  88. #ifdef CONFIG_ARCH_OMAP3
  89. { "nokia,omap3-n9", hsmmc2_internal_input_clk, },
  90. { "nokia,omap3-n950", hsmmc2_internal_input_clk, },
  91. #endif
  92. #ifdef CONFIG_ARCH_OMAP4
  93. { "ti,omap4-sdp", omap4_sdp_legacy_init, },
  94. { "ti,omap4-panda", omap4_panda_legacy_init, },
  95. #endif
  96. #ifdef CONFIG_SOC_OMAP5
  97. { "ti,omap5-uevm", omap5_uevm_legacy_init, },
  98. #endif
  99. { /* sentinel */ },
  100. };
  101. void __init pdata_quirks_init(void)
  102. {
  103. struct pdata_init *quirks = pdata_quirks;
  104. while (quirks->compatible) {
  105. if (of_machine_is_compatible(quirks->compatible)) {
  106. if (quirks->fn)
  107. quirks->fn();
  108. break;
  109. }
  110. quirks++;
  111. }
  112. }