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