Merge tag 'gpio-v3.13-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw...
[linux-2.6.git] / arch / arm / mach-omap2 / pdata-quirks.c
blob39f020c982e8b3a41d547d9d45b60c46cb08877b
1 /*
2 * Legacy platform_data quirks
4 * Copyright (C) 2013 Texas Instruments
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>
17 #include <linux/platform_data/pinctrl-single.h>
19 #include "common.h"
20 #include "common-board-devices.h"
21 #include "dss-common.h"
22 #include "control.h"
24 struct pdata_init {
25 const char *compatible;
26 void (*fn)(void);
30 * Create alias for USB host PHY clock.
31 * Remove this when clock phandle can be provided via DT
33 static void __init __used legacy_init_ehci_clk(char *clkname)
35 int ret;
37 ret = clk_add_alias("main_clk", NULL, clkname, NULL);
38 if (ret)
39 pr_err("%s:Failed to add main_clk alias to %s :%d\n",
40 __func__, clkname, ret);
43 #if IS_ENABLED(CONFIG_WL12XX)
45 static struct wl12xx_platform_data wl12xx __initdata;
47 static void __init __used legacy_init_wl12xx(unsigned ref_clock,
48 unsigned tcxo_clock,
49 int gpio)
51 int res;
53 wl12xx.board_ref_clock = ref_clock;
54 wl12xx.board_tcxo_clock = tcxo_clock;
55 wl12xx.irq = gpio_to_irq(gpio);
57 res = wl12xx_set_platform_data(&wl12xx);
58 if (res) {
59 pr_err("error setting wl12xx data: %d\n", res);
60 return;
63 #else
64 static inline void legacy_init_wl12xx(unsigned ref_clock,
65 unsigned tcxo_clock,
66 int gpio)
69 #endif
71 #ifdef CONFIG_ARCH_OMAP3
72 static void __init hsmmc2_internal_input_clk(void)
74 u32 reg;
76 reg = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1);
77 reg |= OMAP2_MMCSDIO2ADPCLKISEL;
78 omap_ctrl_writel(reg, OMAP343X_CONTROL_DEVCONF1);
81 static void __init omap3_igep0020_legacy_init(void)
83 omap3_igep2_display_init_of();
86 static void __init omap3_evm_legacy_init(void)
88 legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 149);
91 static void __init omap3_zoom_legacy_init(void)
93 legacy_init_wl12xx(WL12XX_REFCLOCK_26, 0, 162);
95 #endif /* CONFIG_ARCH_OMAP3 */
97 #ifdef CONFIG_ARCH_OMAP4
98 static void __init omap4_sdp_legacy_init(void)
100 omap_4430sdp_display_init_of();
101 legacy_init_wl12xx(WL12XX_REFCLOCK_26,
102 WL12XX_TCXOCLOCK_26, 53);
105 static void __init omap4_panda_legacy_init(void)
107 omap4_panda_display_init_of();
108 legacy_init_ehci_clk("auxclk3_ck");
109 legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 53);
111 #endif
113 #ifdef CONFIG_SOC_OMAP5
114 static void __init omap5_uevm_legacy_init(void)
116 legacy_init_ehci_clk("auxclk1_ck");
118 #endif
120 static struct pcs_pdata pcs_pdata;
122 void omap_pcs_legacy_init(int irq, void (*rearm)(void))
124 pcs_pdata.irq = irq;
125 pcs_pdata.rearm = rearm;
128 struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
129 #ifdef CONFIG_ARCH_OMAP3
130 OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002030, "48002030.pinmux", &pcs_pdata),
131 OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002a00, "48002a00.pinmux", &pcs_pdata),
132 #endif
133 #ifdef CONFIG_ARCH_OMAP4
134 OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a100040, "4a100040.pinmux", &pcs_pdata),
135 OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a31e040, "4a31e040.pinmux", &pcs_pdata),
136 #endif
137 { /* sentinel */ },
140 static struct pdata_init pdata_quirks[] __initdata = {
141 #ifdef CONFIG_ARCH_OMAP3
142 { "nokia,omap3-n900", hsmmc2_internal_input_clk, },
143 { "nokia,omap3-n9", hsmmc2_internal_input_clk, },
144 { "nokia,omap3-n950", hsmmc2_internal_input_clk, },
145 { "isee,omap3-igep0020", omap3_igep0020_legacy_init, },
146 { "ti,omap3-evm-37xx", omap3_evm_legacy_init, },
147 { "ti,omap3-zoom3", omap3_zoom_legacy_init, },
148 #endif
149 #ifdef CONFIG_ARCH_OMAP4
150 { "ti,omap4-sdp", omap4_sdp_legacy_init, },
151 { "ti,omap4-panda", omap4_panda_legacy_init, },
152 #endif
153 #ifdef CONFIG_SOC_OMAP5
154 { "ti,omap5-uevm", omap5_uevm_legacy_init, },
155 #endif
156 { /* sentinel */ },
159 void __init pdata_quirks_init(struct of_device_id *omap_dt_match_table)
161 struct pdata_init *quirks = pdata_quirks;
163 omap_sdrc_init(NULL, NULL);
164 of_platform_populate(NULL, omap_dt_match_table,
165 omap_auxdata_lookup, NULL);
167 while (quirks->compatible) {
168 if (of_machine_is_compatible(quirks->compatible)) {
169 if (quirks->fn)
170 quirks->fn();
171 break;
173 quirks++;