blob: 9113e7037ae53385fa88110b0e6ea2d6ebd6e9fd [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 Lindgren5f0a2c62013-09-25 15:44:40 -070014#include <linux/wl12xx.h>
Tony Lindgren6a08e1e2013-09-25 15:44:39 -070015
16#include "common.h"
17#include "common-board-devices.h"
18#include "dss-common.h"
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +030019#include "control.h"
Tony Lindgren6a08e1e2013-09-25 15:44:39 -070020
21struct pdata_init {
22 const char *compatible;
23 void (*fn)(void);
24};
25
Tony Lindgren3e7a3182013-09-25 15:44:39 -070026/*
27 * Create alias for USB host PHY clock.
28 * Remove this when clock phandle can be provided via DT
29 */
30static 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
Tony Lindgren5f0a2c62013-09-25 15:44:40 -070040#if IS_ENABLED(CONFIG_WL12XX)
41
42static struct wl12xx_platform_data wl12xx __initdata;
43
44static 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
61static inline void legacy_init_wl12xx(unsigned ref_clock,
62 unsigned tcxo_clock,
63 int gpio)
64{
65}
66#endif
67
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +030068#ifdef CONFIG_ARCH_OMAP3
69static 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}
Javier Martinez Canillas15c98872013-10-09 11:19:18 +020077
78static void __init omap3_igep0020_legacy_init(void)
79{
80 omap3_igep2_display_init_of();
81}
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +030082#endif /* CONFIG_ARCH_OMAP3 */
83
Tony Lindgren3e7a3182013-09-25 15:44:39 -070084#ifdef CONFIG_ARCH_OMAP4
85static void __init omap4_sdp_legacy_init(void)
86{
87 omap_4430sdp_display_init_of();
Tony Lindgren5f0a2c62013-09-25 15:44:40 -070088 legacy_init_wl12xx(WL12XX_REFCLOCK_26,
89 WL12XX_TCXOCLOCK_26, 53);
Tony Lindgren3e7a3182013-09-25 15:44:39 -070090}
91
92static void __init omap4_panda_legacy_init(void)
93{
94 omap4_panda_display_init_of();
95 legacy_init_ehci_clk("auxclk3_ck");
Tony Lindgren5f0a2c62013-09-25 15:44:40 -070096 legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 53);
Tony Lindgren3e7a3182013-09-25 15:44:39 -070097}
98#endif
99
100#ifdef CONFIG_SOC_OMAP5
101static void __init omap5_uevm_legacy_init(void)
102{
103 legacy_init_ehci_clk("auxclk1_ck");
104}
105#endif
106
Tony Lindgren6a08e1e2013-09-25 15:44:39 -0700107static struct pdata_init pdata_quirks[] __initdata = {
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +0300108#ifdef CONFIG_ARCH_OMAP3
109 { "nokia,omap3-n9", hsmmc2_internal_input_clk, },
110 { "nokia,omap3-n950", hsmmc2_internal_input_clk, },
Javier Martinez Canillas15c98872013-10-09 11:19:18 +0200111 { "isee,omap3-igep0020", omap3_igep0020_legacy_init, },
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +0300112#endif
Tony Lindgren3e7a3182013-09-25 15:44:39 -0700113#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
Tony Lindgren6a08e1e2013-09-25 15:44:39 -0700120 { /* sentinel */ },
121};
122
123void __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}