pdata-quirks.c 2.4 KB

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