static void ehrpwm_tblck_disable(struct clk *clk) { u32 val; val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP1_REG)); val &= ~DA8XX_EHRPWM_TBCLKSYNC; writel(val, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP1_REG)); }
static __init void omapl138_hawk_usb_init(void) { int ret; u32 cfgchip2; ret = davinci_cfg_reg_list(da850_hawk_usb11_pins); if (ret) { pr_warning("%s: USB 1.1 PinMux setup failed: %d\n", __func__, ret); return; } /* Setup the Ref. clock frequency for the HAWK at 24 MHz. */ cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); cfgchip2 &= ~CFGCHIP2_REFFREQ; cfgchip2 |= CFGCHIP2_REFFREQ_24MHZ; __raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); ret = gpio_request_one(DA850_USB1_VBUS_PIN, GPIOF_DIR_OUT, "USB1 VBUS"); if (ret < 0) { pr_err("%s: failed to request GPIO for USB 1.1 port " "power control: %d\n", __func__, ret); return; } ret = gpio_request_one(DA850_USB1_OC_PIN, GPIOF_DIR_IN, "USB1 OC"); if (ret < 0) { pr_err("%s: failed to request GPIO for USB 1.1 port " "over-current indicator: %d\n", __func__, ret); goto usb11_setup_oc_fail; } ret = da8xx_register_usb11(&omapl138_hawk_usb11_pdata); if (ret) { pr_warning("%s: USB 1.1 registration failed: %d\n", __func__, ret); goto usb11_setup_fail; } return; usb11_setup_fail: gpio_free(DA850_USB1_OC_PIN); usb11_setup_oc_fail: gpio_free(DA850_USB1_VBUS_PIN); }
static __init void omapl138_hawk_usb_init(void) { u32 cfgchip2; /* Setup the Ref. clock frequency for the HAWK at 24 MHz. */ cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); cfgchip2 &= ~CFGCHIP2_REFFREQ; cfgchip2 |= CFGCHIP2_REFFREQ_24MHZ; __raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); da8xx_board_usb_init(da850_hawk_usb11_pins, &omapl138_hawk_usb11_pdata); return; }
static int da850_lcd_hw_init(void) { void __iomem *cfg_mstpri2_base; int status; u32 val; /* * Reconfigure the LCDC priority to the highest to ensure that * the throughput/latency requirements for the LCDC are met. */ cfg_mstpri2_base = DA8XX_SYSCFG0_VIRT(DA8XX_MSTPRI2_REG); val = __raw_readl(cfg_mstpri2_base); val &= 0x0fffffff; __raw_writel(val, cfg_mstpri2_base); status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n"); if (status < 0) return status; status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n"); if (status < 0) { gpio_free(DA850_LCD_BL_PIN); return status; } gpio_direction_output(DA850_LCD_BL_PIN, 0); gpio_direction_output(DA850_LCD_PWR_PIN, 0); return 0; }
static __init void omapl138_hawk_config_emac(void) { void __iomem *cfgchip3 = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG); int ret; u32 val; struct davinci_soc_info *soc_info = &davinci_soc_info; val = __raw_readl(cfgchip3); val &= ~BIT(8); ret = davinci_cfg_reg_list(omapl138_hawk_mii_pins); if (ret) { pr_warning("%s: cpgmac/mii mux setup failed: %d\n", __func__, ret); return; } /* configure the CFGCHIP3 register for MII */ __raw_writel(val, cfgchip3); pr_info("EMAC: MII PHY configured\n"); soc_info->emac_pdata->phy_id = HAWKBOARD_PHY_ID; ret = da8xx_register_emac(); if (ret) pr_warning("%s: emac registration failed: %d\n", __func__, ret); }
static int __init da850_evm_config_emac(void) { void __iomem *cfg_chip3_base; int ret; u32 val; struct davinci_soc_info *soc_info = &davinci_soc_info; u8 rmii_en = soc_info->emac_pdata->rmii_en; if (!machine_is_davinci_da850_evm()) return 0; cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG); val = __raw_readl(cfg_chip3_base); if (rmii_en) { val |= BIT(8); ret = davinci_cfg_reg_list(da850_rmii_pins); pr_info("EMAC: RMII PHY configured, MII PHY will not be" " functional\n"); } else { val &= ~BIT(8); ret = davinci_cfg_reg_list(da850_cpgmac_pins); pr_info("EMAC: MII PHY configured, RMII PHY will not be" " functional\n"); } if (ret) pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n", ret); /* configure the CFGCHIP3 register for RMII or MII */ __raw_writel(val, cfg_chip3_base); ret = davinci_cfg_reg(DA850_GPIO2_6); if (ret) pr_warning("da850_evm_init:GPIO(2,6) mux setup " "failed\n"); ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en"); if (ret) { pr_warning("Cannot open GPIO %d\n", DA850_MII_MDIO_CLKEN_PIN); return ret; } /* Enable/Disable MII MDIO clock */ gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en); soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK; soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY; ret = da8xx_register_emac(); if (ret) pr_warning("da850_evm_init: emac registration failed: %d\n", ret); return 0; }
/** * da8xx_get_cfgchip - Lazy gets CFGCHIP as regmap * * This is for use on non-DT boards only. For DT boards, use * syscon_regmap_lookup_by_compatible("ti,da830-cfgchip") * * Returns: Pointer to the CFGCHIP regmap or negative error code. */ struct regmap * __init da8xx_get_cfgchip(void) { if (IS_ERR_OR_NULL(da8xx_cfgchip)) da8xx_cfgchip = regmap_init_mmio(NULL, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP0_REG), &da8xx_cfgchip_config); return da8xx_cfgchip; }
static int da850_async3_set_parent(struct clk *clk, struct clk *parent) { u32 val; val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG)); if (parent == &pll0_sysclk2) { val &= ~CFGCHIP3_ASYNC3_CLKSRC; } else if (parent == &pll1_sysclk2) { val |= CFGCHIP3_ASYNC3_CLKSRC; } else { pr_err("Bad parent on async3 clock mux\n"); return -EINVAL; } writel(val, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG)); return 0; }
static void da850_set_async3_src(int pllnum) { struct clk *clk, *newparent = pllnum ? &pll1_sysclk2 : &pll0_sysclk2; struct clk_lookup *c; unsigned int v; int ret; for (c = da850_clks; c->clk; c++) { clk = c->clk; if (clk->flags & DA850_CLK_ASYNC3) { ret = clk_set_parent(clk, newparent); WARN(ret, "DA850: unable to re-parent clock %s", clk->name); } } v = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG)); if (pllnum) v |= CFGCHIP3_ASYNC3_CLKSRC; else v &= ~CFGCHIP3_ASYNC3_CLKSRC; __raw_writel(v, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG)); }
static void __init mityomapl138_config_emac(void) { void __iomem *cfg_chip3_base; int ret; u32 val; struct davinci_soc_info *soc_info = &davinci_soc_info; soc_info->emac_pdata->rmii_en = 0; /* hardcoded for now */ cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG); val = __raw_readl(cfg_chip3_base); if (soc_info->emac_pdata->rmii_en) { val |= BIT(8); ret = davinci_cfg_reg_list(mityomap_rmii_pins); pr_info("RMII PHY configured\n"); } else { val &= ~BIT(8); ret = davinci_cfg_reg_list(mityomap_mii_pins); pr_info("MII PHY configured\n"); } if (ret) { pr_warning("mii/rmii mux setup failed: %d\n", ret); return; } /* configure the CFGCHIP3 register for RMII or MII */ __raw_writel(val, cfg_chip3_base); soc_info->emac_pdata->phy_id = MITYOMAPL138_PHY_ID; ret = da8xx_register_emac(); if (ret) pr_warning("emac registration failed: %d\n", ret); }
static __init void da830_evm_usb_init(void) { u32 cfgchip2; int ret; /* * Set up USB clock/mode in the CFGCHIP2 register. * FYI: CFGCHIP2 is 0x0000ef00 initially. */ cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); /* USB2.0 PHY reference clock is 24 MHz */ cfgchip2 &= ~CFGCHIP2_REFFREQ; cfgchip2 |= CFGCHIP2_REFFREQ_24MHZ; /* * Select internal reference clock for USB 2.0 PHY * and use it as a clock source for USB 1.1 PHY * (this is the default setting anyway). */ cfgchip2 &= ~CFGCHIP2_USB1PHYCLKMUX; cfgchip2 |= CFGCHIP2_USB2PHYCLKMUX; /* * We have to override VBUS/ID signals when MUSB is configured into the * host-only mode -- ID pin will float if no cable is connected, so the * controller won't be able to drive VBUS thinking that it's a B-device. * Otherwise, we want to use the OTG mode and enable VBUS comparators. */ cfgchip2 &= ~CFGCHIP2_OTGMODE; #ifdef CONFIG_USB_MUSB_HOST cfgchip2 |= CFGCHIP2_FORCE_HOST; #else cfgchip2 |= CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN; #endif __raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); /* USB_REFCLKIN is not used. */ ret = davinci_cfg_reg(DA830_USB0_DRVVBUS); if (ret) pr_warning("%s: USB 2.0 PinMux setup failed: %d\n", __func__, ret); else { /* * TPS2065 switch @ 5V supplies 1 A (sustains 1.5 A), * with the power on to power good time of 3 ms. */ ret = da8xx_register_usb20(1000, 3); if (ret) pr_warning("%s: USB 2.0 registration failed: %d\n", __func__, ret); } ret = davinci_cfg_reg_list(da830_evm_usb11_pins); if (ret) { pr_warning("%s: USB 1.1 PinMux setup failed: %d\n", __func__, ret); return; } ret = gpio_request(ON_BD_USB_DRV, "ON_BD_USB_DRV"); if (ret) { printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port " "power control: %d\n", __func__, ret); return; } gpio_direction_output(ON_BD_USB_DRV, 0); ret = gpio_request(ON_BD_USB_OVC, "ON_BD_USB_OVC"); if (ret) { printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port " "over-current indicator: %d\n", __func__, ret); return; } gpio_direction_input(ON_BD_USB_OVC); ret = da8xx_register_usb11(&da830_evm_usb11_pdata); if (ret) pr_warning("%s: USB 1.1 registration failed: %d\n", __func__, ret); }
/** * da850_enable_pca9543a() - Enable/Disable I2C switch PCA9543A for sensor * @en: enable/disable flag */ static int da850_enable_pca9543a(int en) { static char val = 1; int status = 1; struct i2c_msg msg = { .flags = 0, .len = 1, .buf = &val, }; pr_info("da850evm_enable_pca9543a\n"); if (!en) val = 0; if (!pca9543a) return -ENXIO; msg.addr = pca9543a->addr; /* turn i2c switch, pca9543a, on/off */ status = i2c_transfer(pca9543a->adapter, &msg, 1); if (status == 1) status = 0; return status; } static const short da850_evm_mii_pins[] = { DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3, DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER, DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3, DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK, DA850_MDIO_D, -1 }; static const short da850_evm_rmii_pins[] = { DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN, DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1, DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK, DA850_MDIO_D, -1 }; static int __init da850_evm_config_emac(void) { void __iomem *cfg_chip3_base; int ret; u32 val; struct davinci_soc_info *soc_info = &davinci_soc_info; u8 rmii_en = soc_info->emac_pdata->rmii_en; if (!machine_is_davinci_da850_evm()) return 0; cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG); val = __raw_readl(cfg_chip3_base); if (rmii_en) { val |= BIT(8); ret = davinci_cfg_reg_list(da850_evm_rmii_pins); pr_info("EMAC: RMII PHY configured, MII PHY will not be" " functional\n"); } else { val &= ~BIT(8); ret = davinci_cfg_reg_list(da850_evm_mii_pins); pr_info("EMAC: MII PHY configured, RMII PHY will not be" " functional\n"); } if (ret) pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n", ret); /* configure the CFGCHIP3 register for RMII or MII */ __raw_writel(val, cfg_chip3_base); ret = davinci_cfg_reg(DA850_GPIO2_6); if (ret) pr_warning("da850_evm_init:GPIO(2,6) mux setup " "failed\n"); ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en"); if (ret) { pr_warning("Cannot open GPIO %d\n", DA850_MII_MDIO_CLKEN_PIN); return ret; } /* Enable/Disable MII MDIO clock */ gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en); soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID; ret = da8xx_register_emac(); if (ret) pr_warning("da850_evm_init: emac registration failed: %d\n", ret); return 0; }