xref: /linux/arch/arm/mach-omap2/pdata-quirks.c (revision 319e6ac143b9e9048e527ab9dd2aabb8fdf3d60f)
1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
26a08e1e6STony Lindgren /*
36a08e1e6STony Lindgren  * Legacy platform_data quirks
46a08e1e6STony Lindgren  *
56a08e1e6STony Lindgren  * Copyright (C) 2013 Texas Instruments
66a08e1e6STony Lindgren  */
76a08e1e6STony Lindgren #include <linux/clk.h>
871900314STony Lindgren #include <linux/davinci_emac.h>
9d5f4fa60SLinus Walleij #include <linux/gpio/machine.h>
10d74e3166SArnd Bergmann #include <linux/gpio/consumer.h>
116a08e1e6STony Lindgren #include <linux/init.h>
126a08e1e6STony Lindgren #include <linux/kernel.h>
138651bd8cSTony Lindgren #include <linux/of_platform.h>
14f9d50fefSGrazvydas Ignotas #include <linux/mmc/card.h>
15f9d50fefSGrazvydas Ignotas #include <linux/mmc/host.h>
16d060b405STony Lindgren #include <linux/power/smartreflex.h>
17f9d50fefSGrazvydas Ignotas #include <linux/regulator/machine.h>
18f9d50fefSGrazvydas Ignotas #include <linux/regulator/fixed.h>
196a08e1e6STony Lindgren 
2030a69ef7STony Lindgren #include <linux/platform_data/pinctrl-single.h>
2110c1f7d3STony Lindgren #include <linux/platform_data/hsmmc-omap.h>
22910f1678SSuman Anna #include <linux/platform_data/iommu-omap.h>
23ef70b0bdSTony Lindgren #include <linux/platform_data/ti-sysc.h>
246da74c54SDave Gerlach #include <linux/platform_data/wkup_m3.h>
25c26c84c9SPeter Ujfalusi #include <linux/platform_data/asoc-ti-mcbsp.h>
268de44fb7STero Kristo #include <linux/platform_data/ti-prm.h>
2730a69ef7STony Lindgren 
282b2f7defSTony Lindgren #include "clockdomain.h"
296a08e1e6STony Lindgren #include "common.h"
306a08e1e6STony Lindgren #include "common-board-devices.h"
31faf4bd47SAaro Koskinen #include "control.h"
32910f1678SSuman Anna #include "omap_device.h"
33deff82e6SSebastian Reichel #include "omap-secure.h"
34deff82e6SSebastian Reichel #include "soc.h"
356a08e1e6STony Lindgren 
3610c1f7d3STony Lindgren static struct omap_hsmmc_platform_data __maybe_unused mmc_pdata[2];
3710c1f7d3STony Lindgren 
386a08e1e6STony Lindgren struct pdata_init {
396a08e1e6STony Lindgren 	const char *compatible;
406a08e1e6STony Lindgren 	void (*fn)(void);
416a08e1e6STony Lindgren };
426a08e1e6STony Lindgren 
43f734a9b3SSekhar Nori static struct of_dev_auxdata omap_auxdata_lookup[];
44fa590c92STony Lindgren 
45fa590c92STony Lindgren #ifdef CONFIG_MACH_NOKIA_N8X0
46fa590c92STony Lindgren static void __init omap2420_n8x0_legacy_init(void)
47fa590c92STony Lindgren {
48fa590c92STony Lindgren 	omap_auxdata_lookup[0].platform_data = n8x0_legacy_init();
49fa590c92STony Lindgren }
50fa590c92STony Lindgren #else
51fa590c92STony Lindgren #define omap2420_n8x0_legacy_init	NULL
52fa590c92STony Lindgren #endif
53fa590c92STony Lindgren 
54faf4bd47SAaro Koskinen #ifdef CONFIG_ARCH_OMAP3
55b96b332fSTony Lindgren /*
56b96b332fSTony Lindgren  * Configures GPIOs 126, 127 and 129 to 1.8V mode instead of 3.0V
57b96b332fSTony Lindgren  * mode for MMC1 in case bootloader did not configure things.
58b96b332fSTony Lindgren  * Note that if the pins are used for MMC1, pbias-regulator
59b96b332fSTony Lindgren  * manages the IO voltage.
60b96b332fSTony Lindgren  */
61b96b332fSTony Lindgren static void __init omap3_gpio126_127_129(void)
62b96b332fSTony Lindgren {
63b96b332fSTony Lindgren 	u32 reg;
64b96b332fSTony Lindgren 
65b96b332fSTony Lindgren 	reg = omap_ctrl_readl(OMAP343X_CONTROL_PBIAS_LITE);
66b96b332fSTony Lindgren 	reg &= ~OMAP343X_PBIASLITEVMODE1;
67b96b332fSTony Lindgren 	reg |= OMAP343X_PBIASLITEPWRDNZ1;
68b96b332fSTony Lindgren 	omap_ctrl_writel(reg, OMAP343X_CONTROL_PBIAS_LITE);
69b96b332fSTony Lindgren 	if (cpu_is_omap3630()) {
70b96b332fSTony Lindgren 		reg = omap_ctrl_readl(OMAP34XX_CONTROL_WKUP_CTRL);
71b96b332fSTony Lindgren 		reg |= OMAP36XX_GPIO_IO_PWRDNZ;
72b96b332fSTony Lindgren 		omap_ctrl_writel(reg, OMAP34XX_CONTROL_WKUP_CTRL);
73b96b332fSTony Lindgren 	}
74b96b332fSTony Lindgren }
75b96b332fSTony Lindgren 
76faf4bd47SAaro Koskinen static void __init hsmmc2_internal_input_clk(void)
77faf4bd47SAaro Koskinen {
78faf4bd47SAaro Koskinen 	u32 reg;
79faf4bd47SAaro Koskinen 
80faf4bd47SAaro Koskinen 	reg = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1);
81faf4bd47SAaro Koskinen 	reg |= OMAP2_MMCSDIO2ADPCLKISEL;
82faf4bd47SAaro Koskinen 	omap_ctrl_writel(reg, OMAP343X_CONTROL_DEVCONF1);
83faf4bd47SAaro Koskinen }
8415c9887eSJavier Martinez Canillas 
85133ad7abSTony Lindgren #ifdef CONFIG_OMAP_HWMOD
86910f1678SSuman Anna static struct iommu_platform_data omap3_iommu_pdata = {
87910f1678SSuman Anna 	.reset_name = "mmu",
88910f1678SSuman Anna 	.assert_reset = omap_device_assert_hardreset,
89910f1678SSuman Anna 	.deassert_reset = omap_device_deassert_hardreset,
9019feeee5SSuman Anna 	.device_enable = omap_device_enable,
9119feeee5SSuman Anna 	.device_idle = omap_device_idle,
92910f1678SSuman Anna };
93910f1678SSuman Anna 
940af3e1a4SSuman Anna static struct iommu_platform_data omap3_iommu_isp_pdata = {
950af3e1a4SSuman Anna 	.device_enable = omap_device_enable,
960af3e1a4SSuman Anna 	.device_idle = omap_device_idle,
970af3e1a4SSuman Anna };
98133ad7abSTony Lindgren #endif
990af3e1a4SSuman Anna 
10094075d16SLinus Walleij static void __init omap3_sbc_t3x_usb_hub_init(char *hub_name, int idx)
101b62d91e5SDmitry Lifshitz {
10294075d16SLinus Walleij 	struct gpio_desc *d;
103b62d91e5SDmitry Lifshitz 
10494075d16SLinus Walleij 	/* This asserts the RESET line (reverse polarity) */
10594075d16SLinus Walleij 	d = gpiod_get_index(NULL, "reset", idx, GPIOD_OUT_HIGH);
10694075d16SLinus Walleij 	if (IS_ERR(d)) {
10794075d16SLinus Walleij 		pr_err("Unable to get T3x USB reset GPIO descriptor\n");
108b62d91e5SDmitry Lifshitz 		return;
109b62d91e5SDmitry Lifshitz 	}
11094075d16SLinus Walleij 	gpiod_set_consumer_name(d, hub_name);
11194075d16SLinus Walleij 	gpiod_export(d, 0);
112b62d91e5SDmitry Lifshitz 	udelay(10);
11394075d16SLinus Walleij 	/* De-assert RESET */
11494075d16SLinus Walleij 	gpiod_set_value(d, 0);
115b62d91e5SDmitry Lifshitz 	msleep(1);
116b62d91e5SDmitry Lifshitz }
117b62d91e5SDmitry Lifshitz 
11894075d16SLinus Walleij static struct gpiod_lookup_table omap3_sbc_t3x_usb_gpio_table = {
11994075d16SLinus Walleij 	.dev_id = NULL,
12094075d16SLinus Walleij 	.table = {
12194075d16SLinus Walleij 		GPIO_LOOKUP_IDX("gpio-160-175", 7, "reset", 0,
12294075d16SLinus Walleij 				GPIO_ACTIVE_LOW),
12394075d16SLinus Walleij 		{ }
12494075d16SLinus Walleij 	},
12594075d16SLinus Walleij };
12694075d16SLinus Walleij 
1270f0cfc69STony Lindgren static void __init omap3_sbc_t3730_legacy_init(void)
1280f0cfc69STony Lindgren {
12994075d16SLinus Walleij 	gpiod_add_lookup_table(&omap3_sbc_t3x_usb_gpio_table);
13094075d16SLinus Walleij 	omap3_sbc_t3x_usb_hub_init("sb-t35 usb hub", 0);
1310f0cfc69STony Lindgren }
1320f0cfc69STony Lindgren 
13340ecc02eSDmitry Lifshitz static void __init omap3_sbc_t3530_legacy_init(void)
13440ecc02eSDmitry Lifshitz {
13594075d16SLinus Walleij 	gpiod_add_lookup_table(&omap3_sbc_t3x_usb_gpio_table);
13694075d16SLinus Walleij 	omap3_sbc_t3x_usb_hub_init("sb-t35 usb hub", 0);
13740ecc02eSDmitry Lifshitz }
13840ecc02eSDmitry Lifshitz 
13979b39f79STony Lindgren static void __init omap3_evm_legacy_init(void)
14079b39f79STony Lindgren {
1415b7610f2STony Lindgren 	hsmmc2_internal_input_clk();
14279b39f79STony Lindgren }
14371900314STony Lindgren 
14471900314STony Lindgren static void am35xx_enable_emac_int(void)
14571900314STony Lindgren {
14671900314STony Lindgren 	u32 v;
14771900314STony Lindgren 
14871900314STony Lindgren 	v = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
14971900314STony Lindgren 	v |= (AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR |
15071900314STony Lindgren 	      AM35XX_CPGMAC_C0_MISC_PULSE_CLR | AM35XX_CPGMAC_C0_RX_THRESH_CLR);
15171900314STony Lindgren 	omap_ctrl_writel(v, AM35XX_CONTROL_LVL_INTR_CLEAR);
15271900314STony Lindgren 	omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); /* OCP barrier */
15371900314STony Lindgren }
15471900314STony Lindgren 
15571900314STony Lindgren static void am35xx_disable_emac_int(void)
15671900314STony Lindgren {
15771900314STony Lindgren 	u32 v;
15871900314STony Lindgren 
15971900314STony Lindgren 	v = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
16071900314STony Lindgren 	v |= (AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR);
16171900314STony Lindgren 	omap_ctrl_writel(v, AM35XX_CONTROL_LVL_INTR_CLEAR);
16271900314STony Lindgren 	omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); /* OCP barrier */
16371900314STony Lindgren }
16471900314STony Lindgren 
16571900314STony Lindgren static struct emac_platform_data am35xx_emac_pdata = {
16671900314STony Lindgren 	.interrupt_enable	= am35xx_enable_emac_int,
16771900314STony Lindgren 	.interrupt_disable	= am35xx_disable_emac_int,
16871900314STony Lindgren };
16971900314STony Lindgren 
170fb45105aSDmitry Lifshitz static void __init am35xx_emac_reset(void)
17171900314STony Lindgren {
17271900314STony Lindgren 	u32 v;
17371900314STony Lindgren 
17471900314STony Lindgren 	v = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
17571900314STony Lindgren 	v &= ~AM35XX_CPGMACSS_SW_RST;
17671900314STony Lindgren 	omap_ctrl_writel(v, AM35XX_CONTROL_IP_SW_RESET);
17771900314STony Lindgren 	omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); /* OCP barrier */
17871900314STony Lindgren }
179deff82e6SSebastian Reichel 
180078dc519SLinus Walleij static struct gpiod_lookup_table cm_t3517_wlan_gpio_table = {
181078dc519SLinus Walleij 	.dev_id = NULL,
182078dc519SLinus Walleij 	.table = {
183078dc519SLinus Walleij 		GPIO_LOOKUP("gpio-48-53", 8, "power",
184078dc519SLinus Walleij 			    GPIO_ACTIVE_HIGH),
185078dc519SLinus Walleij 		GPIO_LOOKUP("gpio-0-15", 4, "noe",
186078dc519SLinus Walleij 			    GPIO_ACTIVE_HIGH),
187078dc519SLinus Walleij 		{ }
188078dc519SLinus Walleij 	},
189fb45105aSDmitry Lifshitz };
190fb45105aSDmitry Lifshitz 
191fb45105aSDmitry Lifshitz static void __init omap3_sbc_t3517_wifi_init(void)
192fb45105aSDmitry Lifshitz {
193078dc519SLinus Walleij 	struct gpio_desc *d;
194078dc519SLinus Walleij 
195078dc519SLinus Walleij 	gpiod_add_lookup_table(&cm_t3517_wlan_gpio_table);
196078dc519SLinus Walleij 
197078dc519SLinus Walleij 	/* This asserts the RESET line (reverse polarity) */
198078dc519SLinus Walleij 	d = gpiod_get(NULL, "power", GPIOD_OUT_HIGH);
199078dc519SLinus Walleij 	if (IS_ERR(d)) {
200078dc519SLinus Walleij 		pr_err("Unable to get CM T3517 WLAN power GPIO descriptor\n");
201078dc519SLinus Walleij 	} else {
202078dc519SLinus Walleij 		gpiod_set_consumer_name(d, "wlan pwr");
203078dc519SLinus Walleij 		gpiod_export(d, 0);
204fb45105aSDmitry Lifshitz 	}
205fb45105aSDmitry Lifshitz 
206078dc519SLinus Walleij 	d = gpiod_get(NULL, "noe", GPIOD_OUT_HIGH);
207078dc519SLinus Walleij 	if (IS_ERR(d)) {
208078dc519SLinus Walleij 		pr_err("Unable to get CM T3517 WLAN XCVR NOE GPIO descriptor\n");
209078dc519SLinus Walleij 	} else {
210078dc519SLinus Walleij 		gpiod_set_consumer_name(d, "xcvr noe");
211078dc519SLinus Walleij 		gpiod_export(d, 0);
212078dc519SLinus Walleij 	}
213fb45105aSDmitry Lifshitz 	msleep(100);
214078dc519SLinus Walleij 	gpiod_set_value(d, 0);
215fb45105aSDmitry Lifshitz }
216fb45105aSDmitry Lifshitz 
21794075d16SLinus Walleij static struct gpiod_lookup_table omap3_sbc_t3517_usb_gpio_table = {
21894075d16SLinus Walleij 	.dev_id = NULL,
21994075d16SLinus Walleij 	.table = {
22094075d16SLinus Walleij 		GPIO_LOOKUP_IDX("gpio-144-159", 8, "reset", 0,
22194075d16SLinus Walleij 				GPIO_ACTIVE_LOW),
22294075d16SLinus Walleij 		GPIO_LOOKUP_IDX("gpio-96-111", 2, "reset", 1,
22394075d16SLinus Walleij 				GPIO_ACTIVE_LOW),
22494075d16SLinus Walleij 		{ }
22594075d16SLinus Walleij 	},
22694075d16SLinus Walleij };
22794075d16SLinus Walleij 
228fb45105aSDmitry Lifshitz static void __init omap3_sbc_t3517_legacy_init(void)
229fb45105aSDmitry Lifshitz {
23094075d16SLinus Walleij 	gpiod_add_lookup_table(&omap3_sbc_t3517_usb_gpio_table);
23194075d16SLinus Walleij 	omap3_sbc_t3x_usb_hub_init("cm-t3517 usb hub", 0);
23294075d16SLinus Walleij 	omap3_sbc_t3x_usb_hub_init("sb-t35 usb hub", 1);
233fb45105aSDmitry Lifshitz 	am35xx_emac_reset();
234fb45105aSDmitry Lifshitz 	hsmmc2_internal_input_clk();
235fb45105aSDmitry Lifshitz 	omap3_sbc_t3517_wifi_init();
236fb45105aSDmitry Lifshitz }
237fb45105aSDmitry Lifshitz 
238fb45105aSDmitry Lifshitz static void __init am3517_evm_legacy_init(void)
239fb45105aSDmitry Lifshitz {
240fb45105aSDmitry Lifshitz 	am35xx_emac_reset();
241fb45105aSDmitry Lifshitz }
242f83ccb93SLinus Torvalds 
243deff82e6SSebastian Reichel static void __init nokia_n900_legacy_init(void)
244deff82e6SSebastian Reichel {
245deff82e6SSebastian Reichel 	hsmmc2_internal_input_clk();
24610c1f7d3STony Lindgren 	mmc_pdata[0].name = "external";
24710c1f7d3STony Lindgren 	mmc_pdata[1].name = "internal";
248deff82e6SSebastian Reichel 
2497fb61afbSTony Lindgren 	if (omap_type() != OMAP2_DEVICE_TYPE_GP) {
250deff82e6SSebastian Reichel 		if (IS_ENABLED(CONFIG_ARM_ERRATA_430973)) {
251deff82e6SSebastian Reichel 			pr_info("RX-51: Enabling ARM errata 430973 workaround\n");
252deff82e6SSebastian Reichel 			/* set IBE to 1 */
253deff82e6SSebastian Reichel 			rx51_secure_update_aux_cr(BIT(6), 0);
254deff82e6SSebastian Reichel 		} else {
2553d0cb73eSJoe Perches 			pr_warn("RX-51: Not enabling ARM errata 430973 workaround\n");
2563d0cb73eSJoe Perches 			pr_warn("Thumb binaries may crash randomly without this workaround\n");
257deff82e6SSebastian Reichel 		}
258deff82e6SSebastian Reichel 	}
259deff82e6SSebastian Reichel }
26063dd5bc0SStefan Roese 
26163dd5bc0SStefan Roese static void __init omap3_tao3530_legacy_init(void)
26263dd5bc0SStefan Roese {
26363dd5bc0SStefan Roese 	hsmmc2_internal_input_clk();
26415c9887eSJavier Martinez Canillas }
265fc53e2ccSGrazvydas Ignotas 
266485fa126SAdam Ford static void __init omap3_logicpd_torpedo_init(void)
267485fa126SAdam Ford {
268485fa126SAdam Ford 	omap3_gpio126_127_129();
269485fa126SAdam Ford }
270485fa126SAdam Ford 
271f9d50fefSGrazvydas Ignotas /* omap3pandora legacy devices */
272f9d50fefSGrazvydas Ignotas 
273fc53e2ccSGrazvydas Ignotas static struct platform_device pandora_backlight = {
274fc53e2ccSGrazvydas Ignotas 	.name	= "pandora-backlight",
275fc53e2ccSGrazvydas Ignotas 	.id	= -1,
276fc53e2ccSGrazvydas Ignotas };
277fc53e2ccSGrazvydas Ignotas 
278*319e6ac1SLinus Walleij static struct gpiod_lookup_table pandora_soc_audio_gpios = {
279*319e6ac1SLinus Walleij 	.dev_id = "soc-audio",
280*319e6ac1SLinus Walleij 	.table = {
281*319e6ac1SLinus Walleij 		GPIO_LOOKUP("gpio-112-127", 6, "dac", GPIO_ACTIVE_HIGH),
282*319e6ac1SLinus Walleij 		GPIO_LOOKUP("gpio-0-15", 14, "amp", GPIO_ACTIVE_HIGH),
283*319e6ac1SLinus Walleij 		{ }
284*319e6ac1SLinus Walleij 	},
285*319e6ac1SLinus Walleij };
286*319e6ac1SLinus Walleij 
287fc53e2ccSGrazvydas Ignotas static void __init omap3_pandora_legacy_init(void)
288fc53e2ccSGrazvydas Ignotas {
289fc53e2ccSGrazvydas Ignotas 	platform_device_register(&pandora_backlight);
290*319e6ac1SLinus Walleij 	gpiod_add_lookup_table(&pandora_soc_audio_gpios);
291fc53e2ccSGrazvydas Ignotas }
292faf4bd47SAaro Koskinen #endif /* CONFIG_ARCH_OMAP3 */
293faf4bd47SAaro Koskinen 
294fc66ce0bSSekhar Nori #ifdef CONFIG_SOC_DRA7XX
2954601832fSSuman Anna static struct iommu_platform_data dra7_ipu1_dsp_iommu_pdata = {
2964601832fSSuman Anna 	.set_pwrdm_constraint = omap_iommu_set_pwrdm_constraint,
2974601832fSSuman Anna };
298fc66ce0bSSekhar Nori #endif
299fc66ce0bSSekhar Nori 
3002b2f7defSTony Lindgren static struct clockdomain *ti_sysc_find_one_clockdomain(struct clk *clk)
3012b2f7defSTony Lindgren {
30290bdfa0bSTony Lindgren 	struct clk_hw *hw = __clk_get_hw(clk);
3032b2f7defSTony Lindgren 	struct clockdomain *clkdm = NULL;
3042b2f7defSTony Lindgren 	struct clk_hw_omap *hwclk;
3052b2f7defSTony Lindgren 
30690bdfa0bSTony Lindgren 	hwclk = to_clk_hw_omap(hw);
30790bdfa0bSTony Lindgren 	if (!omap2_clk_is_hw_omap(hw))
30890bdfa0bSTony Lindgren 		return NULL;
30990bdfa0bSTony Lindgren 
3102b2f7defSTony Lindgren 	if (hwclk && hwclk->clkdm_name)
3112b2f7defSTony Lindgren 		clkdm = clkdm_lookup(hwclk->clkdm_name);
3122b2f7defSTony Lindgren 
3132b2f7defSTony Lindgren 	return clkdm;
3142b2f7defSTony Lindgren }
3152b2f7defSTony Lindgren 
3162b2f7defSTony Lindgren /**
3172b2f7defSTony Lindgren  * ti_sysc_clkdm_init - find clockdomain based on clock
3182b2f7defSTony Lindgren  * @fck: device functional clock
3192b2f7defSTony Lindgren  * @ick: device interface clock
3202b2f7defSTony Lindgren  * @dev: struct device
3212b2f7defSTony Lindgren  *
3222b2f7defSTony Lindgren  * Populate clockdomain based on clock. It is needed for
3232b2f7defSTony Lindgren  * clkdm_deny_idle() and clkdm_allow_idle() for blocking clockdomain
3242b2f7defSTony Lindgren  * clockdomain idle during reset, enable and idle.
3252b2f7defSTony Lindgren  *
3262b2f7defSTony Lindgren  * Note that we assume interconnect driver manages the clocks
3272b2f7defSTony Lindgren  * and do not need to populate oh->_clk for dynamically
3282b2f7defSTony Lindgren  * allocated modules.
3292b2f7defSTony Lindgren  */
3302b2f7defSTony Lindgren static int ti_sysc_clkdm_init(struct device *dev,
3312b2f7defSTony Lindgren 			      struct clk *fck, struct clk *ick,
3322b2f7defSTony Lindgren 			      struct ti_sysc_cookie *cookie)
3332b2f7defSTony Lindgren {
3342783d063STony Lindgren 	if (!IS_ERR(fck))
3352b2f7defSTony Lindgren 		cookie->clkdm = ti_sysc_find_one_clockdomain(fck);
3362b2f7defSTony Lindgren 	if (cookie->clkdm)
3372b2f7defSTony Lindgren 		return 0;
3382783d063STony Lindgren 	if (!IS_ERR(ick))
3392b2f7defSTony Lindgren 		cookie->clkdm = ti_sysc_find_one_clockdomain(ick);
3402b2f7defSTony Lindgren 	if (cookie->clkdm)
3412b2f7defSTony Lindgren 		return 0;
3422b2f7defSTony Lindgren 
3432b2f7defSTony Lindgren 	return -ENODEV;
3442b2f7defSTony Lindgren }
3452b2f7defSTony Lindgren 
3462b2f7defSTony Lindgren static void ti_sysc_clkdm_deny_idle(struct device *dev,
3472b2f7defSTony Lindgren 				    const struct ti_sysc_cookie *cookie)
3482b2f7defSTony Lindgren {
3492b2f7defSTony Lindgren 	if (cookie->clkdm)
3502b2f7defSTony Lindgren 		clkdm_deny_idle(cookie->clkdm);
3512b2f7defSTony Lindgren }
3522b2f7defSTony Lindgren 
3532b2f7defSTony Lindgren static void ti_sysc_clkdm_allow_idle(struct device *dev,
3542b2f7defSTony Lindgren 				     const struct ti_sysc_cookie *cookie)
3552b2f7defSTony Lindgren {
3562b2f7defSTony Lindgren 	if (cookie->clkdm)
3572b2f7defSTony Lindgren 		clkdm_allow_idle(cookie->clkdm);
3582b2f7defSTony Lindgren }
3592b2f7defSTony Lindgren 
360133ad7abSTony Lindgren #ifdef CONFIG_OMAP_HWMOD
361ef70b0bdSTony Lindgren static int ti_sysc_enable_module(struct device *dev,
362ef70b0bdSTony Lindgren 				 const struct ti_sysc_cookie *cookie)
363ef70b0bdSTony Lindgren {
364ef70b0bdSTony Lindgren 	if (!cookie->data)
365ef70b0bdSTony Lindgren 		return -EINVAL;
366ef70b0bdSTony Lindgren 
367ef70b0bdSTony Lindgren 	return omap_hwmod_enable(cookie->data);
368ef70b0bdSTony Lindgren }
369ef70b0bdSTony Lindgren 
370ef70b0bdSTony Lindgren static int ti_sysc_idle_module(struct device *dev,
371ef70b0bdSTony Lindgren 			       const struct ti_sysc_cookie *cookie)
372ef70b0bdSTony Lindgren {
373ef70b0bdSTony Lindgren 	if (!cookie->data)
374ef70b0bdSTony Lindgren 		return -EINVAL;
375ef70b0bdSTony Lindgren 
376ef70b0bdSTony Lindgren 	return omap_hwmod_idle(cookie->data);
377ef70b0bdSTony Lindgren }
378ef70b0bdSTony Lindgren 
379ef70b0bdSTony Lindgren static int ti_sysc_shutdown_module(struct device *dev,
380ef70b0bdSTony Lindgren 				   const struct ti_sysc_cookie *cookie)
381ef70b0bdSTony Lindgren {
382ef70b0bdSTony Lindgren 	if (!cookie->data)
383ef70b0bdSTony Lindgren 		return -EINVAL;
384ef70b0bdSTony Lindgren 
385ef70b0bdSTony Lindgren 	return omap_hwmod_shutdown(cookie->data);
386ef70b0bdSTony Lindgren }
387133ad7abSTony Lindgren #endif	/* CONFIG_OMAP_HWMOD */
388ef70b0bdSTony Lindgren 
389feaa8baeSTony Lindgren static bool ti_sysc_soc_type_gp(void)
390feaa8baeSTony Lindgren {
391feaa8baeSTony Lindgren 	return omap_type() == OMAP2_DEVICE_TYPE_GP;
392feaa8baeSTony Lindgren }
393feaa8baeSTony Lindgren 
394ef70b0bdSTony Lindgren static struct of_dev_auxdata omap_auxdata_lookup[];
395ef70b0bdSTony Lindgren 
396ef70b0bdSTony Lindgren static struct ti_sysc_platform_data ti_sysc_pdata = {
397ef70b0bdSTony Lindgren 	.auxdata = omap_auxdata_lookup,
398feaa8baeSTony Lindgren 	.soc_type_gp = ti_sysc_soc_type_gp,
3992b2f7defSTony Lindgren 	.init_clockdomain = ti_sysc_clkdm_init,
4002b2f7defSTony Lindgren 	.clkdm_deny_idle = ti_sysc_clkdm_deny_idle,
4012b2f7defSTony Lindgren 	.clkdm_allow_idle = ti_sysc_clkdm_allow_idle,
402133ad7abSTony Lindgren #ifdef CONFIG_OMAP_HWMOD
403695eea3dSTony Lindgren 	.init_module = omap_hwmod_init_module,
404ef70b0bdSTony Lindgren 	.enable_module = ti_sysc_enable_module,
405ef70b0bdSTony Lindgren 	.idle_module = ti_sysc_idle_module,
406ef70b0bdSTony Lindgren 	.shutdown_module = ti_sysc_shutdown_module,
407133ad7abSTony Lindgren #endif
408ef70b0bdSTony Lindgren };
409ef70b0bdSTony Lindgren 
41030a69ef7STony Lindgren static struct pcs_pdata pcs_pdata;
41130a69ef7STony Lindgren 
41230a69ef7STony Lindgren void omap_pcs_legacy_init(int irq, void (*rearm)(void))
41330a69ef7STony Lindgren {
41430a69ef7STony Lindgren 	pcs_pdata.irq = irq;
41530a69ef7STony Lindgren 	pcs_pdata.rearm = rearm;
41630a69ef7STony Lindgren }
41730a69ef7STony Lindgren 
4188de44fb7STero Kristo static struct ti_prm_platform_data ti_prm_pdata = {
4198de44fb7STero Kristo 	.clkdm_deny_idle = clkdm_deny_idle,
4208de44fb7STero Kristo 	.clkdm_allow_idle = clkdm_allow_idle,
4218de44fb7STero Kristo 	.clkdm_lookup = clkdm_lookup,
4228de44fb7STero Kristo };
4238de44fb7STero Kristo 
424f21af425STony Lindgren #if defined(CONFIG_ARCH_OMAP3) && IS_ENABLED(CONFIG_SND_SOC_OMAP_MCBSP)
425c26c84c9SPeter Ujfalusi static struct omap_mcbsp_platform_data mcbsp_pdata;
426c26c84c9SPeter Ujfalusi static void __init omap3_mcbsp_init(void)
427c26c84c9SPeter Ujfalusi {
428c26c84c9SPeter Ujfalusi 	omap3_mcbsp_init_pdata_callback(&mcbsp_pdata);
429c26c84c9SPeter Ujfalusi }
430c26c84c9SPeter Ujfalusi #else
431c26c84c9SPeter Ujfalusi static void __init omap3_mcbsp_init(void) {}
432c26c84c9SPeter Ujfalusi #endif
433c26c84c9SPeter Ujfalusi 
434dad12d11STony Lindgren /*
435036582f7STony Lindgren  * Few boards still need auxdata populated before we populate
436036582f7STony Lindgren  * the dev entries in of_platform_populate().
437036582f7STony Lindgren  */
438036582f7STony Lindgren static struct pdata_init auxdata_quirks[] __initdata = {
439fa590c92STony Lindgren #ifdef CONFIG_SOC_OMAP2420
440fa590c92STony Lindgren 	{ "nokia,n800", omap2420_n8x0_legacy_init, },
441fa590c92STony Lindgren 	{ "nokia,n810", omap2420_n8x0_legacy_init, },
442fa590c92STony Lindgren 	{ "nokia,n810-wimax", omap2420_n8x0_legacy_init, },
443fa590c92STony Lindgren #endif
444036582f7STony Lindgren 	{ /* sentinel */ },
445036582f7STony Lindgren };
446036582f7STony Lindgren 
447d060b405STony Lindgren struct omap_sr_data __maybe_unused omap_sr_pdata[OMAP_SR_NR];
448d060b405STony Lindgren 
449ef70b0bdSTony Lindgren static struct of_dev_auxdata omap_auxdata_lookup[] = {
450036582f7STony Lindgren #ifdef CONFIG_MACH_NOKIA_N8X0
451036582f7STony Lindgren 	OF_DEV_AUXDATA("ti,omap2420-mmc", 0x4809c000, "mmci-omap.0", NULL),
452e92ce89cSFelipe Balbi 	OF_DEV_AUXDATA("menelaus", 0x72, "1-0072", &n8x0_menelaus_platform_data),
453036582f7STony Lindgren #endif
45430a69ef7STony Lindgren #ifdef CONFIG_ARCH_OMAP3
455910f1678SSuman Anna 	OF_DEV_AUXDATA("ti,omap2-iommu", 0x5d000000, "5d000000.mmu",
456910f1678SSuman Anna 		       &omap3_iommu_pdata),
4570af3e1a4SSuman Anna 	OF_DEV_AUXDATA("ti,omap2-iommu", 0x480bd400, "480bd400.mmu",
4580af3e1a4SSuman Anna 		       &omap3_iommu_isp_pdata),
459d060b405STony Lindgren 	OF_DEV_AUXDATA("ti,omap3-smartreflex-core", 0x480cb000,
460d060b405STony Lindgren 		       "480cb000.smartreflex", &omap_sr_pdata[OMAP_SR_CORE]),
461d060b405STony Lindgren 	OF_DEV_AUXDATA("ti,omap3-smartreflex-mpu-iva", 0x480c9000,
462d060b405STony Lindgren 		       "480c9000.smartreflex", &omap_sr_pdata[OMAP_SR_MPU]),
46310c1f7d3STony Lindgren 	OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x4809c000, "4809c000.mmc", &mmc_pdata[0]),
46410c1f7d3STony Lindgren 	OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x480b4000, "480b4000.mmc", &mmc_pdata[1]),
46571900314STony Lindgren 	/* Only on am3517 */
46671900314STony Lindgren 	OF_DEV_AUXDATA("ti,davinci_mdio", 0x5c030000, "davinci_mdio.0", NULL),
46771900314STony Lindgren 	OF_DEV_AUXDATA("ti,am3517-emac", 0x5c000000, "davinci_emac.0",
46871900314STony Lindgren 		       &am35xx_emac_pdata),
4690c0ef9eaSTony Lindgren 	OF_DEV_AUXDATA("nokia,n900-rom-rng", 0, NULL, rx51_secure_rng_call),
470c26c84c9SPeter Ujfalusi 	/* McBSP modules with sidetone core */
471558eb0bfSPeter Ujfalusi #if IS_ENABLED(CONFIG_SND_SOC_OMAP_MCBSP)
472c26c84c9SPeter Ujfalusi 	OF_DEV_AUXDATA("ti,omap3-mcbsp", 0x49022000, "49022000.mcbsp", &mcbsp_pdata),
473c26c84c9SPeter Ujfalusi 	OF_DEV_AUXDATA("ti,omap3-mcbsp", 0x49024000, "49024000.mcbsp", &mcbsp_pdata),
474c26c84c9SPeter Ujfalusi #endif
47530a69ef7STony Lindgren #endif
47667eb1e6eSSuman Anna #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
477d060b405STony Lindgren 	OF_DEV_AUXDATA("ti,omap4-smartreflex-iva", 0x4a0db000,
478d060b405STony Lindgren 		       "4a0db000.smartreflex", &omap_sr_pdata[OMAP_SR_IVA]),
479d060b405STony Lindgren 	OF_DEV_AUXDATA("ti,omap4-smartreflex-core", 0x4a0dd000,
480d060b405STony Lindgren 		       "4a0dd000.smartreflex", &omap_sr_pdata[OMAP_SR_CORE]),
481d060b405STony Lindgren 	OF_DEV_AUXDATA("ti,omap4-smartreflex-mpu", 0x4a0d9000,
482d060b405STony Lindgren 		       "4a0d9000.smartreflex", &omap_sr_pdata[OMAP_SR_MPU]),
48330a69ef7STony Lindgren #endif
484fc66ce0bSSekhar Nori #ifdef CONFIG_SOC_DRA7XX
4854601832fSSuman Anna 	OF_DEV_AUXDATA("ti,dra7-dsp-iommu", 0x40d01000, "40d01000.mmu",
4864601832fSSuman Anna 		       &dra7_ipu1_dsp_iommu_pdata),
4874601832fSSuman Anna 	OF_DEV_AUXDATA("ti,dra7-dsp-iommu", 0x41501000, "41501000.mmu",
4884601832fSSuman Anna 		       &dra7_ipu1_dsp_iommu_pdata),
4894601832fSSuman Anna 	OF_DEV_AUXDATA("ti,dra7-iommu", 0x58882000, "58882000.mmu",
4904601832fSSuman Anna 		       &dra7_ipu1_dsp_iommu_pdata),
491fc66ce0bSSekhar Nori #endif
492d4f414e5STony Lindgren 	/* Common auxdata */
493eda080eaSTony Lindgren 	OF_DEV_AUXDATA("simple-pm-bus", 0, NULL, omap_auxdata_lookup),
494ef70b0bdSTony Lindgren 	OF_DEV_AUXDATA("ti,sysc", 0, NULL, &ti_sysc_pdata),
495d4f414e5STony Lindgren 	OF_DEV_AUXDATA("pinctrl-single", 0, NULL, &pcs_pdata),
4968de44fb7STero Kristo 	OF_DEV_AUXDATA("ti,omap-prm-inst", 0, NULL, &ti_prm_pdata),
497211010aeSTony Lindgren 	OF_DEV_AUXDATA("ti,omap-sdma", 0, NULL, &dma_plat_info),
4988651bd8cSTony Lindgren 	{ /* sentinel */ },
4998651bd8cSTony Lindgren };
5008651bd8cSTony Lindgren 
501036582f7STony Lindgren /*
502036582f7STony Lindgren  * Few boards still need to initialize some legacy devices with
503036582f7STony Lindgren  * platform data until the drivers support device tree.
504036582f7STony Lindgren  */
5056a08e1e6STony Lindgren static struct pdata_init pdata_quirks[] __initdata = {
506faf4bd47SAaro Koskinen #ifdef CONFIG_ARCH_OMAP3
507fb45105aSDmitry Lifshitz 	{ "compulab,omap3-sbc-t3517", omap3_sbc_t3517_legacy_init, },
50840ecc02eSDmitry Lifshitz 	{ "compulab,omap3-sbc-t3530", omap3_sbc_t3530_legacy_init, },
5090f0cfc69STony Lindgren 	{ "compulab,omap3-sbc-t3730", omap3_sbc_t3730_legacy_init, },
510deff82e6SSebastian Reichel 	{ "nokia,omap3-n900", nokia_n900_legacy_init, },
511faf4bd47SAaro Koskinen 	{ "nokia,omap3-n9", hsmmc2_internal_input_clk, },
512faf4bd47SAaro Koskinen 	{ "nokia,omap3-n950", hsmmc2_internal_input_clk, },
513485fa126SAdam Ford 	{ "logicpd,dm3730-torpedo-devkit", omap3_logicpd_torpedo_init, },
51479b39f79STony Lindgren 	{ "ti,omap3-evm-37xx", omap3_evm_legacy_init, },
51571900314STony Lindgren 	{ "ti,am3517-evm", am3517_evm_legacy_init, },
51663dd5bc0SStefan Roese 	{ "technexion,omap3-tao3530", omap3_tao3530_legacy_init, },
517fc53e2ccSGrazvydas Ignotas 	{ "openpandora,omap3-pandora-600mhz", omap3_pandora_legacy_init, },
518fc53e2ccSGrazvydas Ignotas 	{ "openpandora,omap3-pandora-1ghz", omap3_pandora_legacy_init, },
519faf4bd47SAaro Koskinen #endif
5206a08e1e6STony Lindgren 	{ /* sentinel */ },
5216a08e1e6STony Lindgren };
5226a08e1e6STony Lindgren 
523036582f7STony Lindgren static void pdata_quirks_check(struct pdata_init *quirks)
5246a08e1e6STony Lindgren {
5256a08e1e6STony Lindgren 	while (quirks->compatible) {
5266a08e1e6STony Lindgren 		if (of_machine_is_compatible(quirks->compatible)) {
5276a08e1e6STony Lindgren 			if (quirks->fn)
5286a08e1e6STony Lindgren 				quirks->fn();
5296a08e1e6STony Lindgren 		}
5306a08e1e6STony Lindgren 		quirks++;
5316a08e1e6STony Lindgren 	}
5326a08e1e6STony Lindgren }
533036582f7STony Lindgren 
534a15de032STony Lindgren static const char * const pdata_quirks_init_nodes[] = {
535a15de032STony Lindgren 	"prcm",
536a15de032STony Lindgren 	"prm",
537a15de032STony Lindgren };
538a15de032STony Lindgren 
539aa4e1331SWei Yongjun static void __init
540a15de032STony Lindgren pdata_quirks_init_clocks(const struct of_device_id *omap_dt_match_table)
541036582f7STony Lindgren {
542ae5f70f7STony Lindgren 	struct device_node *np;
543a15de032STony Lindgren 	int i;
544ae5f70f7STony Lindgren 
545a15de032STony Lindgren 	for (i = 0; i < ARRAY_SIZE(pdata_quirks_init_nodes); i++) {
546a15de032STony Lindgren 		np = of_find_node_by_name(NULL, pdata_quirks_init_nodes[i]);
547a15de032STony Lindgren 		if (!np)
548a15de032STony Lindgren 			continue;
549a15de032STony Lindgren 
550a15de032STony Lindgren 		of_platform_populate(np, omap_dt_match_table,
551a15de032STony Lindgren 				     omap_auxdata_lookup, NULL);
5525cdbab96SLiang He 
5535cdbab96SLiang He 		of_node_put(np);
554a15de032STony Lindgren 	}
555a15de032STony Lindgren }
556a15de032STony Lindgren 
557a15de032STony Lindgren void __init pdata_quirks_init(const struct of_device_id *omap_dt_match_table)
558a15de032STony Lindgren {
55957df5380STony Lindgren 	/*
56057df5380STony Lindgren 	 * We still need this for omap2420 and omap3 PM to work, others are
56157df5380STony Lindgren 	 * using drivers/misc/sram.c already.
56257df5380STony Lindgren 	 */
56357df5380STony Lindgren 	if (of_machine_is_compatible("ti,omap2420") ||
56457df5380STony Lindgren 	    of_machine_is_compatible("ti,omap3"))
565036582f7STony Lindgren 		omap_sdrc_init(NULL, NULL);
56657df5380STony Lindgren 
567c26c84c9SPeter Ujfalusi 	if (of_machine_is_compatible("ti,omap3"))
568c26c84c9SPeter Ujfalusi 		omap3_mcbsp_init();
569036582f7STony Lindgren 	pdata_quirks_check(auxdata_quirks);
570ae5f70f7STony Lindgren 
571a15de032STony Lindgren 	pdata_quirks_init_clocks(omap_dt_match_table);
572ae5f70f7STony Lindgren 
573036582f7STony Lindgren 	of_platform_populate(NULL, omap_dt_match_table,
574036582f7STony Lindgren 			     omap_auxdata_lookup, NULL);
575036582f7STony Lindgren 	pdata_quirks_check(pdata_quirks);
576036582f7STony Lindgren }
577