blob: 10c71450cf632c2816c40ab22207ad65ef09dd0b [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 Lindgren3e7a3182013-09-25 15:44:39 -070029/*
30 * Create alias for USB host PHY clock.
31 * Remove this when clock phandle can be provided via DT
32 */
33static void __init __used legacy_init_ehci_clk(char *clkname)
34{
35 int ret;
36
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);
41}
42
Tony Lindgren5f0a2c62013-09-25 15:44:40 -070043#if IS_ENABLED(CONFIG_WL12XX)
44
45static struct wl12xx_platform_data wl12xx __initdata;
46
47static void __init __used legacy_init_wl12xx(unsigned ref_clock,
48 unsigned tcxo_clock,
49 int gpio)
50{
51 int res;
52
53 wl12xx.board_ref_clock = ref_clock;
54 wl12xx.board_tcxo_clock = tcxo_clock;
55 wl12xx.irq = gpio_to_irq(gpio);
56
57 res = wl12xx_set_platform_data(&wl12xx);
58 if (res) {
59 pr_err("error setting wl12xx data: %d\n", res);
60 return;
61 }
62}
63#else
64static inline void legacy_init_wl12xx(unsigned ref_clock,
65 unsigned tcxo_clock,
66 int gpio)
67{
68}
69#endif
70
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +030071#ifdef CONFIG_ARCH_OMAP3
72static void __init hsmmc2_internal_input_clk(void)
73{
74 u32 reg;
75
76 reg = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1);
77 reg |= OMAP2_MMCSDIO2ADPCLKISEL;
78 omap_ctrl_writel(reg, OMAP343X_CONTROL_DEVCONF1);
79}
Javier Martinez Canillas15c98872013-10-09 11:19:18 +020080
81static void __init omap3_igep0020_legacy_init(void)
82{
83 omap3_igep2_display_init_of();
84}
Tony Lindgren79b39f72013-10-11 09:20:54 -070085
86static void __init omap3_evm_legacy_init(void)
87{
88 legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 149);
89}
90
91static void __init omap3_zoom_legacy_init(void)
92{
93 legacy_init_wl12xx(WL12XX_REFCLOCK_26, 0, 162);
94}
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +030095#endif /* CONFIG_ARCH_OMAP3 */
96
Tony Lindgren3e7a3182013-09-25 15:44:39 -070097#ifdef CONFIG_ARCH_OMAP4
98static void __init omap4_sdp_legacy_init(void)
99{
100 omap_4430sdp_display_init_of();
Tony Lindgren5f0a2c62013-09-25 15:44:40 -0700101 legacy_init_wl12xx(WL12XX_REFCLOCK_26,
102 WL12XX_TCXOCLOCK_26, 53);
Tony Lindgren3e7a3182013-09-25 15:44:39 -0700103}
104
105static void __init omap4_panda_legacy_init(void)
106{
107 omap4_panda_display_init_of();
108 legacy_init_ehci_clk("auxclk3_ck");
Tony Lindgren5f0a2c62013-09-25 15:44:40 -0700109 legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 53);
Tony Lindgren3e7a3182013-09-25 15:44:39 -0700110}
111#endif
112
113#ifdef CONFIG_SOC_OMAP5
114static void __init omap5_uevm_legacy_init(void)
115{
116 legacy_init_ehci_clk("auxclk1_ck");
117}
118#endif
119
Tony Lindgren30a69ef2013-10-10 15:45:13 -0700120static struct pcs_pdata pcs_pdata;
121
122void omap_pcs_legacy_init(int irq, void (*rearm)(void))
123{
124 pcs_pdata.irq = irq;
125 pcs_pdata.rearm = rearm;
126}
127
Tony Lindgren8651bd82013-10-10 15:45:12 -0700128struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
Tony Lindgren30a69ef2013-10-10 15:45:13 -0700129#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
Tony Lindgren8651bd82013-10-10 15:45:12 -0700137 { /* sentinel */ },
138};
139
Tony Lindgren6a08e1e2013-09-25 15:44:39 -0700140static struct pdata_init pdata_quirks[] __initdata = {
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +0300141#ifdef CONFIG_ARCH_OMAP3
142 { "nokia,omap3-n9", hsmmc2_internal_input_clk, },
143 { "nokia,omap3-n950", hsmmc2_internal_input_clk, },
Javier Martinez Canillas15c98872013-10-09 11:19:18 +0200144 { "isee,omap3-igep0020", omap3_igep0020_legacy_init, },
Tony Lindgren79b39f72013-10-11 09:20:54 -0700145 { "ti,omap3-evm-37xx", omap3_evm_legacy_init, },
146 { "ti,omap3-zoom3", omap3_zoom_legacy_init, },
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +0300147#endif
Tony Lindgren3e7a3182013-09-25 15:44:39 -0700148#ifdef CONFIG_ARCH_OMAP4
149 { "ti,omap4-sdp", omap4_sdp_legacy_init, },
150 { "ti,omap4-panda", omap4_panda_legacy_init, },
151#endif
152#ifdef CONFIG_SOC_OMAP5
153 { "ti,omap5-uevm", omap5_uevm_legacy_init, },
154#endif
Tony Lindgren6a08e1e2013-09-25 15:44:39 -0700155 { /* sentinel */ },
156};
157
Tony Lindgren8651bd82013-10-10 15:45:12 -0700158void __init pdata_quirks_init(struct of_device_id *omap_dt_match_table)
Tony Lindgren6a08e1e2013-09-25 15:44:39 -0700159{
160 struct pdata_init *quirks = pdata_quirks;
161
Tony Lindgren8651bd82013-10-10 15:45:12 -0700162 omap_sdrc_init(NULL, NULL);
163 of_platform_populate(NULL, omap_dt_match_table,
164 omap_auxdata_lookup, NULL);
165
Tony Lindgren6a08e1e2013-09-25 15:44:39 -0700166 while (quirks->compatible) {
167 if (of_machine_is_compatible(quirks->compatible)) {
168 if (quirks->fn)
169 quirks->fn();
170 break;
171 }
172 quirks++;
173 }
174}