static void __init sun5i_timer_init(struct device_node *node) { struct reset_control *rstc; void __iomem *timer_base; struct clk *clk; int irq; timer_base = of_io_request_and_map(node, 0, of_node_full_name(node)); if (!timer_base) panic("Can't map registers"); irq = irq_of_parse_and_map(node, 0); if (irq <= 0) panic("Can't parse IRQ"); clk = of_clk_get(node, 0); if (IS_ERR(clk)) panic("Can't get timer clock"); rstc = of_reset_control_get(node, NULL); if (!IS_ERR(rstc)) reset_control_deassert(rstc); sun5i_setup_clocksource(node, timer_base, clk, irq); sun5i_setup_clockevent(node, timer_base, clk, irq); }
static int __init sun5i_timer_init(struct device_node *node) { struct reset_control *rstc; void __iomem *timer_base; struct clk *clk; int irq, ret; timer_base = of_io_request_and_map(node, 0, of_node_full_name(node)); if (IS_ERR(timer_base)) { pr_err("Can't map registers\n"); return PTR_ERR(timer_base); } irq = irq_of_parse_and_map(node, 0); if (irq <= 0) { pr_err("Can't parse IRQ\n"); return -EINVAL; } clk = of_clk_get(node, 0); if (IS_ERR(clk)) { pr_err("Can't get timer clock\n"); return PTR_ERR(clk); } rstc = of_reset_control_get(node, NULL); if (!IS_ERR(rstc)) reset_control_deassert(rstc); ret = sun5i_setup_clocksource(node, timer_base, clk, irq); if (ret) return ret; return sun5i_setup_clockevent(node, timer_base, clk, irq); }
static void __init sun5i_timer_init(struct device_node *node) { struct reset_control *rstc; unsigned long rate; struct clk *clk; int ret, irq; u32 val; timer_base = of_iomap(node, 0); if (!timer_base) panic("Can't map registers"); irq = irq_of_parse_and_map(node, 0); if (irq <= 0) panic("Can't parse IRQ"); clk = of_clk_get(node, 0); if (IS_ERR(clk)) panic("Can't get timer clock"); clk_prepare_enable(clk); rate = clk_get_rate(clk); rstc = of_reset_control_get(node, NULL); if (!IS_ERR(rstc)) reset_control_deassert(rstc); writel(~0, timer_base + TIMER_INTVAL_LO_REG(1)); writel(TIMER_CTL_ENABLE | TIMER_CTL_RELOAD, timer_base + TIMER_CTL_REG(1)); sched_clock_register(sun5i_timer_sched_read, 32, rate); clocksource_mmio_init(timer_base + TIMER_CNTVAL_LO_REG(1), node->name, rate, 340, 32, clocksource_mmio_readl_down); ticks_per_jiffy = DIV_ROUND_UP(rate, HZ); ret = setup_irq(irq, &sun5i_timer_irq); if (ret) pr_warn("failed to setup irq %d\n", irq); /* Enable timer0 interrupt */ val = readl(timer_base + TIMER_IRQ_EN_REG); writel(val | TIMER_IRQ_EN(0), timer_base + TIMER_IRQ_EN_REG); sun5i_clockevent.cpumask = cpu_possible_mask; sun5i_clockevent.irq = irq; clockevents_config_and_register(&sun5i_clockevent, rate, TIMER_SYNC_TICKS, 0xffffffff); }
/* * The 1st USB controller contains some UTMI pad registers that are global for * all the controllers on the chip. Those registers are also cleared when * reset is asserted to the 1st controller. This means that the 1st controller * can only be reset when no other controlled has finished probing. So we'll * reset the 1st controller before doing any other setup on any of the * controllers, and then never again. * * Since this is a PHY issue, the Tegra PHY driver should probably be doing * the resetting of the USB controllers. But to keep compatibility with old * device trees that don't have reset phandles in the PHYs, do it here. * Those old DTs will be vulnerable to total USB breakage if the 1st EHCI * device isn't the first one to finish probing, so warn them. */ static int tegra_reset_usb_controller(struct platform_device *pdev) { struct device_node *phy_np; struct usb_hcd *hcd = platform_get_drvdata(pdev); struct tegra_ehci_hcd *tegra = (struct tegra_ehci_hcd *)hcd_to_ehci(hcd)->priv; phy_np = of_parse_phandle(pdev->dev.of_node, "nvidia,phy", 0); if (!phy_np) return -ENOENT; if (!usb1_reset_attempted) { struct reset_control *usb1_reset; usb1_reset = of_reset_control_get(phy_np, "usb"); if (IS_ERR(usb1_reset)) { dev_warn(&pdev->dev, "can't get utmi-pads reset from the PHY\n"); dev_warn(&pdev->dev, "continuing, but please update your DT\n"); } else { reset_control_assert(usb1_reset); udelay(1); reset_control_deassert(usb1_reset); } reset_control_put(usb1_reset); usb1_reset_attempted = true; } if (!of_property_read_bool(phy_np, "nvidia,has-utmi-pad-registers")) { reset_control_assert(tegra->rst); udelay(1); reset_control_deassert(tegra->rst); } of_node_put(phy_np); return 0; }
static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev, struct plat_stmmacenet_data *plat, const struct rk_gmac_ops *ops) { struct rk_priv_data *bsp_priv; struct device *dev = &pdev->dev; int ret; const char *strings = NULL; int value; bsp_priv = devm_kzalloc(dev, sizeof(*bsp_priv), GFP_KERNEL); if (!bsp_priv) return ERR_PTR(-ENOMEM); bsp_priv->phy_iface = of_get_phy_mode(dev->of_node); bsp_priv->ops = ops; bsp_priv->regulator = devm_regulator_get_optional(dev, "phy"); if (IS_ERR(bsp_priv->regulator)) { if (PTR_ERR(bsp_priv->regulator) == -EPROBE_DEFER) { dev_err(dev, "phy regulator is not available yet, deferred probing\n"); return ERR_PTR(-EPROBE_DEFER); } dev_err(dev, "no regulator found\n"); bsp_priv->regulator = NULL; } ret = of_property_read_string(dev->of_node, "clock_in_out", &strings); if (ret) { dev_err(dev, "Can not read property: clock_in_out.\n"); bsp_priv->clock_input = true; } else { dev_info(dev, "clock input or output? (%s).\n", strings); if (!strcmp(strings, "input")) bsp_priv->clock_input = true; else bsp_priv->clock_input = false; } ret = of_property_read_u32(dev->of_node, "tx_delay", &value); if (ret) { bsp_priv->tx_delay = 0x30; dev_err(dev, "Can not read property: tx_delay."); dev_err(dev, "set tx_delay to 0x%x\n", bsp_priv->tx_delay); } else { dev_info(dev, "TX delay(0x%x).\n", value); bsp_priv->tx_delay = value; } ret = of_property_read_u32(dev->of_node, "rx_delay", &value); if (ret) { bsp_priv->rx_delay = 0x10; dev_err(dev, "Can not read property: rx_delay."); dev_err(dev, "set rx_delay to 0x%x\n", bsp_priv->rx_delay); } else { dev_info(dev, "RX delay(0x%x).\n", value); bsp_priv->rx_delay = value; } bsp_priv->grf = syscon_regmap_lookup_by_phandle(dev->of_node, "rockchip,grf"); if (plat->phy_node) { bsp_priv->integrated_phy = of_property_read_bool(plat->phy_node, "phy-is-integrated"); if (bsp_priv->integrated_phy) { bsp_priv->phy_reset = of_reset_control_get(plat->phy_node, NULL); if (IS_ERR(bsp_priv->phy_reset)) { dev_err(&pdev->dev, "No PHY reset control found.\n"); bsp_priv->phy_reset = NULL; } } } dev_info(dev, "integrated PHY? (%s).\n", bsp_priv->integrated_phy ? "yes" : "no"); bsp_priv->pdev = pdev; return bsp_priv; }