xref: /linux/arch/arm/mach-omap2/pdata-quirks.c (revision edd5eb4e99e4153ea7be05390fda542d986bf28d)
16a08e1e6STony Lindgren /*
26a08e1e6STony Lindgren  * Legacy platform_data quirks
36a08e1e6STony Lindgren  *
46a08e1e6STony Lindgren  * Copyright (C) 2013 Texas Instruments
56a08e1e6STony Lindgren  *
66a08e1e6STony Lindgren  * This program is free software; you can redistribute it and/or modify
76a08e1e6STony Lindgren  * it under the terms of the GNU General Public License version 2 as
86a08e1e6STony Lindgren  * published by the Free Software Foundation.
96a08e1e6STony Lindgren  */
106a08e1e6STony Lindgren #include <linux/clk.h>
115f0a2c69STony Lindgren #include <linux/gpio.h>
126a08e1e6STony Lindgren #include <linux/init.h>
136a08e1e6STony Lindgren #include <linux/kernel.h>
148651bd8cSTony Lindgren #include <linux/of_platform.h>
155f0a2c69STony Lindgren #include <linux/wl12xx.h>
166a08e1e6STony Lindgren 
1730a69ef7STony Lindgren #include <linux/platform_data/pinctrl-single.h>
1830a69ef7STony Lindgren 
196a08e1e6STony Lindgren #include "common.h"
206a08e1e6STony Lindgren #include "common-board-devices.h"
216a08e1e6STony Lindgren #include "dss-common.h"
22faf4bd47SAaro Koskinen #include "control.h"
236a08e1e6STony Lindgren 
246a08e1e6STony Lindgren struct pdata_init {
256a08e1e6STony Lindgren 	const char *compatible;
266a08e1e6STony Lindgren 	void (*fn)(void);
276a08e1e6STony Lindgren };
286a08e1e6STony Lindgren 
293e7a3185STony Lindgren /*
303e7a3185STony Lindgren  * Create alias for USB host PHY clock.
313e7a3185STony Lindgren  * Remove this when clock phandle can be provided via DT
323e7a3185STony Lindgren  */
333e7a3185STony Lindgren static void __init __used legacy_init_ehci_clk(char *clkname)
343e7a3185STony Lindgren {
353e7a3185STony Lindgren 	int ret;
363e7a3185STony Lindgren 
373e7a3185STony Lindgren 	ret = clk_add_alias("main_clk", NULL, clkname, NULL);
383e7a3185STony Lindgren 	if (ret)
393e7a3185STony Lindgren 		pr_err("%s:Failed to add main_clk alias to %s :%d\n",
403e7a3185STony Lindgren 		       __func__, clkname, ret);
413e7a3185STony Lindgren }
423e7a3185STony Lindgren 
435f0a2c69STony Lindgren #if IS_ENABLED(CONFIG_WL12XX)
445f0a2c69STony Lindgren 
455f0a2c69STony Lindgren static struct wl12xx_platform_data wl12xx __initdata;
465f0a2c69STony Lindgren 
475f0a2c69STony Lindgren static void __init __used legacy_init_wl12xx(unsigned ref_clock,
485f0a2c69STony Lindgren 					     unsigned tcxo_clock,
495f0a2c69STony Lindgren 					     int gpio)
505f0a2c69STony Lindgren {
515f0a2c69STony Lindgren 	int res;
525f0a2c69STony Lindgren 
535f0a2c69STony Lindgren 	wl12xx.board_ref_clock = ref_clock;
545f0a2c69STony Lindgren 	wl12xx.board_tcxo_clock = tcxo_clock;
555f0a2c69STony Lindgren 	wl12xx.irq = gpio_to_irq(gpio);
565f0a2c69STony Lindgren 
575f0a2c69STony Lindgren 	res = wl12xx_set_platform_data(&wl12xx);
585f0a2c69STony Lindgren 	if (res) {
595f0a2c69STony Lindgren 		pr_err("error setting wl12xx data: %d\n", res);
605f0a2c69STony Lindgren 		return;
615f0a2c69STony Lindgren 	}
625f0a2c69STony Lindgren }
635f0a2c69STony Lindgren #else
645f0a2c69STony Lindgren static inline void legacy_init_wl12xx(unsigned ref_clock,
655f0a2c69STony Lindgren 				      unsigned tcxo_clock,
665f0a2c69STony Lindgren 				      int gpio)
675f0a2c69STony Lindgren {
685f0a2c69STony Lindgren }
695f0a2c69STony Lindgren #endif
705f0a2c69STony Lindgren 
71faf4bd47SAaro Koskinen #ifdef CONFIG_ARCH_OMAP3
72faf4bd47SAaro Koskinen static void __init hsmmc2_internal_input_clk(void)
73faf4bd47SAaro Koskinen {
74faf4bd47SAaro Koskinen 	u32 reg;
75faf4bd47SAaro Koskinen 
76faf4bd47SAaro Koskinen 	reg = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1);
77faf4bd47SAaro Koskinen 	reg |= OMAP2_MMCSDIO2ADPCLKISEL;
78faf4bd47SAaro Koskinen 	omap_ctrl_writel(reg, OMAP343X_CONTROL_DEVCONF1);
79faf4bd47SAaro Koskinen }
8015c9887eSJavier Martinez Canillas 
8115c9887eSJavier Martinez Canillas static void __init omap3_igep0020_legacy_init(void)
8215c9887eSJavier Martinez Canillas {
8315c9887eSJavier Martinez Canillas 	omap3_igep2_display_init_of();
8415c9887eSJavier Martinez Canillas }
8579b39f79STony Lindgren 
8679b39f79STony Lindgren static void __init omap3_evm_legacy_init(void)
8779b39f79STony Lindgren {
8879b39f79STony Lindgren 	legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 149);
8979b39f79STony Lindgren }
9079b39f79STony Lindgren 
9179b39f79STony Lindgren static void __init omap3_zoom_legacy_init(void)
9279b39f79STony Lindgren {
9379b39f79STony Lindgren 	legacy_init_wl12xx(WL12XX_REFCLOCK_26, 0, 162);
9479b39f79STony Lindgren }
95faf4bd47SAaro Koskinen #endif /* CONFIG_ARCH_OMAP3 */
96faf4bd47SAaro Koskinen 
973e7a3185STony Lindgren #ifdef CONFIG_ARCH_OMAP4
983e7a3185STony Lindgren static void __init omap4_sdp_legacy_init(void)
993e7a3185STony Lindgren {
1003e7a3185STony Lindgren 	omap_4430sdp_display_init_of();
1015f0a2c69STony Lindgren 	legacy_init_wl12xx(WL12XX_REFCLOCK_26,
1025f0a2c69STony Lindgren 			   WL12XX_TCXOCLOCK_26, 53);
1033e7a3185STony Lindgren }
1043e7a3185STony Lindgren 
1053e7a3185STony Lindgren static void __init omap4_panda_legacy_init(void)
1063e7a3185STony Lindgren {
1073e7a3185STony Lindgren 	omap4_panda_display_init_of();
1083e7a3185STony Lindgren 	legacy_init_ehci_clk("auxclk3_ck");
1095f0a2c69STony Lindgren 	legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 53);
1103e7a3185STony Lindgren }
1113e7a3185STony Lindgren #endif
1123e7a3185STony Lindgren 
1133e7a3185STony Lindgren #ifdef CONFIG_SOC_OMAP5
1143e7a3185STony Lindgren static void __init omap5_uevm_legacy_init(void)
1153e7a3185STony Lindgren {
1163e7a3185STony Lindgren 	legacy_init_ehci_clk("auxclk1_ck");
1173e7a3185STony Lindgren }
1183e7a3185STony Lindgren #endif
1193e7a3185STony Lindgren 
12030a69ef7STony Lindgren static struct pcs_pdata pcs_pdata;
12130a69ef7STony Lindgren 
12230a69ef7STony Lindgren void omap_pcs_legacy_init(int irq, void (*rearm)(void))
12330a69ef7STony Lindgren {
12430a69ef7STony Lindgren 	pcs_pdata.irq = irq;
12530a69ef7STony Lindgren 	pcs_pdata.rearm = rearm;
12630a69ef7STony Lindgren }
12730a69ef7STony Lindgren 
1288651bd8cSTony Lindgren struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
12930a69ef7STony Lindgren #ifdef CONFIG_ARCH_OMAP3
13030a69ef7STony Lindgren 	OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002030, "48002030.pinmux", &pcs_pdata),
13130a69ef7STony Lindgren 	OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002a00, "48002a00.pinmux", &pcs_pdata),
13230a69ef7STony Lindgren #endif
13330a69ef7STony Lindgren #ifdef CONFIG_ARCH_OMAP4
13430a69ef7STony Lindgren 	OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a100040, "4a100040.pinmux", &pcs_pdata),
13530a69ef7STony Lindgren 	OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a31e040, "4a31e040.pinmux", &pcs_pdata),
13630a69ef7STony Lindgren #endif
1378651bd8cSTony Lindgren 	{ /* sentinel */ },
1388651bd8cSTony Lindgren };
1398651bd8cSTony Lindgren 
1406a08e1e6STony Lindgren static struct pdata_init pdata_quirks[] __initdata = {
141faf4bd47SAaro Koskinen #ifdef CONFIG_ARCH_OMAP3
142*edd5eb4eSTony Lindgren 	{ "nokia,omap3-n900", hsmmc2_internal_input_clk, },
143faf4bd47SAaro Koskinen 	{ "nokia,omap3-n9", hsmmc2_internal_input_clk, },
144faf4bd47SAaro Koskinen 	{ "nokia,omap3-n950", hsmmc2_internal_input_clk, },
14515c9887eSJavier Martinez Canillas 	{ "isee,omap3-igep0020", omap3_igep0020_legacy_init, },
14679b39f79STony Lindgren 	{ "ti,omap3-evm-37xx", omap3_evm_legacy_init, },
14779b39f79STony Lindgren 	{ "ti,omap3-zoom3", omap3_zoom_legacy_init, },
148faf4bd47SAaro Koskinen #endif
1493e7a3185STony Lindgren #ifdef CONFIG_ARCH_OMAP4
1503e7a3185STony Lindgren 	{ "ti,omap4-sdp", omap4_sdp_legacy_init, },
1513e7a3185STony Lindgren 	{ "ti,omap4-panda", omap4_panda_legacy_init, },
1523e7a3185STony Lindgren #endif
1533e7a3185STony Lindgren #ifdef CONFIG_SOC_OMAP5
1543e7a3185STony Lindgren 	{ "ti,omap5-uevm", omap5_uevm_legacy_init, },
1553e7a3185STony Lindgren #endif
1566a08e1e6STony Lindgren 	{ /* sentinel */ },
1576a08e1e6STony Lindgren };
1586a08e1e6STony Lindgren 
1598651bd8cSTony Lindgren void __init pdata_quirks_init(struct of_device_id *omap_dt_match_table)
1606a08e1e6STony Lindgren {
1616a08e1e6STony Lindgren 	struct pdata_init *quirks = pdata_quirks;
1626a08e1e6STony Lindgren 
1638651bd8cSTony Lindgren 	omap_sdrc_init(NULL, NULL);
1648651bd8cSTony Lindgren 	of_platform_populate(NULL, omap_dt_match_table,
1658651bd8cSTony Lindgren 			     omap_auxdata_lookup, NULL);
1668651bd8cSTony Lindgren 
1676a08e1e6STony Lindgren 	while (quirks->compatible) {
1686a08e1e6STony Lindgren 		if (of_machine_is_compatible(quirks->compatible)) {
1696a08e1e6STony Lindgren 			if (quirks->fn)
1706a08e1e6STony Lindgren 				quirks->fn();
1716a08e1e6STony Lindgren 			break;
1726a08e1e6STony Lindgren 		}
1736a08e1e6STony Lindgren 		quirks++;
1746a08e1e6STony Lindgren 	}
1756a08e1e6STony Lindgren }
176