blob: 6a7554515b6eca0cb61d702a37c92f3e01a29713 [file] [log] [blame]
Tony Lindgren6a08e1e2013-09-25 15:44:39 -07001/*
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>
Tony Lindgren5f0a2c62013-09-25 15:44:40 -070011#include <linux/gpio.h>
Tony Lindgren6a08e1e2013-09-25 15:44:39 -070012#include <linux/init.h>
13#include <linux/kernel.h>
Tony Lindgren8651bd82013-10-10 15:45:12 -070014#include <linux/of_platform.h>
Tony Lindgren5f0a2c62013-09-25 15:44:40 -070015#include <linux/wl12xx.h>
Tony Lindgren6a08e1e2013-09-25 15:44:39 -070016
Tony Lindgren30a69ef2013-10-10 15:45:13 -070017#include <linux/platform_data/pinctrl-single.h>
18
Tony Lindgren6a08e1e2013-09-25 15:44:39 -070019#include "common.h"
20#include "common-board-devices.h"
21#include "dss-common.h"
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +030022#include "control.h"
Tony Lindgren6a08e1e2013-09-25 15:44:39 -070023
24struct pdata_init {
25 const char *compatible;
26 void (*fn)(void);
27};
28
Tony Lindgrenfa590c92013-11-25 15:17:10 -080029struct of_dev_auxdata omap_auxdata_lookup[];
30
Tony Lindgren3e7a3182013-09-25 15:44:39 -070031/*
32 * Create alias for USB host PHY clock.
33 * Remove this when clock phandle can be provided via DT
34 */
35static void __init __used legacy_init_ehci_clk(char *clkname)
36{
37 int ret;
38
39 ret = clk_add_alias("main_clk", NULL, clkname, NULL);
40 if (ret)
41 pr_err("%s:Failed to add main_clk alias to %s :%d\n",
42 __func__, clkname, ret);
43}
44
Tony Lindgren5f0a2c62013-09-25 15:44:40 -070045#if IS_ENABLED(CONFIG_WL12XX)
46
47static struct wl12xx_platform_data wl12xx __initdata;
48
49static void __init __used legacy_init_wl12xx(unsigned ref_clock,
50 unsigned tcxo_clock,
51 int gpio)
52{
53 int res;
54
55 wl12xx.board_ref_clock = ref_clock;
56 wl12xx.board_tcxo_clock = tcxo_clock;
57 wl12xx.irq = gpio_to_irq(gpio);
58
59 res = wl12xx_set_platform_data(&wl12xx);
60 if (res) {
61 pr_err("error setting wl12xx data: %d\n", res);
62 return;
63 }
64}
65#else
66static inline void legacy_init_wl12xx(unsigned ref_clock,
67 unsigned tcxo_clock,
68 int gpio)
69{
70}
71#endif
72
Tony Lindgrenfa590c92013-11-25 15:17:10 -080073#ifdef CONFIG_MACH_NOKIA_N8X0
74static void __init omap2420_n8x0_legacy_init(void)
75{
76 omap_auxdata_lookup[0].platform_data = n8x0_legacy_init();
77}
78#else
79#define omap2420_n8x0_legacy_init NULL
80#endif
81
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +030082#ifdef CONFIG_ARCH_OMAP3
83static void __init hsmmc2_internal_input_clk(void)
84{
85 u32 reg;
86
87 reg = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1);
88 reg |= OMAP2_MMCSDIO2ADPCLKISEL;
89 omap_ctrl_writel(reg, OMAP343X_CONTROL_DEVCONF1);
90}
Javier Martinez Canillas15c98872013-10-09 11:19:18 +020091
92static void __init omap3_igep0020_legacy_init(void)
93{
94 omap3_igep2_display_init_of();
95}
Tony Lindgren79b39f72013-10-11 09:20:54 -070096
97static void __init omap3_evm_legacy_init(void)
98{
99 legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 149);
100}
101
102static void __init omap3_zoom_legacy_init(void)
103{
104 legacy_init_wl12xx(WL12XX_REFCLOCK_26, 0, 162);
105}
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +0300106#endif /* CONFIG_ARCH_OMAP3 */
107
Tony Lindgren3e7a3182013-09-25 15:44:39 -0700108#ifdef CONFIG_ARCH_OMAP4
109static void __init omap4_sdp_legacy_init(void)
110{
111 omap_4430sdp_display_init_of();
Tony Lindgren5f0a2c62013-09-25 15:44:40 -0700112 legacy_init_wl12xx(WL12XX_REFCLOCK_26,
113 WL12XX_TCXOCLOCK_26, 53);
Tony Lindgren3e7a3182013-09-25 15:44:39 -0700114}
115
116static void __init omap4_panda_legacy_init(void)
117{
118 omap4_panda_display_init_of();
119 legacy_init_ehci_clk("auxclk3_ck");
Tony Lindgren5f0a2c62013-09-25 15:44:40 -0700120 legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 53);
Tony Lindgren3e7a3182013-09-25 15:44:39 -0700121}
122#endif
123
124#ifdef CONFIG_SOC_OMAP5
125static void __init omap5_uevm_legacy_init(void)
126{
127 legacy_init_ehci_clk("auxclk1_ck");
128}
129#endif
130
Tony Lindgren30a69ef2013-10-10 15:45:13 -0700131static struct pcs_pdata pcs_pdata;
132
133void omap_pcs_legacy_init(int irq, void (*rearm)(void))
134{
135 pcs_pdata.irq = irq;
136 pcs_pdata.rearm = rearm;
137}
138
Tony Lindgren036582f2013-11-25 15:17:09 -0800139/*
140 * Few boards still need auxdata populated before we populate
141 * the dev entries in of_platform_populate().
142 */
143static struct pdata_init auxdata_quirks[] __initdata = {
Tony Lindgrenfa590c92013-11-25 15:17:10 -0800144#ifdef CONFIG_SOC_OMAP2420
145 { "nokia,n800", omap2420_n8x0_legacy_init, },
146 { "nokia,n810", omap2420_n8x0_legacy_init, },
147 { "nokia,n810-wimax", omap2420_n8x0_legacy_init, },
148#endif
Tony Lindgren036582f2013-11-25 15:17:09 -0800149 { /* sentinel */ },
150};
151
Tony Lindgren8651bd82013-10-10 15:45:12 -0700152struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
Tony Lindgren036582f2013-11-25 15:17:09 -0800153#ifdef CONFIG_MACH_NOKIA_N8X0
154 OF_DEV_AUXDATA("ti,omap2420-mmc", 0x4809c000, "mmci-omap.0", NULL),
155#endif
Tony Lindgren30a69ef2013-10-10 15:45:13 -0700156#ifdef CONFIG_ARCH_OMAP3
157 OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002030, "48002030.pinmux", &pcs_pdata),
158 OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002a00, "48002a00.pinmux", &pcs_pdata),
159#endif
160#ifdef CONFIG_ARCH_OMAP4
161 OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a100040, "4a100040.pinmux", &pcs_pdata),
162 OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a31e040, "4a31e040.pinmux", &pcs_pdata),
163#endif
Tony Lindgren8651bd82013-10-10 15:45:12 -0700164 { /* sentinel */ },
165};
166
Tony Lindgren036582f2013-11-25 15:17:09 -0800167/*
168 * Few boards still need to initialize some legacy devices with
169 * platform data until the drivers support device tree.
170 */
Tony Lindgren6a08e1e2013-09-25 15:44:39 -0700171static struct pdata_init pdata_quirks[] __initdata = {
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +0300172#ifdef CONFIG_ARCH_OMAP3
Tony Lindgrenedd5eb42013-11-25 14:23:45 -0800173 { "nokia,omap3-n900", hsmmc2_internal_input_clk, },
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +0300174 { "nokia,omap3-n9", hsmmc2_internal_input_clk, },
175 { "nokia,omap3-n950", hsmmc2_internal_input_clk, },
Javier Martinez Canillas15c98872013-10-09 11:19:18 +0200176 { "isee,omap3-igep0020", omap3_igep0020_legacy_init, },
Tony Lindgren79b39f72013-10-11 09:20:54 -0700177 { "ti,omap3-evm-37xx", omap3_evm_legacy_init, },
178 { "ti,omap3-zoom3", omap3_zoom_legacy_init, },
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +0300179#endif
Tony Lindgren3e7a3182013-09-25 15:44:39 -0700180#ifdef CONFIG_ARCH_OMAP4
181 { "ti,omap4-sdp", omap4_sdp_legacy_init, },
182 { "ti,omap4-panda", omap4_panda_legacy_init, },
183#endif
184#ifdef CONFIG_SOC_OMAP5
185 { "ti,omap5-uevm", omap5_uevm_legacy_init, },
186#endif
Tony Lindgren6a08e1e2013-09-25 15:44:39 -0700187 { /* sentinel */ },
188};
189
Tony Lindgren036582f2013-11-25 15:17:09 -0800190static void pdata_quirks_check(struct pdata_init *quirks)
Tony Lindgren6a08e1e2013-09-25 15:44:39 -0700191{
Tony Lindgren6a08e1e2013-09-25 15:44:39 -0700192 while (quirks->compatible) {
193 if (of_machine_is_compatible(quirks->compatible)) {
194 if (quirks->fn)
195 quirks->fn();
196 break;
197 }
198 quirks++;
199 }
200}
Tony Lindgren036582f2013-11-25 15:17:09 -0800201
202void __init pdata_quirks_init(struct of_device_id *omap_dt_match_table)
203{
204 omap_sdrc_init(NULL, NULL);
205 pdata_quirks_check(auxdata_quirks);
206 of_platform_populate(NULL, omap_dt_match_table,
207 omap_auxdata_lookup, NULL);
208 pdata_quirks_check(pdata_quirks);
209}