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