]> Pileus Git - ~andy/linux/blob - arch/arm/mach-omap2/pdata-quirks.c
76abc5b63d6d1952af6f96df4ec95ad0bed0f780
[~andy/linux] / arch / arm / mach-omap2 / pdata-quirks.c
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
17 #include "common.h"
18 #include "common-board-devices.h"
19 #include "dss-common.h"
20 #include "control.h"
21
22 struct pdata_init {
23         const char *compatible;
24         void (*fn)(void);
25 };
26
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
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
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 }
78
79 static void __init omap3_igep0020_legacy_init(void)
80 {
81         omap3_igep2_display_init_of();
82 }
83 #endif /* CONFIG_ARCH_OMAP3 */
84
85 #ifdef CONFIG_ARCH_OMAP4
86 static void __init omap4_sdp_legacy_init(void)
87 {
88         omap_4430sdp_display_init_of();
89         legacy_init_wl12xx(WL12XX_REFCLOCK_26,
90                            WL12XX_TCXOCLOCK_26, 53);
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");
97         legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 53);
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
108 struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
109         { /* sentinel */ },
110 };
111
112 static struct pdata_init pdata_quirks[] __initdata = {
113 #ifdef CONFIG_ARCH_OMAP3
114         { "nokia,omap3-n9", hsmmc2_internal_input_clk, },
115         { "nokia,omap3-n950", hsmmc2_internal_input_clk, },
116         { "isee,omap3-igep0020", omap3_igep0020_legacy_init, },
117 #endif
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
125         { /* sentinel */ },
126 };
127
128 void __init pdata_quirks_init(struct of_device_id *omap_dt_match_table)
129 {
130         struct pdata_init *quirks = pdata_quirks;
131
132         omap_sdrc_init(NULL, NULL);
133         of_platform_populate(NULL, omap_dt_match_table,
134                              omap_auxdata_lookup, NULL);
135
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 }