0001
0002
0003
0004
0005
0006
0007 #include <linux/clk.h>
0008 #include <linux/davinci_emac.h>
0009 #include <linux/gpio.h>
0010 #include <linux/init.h>
0011 #include <linux/kernel.h>
0012 #include <linux/of_platform.h>
0013 #include <linux/wl12xx.h>
0014 #include <linux/mmc/card.h>
0015 #include <linux/mmc/host.h>
0016 #include <linux/power/smartreflex.h>
0017 #include <linux/regulator/machine.h>
0018 #include <linux/regulator/fixed.h>
0019
0020 #include <linux/platform_data/pinctrl-single.h>
0021 #include <linux/platform_data/hsmmc-omap.h>
0022 #include <linux/platform_data/iommu-omap.h>
0023 #include <linux/platform_data/ti-sysc.h>
0024 #include <linux/platform_data/wkup_m3.h>
0025 #include <linux/platform_data/asoc-ti-mcbsp.h>
0026 #include <linux/platform_data/ti-prm.h>
0027
0028 #include "clockdomain.h"
0029 #include "common.h"
0030 #include "common-board-devices.h"
0031 #include "control.h"
0032 #include "omap_device.h"
0033 #include "omap-secure.h"
0034 #include "soc.h"
0035
0036 static struct omap_hsmmc_platform_data __maybe_unused mmc_pdata[2];
0037
0038 struct pdata_init {
0039 const char *compatible;
0040 void (*fn)(void);
0041 };
0042
0043 static struct of_dev_auxdata omap_auxdata_lookup[];
0044 static struct twl4030_gpio_platform_data twl_gpio_auxdata;
0045
0046 #ifdef CONFIG_MACH_NOKIA_N8X0
0047 static void __init omap2420_n8x0_legacy_init(void)
0048 {
0049 omap_auxdata_lookup[0].platform_data = n8x0_legacy_init();
0050 }
0051 #else
0052 #define omap2420_n8x0_legacy_init NULL
0053 #endif
0054
0055 #ifdef CONFIG_ARCH_OMAP3
0056
0057
0058
0059
0060
0061
0062 static void __init omap3_gpio126_127_129(void)
0063 {
0064 u32 reg;
0065
0066 reg = omap_ctrl_readl(OMAP343X_CONTROL_PBIAS_LITE);
0067 reg &= ~OMAP343X_PBIASLITEVMODE1;
0068 reg |= OMAP343X_PBIASLITEPWRDNZ1;
0069 omap_ctrl_writel(reg, OMAP343X_CONTROL_PBIAS_LITE);
0070 if (cpu_is_omap3630()) {
0071 reg = omap_ctrl_readl(OMAP34XX_CONTROL_WKUP_CTRL);
0072 reg |= OMAP36XX_GPIO_IO_PWRDNZ;
0073 omap_ctrl_writel(reg, OMAP34XX_CONTROL_WKUP_CTRL);
0074 }
0075 }
0076
0077 static void __init hsmmc2_internal_input_clk(void)
0078 {
0079 u32 reg;
0080
0081 reg = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1);
0082 reg |= OMAP2_MMCSDIO2ADPCLKISEL;
0083 omap_ctrl_writel(reg, OMAP343X_CONTROL_DEVCONF1);
0084 }
0085
0086 #ifdef CONFIG_OMAP_HWMOD
0087 static struct iommu_platform_data omap3_iommu_pdata = {
0088 .reset_name = "mmu",
0089 .assert_reset = omap_device_assert_hardreset,
0090 .deassert_reset = omap_device_deassert_hardreset,
0091 .device_enable = omap_device_enable,
0092 .device_idle = omap_device_idle,
0093 };
0094
0095 static struct iommu_platform_data omap3_iommu_isp_pdata = {
0096 .device_enable = omap_device_enable,
0097 .device_idle = omap_device_idle,
0098 };
0099 #endif
0100
0101 static int omap3_sbc_t3730_twl_callback(struct device *dev,
0102 unsigned gpio,
0103 unsigned ngpio)
0104 {
0105 int res;
0106
0107 res = gpio_request_one(gpio + 2, GPIOF_OUT_INIT_HIGH,
0108 "wlan pwr");
0109 if (res)
0110 return res;
0111
0112 gpio_export(gpio, 0);
0113
0114 return 0;
0115 }
0116
0117 static void __init omap3_sbc_t3x_usb_hub_init(int gpio, char *hub_name)
0118 {
0119 int err = gpio_request_one(gpio, GPIOF_OUT_INIT_LOW, hub_name);
0120
0121 if (err) {
0122 pr_err("SBC-T3x: %s reset gpio request failed: %d\n",
0123 hub_name, err);
0124 return;
0125 }
0126
0127 gpio_export(gpio, 0);
0128
0129 udelay(10);
0130 gpio_set_value(gpio, 1);
0131 msleep(1);
0132 }
0133
0134 static void __init omap3_sbc_t3730_twl_init(void)
0135 {
0136 twl_gpio_auxdata.setup = omap3_sbc_t3730_twl_callback;
0137 }
0138
0139 static void __init omap3_sbc_t3730_legacy_init(void)
0140 {
0141 omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub");
0142 }
0143
0144 static void __init omap3_sbc_t3530_legacy_init(void)
0145 {
0146 omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub");
0147 }
0148
0149 static void __init omap3_evm_legacy_init(void)
0150 {
0151 hsmmc2_internal_input_clk();
0152 }
0153
0154 static void am35xx_enable_emac_int(void)
0155 {
0156 u32 v;
0157
0158 v = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
0159 v |= (AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR |
0160 AM35XX_CPGMAC_C0_MISC_PULSE_CLR | AM35XX_CPGMAC_C0_RX_THRESH_CLR);
0161 omap_ctrl_writel(v, AM35XX_CONTROL_LVL_INTR_CLEAR);
0162 omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
0163 }
0164
0165 static void am35xx_disable_emac_int(void)
0166 {
0167 u32 v;
0168
0169 v = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
0170 v |= (AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR);
0171 omap_ctrl_writel(v, AM35XX_CONTROL_LVL_INTR_CLEAR);
0172 omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
0173 }
0174
0175 static struct emac_platform_data am35xx_emac_pdata = {
0176 .interrupt_enable = am35xx_enable_emac_int,
0177 .interrupt_disable = am35xx_disable_emac_int,
0178 };
0179
0180 static void __init am35xx_emac_reset(void)
0181 {
0182 u32 v;
0183
0184 v = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
0185 v &= ~AM35XX_CPGMACSS_SW_RST;
0186 omap_ctrl_writel(v, AM35XX_CONTROL_IP_SW_RESET);
0187 omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
0188 }
0189
0190 static struct gpio cm_t3517_wlan_gpios[] __initdata = {
0191 { 56, GPIOF_OUT_INIT_HIGH, "wlan pwr" },
0192 { 4, GPIOF_OUT_INIT_HIGH, "xcvr noe" },
0193 };
0194
0195 static void __init omap3_sbc_t3517_wifi_init(void)
0196 {
0197 int err = gpio_request_array(cm_t3517_wlan_gpios,
0198 ARRAY_SIZE(cm_t3517_wlan_gpios));
0199 if (err) {
0200 pr_err("SBC-T3517: wl12xx gpios request failed: %d\n", err);
0201 return;
0202 }
0203
0204 gpio_export(cm_t3517_wlan_gpios[0].gpio, 0);
0205 gpio_export(cm_t3517_wlan_gpios[1].gpio, 0);
0206
0207 msleep(100);
0208 gpio_set_value(cm_t3517_wlan_gpios[1].gpio, 0);
0209 }
0210
0211 static void __init omap3_sbc_t3517_legacy_init(void)
0212 {
0213 omap3_sbc_t3x_usb_hub_init(152, "cm-t3517 usb hub");
0214 omap3_sbc_t3x_usb_hub_init(98, "sb-t35 usb hub");
0215 am35xx_emac_reset();
0216 hsmmc2_internal_input_clk();
0217 omap3_sbc_t3517_wifi_init();
0218 }
0219
0220 static void __init am3517_evm_legacy_init(void)
0221 {
0222 am35xx_emac_reset();
0223 }
0224
0225 static void __init nokia_n900_legacy_init(void)
0226 {
0227 hsmmc2_internal_input_clk();
0228 mmc_pdata[0].name = "external";
0229 mmc_pdata[1].name = "internal";
0230
0231 if (omap_type() != OMAP2_DEVICE_TYPE_GP) {
0232 if (IS_ENABLED(CONFIG_ARM_ERRATA_430973)) {
0233 pr_info("RX-51: Enabling ARM errata 430973 workaround\n");
0234
0235 rx51_secure_update_aux_cr(BIT(6), 0);
0236 } else {
0237 pr_warn("RX-51: Not enabling ARM errata 430973 workaround\n");
0238 pr_warn("Thumb binaries may crash randomly without this workaround\n");
0239 }
0240 }
0241 }
0242
0243 static void __init omap3_tao3530_legacy_init(void)
0244 {
0245 hsmmc2_internal_input_clk();
0246 }
0247
0248 static void __init omap3_logicpd_torpedo_init(void)
0249 {
0250 omap3_gpio126_127_129();
0251 }
0252
0253
0254
0255 static struct platform_device pandora_backlight = {
0256 .name = "pandora-backlight",
0257 .id = -1,
0258 };
0259
0260 static void __init omap3_pandora_legacy_init(void)
0261 {
0262 platform_device_register(&pandora_backlight);
0263 }
0264 #endif
0265
0266 #ifdef CONFIG_SOC_DRA7XX
0267 static struct iommu_platform_data dra7_ipu1_dsp_iommu_pdata = {
0268 .set_pwrdm_constraint = omap_iommu_set_pwrdm_constraint,
0269 };
0270 #endif
0271
0272 static struct clockdomain *ti_sysc_find_one_clockdomain(struct clk *clk)
0273 {
0274 struct clk_hw *hw = __clk_get_hw(clk);
0275 struct clockdomain *clkdm = NULL;
0276 struct clk_hw_omap *hwclk;
0277
0278 hwclk = to_clk_hw_omap(hw);
0279 if (!omap2_clk_is_hw_omap(hw))
0280 return NULL;
0281
0282 if (hwclk && hwclk->clkdm_name)
0283 clkdm = clkdm_lookup(hwclk->clkdm_name);
0284
0285 return clkdm;
0286 }
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302 static int ti_sysc_clkdm_init(struct device *dev,
0303 struct clk *fck, struct clk *ick,
0304 struct ti_sysc_cookie *cookie)
0305 {
0306 if (!IS_ERR(fck))
0307 cookie->clkdm = ti_sysc_find_one_clockdomain(fck);
0308 if (cookie->clkdm)
0309 return 0;
0310 if (!IS_ERR(ick))
0311 cookie->clkdm = ti_sysc_find_one_clockdomain(ick);
0312 if (cookie->clkdm)
0313 return 0;
0314
0315 return -ENODEV;
0316 }
0317
0318 static void ti_sysc_clkdm_deny_idle(struct device *dev,
0319 const struct ti_sysc_cookie *cookie)
0320 {
0321 if (cookie->clkdm)
0322 clkdm_deny_idle(cookie->clkdm);
0323 }
0324
0325 static void ti_sysc_clkdm_allow_idle(struct device *dev,
0326 const struct ti_sysc_cookie *cookie)
0327 {
0328 if (cookie->clkdm)
0329 clkdm_allow_idle(cookie->clkdm);
0330 }
0331
0332 #ifdef CONFIG_OMAP_HWMOD
0333 static int ti_sysc_enable_module(struct device *dev,
0334 const struct ti_sysc_cookie *cookie)
0335 {
0336 if (!cookie->data)
0337 return -EINVAL;
0338
0339 return omap_hwmod_enable(cookie->data);
0340 }
0341
0342 static int ti_sysc_idle_module(struct device *dev,
0343 const struct ti_sysc_cookie *cookie)
0344 {
0345 if (!cookie->data)
0346 return -EINVAL;
0347
0348 return omap_hwmod_idle(cookie->data);
0349 }
0350
0351 static int ti_sysc_shutdown_module(struct device *dev,
0352 const struct ti_sysc_cookie *cookie)
0353 {
0354 if (!cookie->data)
0355 return -EINVAL;
0356
0357 return omap_hwmod_shutdown(cookie->data);
0358 }
0359 #endif
0360
0361 static bool ti_sysc_soc_type_gp(void)
0362 {
0363 return omap_type() == OMAP2_DEVICE_TYPE_GP;
0364 }
0365
0366 static struct of_dev_auxdata omap_auxdata_lookup[];
0367
0368 static struct ti_sysc_platform_data ti_sysc_pdata = {
0369 .auxdata = omap_auxdata_lookup,
0370 .soc_type_gp = ti_sysc_soc_type_gp,
0371 .init_clockdomain = ti_sysc_clkdm_init,
0372 .clkdm_deny_idle = ti_sysc_clkdm_deny_idle,
0373 .clkdm_allow_idle = ti_sysc_clkdm_allow_idle,
0374 #ifdef CONFIG_OMAP_HWMOD
0375 .init_module = omap_hwmod_init_module,
0376 .enable_module = ti_sysc_enable_module,
0377 .idle_module = ti_sysc_idle_module,
0378 .shutdown_module = ti_sysc_shutdown_module,
0379 #endif
0380 };
0381
0382 static struct pcs_pdata pcs_pdata;
0383
0384 void omap_pcs_legacy_init(int irq, void (*rearm)(void))
0385 {
0386 pcs_pdata.irq = irq;
0387 pcs_pdata.rearm = rearm;
0388 }
0389
0390 static struct ti_prm_platform_data ti_prm_pdata = {
0391 .clkdm_deny_idle = clkdm_deny_idle,
0392 .clkdm_allow_idle = clkdm_allow_idle,
0393 .clkdm_lookup = clkdm_lookup,
0394 };
0395
0396
0397
0398
0399
0400 void omap_auxdata_legacy_init(struct device *dev)
0401 {
0402 if (dev->platform_data)
0403 return;
0404
0405 if (strcmp("twl4030-gpio", dev_name(dev)))
0406 return;
0407
0408 dev->platform_data = &twl_gpio_auxdata;
0409 }
0410
0411 #if defined(CONFIG_ARCH_OMAP3) && IS_ENABLED(CONFIG_SND_SOC_OMAP_MCBSP)
0412 static struct omap_mcbsp_platform_data mcbsp_pdata;
0413 static void __init omap3_mcbsp_init(void)
0414 {
0415 omap3_mcbsp_init_pdata_callback(&mcbsp_pdata);
0416 }
0417 #else
0418 static void __init omap3_mcbsp_init(void) {}
0419 #endif
0420
0421
0422
0423
0424
0425 static struct pdata_init auxdata_quirks[] __initdata = {
0426 #ifdef CONFIG_SOC_OMAP2420
0427 { "nokia,n800", omap2420_n8x0_legacy_init, },
0428 { "nokia,n810", omap2420_n8x0_legacy_init, },
0429 { "nokia,n810-wimax", omap2420_n8x0_legacy_init, },
0430 #endif
0431 #ifdef CONFIG_ARCH_OMAP3
0432 { "compulab,omap3-sbc-t3730", omap3_sbc_t3730_twl_init, },
0433 #endif
0434 { },
0435 };
0436
0437 struct omap_sr_data __maybe_unused omap_sr_pdata[OMAP_SR_NR];
0438
0439 static struct of_dev_auxdata omap_auxdata_lookup[] = {
0440 #ifdef CONFIG_MACH_NOKIA_N8X0
0441 OF_DEV_AUXDATA("ti,omap2420-mmc", 0x4809c000, "mmci-omap.0", NULL),
0442 OF_DEV_AUXDATA("menelaus", 0x72, "1-0072", &n8x0_menelaus_platform_data),
0443 OF_DEV_AUXDATA("tlv320aic3x", 0x18, "2-0018", &n810_aic33_data),
0444 #endif
0445 #ifdef CONFIG_ARCH_OMAP3
0446 OF_DEV_AUXDATA("ti,omap2-iommu", 0x5d000000, "5d000000.mmu",
0447 &omap3_iommu_pdata),
0448 OF_DEV_AUXDATA("ti,omap2-iommu", 0x480bd400, "480bd400.mmu",
0449 &omap3_iommu_isp_pdata),
0450 OF_DEV_AUXDATA("ti,omap3-smartreflex-core", 0x480cb000,
0451 "480cb000.smartreflex", &omap_sr_pdata[OMAP_SR_CORE]),
0452 OF_DEV_AUXDATA("ti,omap3-smartreflex-mpu-iva", 0x480c9000,
0453 "480c9000.smartreflex", &omap_sr_pdata[OMAP_SR_MPU]),
0454 OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x4809c000, "4809c000.mmc", &mmc_pdata[0]),
0455 OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x480b4000, "480b4000.mmc", &mmc_pdata[1]),
0456
0457 OF_DEV_AUXDATA("ti,davinci_mdio", 0x5c030000, "davinci_mdio.0", NULL),
0458 OF_DEV_AUXDATA("ti,am3517-emac", 0x5c000000, "davinci_emac.0",
0459 &am35xx_emac_pdata),
0460 OF_DEV_AUXDATA("nokia,n900-rom-rng", 0, NULL, rx51_secure_rng_call),
0461
0462 #if IS_ENABLED(CONFIG_SND_SOC_OMAP_MCBSP)
0463 OF_DEV_AUXDATA("ti,omap3-mcbsp", 0x49022000, "49022000.mcbsp", &mcbsp_pdata),
0464 OF_DEV_AUXDATA("ti,omap3-mcbsp", 0x49024000, "49024000.mcbsp", &mcbsp_pdata),
0465 #endif
0466 #endif
0467 #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
0468 OF_DEV_AUXDATA("ti,omap4-smartreflex-iva", 0x4a0db000,
0469 "4a0db000.smartreflex", &omap_sr_pdata[OMAP_SR_IVA]),
0470 OF_DEV_AUXDATA("ti,omap4-smartreflex-core", 0x4a0dd000,
0471 "4a0dd000.smartreflex", &omap_sr_pdata[OMAP_SR_CORE]),
0472 OF_DEV_AUXDATA("ti,omap4-smartreflex-mpu", 0x4a0d9000,
0473 "4a0d9000.smartreflex", &omap_sr_pdata[OMAP_SR_MPU]),
0474 #endif
0475 #ifdef CONFIG_SOC_DRA7XX
0476 OF_DEV_AUXDATA("ti,dra7-dsp-iommu", 0x40d01000, "40d01000.mmu",
0477 &dra7_ipu1_dsp_iommu_pdata),
0478 OF_DEV_AUXDATA("ti,dra7-dsp-iommu", 0x41501000, "41501000.mmu",
0479 &dra7_ipu1_dsp_iommu_pdata),
0480 OF_DEV_AUXDATA("ti,dra7-iommu", 0x58882000, "58882000.mmu",
0481 &dra7_ipu1_dsp_iommu_pdata),
0482 #endif
0483
0484 OF_DEV_AUXDATA("simple-pm-bus", 0, NULL, omap_auxdata_lookup),
0485 OF_DEV_AUXDATA("ti,sysc", 0, NULL, &ti_sysc_pdata),
0486 OF_DEV_AUXDATA("pinctrl-single", 0, NULL, &pcs_pdata),
0487 OF_DEV_AUXDATA("ti,omap-prm-inst", 0, NULL, &ti_prm_pdata),
0488 OF_DEV_AUXDATA("ti,omap-sdma", 0, NULL, &dma_plat_info),
0489 { },
0490 };
0491
0492
0493
0494
0495
0496 static struct pdata_init pdata_quirks[] __initdata = {
0497 #ifdef CONFIG_ARCH_OMAP3
0498 { "compulab,omap3-sbc-t3517", omap3_sbc_t3517_legacy_init, },
0499 { "compulab,omap3-sbc-t3530", omap3_sbc_t3530_legacy_init, },
0500 { "compulab,omap3-sbc-t3730", omap3_sbc_t3730_legacy_init, },
0501 { "nokia,omap3-n900", nokia_n900_legacy_init, },
0502 { "nokia,omap3-n9", hsmmc2_internal_input_clk, },
0503 { "nokia,omap3-n950", hsmmc2_internal_input_clk, },
0504 { "logicpd,dm3730-torpedo-devkit", omap3_logicpd_torpedo_init, },
0505 { "ti,omap3-evm-37xx", omap3_evm_legacy_init, },
0506 { "ti,am3517-evm", am3517_evm_legacy_init, },
0507 { "technexion,omap3-tao3530", omap3_tao3530_legacy_init, },
0508 { "openpandora,omap3-pandora-600mhz", omap3_pandora_legacy_init, },
0509 { "openpandora,omap3-pandora-1ghz", omap3_pandora_legacy_init, },
0510 #endif
0511 { },
0512 };
0513
0514 static void pdata_quirks_check(struct pdata_init *quirks)
0515 {
0516 while (quirks->compatible) {
0517 if (of_machine_is_compatible(quirks->compatible)) {
0518 if (quirks->fn)
0519 quirks->fn();
0520 }
0521 quirks++;
0522 }
0523 }
0524
0525 static const char * const pdata_quirks_init_nodes[] = {
0526 "prcm",
0527 "prm",
0528 };
0529
0530 static void __init
0531 pdata_quirks_init_clocks(const struct of_device_id *omap_dt_match_table)
0532 {
0533 struct device_node *np;
0534 int i;
0535
0536 for (i = 0; i < ARRAY_SIZE(pdata_quirks_init_nodes); i++) {
0537 np = of_find_node_by_name(NULL, pdata_quirks_init_nodes[i]);
0538 if (!np)
0539 continue;
0540
0541 of_platform_populate(np, omap_dt_match_table,
0542 omap_auxdata_lookup, NULL);
0543
0544 of_node_put(np);
0545 }
0546 }
0547
0548 void __init pdata_quirks_init(const struct of_device_id *omap_dt_match_table)
0549 {
0550
0551
0552
0553
0554 if (of_machine_is_compatible("ti,omap2420") ||
0555 of_machine_is_compatible("ti,omap3"))
0556 omap_sdrc_init(NULL, NULL);
0557
0558 if (of_machine_is_compatible("ti,omap3"))
0559 omap3_mcbsp_init();
0560 pdata_quirks_check(auxdata_quirks);
0561
0562 pdata_quirks_init_clocks(omap_dt_match_table);
0563
0564 of_platform_populate(NULL, omap_dt_match_table,
0565 omap_auxdata_lookup, NULL);
0566 pdata_quirks_check(pdata_quirks);
0567 }