xref: /linux/arch/arm/mach-omap2/pdata-quirks.c (revision 485fa1261f780e8a13d0b25a24673947e6c50953)
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>
1171900314STony Lindgren #include <linux/davinci_emac.h>
125f0a2c69STony Lindgren #include <linux/gpio.h>
136a08e1e6STony Lindgren #include <linux/init.h>
146a08e1e6STony Lindgren #include <linux/kernel.h>
158651bd8cSTony Lindgren #include <linux/of_platform.h>
16d565b5f4SEnric Balletbo i Serra #include <linux/ti_wilink_st.h>
17f9d50fefSGrazvydas Ignotas #include <linux/wl12xx.h>
18f9d50fefSGrazvydas Ignotas #include <linux/mmc/card.h>
19f9d50fefSGrazvydas Ignotas #include <linux/mmc/host.h>
20f9d50fefSGrazvydas Ignotas #include <linux/regulator/machine.h>
21f9d50fefSGrazvydas Ignotas #include <linux/regulator/fixed.h>
226a08e1e6STony Lindgren 
2330a69ef7STony Lindgren #include <linux/platform_data/pinctrl-single.h>
24910f1678SSuman Anna #include <linux/platform_data/iommu-omap.h>
256da74c54SDave Gerlach #include <linux/platform_data/wkup_m3.h>
2630a69ef7STony Lindgren 
27f5887fe5STony Lindgren #include <asm/siginfo.h>
28f5887fe5STony Lindgren #include <asm/signal.h>
296a08e1e6STony Lindgren 
306a08e1e6STony Lindgren #include "common.h"
316a08e1e6STony Lindgren #include "common-board-devices.h"
326a08e1e6STony Lindgren #include "dss-common.h"
33faf4bd47SAaro Koskinen #include "control.h"
34910f1678SSuman Anna #include "omap_device.h"
35deff82e6SSebastian Reichel #include "omap-secure.h"
36deff82e6SSebastian Reichel #include "soc.h"
37f9d50fefSGrazvydas Ignotas #include "hsmmc.h"
386a08e1e6STony Lindgren 
396a08e1e6STony Lindgren struct pdata_init {
406a08e1e6STony Lindgren 	const char *compatible;
416a08e1e6STony Lindgren 	void (*fn)(void);
426a08e1e6STony Lindgren };
436a08e1e6STony Lindgren 
44f734a9b3SSekhar Nori static struct of_dev_auxdata omap_auxdata_lookup[];
45dad12d11STony Lindgren static struct twl4030_gpio_platform_data twl_gpio_auxdata;
46fa590c92STony Lindgren 
47fa590c92STony Lindgren #ifdef CONFIG_MACH_NOKIA_N8X0
48fa590c92STony Lindgren static void __init omap2420_n8x0_legacy_init(void)
49fa590c92STony Lindgren {
50fa590c92STony Lindgren 	omap_auxdata_lookup[0].platform_data = n8x0_legacy_init();
51fa590c92STony Lindgren }
52fa590c92STony Lindgren #else
53fa590c92STony Lindgren #define omap2420_n8x0_legacy_init	NULL
54fa590c92STony Lindgren #endif
55fa590c92STony Lindgren 
56faf4bd47SAaro Koskinen #ifdef CONFIG_ARCH_OMAP3
57b96b332fSTony Lindgren /*
58b96b332fSTony Lindgren  * Configures GPIOs 126, 127 and 129 to 1.8V mode instead of 3.0V
59b96b332fSTony Lindgren  * mode for MMC1 in case bootloader did not configure things.
60b96b332fSTony Lindgren  * Note that if the pins are used for MMC1, pbias-regulator
61b96b332fSTony Lindgren  * manages the IO voltage.
62b96b332fSTony Lindgren  */
63b96b332fSTony Lindgren static void __init omap3_gpio126_127_129(void)
64b96b332fSTony Lindgren {
65b96b332fSTony Lindgren 	u32 reg;
66b96b332fSTony Lindgren 
67b96b332fSTony Lindgren 	reg = omap_ctrl_readl(OMAP343X_CONTROL_PBIAS_LITE);
68b96b332fSTony Lindgren 	reg &= ~OMAP343X_PBIASLITEVMODE1;
69b96b332fSTony Lindgren 	reg |= OMAP343X_PBIASLITEPWRDNZ1;
70b96b332fSTony Lindgren 	omap_ctrl_writel(reg, OMAP343X_CONTROL_PBIAS_LITE);
71b96b332fSTony Lindgren 	if (cpu_is_omap3630()) {
72b96b332fSTony Lindgren 		reg = omap_ctrl_readl(OMAP34XX_CONTROL_WKUP_CTRL);
73b96b332fSTony Lindgren 		reg |= OMAP36XX_GPIO_IO_PWRDNZ;
74b96b332fSTony Lindgren 		omap_ctrl_writel(reg, OMAP34XX_CONTROL_WKUP_CTRL);
75b96b332fSTony Lindgren 	}
76b96b332fSTony Lindgren }
77b96b332fSTony Lindgren 
78faf4bd47SAaro Koskinen static void __init hsmmc2_internal_input_clk(void)
79faf4bd47SAaro Koskinen {
80faf4bd47SAaro Koskinen 	u32 reg;
81faf4bd47SAaro Koskinen 
82faf4bd47SAaro Koskinen 	reg = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1);
83faf4bd47SAaro Koskinen 	reg |= OMAP2_MMCSDIO2ADPCLKISEL;
84faf4bd47SAaro Koskinen 	omap_ctrl_writel(reg, OMAP343X_CONTROL_DEVCONF1);
85faf4bd47SAaro Koskinen }
8615c9887eSJavier Martinez Canillas 
87910f1678SSuman Anna static struct iommu_platform_data omap3_iommu_pdata = {
88910f1678SSuman Anna 	.reset_name = "mmu",
89910f1678SSuman Anna 	.assert_reset = omap_device_assert_hardreset,
90910f1678SSuman Anna 	.deassert_reset = omap_device_deassert_hardreset,
91910f1678SSuman Anna };
92910f1678SSuman Anna 
930f0cfc69STony Lindgren static int omap3_sbc_t3730_twl_callback(struct device *dev,
940f0cfc69STony Lindgren 					   unsigned gpio,
950f0cfc69STony Lindgren 					   unsigned ngpio)
960f0cfc69STony Lindgren {
970f0cfc69STony Lindgren 	int res;
980f0cfc69STony Lindgren 
990f0cfc69STony Lindgren 	res = gpio_request_one(gpio + 2, GPIOF_OUT_INIT_HIGH,
100d234e423SDmitry Lifshitz 			       "wlan pwr");
1010f0cfc69STony Lindgren 	if (res)
1020f0cfc69STony Lindgren 		return res;
1030f0cfc69STony Lindgren 
1040f0cfc69STony Lindgren 	gpio_export(gpio, 0);
1050f0cfc69STony Lindgren 
1060f0cfc69STony Lindgren 	return 0;
1070f0cfc69STony Lindgren }
1080f0cfc69STony Lindgren 
109b62d91e5SDmitry Lifshitz static void __init omap3_sbc_t3x_usb_hub_init(int gpio, char *hub_name)
110b62d91e5SDmitry Lifshitz {
111b62d91e5SDmitry Lifshitz 	int err = gpio_request_one(gpio, GPIOF_OUT_INIT_LOW, hub_name);
112b62d91e5SDmitry Lifshitz 
113b62d91e5SDmitry Lifshitz 	if (err) {
114b62d91e5SDmitry Lifshitz 		pr_err("SBC-T3x: %s reset gpio request failed: %d\n",
115b62d91e5SDmitry Lifshitz 			hub_name, err);
116b62d91e5SDmitry Lifshitz 		return;
117b62d91e5SDmitry Lifshitz 	}
118b62d91e5SDmitry Lifshitz 
119b62d91e5SDmitry Lifshitz 	gpio_export(gpio, 0);
120b62d91e5SDmitry Lifshitz 
121b62d91e5SDmitry Lifshitz 	udelay(10);
122b62d91e5SDmitry Lifshitz 	gpio_set_value(gpio, 1);
123b62d91e5SDmitry Lifshitz 	msleep(1);
124b62d91e5SDmitry Lifshitz }
125b62d91e5SDmitry Lifshitz 
1260f0cfc69STony Lindgren static void __init omap3_sbc_t3730_twl_init(void)
1270f0cfc69STony Lindgren {
1280f0cfc69STony Lindgren 	twl_gpio_auxdata.setup = omap3_sbc_t3730_twl_callback;
1290f0cfc69STony Lindgren }
1300f0cfc69STony Lindgren 
1310f0cfc69STony Lindgren static void __init omap3_sbc_t3730_legacy_init(void)
1320f0cfc69STony Lindgren {
133b62d91e5SDmitry Lifshitz 	omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub");
1340f0cfc69STony Lindgren }
1350f0cfc69STony Lindgren 
13640ecc02eSDmitry Lifshitz static void __init omap3_sbc_t3530_legacy_init(void)
13740ecc02eSDmitry Lifshitz {
138b62d91e5SDmitry Lifshitz 	omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub");
13940ecc02eSDmitry Lifshitz }
14040ecc02eSDmitry Lifshitz 
141f734a9b3SSekhar Nori static struct ti_st_plat_data wilink_pdata = {
142d565b5f4SEnric Balletbo i Serra 	.nshutdown_gpio = 137,
143d565b5f4SEnric Balletbo i Serra 	.dev_name = "/dev/ttyO1",
144d565b5f4SEnric Balletbo i Serra 	.flow_cntrl = 1,
145d565b5f4SEnric Balletbo i Serra 	.baud_rate = 300000,
146d565b5f4SEnric Balletbo i Serra };
147d565b5f4SEnric Balletbo i Serra 
148d565b5f4SEnric Balletbo i Serra static struct platform_device wl18xx_device = {
149d565b5f4SEnric Balletbo i Serra 	.name	= "kim",
150d565b5f4SEnric Balletbo i Serra 	.id	= -1,
151d565b5f4SEnric Balletbo i Serra 	.dev	= {
152d565b5f4SEnric Balletbo i Serra 		.platform_data = &wilink_pdata,
153d565b5f4SEnric Balletbo i Serra 	}
154d565b5f4SEnric Balletbo i Serra };
155d565b5f4SEnric Balletbo i Serra 
156*485fa126SAdam Ford static struct ti_st_plat_data wilink7_pdata = {
157*485fa126SAdam Ford 	.nshutdown_gpio = 162,
158*485fa126SAdam Ford 	.dev_name = "/dev/ttyO1",
159*485fa126SAdam Ford 	.flow_cntrl = 1,
160*485fa126SAdam Ford 	.baud_rate = 300000,
161*485fa126SAdam Ford };
162*485fa126SAdam Ford 
163*485fa126SAdam Ford static struct platform_device wl128x_device = {
164*485fa126SAdam Ford 	.name	= "kim",
165*485fa126SAdam Ford 	.id	= -1,
166*485fa126SAdam Ford 	.dev	= {
167*485fa126SAdam Ford 		.platform_data = &wilink7_pdata,
168*485fa126SAdam Ford 	}
169*485fa126SAdam Ford };
170*485fa126SAdam Ford 
171d565b5f4SEnric Balletbo i Serra static struct platform_device btwilink_device = {
172d565b5f4SEnric Balletbo i Serra 	.name	= "btwilink",
173d565b5f4SEnric Balletbo i Serra 	.id	= -1,
174d565b5f4SEnric Balletbo i Serra };
175d565b5f4SEnric Balletbo i Serra 
176d565b5f4SEnric Balletbo i Serra static void __init omap3_igep0020_rev_f_legacy_init(void)
17715c9887eSJavier Martinez Canillas {
178d565b5f4SEnric Balletbo i Serra 	platform_device_register(&wl18xx_device);
179d565b5f4SEnric Balletbo i Serra 	platform_device_register(&btwilink_device);
180d565b5f4SEnric Balletbo i Serra }
181d565b5f4SEnric Balletbo i Serra 
182d565b5f4SEnric Balletbo i Serra static void __init omap3_igep0030_rev_g_legacy_init(void)
183d565b5f4SEnric Balletbo i Serra {
184d565b5f4SEnric Balletbo i Serra 	platform_device_register(&wl18xx_device);
185d565b5f4SEnric Balletbo i Serra 	platform_device_register(&btwilink_device);
18615c9887eSJavier Martinez Canillas }
18779b39f79STony Lindgren 
18879b39f79STony Lindgren static void __init omap3_evm_legacy_init(void)
18979b39f79STony Lindgren {
1905b7610f2STony Lindgren 	hsmmc2_internal_input_clk();
19179b39f79STony Lindgren }
19271900314STony Lindgren 
19371900314STony Lindgren static void am35xx_enable_emac_int(void)
19471900314STony Lindgren {
19571900314STony Lindgren 	u32 v;
19671900314STony Lindgren 
19771900314STony Lindgren 	v = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
19871900314STony Lindgren 	v |= (AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR |
19971900314STony Lindgren 	      AM35XX_CPGMAC_C0_MISC_PULSE_CLR | AM35XX_CPGMAC_C0_RX_THRESH_CLR);
20071900314STony Lindgren 	omap_ctrl_writel(v, AM35XX_CONTROL_LVL_INTR_CLEAR);
20171900314STony Lindgren 	omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); /* OCP barrier */
20271900314STony Lindgren }
20371900314STony Lindgren 
20471900314STony Lindgren static void am35xx_disable_emac_int(void)
20571900314STony Lindgren {
20671900314STony Lindgren 	u32 v;
20771900314STony Lindgren 
20871900314STony Lindgren 	v = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
20971900314STony Lindgren 	v |= (AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR);
21071900314STony Lindgren 	omap_ctrl_writel(v, AM35XX_CONTROL_LVL_INTR_CLEAR);
21171900314STony Lindgren 	omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); /* OCP barrier */
21271900314STony Lindgren }
21371900314STony Lindgren 
21471900314STony Lindgren static struct emac_platform_data am35xx_emac_pdata = {
21571900314STony Lindgren 	.interrupt_enable	= am35xx_enable_emac_int,
21671900314STony Lindgren 	.interrupt_disable	= am35xx_disable_emac_int,
21771900314STony Lindgren };
21871900314STony Lindgren 
219fb45105aSDmitry Lifshitz static void __init am35xx_emac_reset(void)
22071900314STony Lindgren {
22171900314STony Lindgren 	u32 v;
22271900314STony Lindgren 
22371900314STony Lindgren 	v = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
22471900314STony Lindgren 	v &= ~AM35XX_CPGMACSS_SW_RST;
22571900314STony Lindgren 	omap_ctrl_writel(v, AM35XX_CONTROL_IP_SW_RESET);
22671900314STony Lindgren 	omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); /* OCP barrier */
22771900314STony Lindgren }
228deff82e6SSebastian Reichel 
229fb45105aSDmitry Lifshitz static struct gpio cm_t3517_wlan_gpios[] __initdata = {
230fb45105aSDmitry Lifshitz 	{ 56,	GPIOF_OUT_INIT_HIGH,	"wlan pwr" },
231fb45105aSDmitry Lifshitz 	{ 4,	GPIOF_OUT_INIT_HIGH,	"xcvr noe" },
232fb45105aSDmitry Lifshitz };
233fb45105aSDmitry Lifshitz 
234fb45105aSDmitry Lifshitz static void __init omap3_sbc_t3517_wifi_init(void)
235fb45105aSDmitry Lifshitz {
236fb45105aSDmitry Lifshitz 	int err = gpio_request_array(cm_t3517_wlan_gpios,
237fb45105aSDmitry Lifshitz 				ARRAY_SIZE(cm_t3517_wlan_gpios));
238fb45105aSDmitry Lifshitz 	if (err) {
239fb45105aSDmitry Lifshitz 		pr_err("SBC-T3517: wl12xx gpios request failed: %d\n", err);
240fb45105aSDmitry Lifshitz 		return;
241fb45105aSDmitry Lifshitz 	}
242fb45105aSDmitry Lifshitz 
243fb45105aSDmitry Lifshitz 	gpio_export(cm_t3517_wlan_gpios[0].gpio, 0);
244fb45105aSDmitry Lifshitz 	gpio_export(cm_t3517_wlan_gpios[1].gpio, 0);
245fb45105aSDmitry Lifshitz 
246fb45105aSDmitry Lifshitz 	msleep(100);
247fb45105aSDmitry Lifshitz 	gpio_set_value(cm_t3517_wlan_gpios[1].gpio, 0);
248fb45105aSDmitry Lifshitz }
249fb45105aSDmitry Lifshitz 
250fb45105aSDmitry Lifshitz static void __init omap3_sbc_t3517_legacy_init(void)
251fb45105aSDmitry Lifshitz {
252b62d91e5SDmitry Lifshitz 	omap3_sbc_t3x_usb_hub_init(152, "cm-t3517 usb hub");
253b62d91e5SDmitry Lifshitz 	omap3_sbc_t3x_usb_hub_init(98, "sb-t35 usb hub");
254fb45105aSDmitry Lifshitz 	am35xx_emac_reset();
255fb45105aSDmitry Lifshitz 	hsmmc2_internal_input_clk();
256fb45105aSDmitry Lifshitz 	omap3_sbc_t3517_wifi_init();
257fb45105aSDmitry Lifshitz }
258fb45105aSDmitry Lifshitz 
259fb45105aSDmitry Lifshitz static void __init am3517_evm_legacy_init(void)
260fb45105aSDmitry Lifshitz {
261fb45105aSDmitry Lifshitz 	am35xx_emac_reset();
262fb45105aSDmitry Lifshitz }
263f83ccb93SLinus Torvalds 
26414c0a5b4SSebastian Reichel static struct platform_device omap3_rom_rng_device = {
26514c0a5b4SSebastian Reichel 	.name		= "omap3-rom-rng",
26614c0a5b4SSebastian Reichel 	.id		= -1,
26714c0a5b4SSebastian Reichel 	.dev	= {
26814c0a5b4SSebastian Reichel 		.platform_data	= rx51_secure_rng_call,
26914c0a5b4SSebastian Reichel 	},
27014c0a5b4SSebastian Reichel };
27114c0a5b4SSebastian Reichel 
272deff82e6SSebastian Reichel static void __init nokia_n900_legacy_init(void)
273deff82e6SSebastian Reichel {
274deff82e6SSebastian Reichel 	hsmmc2_internal_input_clk();
275deff82e6SSebastian Reichel 
276deff82e6SSebastian Reichel 	if (omap_type() == OMAP2_DEVICE_TYPE_SEC) {
277deff82e6SSebastian Reichel 		if (IS_ENABLED(CONFIG_ARM_ERRATA_430973)) {
278deff82e6SSebastian Reichel 			pr_info("RX-51: Enabling ARM errata 430973 workaround\n");
279deff82e6SSebastian Reichel 			/* set IBE to 1 */
280deff82e6SSebastian Reichel 			rx51_secure_update_aux_cr(BIT(6), 0);
281deff82e6SSebastian Reichel 		} else {
2823d0cb73eSJoe Perches 			pr_warn("RX-51: Not enabling ARM errata 430973 workaround\n");
2833d0cb73eSJoe Perches 			pr_warn("Thumb binaries may crash randomly without this workaround\n");
284deff82e6SSebastian Reichel 		}
28514c0a5b4SSebastian Reichel 
28614c0a5b4SSebastian Reichel 		pr_info("RX-51: Registring OMAP3 HWRNG device\n");
28714c0a5b4SSebastian Reichel 		platform_device_register(&omap3_rom_rng_device);
28814c0a5b4SSebastian Reichel 
289deff82e6SSebastian Reichel 	}
290deff82e6SSebastian Reichel }
29163dd5bc0SStefan Roese 
29263dd5bc0SStefan Roese static void __init omap3_tao3530_legacy_init(void)
29363dd5bc0SStefan Roese {
29463dd5bc0SStefan Roese 	hsmmc2_internal_input_clk();
295faf4bd47SAaro Koskinen }
296fc53e2ccSGrazvydas Ignotas 
297*485fa126SAdam Ford static void __init omap3_logicpd_torpedo_init(void)
298*485fa126SAdam Ford {
299*485fa126SAdam Ford 	omap3_gpio126_127_129();
300*485fa126SAdam Ford 	platform_device_register(&wl128x_device);
301*485fa126SAdam Ford 	platform_device_register(&btwilink_device);
302*485fa126SAdam Ford }
303*485fa126SAdam Ford 
304f9d50fefSGrazvydas Ignotas /* omap3pandora legacy devices */
305f9d50fefSGrazvydas Ignotas #define PANDORA_WIFI_IRQ_GPIO		21
306f9d50fefSGrazvydas Ignotas #define PANDORA_WIFI_NRESET_GPIO	23
307f9d50fefSGrazvydas Ignotas 
308fc53e2ccSGrazvydas Ignotas static struct platform_device pandora_backlight = {
309fc53e2ccSGrazvydas Ignotas 	.name	= "pandora-backlight",
310fc53e2ccSGrazvydas Ignotas 	.id	= -1,
311fc53e2ccSGrazvydas Ignotas };
312fc53e2ccSGrazvydas Ignotas 
313f9d50fefSGrazvydas Ignotas static struct regulator_consumer_supply pandora_vmmc3_supply[] = {
314f9d50fefSGrazvydas Ignotas 	REGULATOR_SUPPLY("vmmc", "omap_hsmmc.2"),
315f9d50fefSGrazvydas Ignotas };
316f9d50fefSGrazvydas Ignotas 
317f9d50fefSGrazvydas Ignotas static struct regulator_init_data pandora_vmmc3 = {
318f9d50fefSGrazvydas Ignotas 	.constraints = {
319f9d50fefSGrazvydas Ignotas 		.valid_ops_mask		= REGULATOR_CHANGE_STATUS,
320f9d50fefSGrazvydas Ignotas 	},
321f9d50fefSGrazvydas Ignotas 	.num_consumer_supplies	= ARRAY_SIZE(pandora_vmmc3_supply),
322f9d50fefSGrazvydas Ignotas 	.consumer_supplies	= pandora_vmmc3_supply,
323f9d50fefSGrazvydas Ignotas };
324f9d50fefSGrazvydas Ignotas 
325f9d50fefSGrazvydas Ignotas static struct fixed_voltage_config pandora_vwlan = {
326f9d50fefSGrazvydas Ignotas 	.supply_name		= "vwlan",
327f9d50fefSGrazvydas Ignotas 	.microvolts		= 1800000, /* 1.8V */
328f9d50fefSGrazvydas Ignotas 	.gpio			= PANDORA_WIFI_NRESET_GPIO,
329f9d50fefSGrazvydas Ignotas 	.startup_delay		= 50000, /* 50ms */
330f9d50fefSGrazvydas Ignotas 	.enable_high		= 1,
331f9d50fefSGrazvydas Ignotas 	.init_data		= &pandora_vmmc3,
332f9d50fefSGrazvydas Ignotas };
333f9d50fefSGrazvydas Ignotas 
334f9d50fefSGrazvydas Ignotas static struct platform_device pandora_vwlan_device = {
335f9d50fefSGrazvydas Ignotas 	.name		= "reg-fixed-voltage",
336f9d50fefSGrazvydas Ignotas 	.id		= 1,
337f9d50fefSGrazvydas Ignotas 	.dev = {
338f9d50fefSGrazvydas Ignotas 		.platform_data = &pandora_vwlan,
339f9d50fefSGrazvydas Ignotas 	},
340f9d50fefSGrazvydas Ignotas };
341f9d50fefSGrazvydas Ignotas 
342f9d50fefSGrazvydas Ignotas static void pandora_wl1251_init_card(struct mmc_card *card)
343f9d50fefSGrazvydas Ignotas {
344f9d50fefSGrazvydas Ignotas 	/*
345f9d50fefSGrazvydas Ignotas 	 * We have TI wl1251 attached to MMC3. Pass this information to
346f9d50fefSGrazvydas Ignotas 	 * SDIO core because it can't be probed by normal methods.
347f9d50fefSGrazvydas Ignotas 	 */
348f9d50fefSGrazvydas Ignotas 	if (card->type == MMC_TYPE_SDIO || card->type == MMC_TYPE_SD_COMBO) {
349f9d50fefSGrazvydas Ignotas 		card->quirks |= MMC_QUIRK_NONSTD_SDIO;
350f9d50fefSGrazvydas Ignotas 		card->cccr.wide_bus = 1;
351f9d50fefSGrazvydas Ignotas 		card->cis.vendor = 0x104c;
352f9d50fefSGrazvydas Ignotas 		card->cis.device = 0x9066;
353f9d50fefSGrazvydas Ignotas 		card->cis.blksize = 512;
354f9d50fefSGrazvydas Ignotas 		card->cis.max_dtr = 24000000;
355f9d50fefSGrazvydas Ignotas 		card->ocr = 0x80;
356f9d50fefSGrazvydas Ignotas 	}
357f9d50fefSGrazvydas Ignotas }
358f9d50fefSGrazvydas Ignotas 
359f9d50fefSGrazvydas Ignotas static struct omap2_hsmmc_info pandora_mmc3[] = {
360f9d50fefSGrazvydas Ignotas 	{
361f9d50fefSGrazvydas Ignotas 		.mmc		= 3,
362f9d50fefSGrazvydas Ignotas 		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
363f9d50fefSGrazvydas Ignotas 		.gpio_cd	= -EINVAL,
364f9d50fefSGrazvydas Ignotas 		.gpio_wp	= -EINVAL,
365f9d50fefSGrazvydas Ignotas 		.init_card	= pandora_wl1251_init_card,
366f9d50fefSGrazvydas Ignotas 	},
367f9d50fefSGrazvydas Ignotas 	{}	/* Terminator */
368f9d50fefSGrazvydas Ignotas };
369f9d50fefSGrazvydas Ignotas 
370f9d50fefSGrazvydas Ignotas static void __init pandora_wl1251_init(void)
371f9d50fefSGrazvydas Ignotas {
372f9d50fefSGrazvydas Ignotas 	struct wl1251_platform_data pandora_wl1251_pdata;
373f9d50fefSGrazvydas Ignotas 	int ret;
374f9d50fefSGrazvydas Ignotas 
375f9d50fefSGrazvydas Ignotas 	memset(&pandora_wl1251_pdata, 0, sizeof(pandora_wl1251_pdata));
376f9d50fefSGrazvydas Ignotas 
377f9d50fefSGrazvydas Ignotas 	pandora_wl1251_pdata.power_gpio = -1;
378f9d50fefSGrazvydas Ignotas 
379f9d50fefSGrazvydas Ignotas 	ret = gpio_request_one(PANDORA_WIFI_IRQ_GPIO, GPIOF_IN, "wl1251 irq");
380f9d50fefSGrazvydas Ignotas 	if (ret < 0)
381f9d50fefSGrazvydas Ignotas 		goto fail;
382f9d50fefSGrazvydas Ignotas 
383f9d50fefSGrazvydas Ignotas 	pandora_wl1251_pdata.irq = gpio_to_irq(PANDORA_WIFI_IRQ_GPIO);
384f9d50fefSGrazvydas Ignotas 	if (pandora_wl1251_pdata.irq < 0)
385f9d50fefSGrazvydas Ignotas 		goto fail_irq;
386f9d50fefSGrazvydas Ignotas 
387f9d50fefSGrazvydas Ignotas 	pandora_wl1251_pdata.use_eeprom = true;
388f9d50fefSGrazvydas Ignotas 	ret = wl1251_set_platform_data(&pandora_wl1251_pdata);
389f9d50fefSGrazvydas Ignotas 	if (ret < 0)
390f9d50fefSGrazvydas Ignotas 		goto fail_irq;
391f9d50fefSGrazvydas Ignotas 
392f9d50fefSGrazvydas Ignotas 	return;
393f9d50fefSGrazvydas Ignotas 
394f9d50fefSGrazvydas Ignotas fail_irq:
395f9d50fefSGrazvydas Ignotas 	gpio_free(PANDORA_WIFI_IRQ_GPIO);
396f9d50fefSGrazvydas Ignotas fail:
397f9d50fefSGrazvydas Ignotas 	pr_err("wl1251 board initialisation failed\n");
398f9d50fefSGrazvydas Ignotas }
399f9d50fefSGrazvydas Ignotas 
400fc53e2ccSGrazvydas Ignotas static void __init omap3_pandora_legacy_init(void)
401fc53e2ccSGrazvydas Ignotas {
402fc53e2ccSGrazvydas Ignotas 	platform_device_register(&pandora_backlight);
403f9d50fefSGrazvydas Ignotas 	platform_device_register(&pandora_vwlan_device);
404f9d50fefSGrazvydas Ignotas 	omap_hsmmc_init(pandora_mmc3);
405f9d50fefSGrazvydas Ignotas 	omap_hsmmc_late_init(pandora_mmc3);
406f9d50fefSGrazvydas Ignotas 	pandora_wl1251_init();
407fc53e2ccSGrazvydas Ignotas }
408faf4bd47SAaro Koskinen #endif /* CONFIG_ARCH_OMAP3 */
409faf4bd47SAaro Koskinen 
410f5887fe5STony Lindgren #ifdef CONFIG_SOC_TI81XX
411f5887fe5STony Lindgren static int fault_fixed_up;
412f5887fe5STony Lindgren 
413f5887fe5STony Lindgren static int t410_abort_handler(unsigned long addr, unsigned int fsr,
414f5887fe5STony Lindgren 			      struct pt_regs *regs)
415f5887fe5STony Lindgren {
416f5887fe5STony Lindgren 	if ((fsr == 0x406 || fsr == 0xc06) && !fault_fixed_up) {
417f5887fe5STony Lindgren 		pr_warn("External imprecise Data abort at addr=%#lx, fsr=%#x ignored.\n",
418f5887fe5STony Lindgren 			addr, fsr);
419f5887fe5STony Lindgren 		fault_fixed_up = 1;
420f5887fe5STony Lindgren 		return 0;
421f5887fe5STony Lindgren 	}
422f5887fe5STony Lindgren 
423f5887fe5STony Lindgren 	return 1;
424f5887fe5STony Lindgren }
425f5887fe5STony Lindgren 
426f5887fe5STony Lindgren static void __init t410_abort_init(void)
427f5887fe5STony Lindgren {
428f5887fe5STony Lindgren 	hook_fault_code(16 + 6, t410_abort_handler, SIGBUS, BUS_OBJERR,
429f5887fe5STony Lindgren 			"imprecise external abort");
430f5887fe5STony Lindgren }
431f5887fe5STony Lindgren #endif
432f5887fe5STony Lindgren 
43367eb1e6eSSuman Anna #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
434910f1678SSuman Anna static struct iommu_platform_data omap4_iommu_pdata = {
435910f1678SSuman Anna 	.reset_name = "mmu_cache",
436910f1678SSuman Anna 	.assert_reset = omap_device_assert_hardreset,
437910f1678SSuman Anna 	.deassert_reset = omap_device_deassert_hardreset,
438910f1678SSuman Anna };
4393e7a3185STony Lindgren #endif
4403e7a3185STony Lindgren 
4416da74c54SDave Gerlach #if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
4426da74c54SDave Gerlach static struct wkup_m3_platform_data wkup_m3_data = {
4436da74c54SDave Gerlach 	.reset_name = "wkup_m3",
4446da74c54SDave Gerlach 	.assert_reset = omap_device_assert_hardreset,
4456da74c54SDave Gerlach 	.deassert_reset = omap_device_deassert_hardreset,
4466da74c54SDave Gerlach };
4476da74c54SDave Gerlach #endif
4486da74c54SDave Gerlach 
4493e7a3185STony Lindgren #ifdef CONFIG_SOC_OMAP5
4503e7a3185STony Lindgren static void __init omap5_uevm_legacy_init(void)
4513e7a3185STony Lindgren {
4523e7a3185STony Lindgren }
4533e7a3185STony Lindgren #endif
4543e7a3185STony Lindgren 
45530a69ef7STony Lindgren static struct pcs_pdata pcs_pdata;
45630a69ef7STony Lindgren 
45730a69ef7STony Lindgren void omap_pcs_legacy_init(int irq, void (*rearm)(void))
45830a69ef7STony Lindgren {
45930a69ef7STony Lindgren 	pcs_pdata.irq = irq;
46030a69ef7STony Lindgren 	pcs_pdata.rearm = rearm;
46130a69ef7STony Lindgren }
46230a69ef7STony Lindgren 
463036582f7STony Lindgren /*
464dad12d11STony Lindgren  * GPIOs for TWL are initialized by the I2C bus and need custom
465dad12d11STony Lindgren  * handing until DSS has device tree bindings.
466dad12d11STony Lindgren  */
467dad12d11STony Lindgren void omap_auxdata_legacy_init(struct device *dev)
468dad12d11STony Lindgren {
469dad12d11STony Lindgren 	if (dev->platform_data)
470dad12d11STony Lindgren 		return;
471dad12d11STony Lindgren 
472dad12d11STony Lindgren 	if (strcmp("twl4030-gpio", dev_name(dev)))
473dad12d11STony Lindgren 		return;
474dad12d11STony Lindgren 
475dad12d11STony Lindgren 	dev->platform_data = &twl_gpio_auxdata;
476dad12d11STony Lindgren }
477dad12d11STony Lindgren 
478dad12d11STony Lindgren /*
479036582f7STony Lindgren  * Few boards still need auxdata populated before we populate
480036582f7STony Lindgren  * the dev entries in of_platform_populate().
481036582f7STony Lindgren  */
482036582f7STony Lindgren static struct pdata_init auxdata_quirks[] __initdata = {
483fa590c92STony Lindgren #ifdef CONFIG_SOC_OMAP2420
484fa590c92STony Lindgren 	{ "nokia,n800", omap2420_n8x0_legacy_init, },
485fa590c92STony Lindgren 	{ "nokia,n810", omap2420_n8x0_legacy_init, },
486fa590c92STony Lindgren 	{ "nokia,n810-wimax", omap2420_n8x0_legacy_init, },
487fa590c92STony Lindgren #endif
4880f0cfc69STony Lindgren #ifdef CONFIG_ARCH_OMAP3
4890f0cfc69STony Lindgren 	{ "compulab,omap3-sbc-t3730", omap3_sbc_t3730_twl_init, },
4900f0cfc69STony Lindgren #endif
491036582f7STony Lindgren 	{ /* sentinel */ },
492036582f7STony Lindgren };
493036582f7STony Lindgren 
494f734a9b3SSekhar Nori static struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
495036582f7STony Lindgren #ifdef CONFIG_MACH_NOKIA_N8X0
496036582f7STony Lindgren 	OF_DEV_AUXDATA("ti,omap2420-mmc", 0x4809c000, "mmci-omap.0", NULL),
497e92ce89cSFelipe Balbi 	OF_DEV_AUXDATA("menelaus", 0x72, "1-0072", &n8x0_menelaus_platform_data),
498e92ce89cSFelipe Balbi 	OF_DEV_AUXDATA("tlv320aic3x", 0x18, "2-0018", &n810_aic33_data),
499036582f7STony Lindgren #endif
50030a69ef7STony Lindgren #ifdef CONFIG_ARCH_OMAP3
50130a69ef7STony Lindgren 	OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002030, "48002030.pinmux", &pcs_pdata),
5024b416368STony Lindgren 	OF_DEV_AUXDATA("ti,omap3-padconf", 0x480025a0, "480025a0.pinmux", &pcs_pdata),
50330a69ef7STony Lindgren 	OF_DEV_AUXDATA("ti,omap3-padconf", 0x48002a00, "48002a00.pinmux", &pcs_pdata),
504910f1678SSuman Anna 	OF_DEV_AUXDATA("ti,omap2-iommu", 0x5d000000, "5d000000.mmu",
505910f1678SSuman Anna 		       &omap3_iommu_pdata),
50671900314STony Lindgren 	/* Only on am3517 */
50771900314STony Lindgren 	OF_DEV_AUXDATA("ti,davinci_mdio", 0x5c030000, "davinci_mdio.0", NULL),
50871900314STony Lindgren 	OF_DEV_AUXDATA("ti,am3517-emac", 0x5c000000, "davinci_emac.0",
50971900314STony Lindgren 		       &am35xx_emac_pdata),
51030a69ef7STony Lindgren #endif
5116da74c54SDave Gerlach #ifdef CONFIG_SOC_AM33XX
5126da74c54SDave Gerlach 	OF_DEV_AUXDATA("ti,am3352-wkup-m3", 0x44d00000, "44d00000.wkup_m3",
5136da74c54SDave Gerlach 		       &wkup_m3_data),
5146da74c54SDave Gerlach #endif
51530a69ef7STony Lindgren #ifdef CONFIG_ARCH_OMAP4
51630a69ef7STony Lindgren 	OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a100040, "4a100040.pinmux", &pcs_pdata),
51730a69ef7STony Lindgren 	OF_DEV_AUXDATA("ti,omap4-padconf", 0x4a31e040, "4a31e040.pinmux", &pcs_pdata),
51830a69ef7STony Lindgren #endif
519874fef7dSNishanth Menon #ifdef CONFIG_SOC_OMAP5
520874fef7dSNishanth Menon 	OF_DEV_AUXDATA("ti,omap5-padconf", 0x4a002840, "4a002840.pinmux", &pcs_pdata),
521874fef7dSNishanth Menon 	OF_DEV_AUXDATA("ti,omap5-padconf", 0x4ae0c840, "4ae0c840.pinmux", &pcs_pdata),
522874fef7dSNishanth Menon #endif
523b0a3d0daSNishanth Menon #ifdef CONFIG_SOC_DRA7XX
524b0a3d0daSNishanth Menon 	OF_DEV_AUXDATA("ti,dra7-padconf", 0x4a003400, "4a003400.pinmux", &pcs_pdata),
525b0a3d0daSNishanth Menon #endif
526dbbe9770SKeerthy #ifdef CONFIG_SOC_AM43XX
527dbbe9770SKeerthy 	OF_DEV_AUXDATA("ti,am437-padconf", 0x44e10800, "44e10800.pinmux", &pcs_pdata),
5286da74c54SDave Gerlach 	OF_DEV_AUXDATA("ti,am4372-wkup-m3", 0x44d00000, "44d00000.wkup_m3",
5296da74c54SDave Gerlach 		       &wkup_m3_data),
530dbbe9770SKeerthy #endif
53167eb1e6eSSuman Anna #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
532910f1678SSuman Anna 	OF_DEV_AUXDATA("ti,omap4-iommu", 0x4a066000, "4a066000.mmu",
533910f1678SSuman Anna 		       &omap4_iommu_pdata),
534910f1678SSuman Anna 	OF_DEV_AUXDATA("ti,omap4-iommu", 0x55082000, "55082000.mmu",
535910f1678SSuman Anna 		       &omap4_iommu_pdata),
5366a08e1e6STony Lindgren #endif
5376a08e1e6STony Lindgren 	{ /* sentinel */ },
5388651bd8cSTony Lindgren };
5396a08e1e6STony Lindgren 
540036582f7STony Lindgren /*
541036582f7STony Lindgren  * Few boards still need to initialize some legacy devices with
542036582f7STony Lindgren  * platform data until the drivers support device tree.
543036582f7STony Lindgren  */
5446a08e1e6STony Lindgren static struct pdata_init pdata_quirks[] __initdata = {
5456a08e1e6STony Lindgren #ifdef CONFIG_ARCH_OMAP3
546fb45105aSDmitry Lifshitz 	{ "compulab,omap3-sbc-t3517", omap3_sbc_t3517_legacy_init, },
54740ecc02eSDmitry Lifshitz 	{ "compulab,omap3-sbc-t3530", omap3_sbc_t3530_legacy_init, },
5480f0cfc69STony Lindgren 	{ "compulab,omap3-sbc-t3730", omap3_sbc_t3730_legacy_init, },
549deff82e6SSebastian Reichel 	{ "nokia,omap3-n900", nokia_n900_legacy_init, },
5506a08e1e6STony Lindgren 	{ "nokia,omap3-n9", hsmmc2_internal_input_clk, },
5516a08e1e6STony Lindgren 	{ "nokia,omap3-n950", hsmmc2_internal_input_clk, },
552d565b5f4SEnric Balletbo i Serra 	{ "isee,omap3-igep0020-rev-f", omap3_igep0020_rev_f_legacy_init, },
553d565b5f4SEnric Balletbo i Serra 	{ "isee,omap3-igep0030-rev-g", omap3_igep0030_rev_g_legacy_init, },
554*485fa126SAdam Ford 	{ "logicpd,dm3730-torpedo-devkit", omap3_logicpd_torpedo_init, },
55579b39f79STony Lindgren 	{ "ti,omap3-evm-37xx", omap3_evm_legacy_init, },
55671900314STony Lindgren 	{ "ti,am3517-evm", am3517_evm_legacy_init, },
55763dd5bc0SStefan Roese 	{ "technexion,omap3-tao3530", omap3_tao3530_legacy_init, },
558fc53e2ccSGrazvydas Ignotas 	{ "openpandora,omap3-pandora-600mhz", omap3_pandora_legacy_init, },
559fc53e2ccSGrazvydas Ignotas 	{ "openpandora,omap3-pandora-1ghz", omap3_pandora_legacy_init, },
5606a08e1e6STony Lindgren #endif
561f5887fe5STony Lindgren #ifdef CONFIG_SOC_TI81XX
562f5887fe5STony Lindgren 	{ "hp,t410", t410_abort_init, },
5636a08e1e6STony Lindgren #endif
5646a08e1e6STony Lindgren #ifdef CONFIG_SOC_OMAP5
5656a08e1e6STony Lindgren 	{ "ti,omap5-uevm", omap5_uevm_legacy_init, },
5666a08e1e6STony Lindgren #endif
5676a08e1e6STony Lindgren 	{ /* sentinel */ },
5686a08e1e6STony Lindgren };
5696a08e1e6STony Lindgren 
570036582f7STony Lindgren static void pdata_quirks_check(struct pdata_init *quirks)
5716a08e1e6STony Lindgren {
5726a08e1e6STony Lindgren 	while (quirks->compatible) {
5736a08e1e6STony Lindgren 		if (of_machine_is_compatible(quirks->compatible)) {
5746a08e1e6STony Lindgren 			if (quirks->fn)
5756a08e1e6STony Lindgren 				quirks->fn();
5766a08e1e6STony Lindgren 			break;
5776a08e1e6STony Lindgren 		}
5786a08e1e6STony Lindgren 		quirks++;
5796a08e1e6STony Lindgren 	}
5806a08e1e6STony Lindgren }
581036582f7STony Lindgren 
58231957609SUwe Kleine-König void __init pdata_quirks_init(const struct of_device_id *omap_dt_match_table)
583036582f7STony Lindgren {
58457df5380STony Lindgren 	/*
58557df5380STony Lindgren 	 * We still need this for omap2420 and omap3 PM to work, others are
58657df5380STony Lindgren 	 * using drivers/misc/sram.c already.
58757df5380STony Lindgren 	 */
58857df5380STony Lindgren 	if (of_machine_is_compatible("ti,omap2420") ||
58957df5380STony Lindgren 	    of_machine_is_compatible("ti,omap3"))
590036582f7STony Lindgren 		omap_sdrc_init(NULL, NULL);
59157df5380STony Lindgren 
592036582f7STony Lindgren 	pdata_quirks_check(auxdata_quirks);
593036582f7STony Lindgren 	of_platform_populate(NULL, omap_dt_match_table,
594036582f7STony Lindgren 			     omap_auxdata_lookup, NULL);
595036582f7STony Lindgren 	pdata_quirks_check(pdata_quirks);
596036582f7STony Lindgren }
597