blob: 67e2fcdfe3f07afee02e5267df703fe30df742f7 [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 Lindgren71900312013-12-06 10:53:04 -080011#include <linux/davinci_emac.h>
Tony Lindgren5f0a2c62013-09-25 15:44:40 -070012#include <linux/gpio.h>
Tony Lindgren6a08e1e2013-09-25 15:44:39 -070013#include <linux/init.h>
14#include <linux/kernel.h>
Tony Lindgren8651bd82013-10-10 15:45:12 -070015#include <linux/of_platform.h>
Enric Balletbo i Serrad565b5f2014-11-06 13:01:51 +010016#include <linux/ti_wilink_st.h>
Grazvydas Ignotasf9d50fe2015-07-21 04:12:01 +030017#include <linux/wl12xx.h>
18#include <linux/mmc/card.h>
19#include <linux/mmc/host.h>
Tony Lindgrend060b402018-02-22 13:57:30 -080020#include <linux/power/smartreflex.h>
Grazvydas Ignotasf9d50fe2015-07-21 04:12:01 +030021#include <linux/regulator/machine.h>
22#include <linux/regulator/fixed.h>
Tony Lindgren6a08e1e2013-09-25 15:44:39 -070023
Tony Lindgren30a69ef2013-10-10 15:45:13 -070024#include <linux/platform_data/pinctrl-single.h>
Tony Lindgren10c1f7d2016-04-28 08:20:53 -070025#include <linux/platform_data/hsmmc-omap.h>
Suman Anna910f1672014-03-05 18:24:13 -060026#include <linux/platform_data/iommu-omap.h>
Tony Lindgrenef70b0b2018-02-22 14:00:25 -080027#include <linux/platform_data/ti-sysc.h>
Dave Gerlach6da74c52015-07-13 12:34:53 -050028#include <linux/platform_data/wkup_m3.h>
Neil Armstrong20437f72016-01-22 17:15:51 +010029#include <linux/platform_data/pwm_omap_dmtimer.h>
Tony Lindgren8453c5c2016-04-28 08:21:03 -070030#include <linux/platform_data/media/ir-rx51.h>
Peter Ujfalusic26c84c2016-05-30 11:23:47 +030031#include <linux/platform_data/asoc-ti-mcbsp.h>
Neil Armstrong20437f72016-01-22 17:15:51 +010032#include <plat/dmtimer.h>
Tony Lindgren30a69ef2013-10-10 15:45:13 -070033
Tony Lindgren6a08e1e2013-09-25 15:44:39 -070034#include "common.h"
35#include "common-board-devices.h"
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +030036#include "control.h"
Suman Anna910f1672014-03-05 18:24:13 -060037#include "omap_device.h"
Tony Lindgren8453c5c2016-04-28 08:21:03 -070038#include "omap-pm.h"
Sebastian Reicheldeff82e2014-02-17 22:30:58 +010039#include "omap-secure.h"
40#include "soc.h"
Grazvydas Ignotasf9d50fe2015-07-21 04:12:01 +030041#include "hsmmc.h"
Tony Lindgren6a08e1e2013-09-25 15:44:39 -070042
Tony Lindgren10c1f7d2016-04-28 08:20:53 -070043static struct omap_hsmmc_platform_data __maybe_unused mmc_pdata[2];
44
Tony Lindgren6a08e1e2013-09-25 15:44:39 -070045struct pdata_init {
46 const char *compatible;
47 void (*fn)(void);
48};
49
Sekhar Norif734a9b2015-07-11 20:29:15 +053050static struct of_dev_auxdata omap_auxdata_lookup[];
Tony Lindgrendad12d12013-12-06 10:52:58 -080051static struct twl4030_gpio_platform_data twl_gpio_auxdata;
Tony Lindgrenfa590c92013-11-25 15:17:10 -080052
Tony Lindgrenfa590c92013-11-25 15:17:10 -080053#ifdef CONFIG_MACH_NOKIA_N8X0
54static void __init omap2420_n8x0_legacy_init(void)
55{
56 omap_auxdata_lookup[0].platform_data = n8x0_legacy_init();
57}
58#else
59#define omap2420_n8x0_legacy_init NULL
60#endif
61
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +030062#ifdef CONFIG_ARCH_OMAP3
Tony Lindgrenb96b3322015-05-20 09:23:43 -070063/*
64 * Configures GPIOs 126, 127 and 129 to 1.8V mode instead of 3.0V
65 * mode for MMC1 in case bootloader did not configure things.
66 * Note that if the pins are used for MMC1, pbias-regulator
67 * manages the IO voltage.
68 */
69static void __init omap3_gpio126_127_129(void)
70{
71 u32 reg;
72
73 reg = omap_ctrl_readl(OMAP343X_CONTROL_PBIAS_LITE);
74 reg &= ~OMAP343X_PBIASLITEVMODE1;
75 reg |= OMAP343X_PBIASLITEPWRDNZ1;
76 omap_ctrl_writel(reg, OMAP343X_CONTROL_PBIAS_LITE);
77 if (cpu_is_omap3630()) {
78 reg = omap_ctrl_readl(OMAP34XX_CONTROL_WKUP_CTRL);
79 reg |= OMAP36XX_GPIO_IO_PWRDNZ;
80 omap_ctrl_writel(reg, OMAP34XX_CONTROL_WKUP_CTRL);
81 }
82}
83
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +030084static void __init hsmmc2_internal_input_clk(void)
85{
86 u32 reg;
87
88 reg = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1);
89 reg |= OMAP2_MMCSDIO2ADPCLKISEL;
90 omap_ctrl_writel(reg, OMAP343X_CONTROL_DEVCONF1);
91}
Javier Martinez Canillas15c98872013-10-09 11:19:18 +020092
Suman Anna910f1672014-03-05 18:24:13 -060093static struct iommu_platform_data omap3_iommu_pdata = {
94 .reset_name = "mmu",
95 .assert_reset = omap_device_assert_hardreset,
96 .deassert_reset = omap_device_deassert_hardreset,
97};
98
Tony Lindgren0f0cfc62013-12-18 13:13:21 -080099static int omap3_sbc_t3730_twl_callback(struct device *dev,
100 unsigned gpio,
101 unsigned ngpio)
102{
103 int res;
104
105 res = gpio_request_one(gpio + 2, GPIOF_OUT_INIT_HIGH,
Dmitry Lifshitzd234e422014-01-12 15:22:45 +0200106 "wlan pwr");
Tony Lindgren0f0cfc62013-12-18 13:13:21 -0800107 if (res)
108 return res;
109
110 gpio_export(gpio, 0);
111
112 return 0;
113}
114
Dmitry Lifshitzb62d91e2014-01-12 15:22:55 +0200115static void __init omap3_sbc_t3x_usb_hub_init(int gpio, char *hub_name)
116{
117 int err = gpio_request_one(gpio, GPIOF_OUT_INIT_LOW, hub_name);
118
119 if (err) {
120 pr_err("SBC-T3x: %s reset gpio request failed: %d\n",
121 hub_name, err);
122 return;
123 }
124
125 gpio_export(gpio, 0);
126
127 udelay(10);
128 gpio_set_value(gpio, 1);
129 msleep(1);
130}
131
Tony Lindgren0f0cfc62013-12-18 13:13:21 -0800132static void __init omap3_sbc_t3730_twl_init(void)
133{
134 twl_gpio_auxdata.setup = omap3_sbc_t3730_twl_callback;
135}
136
137static void __init omap3_sbc_t3730_legacy_init(void)
138{
Dmitry Lifshitzb62d91e2014-01-12 15:22:55 +0200139 omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub");
Tony Lindgren0f0cfc62013-12-18 13:13:21 -0800140}
141
Dmitry Lifshitz40ecc022014-01-12 15:22:53 +0200142static void __init omap3_sbc_t3530_legacy_init(void)
143{
Dmitry Lifshitzb62d91e2014-01-12 15:22:55 +0200144 omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub");
Dmitry Lifshitz40ecc022014-01-12 15:22:53 +0200145}
146
Sekhar Norif734a9b2015-07-11 20:29:15 +0530147static struct ti_st_plat_data wilink_pdata = {
Enric Balletbo i Serrad565b5f2014-11-06 13:01:51 +0100148 .nshutdown_gpio = 137,
149 .dev_name = "/dev/ttyO1",
150 .flow_cntrl = 1,
151 .baud_rate = 300000,
152};
153
154static struct platform_device wl18xx_device = {
155 .name = "kim",
156 .id = -1,
157 .dev = {
158 .platform_data = &wilink_pdata,
159 }
160};
161
Adam Ford485fa122015-12-16 15:34:15 -0600162static struct ti_st_plat_data wilink7_pdata = {
163 .nshutdown_gpio = 162,
164 .dev_name = "/dev/ttyO1",
165 .flow_cntrl = 1,
Adam Forda3ac3502017-01-03 11:37:48 -0600166 .baud_rate = 3000000,
Adam Ford485fa122015-12-16 15:34:15 -0600167};
168
169static struct platform_device wl128x_device = {
170 .name = "kim",
171 .id = -1,
172 .dev = {
173 .platform_data = &wilink7_pdata,
174 }
175};
176
Enric Balletbo i Serrad565b5f2014-11-06 13:01:51 +0100177static struct platform_device btwilink_device = {
178 .name = "btwilink",
179 .id = -1,
180};
181
182static void __init omap3_igep0020_rev_f_legacy_init(void)
Javier Martinez Canillas15c98872013-10-09 11:19:18 +0200183{
Enric Balletbo i Serrad565b5f2014-11-06 13:01:51 +0100184 platform_device_register(&wl18xx_device);
185 platform_device_register(&btwilink_device);
186}
187
188static void __init omap3_igep0030_rev_g_legacy_init(void)
189{
Enric Balletbo i Serrad565b5f2014-11-06 13:01:51 +0100190 platform_device_register(&wl18xx_device);
191 platform_device_register(&btwilink_device);
Javier Martinez Canillas15c98872013-10-09 11:19:18 +0200192}
Tony Lindgren79b39f72013-10-11 09:20:54 -0700193
194static void __init omap3_evm_legacy_init(void)
195{
Tony Lindgren5b7610f2015-03-06 10:37:34 -0800196 hsmmc2_internal_input_clk();
Tony Lindgren79b39f72013-10-11 09:20:54 -0700197}
Tony Lindgren71900312013-12-06 10:53:04 -0800198
199static void am35xx_enable_emac_int(void)
200{
201 u32 v;
202
203 v = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
204 v |= (AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR |
205 AM35XX_CPGMAC_C0_MISC_PULSE_CLR | AM35XX_CPGMAC_C0_RX_THRESH_CLR);
206 omap_ctrl_writel(v, AM35XX_CONTROL_LVL_INTR_CLEAR);
207 omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); /* OCP barrier */
208}
209
210static void am35xx_disable_emac_int(void)
211{
212 u32 v;
213
214 v = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
215 v |= (AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR);
216 omap_ctrl_writel(v, AM35XX_CONTROL_LVL_INTR_CLEAR);
217 omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); /* OCP barrier */
218}
219
220static struct emac_platform_data am35xx_emac_pdata = {
221 .interrupt_enable = am35xx_enable_emac_int,
222 .interrupt_disable = am35xx_disable_emac_int,
223};
224
Dmitry Lifshitzfb451052014-01-12 15:22:54 +0200225static void __init am35xx_emac_reset(void)
Tony Lindgren71900312013-12-06 10:53:04 -0800226{
227 u32 v;
228
229 v = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
230 v &= ~AM35XX_CPGMACSS_SW_RST;
231 omap_ctrl_writel(v, AM35XX_CONTROL_IP_SW_RESET);
232 omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); /* OCP barrier */
233}
Sebastian Reicheldeff82e2014-02-17 22:30:58 +0100234
Dmitry Lifshitzfb451052014-01-12 15:22:54 +0200235static struct gpio cm_t3517_wlan_gpios[] __initdata = {
236 { 56, GPIOF_OUT_INIT_HIGH, "wlan pwr" },
237 { 4, GPIOF_OUT_INIT_HIGH, "xcvr noe" },
238};
239
240static void __init omap3_sbc_t3517_wifi_init(void)
241{
242 int err = gpio_request_array(cm_t3517_wlan_gpios,
243 ARRAY_SIZE(cm_t3517_wlan_gpios));
244 if (err) {
245 pr_err("SBC-T3517: wl12xx gpios request failed: %d\n", err);
246 return;
247 }
248
249 gpio_export(cm_t3517_wlan_gpios[0].gpio, 0);
250 gpio_export(cm_t3517_wlan_gpios[1].gpio, 0);
251
252 msleep(100);
253 gpio_set_value(cm_t3517_wlan_gpios[1].gpio, 0);
254}
255
256static void __init omap3_sbc_t3517_legacy_init(void)
257{
Dmitry Lifshitzb62d91e2014-01-12 15:22:55 +0200258 omap3_sbc_t3x_usb_hub_init(152, "cm-t3517 usb hub");
259 omap3_sbc_t3x_usb_hub_init(98, "sb-t35 usb hub");
Dmitry Lifshitzfb451052014-01-12 15:22:54 +0200260 am35xx_emac_reset();
261 hsmmc2_internal_input_clk();
262 omap3_sbc_t3517_wifi_init();
Dmitry Lifshitzfb451052014-01-12 15:22:54 +0200263}
264
265static void __init am3517_evm_legacy_init(void)
266{
267 am35xx_emac_reset();
268}
Linus Torvaldsf83ccb92014-04-05 15:29:04 -0700269
Sebastian Reichel14c0a5b2014-04-07 14:28:46 +0200270static struct platform_device omap3_rom_rng_device = {
271 .name = "omap3-rom-rng",
272 .id = -1,
273 .dev = {
274 .platform_data = rx51_secure_rng_call,
275 },
276};
277
Sebastian Reicheldeff82e2014-02-17 22:30:58 +0100278static void __init nokia_n900_legacy_init(void)
279{
280 hsmmc2_internal_input_clk();
Tony Lindgren10c1f7d2016-04-28 08:20:53 -0700281 mmc_pdata[0].name = "external";
282 mmc_pdata[1].name = "internal";
Sebastian Reicheldeff82e2014-02-17 22:30:58 +0100283
284 if (omap_type() == OMAP2_DEVICE_TYPE_SEC) {
285 if (IS_ENABLED(CONFIG_ARM_ERRATA_430973)) {
286 pr_info("RX-51: Enabling ARM errata 430973 workaround\n");
287 /* set IBE to 1 */
288 rx51_secure_update_aux_cr(BIT(6), 0);
289 } else {
Joe Perches3d0cb732014-09-13 11:31:16 -0700290 pr_warn("RX-51: Not enabling ARM errata 430973 workaround\n");
291 pr_warn("Thumb binaries may crash randomly without this workaround\n");
Sebastian Reicheldeff82e2014-02-17 22:30:58 +0100292 }
Sebastian Reichel14c0a5b2014-04-07 14:28:46 +0200293
Aaro Koskinen448f8bc2015-11-23 23:32:57 +0200294 pr_info("RX-51: Registering OMAP3 HWRNG device\n");
Sebastian Reichel14c0a5b2014-04-07 14:28:46 +0200295 platform_device_register(&omap3_rom_rng_device);
Sebastian Reicheldeff82e2014-02-17 22:30:58 +0100296 }
297}
Stefan Roese63dd5bc2014-08-29 12:40:03 +0200298
299static void __init omap3_tao3530_legacy_init(void)
300{
301 hsmmc2_internal_input_clk();
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +0300302}
Grazvydas Ignotasfc53e2c2015-07-21 04:12:00 +0300303
Adam Ford485fa122015-12-16 15:34:15 -0600304static void __init omap3_logicpd_torpedo_init(void)
305{
306 omap3_gpio126_127_129();
307 platform_device_register(&wl128x_device);
308 platform_device_register(&btwilink_device);
309}
310
Grazvydas Ignotasf9d50fe2015-07-21 04:12:01 +0300311/* omap3pandora legacy devices */
312#define PANDORA_WIFI_IRQ_GPIO 21
313#define PANDORA_WIFI_NRESET_GPIO 23
314
Grazvydas Ignotasfc53e2c2015-07-21 04:12:00 +0300315static struct platform_device pandora_backlight = {
316 .name = "pandora-backlight",
317 .id = -1,
318};
319
Grazvydas Ignotasf9d50fe2015-07-21 04:12:01 +0300320static struct regulator_consumer_supply pandora_vmmc3_supply[] = {
321 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.2"),
322};
323
324static struct regulator_init_data pandora_vmmc3 = {
325 .constraints = {
326 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
327 },
328 .num_consumer_supplies = ARRAY_SIZE(pandora_vmmc3_supply),
329 .consumer_supplies = pandora_vmmc3_supply,
330};
331
332static struct fixed_voltage_config pandora_vwlan = {
333 .supply_name = "vwlan",
334 .microvolts = 1800000, /* 1.8V */
335 .gpio = PANDORA_WIFI_NRESET_GPIO,
336 .startup_delay = 50000, /* 50ms */
337 .enable_high = 1,
338 .init_data = &pandora_vmmc3,
339};
340
341static struct platform_device pandora_vwlan_device = {
342 .name = "reg-fixed-voltage",
343 .id = 1,
344 .dev = {
345 .platform_data = &pandora_vwlan,
346 },
347};
348
349static void pandora_wl1251_init_card(struct mmc_card *card)
350{
351 /*
352 * We have TI wl1251 attached to MMC3. Pass this information to
353 * SDIO core because it can't be probed by normal methods.
354 */
355 if (card->type == MMC_TYPE_SDIO || card->type == MMC_TYPE_SD_COMBO) {
356 card->quirks |= MMC_QUIRK_NONSTD_SDIO;
357 card->cccr.wide_bus = 1;
358 card->cis.vendor = 0x104c;
359 card->cis.device = 0x9066;
360 card->cis.blksize = 512;
361 card->cis.max_dtr = 24000000;
362 card->ocr = 0x80;
363 }
364}
365
366static struct omap2_hsmmc_info pandora_mmc3[] = {
367 {
368 .mmc = 3,
369 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
370 .gpio_cd = -EINVAL,
371 .gpio_wp = -EINVAL,
372 .init_card = pandora_wl1251_init_card,
373 },
374 {} /* Terminator */
375};
376
377static void __init pandora_wl1251_init(void)
378{
379 struct wl1251_platform_data pandora_wl1251_pdata;
380 int ret;
381
382 memset(&pandora_wl1251_pdata, 0, sizeof(pandora_wl1251_pdata));
383
384 pandora_wl1251_pdata.power_gpio = -1;
385
386 ret = gpio_request_one(PANDORA_WIFI_IRQ_GPIO, GPIOF_IN, "wl1251 irq");
387 if (ret < 0)
388 goto fail;
389
390 pandora_wl1251_pdata.irq = gpio_to_irq(PANDORA_WIFI_IRQ_GPIO);
391 if (pandora_wl1251_pdata.irq < 0)
392 goto fail_irq;
393
394 pandora_wl1251_pdata.use_eeprom = true;
395 ret = wl1251_set_platform_data(&pandora_wl1251_pdata);
396 if (ret < 0)
397 goto fail_irq;
398
399 return;
400
401fail_irq:
402 gpio_free(PANDORA_WIFI_IRQ_GPIO);
403fail:
404 pr_err("wl1251 board initialisation failed\n");
405}
406
Grazvydas Ignotasfc53e2c2015-07-21 04:12:00 +0300407static void __init omap3_pandora_legacy_init(void)
408{
409 platform_device_register(&pandora_backlight);
Grazvydas Ignotasf9d50fe2015-07-21 04:12:01 +0300410 platform_device_register(&pandora_vwlan_device);
411 omap_hsmmc_init(pandora_mmc3);
412 omap_hsmmc_late_init(pandora_mmc3);
413 pandora_wl1251_init();
Grazvydas Ignotasfc53e2c2015-07-21 04:12:00 +0300414}
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +0300415#endif /* CONFIG_ARCH_OMAP3 */
416
Suman Anna67eb1e62014-03-05 18:24:15 -0600417#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
Suman Anna910f1672014-03-05 18:24:13 -0600418static struct iommu_platform_data omap4_iommu_pdata = {
419 .reset_name = "mmu_cache",
420 .assert_reset = omap_device_assert_hardreset,
421 .deassert_reset = omap_device_deassert_hardreset,
422};
Tony Lindgren3e7a3182013-09-25 15:44:39 -0700423#endif
424
Dave Gerlach6da74c52015-07-13 12:34:53 -0500425#if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
426static struct wkup_m3_platform_data wkup_m3_data = {
427 .reset_name = "wkup_m3",
428 .assert_reset = omap_device_assert_hardreset,
429 .deassert_reset = omap_device_deassert_hardreset,
430};
431#endif
432
Tony Lindgren3e7a3182013-09-25 15:44:39 -0700433#ifdef CONFIG_SOC_OMAP5
434static void __init omap5_uevm_legacy_init(void)
435{
Tony Lindgren3e7a3182013-09-25 15:44:39 -0700436}
437#endif
438
Sekhar Norifc66ce02017-08-10 09:02:37 -0700439#ifdef CONFIG_SOC_DRA7XX
440static struct omap_hsmmc_platform_data dra7_hsmmc_data_mmc1;
441static struct omap_hsmmc_platform_data dra7_hsmmc_data_mmc2;
442static struct omap_hsmmc_platform_data dra7_hsmmc_data_mmc3;
443
444static void __init dra7x_evm_mmc_quirk(void)
445{
446 if (omap_rev() == DRA752_REV_ES1_1 || omap_rev() == DRA752_REV_ES1_0) {
447 dra7_hsmmc_data_mmc1.version = "rev11";
448 dra7_hsmmc_data_mmc1.max_freq = 96000000;
449
450 dra7_hsmmc_data_mmc2.version = "rev11";
451 dra7_hsmmc_data_mmc2.max_freq = 48000000;
452
453 dra7_hsmmc_data_mmc3.version = "rev11";
454 dra7_hsmmc_data_mmc3.max_freq = 48000000;
455 }
456}
457#endif
458
Tony Lindgrenef70b0b2018-02-22 14:00:25 -0800459static int ti_sysc_enable_module(struct device *dev,
460 const struct ti_sysc_cookie *cookie)
461{
462 if (!cookie->data)
463 return -EINVAL;
464
465 return omap_hwmod_enable(cookie->data);
466}
467
468static int ti_sysc_idle_module(struct device *dev,
469 const struct ti_sysc_cookie *cookie)
470{
471 if (!cookie->data)
472 return -EINVAL;
473
474 return omap_hwmod_idle(cookie->data);
475}
476
477static int ti_sysc_shutdown_module(struct device *dev,
478 const struct ti_sysc_cookie *cookie)
479{
480 if (!cookie->data)
481 return -EINVAL;
482
483 return omap_hwmod_shutdown(cookie->data);
484}
485
486static struct of_dev_auxdata omap_auxdata_lookup[];
487
488static struct ti_sysc_platform_data ti_sysc_pdata = {
489 .auxdata = omap_auxdata_lookup,
Tony Lindgren695eea32018-02-22 14:05:31 -0800490 .init_module = omap_hwmod_init_module,
Tony Lindgrenef70b0b2018-02-22 14:00:25 -0800491 .enable_module = ti_sysc_enable_module,
492 .idle_module = ti_sysc_idle_module,
493 .shutdown_module = ti_sysc_shutdown_module,
494};
495
Tony Lindgren30a69ef2013-10-10 15:45:13 -0700496static struct pcs_pdata pcs_pdata;
497
498void omap_pcs_legacy_init(int irq, void (*rearm)(void))
499{
500 pcs_pdata.irq = irq;
501 pcs_pdata.rearm = rearm;
502}
503
Tony Lindgren036582f2013-11-25 15:17:09 -0800504/*
Tony Lindgrendad12d12013-12-06 10:52:58 -0800505 * GPIOs for TWL are initialized by the I2C bus and need custom
506 * handing until DSS has device tree bindings.
507 */
508void omap_auxdata_legacy_init(struct device *dev)
509{
510 if (dev->platform_data)
511 return;
512
513 if (strcmp("twl4030-gpio", dev_name(dev)))
514 return;
515
516 dev->platform_data = &twl_gpio_auxdata;
517}
518
Neil Armstrong20437f72016-01-22 17:15:51 +0100519/* Dual mode timer PWM callbacks platdata */
520#if IS_ENABLED(CONFIG_OMAP_DM_TIMER)
Tony Lindgren8453c5c2016-04-28 08:21:03 -0700521static struct pwm_omap_dmtimer_pdata pwm_dmtimer_pdata = {
Neil Armstrong20437f72016-01-22 17:15:51 +0100522 .request_by_node = omap_dm_timer_request_by_node,
Tony Lindgren8453c5c2016-04-28 08:21:03 -0700523 .request_specific = omap_dm_timer_request_specific,
524 .request = omap_dm_timer_request,
525 .set_source = omap_dm_timer_set_source,
526 .get_irq = omap_dm_timer_get_irq,
527 .set_int_enable = omap_dm_timer_set_int_enable,
528 .set_int_disable = omap_dm_timer_set_int_disable,
Neil Armstrong20437f72016-01-22 17:15:51 +0100529 .free = omap_dm_timer_free,
530 .enable = omap_dm_timer_enable,
531 .disable = omap_dm_timer_disable,
532 .get_fclk = omap_dm_timer_get_fclk,
533 .start = omap_dm_timer_start,
534 .stop = omap_dm_timer_stop,
535 .set_load = omap_dm_timer_set_load,
536 .set_match = omap_dm_timer_set_match,
537 .set_pwm = omap_dm_timer_set_pwm,
538 .set_prescaler = omap_dm_timer_set_prescaler,
Tony Lindgren8453c5c2016-04-28 08:21:03 -0700539 .read_counter = omap_dm_timer_read_counter,
Neil Armstrong20437f72016-01-22 17:15:51 +0100540 .write_counter = omap_dm_timer_write_counter,
Tony Lindgren8453c5c2016-04-28 08:21:03 -0700541 .read_status = omap_dm_timer_read_status,
542 .write_status = omap_dm_timer_write_status,
Neil Armstrong20437f72016-01-22 17:15:51 +0100543};
544#endif
545
Sean Younga92def12016-12-19 18:48:29 -0200546static struct ir_rx51_platform_data __maybe_unused rx51_ir_data = {
Tony Lindgren8453c5c2016-04-28 08:21:03 -0700547 .set_max_mpu_wakeup_lat = omap_pm_set_max_mpu_wakeup_lat,
Tony Lindgren8453c5c2016-04-28 08:21:03 -0700548};
549
Sean Younga92def12016-12-19 18:48:29 -0200550static struct platform_device __maybe_unused rx51_ir_device = {
551 .name = "ir_rx51",
Tony Lindgren8453c5c2016-04-28 08:21:03 -0700552 .id = -1,
553 .dev = {
Sean Younga92def12016-12-19 18:48:29 -0200554 .platform_data = &rx51_ir_data,
Tony Lindgren8453c5c2016-04-28 08:21:03 -0700555 },
556};
557
Peter Ujfalusic26c84c2016-05-30 11:23:47 +0300558#if IS_ENABLED(CONFIG_SND_OMAP_SOC_MCBSP)
559static struct omap_mcbsp_platform_data mcbsp_pdata;
560static void __init omap3_mcbsp_init(void)
561{
562 omap3_mcbsp_init_pdata_callback(&mcbsp_pdata);
563}
564#else
565static void __init omap3_mcbsp_init(void) {}
566#endif
567
Tony Lindgrendad12d12013-12-06 10:52:58 -0800568/*
Tony Lindgren036582f2013-11-25 15:17:09 -0800569 * Few boards still need auxdata populated before we populate
570 * the dev entries in of_platform_populate().
571 */
572static struct pdata_init auxdata_quirks[] __initdata = {
Tony Lindgrenfa590c92013-11-25 15:17:10 -0800573#ifdef CONFIG_SOC_OMAP2420
574 { "nokia,n800", omap2420_n8x0_legacy_init, },
575 { "nokia,n810", omap2420_n8x0_legacy_init, },
576 { "nokia,n810-wimax", omap2420_n8x0_legacy_init, },
577#endif
Tony Lindgren0f0cfc62013-12-18 13:13:21 -0800578#ifdef CONFIG_ARCH_OMAP3
579 { "compulab,omap3-sbc-t3730", omap3_sbc_t3730_twl_init, },
580#endif
Tony Lindgren036582f2013-11-25 15:17:09 -0800581 { /* sentinel */ },
582};
583
Tony Lindgrend060b402018-02-22 13:57:30 -0800584struct omap_sr_data __maybe_unused omap_sr_pdata[OMAP_SR_NR];
585
Tony Lindgrenef70b0b2018-02-22 14:00:25 -0800586static struct of_dev_auxdata omap_auxdata_lookup[] = {
Tony Lindgren036582f2013-11-25 15:17:09 -0800587#ifdef CONFIG_MACH_NOKIA_N8X0
588 OF_DEV_AUXDATA("ti,omap2420-mmc", 0x4809c000, "mmci-omap.0", NULL),
Felipe Balbie92ce892014-09-16 15:31:40 -0500589 OF_DEV_AUXDATA("menelaus", 0x72, "1-0072", &n8x0_menelaus_platform_data),
590 OF_DEV_AUXDATA("tlv320aic3x", 0x18, "2-0018", &n810_aic33_data),
Tony Lindgren036582f2013-11-25 15:17:09 -0800591#endif
Tony Lindgren30a69ef2013-10-10 15:45:13 -0700592#ifdef CONFIG_ARCH_OMAP3
Suman Anna910f1672014-03-05 18:24:13 -0600593 OF_DEV_AUXDATA("ti,omap2-iommu", 0x5d000000, "5d000000.mmu",
594 &omap3_iommu_pdata),
Tony Lindgrend060b402018-02-22 13:57:30 -0800595 OF_DEV_AUXDATA("ti,omap3-smartreflex-core", 0x480cb000,
596 "480cb000.smartreflex", &omap_sr_pdata[OMAP_SR_CORE]),
597 OF_DEV_AUXDATA("ti,omap3-smartreflex-mpu-iva", 0x480c9000,
598 "480c9000.smartreflex", &omap_sr_pdata[OMAP_SR_MPU]),
Tony Lindgren10c1f7d2016-04-28 08:20:53 -0700599 OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x4809c000, "4809c000.mmc", &mmc_pdata[0]),
600 OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x480b4000, "480b4000.mmc", &mmc_pdata[1]),
Sean Young922ee722017-01-30 17:58:19 -0200601 OF_DEV_AUXDATA("nokia,n900-ir", 0, "n900-ir", &rx51_ir_data),
Tony Lindgren71900312013-12-06 10:53:04 -0800602 /* Only on am3517 */
603 OF_DEV_AUXDATA("ti,davinci_mdio", 0x5c030000, "davinci_mdio.0", NULL),
604 OF_DEV_AUXDATA("ti,am3517-emac", 0x5c000000, "davinci_emac.0",
605 &am35xx_emac_pdata),
Peter Ujfalusic26c84c2016-05-30 11:23:47 +0300606 /* McBSP modules with sidetone core */
607#if IS_ENABLED(CONFIG_SND_OMAP_SOC_MCBSP)
608 OF_DEV_AUXDATA("ti,omap3-mcbsp", 0x49022000, "49022000.mcbsp", &mcbsp_pdata),
609 OF_DEV_AUXDATA("ti,omap3-mcbsp", 0x49024000, "49024000.mcbsp", &mcbsp_pdata),
610#endif
Tony Lindgren30a69ef2013-10-10 15:45:13 -0700611#endif
Dave Gerlach6da74c52015-07-13 12:34:53 -0500612#ifdef CONFIG_SOC_AM33XX
613 OF_DEV_AUXDATA("ti,am3352-wkup-m3", 0x44d00000, "44d00000.wkup_m3",
614 &wkup_m3_data),
615#endif
Keerthydbbe9772014-04-07 11:54:49 +0530616#ifdef CONFIG_SOC_AM43XX
Dave Gerlach6da74c52015-07-13 12:34:53 -0500617 OF_DEV_AUXDATA("ti,am4372-wkup-m3", 0x44d00000, "44d00000.wkup_m3",
618 &wkup_m3_data),
Keerthydbbe9772014-04-07 11:54:49 +0530619#endif
Neil Armstrong20437f72016-01-22 17:15:51 +0100620#if IS_ENABLED(CONFIG_OMAP_DM_TIMER)
621 OF_DEV_AUXDATA("ti,omap-dmtimer-pwm", 0, NULL, &pwm_dmtimer_pdata),
622#endif
Suman Anna67eb1e62014-03-05 18:24:15 -0600623#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
Suman Anna910f1672014-03-05 18:24:13 -0600624 OF_DEV_AUXDATA("ti,omap4-iommu", 0x4a066000, "4a066000.mmu",
625 &omap4_iommu_pdata),
626 OF_DEV_AUXDATA("ti,omap4-iommu", 0x55082000, "55082000.mmu",
627 &omap4_iommu_pdata),
Tony Lindgrend060b402018-02-22 13:57:30 -0800628 OF_DEV_AUXDATA("ti,omap4-smartreflex-iva", 0x4a0db000,
629 "4a0db000.smartreflex", &omap_sr_pdata[OMAP_SR_IVA]),
630 OF_DEV_AUXDATA("ti,omap4-smartreflex-core", 0x4a0dd000,
631 "4a0dd000.smartreflex", &omap_sr_pdata[OMAP_SR_CORE]),
632 OF_DEV_AUXDATA("ti,omap4-smartreflex-mpu", 0x4a0d9000,
633 "4a0d9000.smartreflex", &omap_sr_pdata[OMAP_SR_MPU]),
Tony Lindgren30a69ef2013-10-10 15:45:13 -0700634#endif
Sekhar Norifc66ce02017-08-10 09:02:37 -0700635#ifdef CONFIG_SOC_DRA7XX
636 OF_DEV_AUXDATA("ti,dra7-hsmmc", 0x4809c000, "4809c000.mmc",
637 &dra7_hsmmc_data_mmc1),
638 OF_DEV_AUXDATA("ti,dra7-hsmmc", 0x480b4000, "480b4000.mmc",
639 &dra7_hsmmc_data_mmc2),
640 OF_DEV_AUXDATA("ti,dra7-hsmmc", 0x480ad000, "480ad000.mmc",
641 &dra7_hsmmc_data_mmc3),
642#endif
Tony Lindgrend4f414e2016-04-15 08:45:33 -0700643 /* Common auxdata */
Tony Lindgrenef70b0b2018-02-22 14:00:25 -0800644 OF_DEV_AUXDATA("ti,sysc", 0, NULL, &ti_sysc_pdata),
Tony Lindgrend4f414e2016-04-15 08:45:33 -0700645 OF_DEV_AUXDATA("pinctrl-single", 0, NULL, &pcs_pdata),
Tony Lindgren8651bd82013-10-10 15:45:12 -0700646 { /* sentinel */ },
647};
648
Tony Lindgren036582f2013-11-25 15:17:09 -0800649/*
650 * Few boards still need to initialize some legacy devices with
651 * platform data until the drivers support device tree.
652 */
Tony Lindgren6a08e1e2013-09-25 15:44:39 -0700653static struct pdata_init pdata_quirks[] __initdata = {
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +0300654#ifdef CONFIG_ARCH_OMAP3
Dmitry Lifshitzfb451052014-01-12 15:22:54 +0200655 { "compulab,omap3-sbc-t3517", omap3_sbc_t3517_legacy_init, },
Dmitry Lifshitz40ecc022014-01-12 15:22:53 +0200656 { "compulab,omap3-sbc-t3530", omap3_sbc_t3530_legacy_init, },
Tony Lindgren0f0cfc62013-12-18 13:13:21 -0800657 { "compulab,omap3-sbc-t3730", omap3_sbc_t3730_legacy_init, },
Sebastian Reicheldeff82e2014-02-17 22:30:58 +0100658 { "nokia,omap3-n900", nokia_n900_legacy_init, },
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +0300659 { "nokia,omap3-n9", hsmmc2_internal_input_clk, },
660 { "nokia,omap3-n950", hsmmc2_internal_input_clk, },
Enric Balletbo i Serrad565b5f2014-11-06 13:01:51 +0100661 { "isee,omap3-igep0020-rev-f", omap3_igep0020_rev_f_legacy_init, },
662 { "isee,omap3-igep0030-rev-g", omap3_igep0030_rev_g_legacy_init, },
Adam Ford485fa122015-12-16 15:34:15 -0600663 { "logicpd,dm3730-torpedo-devkit", omap3_logicpd_torpedo_init, },
Tony Lindgren79b39f72013-10-11 09:20:54 -0700664 { "ti,omap3-evm-37xx", omap3_evm_legacy_init, },
Tony Lindgren71900312013-12-06 10:53:04 -0800665 { "ti,am3517-evm", am3517_evm_legacy_init, },
Stefan Roese63dd5bc2014-08-29 12:40:03 +0200666 { "technexion,omap3-tao3530", omap3_tao3530_legacy_init, },
Grazvydas Ignotasfc53e2c2015-07-21 04:12:00 +0300667 { "openpandora,omap3-pandora-600mhz", omap3_pandora_legacy_init, },
668 { "openpandora,omap3-pandora-1ghz", omap3_pandora_legacy_init, },
Aaro Koskinenfaf4bd42013-09-24 22:28:15 +0300669#endif
Tony Lindgren3e7a3182013-09-25 15:44:39 -0700670#ifdef CONFIG_SOC_OMAP5
671 { "ti,omap5-uevm", omap5_uevm_legacy_init, },
672#endif
Sekhar Norifc66ce02017-08-10 09:02:37 -0700673#ifdef CONFIG_SOC_DRA7XX
674 { "ti,dra7-evm", dra7x_evm_mmc_quirk, },
675#endif
Tony Lindgren6a08e1e2013-09-25 15:44:39 -0700676 { /* sentinel */ },
677};
678
Tony Lindgren036582f2013-11-25 15:17:09 -0800679static void pdata_quirks_check(struct pdata_init *quirks)
Tony Lindgren6a08e1e2013-09-25 15:44:39 -0700680{
Tony Lindgren6a08e1e2013-09-25 15:44:39 -0700681 while (quirks->compatible) {
682 if (of_machine_is_compatible(quirks->compatible)) {
683 if (quirks->fn)
684 quirks->fn();
Tony Lindgren6a08e1e2013-09-25 15:44:39 -0700685 }
686 quirks++;
687 }
688}
Tony Lindgren036582f2013-11-25 15:17:09 -0800689
Uwe Kleine-König31957602014-09-10 10:26:17 +0200690void __init pdata_quirks_init(const struct of_device_id *omap_dt_match_table)
Tony Lindgren036582f2013-11-25 15:17:09 -0800691{
Tony Lindgren57df5382015-10-16 12:23:33 -0700692 /*
693 * We still need this for omap2420 and omap3 PM to work, others are
694 * using drivers/misc/sram.c already.
695 */
696 if (of_machine_is_compatible("ti,omap2420") ||
697 of_machine_is_compatible("ti,omap3"))
698 omap_sdrc_init(NULL, NULL);
699
Peter Ujfalusic26c84c2016-05-30 11:23:47 +0300700 if (of_machine_is_compatible("ti,omap3"))
701 omap3_mcbsp_init();
Tony Lindgren036582f2013-11-25 15:17:09 -0800702 pdata_quirks_check(auxdata_quirks);
703 of_platform_populate(NULL, omap_dt_match_table,
704 omap_auxdata_lookup, NULL);
705 pdata_quirks_check(pdata_quirks);
706}