Lines Matching +full:omap +full:- +full:l13x
1 // SPDX-License-Identifier: GPL-2.0
3 * Clock driver for DA8xx/AM17xx/AM18xx/OMAP-L13x CFGCHIP
8 #include <linux/clk-provider.h>
12 #include <linux/mfd/da8xx-cfgchip.h>
15 #include <linux/platform_data/clk-da8xx-cfgchip.h>
21 /* --- Gate clocks --- */
46 return regmap_write_bits(clk->regmap, clk->reg, clk->mask, clk->mask); in da8xx_cfgchip_gate_clk_enable()
53 regmap_write_bits(clk->regmap, clk->reg, clk->mask, 0); in da8xx_cfgchip_gate_clk_disable()
61 regmap_read(clk->regmap, clk->reg, &val); in da8xx_cfgchip_gate_clk_is_enabled()
63 return !!(val & clk->mask); in da8xx_cfgchip_gate_clk_is_enabled()
105 return ERR_PTR(-ENOMEM); in da8xx_cfgchip_gate_clk_register()
107 init.name = info->name; in da8xx_cfgchip_gate_clk_register()
108 if (info->flags & DA8XX_GATE_CLOCK_IS_DIV4P5) in da8xx_cfgchip_gate_clk_register()
116 gate->hw.init = &init; in da8xx_cfgchip_gate_clk_register()
117 gate->regmap = regmap; in da8xx_cfgchip_gate_clk_register()
118 gate->reg = info->cfgchip; in da8xx_cfgchip_gate_clk_register()
119 gate->mask = info->bit; in da8xx_cfgchip_gate_clk_register()
121 ret = devm_clk_hw_register(dev, &gate->hw); in da8xx_cfgchip_gate_clk_register()
144 clk_hw_register_clkdev(&gate->hw, "tbclk", "ehrpwm.0"); in da8xx_cfgchip_register_tbclk()
145 clk_hw_register_clkdev(&gate->hw, "tbclk", "ehrpwm.1"); in da8xx_cfgchip_register_tbclk()
193 /* --- MUX clocks --- */
216 unsigned int val = index ? clk->mask : 0; in da8xx_cfgchip_mux_clk_set_parent()
218 return regmap_write_bits(clk->regmap, clk->reg, clk->mask, val); in da8xx_cfgchip_mux_clk_set_parent()
226 regmap_read(clk->regmap, clk->reg, &val); in da8xx_cfgchip_mux_clk_get_parent()
228 return (val & clk->mask) ? 1 : 0; in da8xx_cfgchip_mux_clk_get_parent()
242 const char * const parent_names[] = { info->parent0, info->parent1 }; in da8xx_cfgchip_mux_clk_register()
249 return ERR_PTR(-ENOMEM); in da8xx_cfgchip_mux_clk_register()
251 init.name = info->name; in da8xx_cfgchip_mux_clk_register()
257 mux->hw.init = &init; in da8xx_cfgchip_mux_clk_register()
258 mux->regmap = regmap; in da8xx_cfgchip_mux_clk_register()
259 mux->reg = info->cfgchip; in da8xx_cfgchip_mux_clk_register()
260 mux->mask = info->bit; in da8xx_cfgchip_mux_clk_register()
262 ret = devm_clk_hw_register(dev, &mux->hw); in da8xx_cfgchip_mux_clk_register()
286 clk_hw_register_clkdev(&mux->hw, "async1", "da850-psc0"); in da8xx_cfgchip_register_async1()
309 clk_hw_register_clkdev(&mux->hw, "async3", "da850-psc1"); in da850_cfgchip_register_async3()
312 parent = clk_hw_get_parent_by_index(&mux->hw, 1); in da850_cfgchip_register_async3()
314 clk_set_parent(mux->hw.clk, parent->clk); in da850_cfgchip_register_async3()
332 return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, &mux->hw); in of_da8xx_cfgchip_init_mux_clock()
345 /* --- USB 2.0 PHY clock --- */
364 return clk_prepare(usb0->fck); in da8xx_usb0_clk48_prepare()
371 clk_unprepare(usb0->fck); in da8xx_usb0_clk48_unprepare()
383 clk_enable(usb0->fck); in da8xx_usb0_clk48_enable()
391 regmap_write_bits(usb0->regmap, CFGCHIP(2), mask, val); in da8xx_usb0_clk48_enable()
392 ret = regmap_read_poll_timeout(usb0->regmap, CFGCHIP(2), val, in da8xx_usb0_clk48_enable()
395 clk_disable(usb0->fck); in da8xx_usb0_clk48_enable()
406 regmap_write_bits(usb0->regmap, CFGCHIP(2), val, val); in da8xx_usb0_clk48_disable()
414 regmap_read(usb0->regmap, CFGCHIP(2), &val); in da8xx_usb0_clk48_is_enabled()
459 regmap_write_bits(usb0->regmap, CFGCHIP(2), mask, val); in da8xx_usb0_clk48_recalc_rate()
468 req->rate = 48000000; in da8xx_usb0_clk48_determine_rate()
477 return regmap_write_bits(usb0->regmap, CFGCHIP(2), in da8xx_usb0_clk48_set_parent()
487 regmap_read(usb0->regmap, CFGCHIP(2), &val); in da8xx_usb0_clk48_get_parent()
521 return ERR_PTR(-ENOMEM); in da8xx_cfgchip_register_usb0_clk48()
528 usb0->hw.init = &init; in da8xx_cfgchip_register_usb0_clk48()
529 usb0->fck = fck_clk; in da8xx_cfgchip_register_usb0_clk48()
530 usb0->regmap = regmap; in da8xx_cfgchip_register_usb0_clk48()
532 ret = devm_clk_hw_register(dev, &usb0->hw); in da8xx_cfgchip_register_usb0_clk48()
539 /* --- USB 1.1 PHY clock --- */
553 return regmap_write_bits(usb1->regmap, CFGCHIP(2), in da8xx_usb1_clk48_set_parent()
563 regmap_read(usb1->regmap, CFGCHIP(2), &val); in da8xx_usb1_clk48_get_parent()
575 * da8xx_cfgchip_register_usb1_clk48 - Register a new USB 1.1 PHY clock
590 return ERR_PTR(-ENOMEM); in da8xx_cfgchip_register_usb1_clk48()
597 usb1->hw.init = &init; in da8xx_cfgchip_register_usb1_clk48()
598 usb1->regmap = regmap; in da8xx_cfgchip_register_usb1_clk48()
600 ret = devm_clk_hw_register(dev, &usb1->hw); in da8xx_cfgchip_register_usb1_clk48()
620 * should use device tree, so hard-coding the value (1) here. in da8xx_cfgchip_register_usb_phy_clk()
622 parent = clk_hw_get_parent_by_index(&usb0->hw, 1); in da8xx_cfgchip_register_usb_phy_clk()
624 clk_set_parent(usb0->hw.clk, parent->clk); in da8xx_cfgchip_register_usb_phy_clk()
634 * should use device tree, so hard-coding the value (0) here. in da8xx_cfgchip_register_usb_phy_clk()
636 parent = clk_hw_get_parent_by_index(&usb1->hw, 0); in da8xx_cfgchip_register_usb_phy_clk()
638 clk_set_parent(usb1->hw.clk, parent->clk); in da8xx_cfgchip_register_usb_phy_clk()
642 clk_hw_register_clkdev(&usb0->hw, "usb0_clk48", "da8xx-usb-phy"); in da8xx_cfgchip_register_usb_phy_clk()
643 clk_hw_register_clkdev(&usb1->hw, "usb1_clk48", "da8xx-usb-phy"); in da8xx_cfgchip_register_usb_phy_clk()
657 return -ENOMEM; in of_da8xx_usb_phy_clk_init()
659 clk_data->num = 2; in of_da8xx_usb_phy_clk_init()
663 if (PTR_ERR(usb0) == -EPROBE_DEFER) in of_da8xx_usb_phy_clk_init()
664 return -EPROBE_DEFER; in of_da8xx_usb_phy_clk_init()
669 clk_data->hws[0] = ERR_PTR(-ENOENT); in of_da8xx_usb_phy_clk_init()
671 clk_data->hws[0] = &usb0->hw; in of_da8xx_usb_phy_clk_init()
676 if (PTR_ERR(usb1) == -EPROBE_DEFER) in of_da8xx_usb_phy_clk_init()
677 return -EPROBE_DEFER; in of_da8xx_usb_phy_clk_init()
682 clk_data->hws[1] = ERR_PTR(-ENOENT); in of_da8xx_usb_phy_clk_init()
684 clk_data->hws[1] = &usb1->hw; in of_da8xx_usb_phy_clk_init()
690 /* --- platform device --- */
694 .compatible = "ti,da830-tbclksync",
698 .compatible = "ti,da830-div4p5ena",
702 .compatible = "ti,da850-async1-clksrc",
706 .compatible = "ti,da850-async3-clksrc",
710 .compatible = "ti,da830-usb-phy-clocks",
718 .name = "da830-tbclksync",
722 .name = "da830-div4p5ena",
726 .name = "da850-async1-clksrc",
730 .name = "da850-async3-clksrc",
734 .name = "da830-usb-phy-clks",
744 struct device *dev = &pdev->dev; in da8xx_cfgchip_probe()
745 struct da8xx_cfgchip_clk_platform_data *pdata = dev->platform_data; in da8xx_cfgchip_probe()
751 struct device_node *parent __free(device_node) = of_get_parent(dev->of_node); in da8xx_cfgchip_probe()
754 } else if (pdev->id_entry && pdata) { in da8xx_cfgchip_probe()
755 clk_init = (void *)pdev->id_entry->driver_data; in da8xx_cfgchip_probe()
756 regmap = pdata->cfgchip; in da8xx_cfgchip_probe()
761 return -EINVAL; in da8xx_cfgchip_probe()
766 return regmap ? PTR_ERR(regmap) : -ENOENT; in da8xx_cfgchip_probe()
775 .name = "da8xx-cfgchip-clk",