[PATCH v9 6/7] clk: rockchip: implement linked gate clock support

Heiko Stübner heiko at sntech.de
Mon Sep 2 07:03:56 PDT 2024


Am Montag, 25. März 2024, 20:33:37 CEST schrieb Sebastian Reichel:
> Recent Rockchip SoCs have a new hardware block called Native Interface
> Unit (NIU), which gates clocks to devices behind them. These clock
> gates will only have a running output clock when all of the following
> conditions are met:
> 
> 1. the parent clock is enabled
> 2. the enable bit is set correctly
> 3. the linked clock is enabled
> 
> To handle them this code registers them as a normal gate type clock,
> which takes care of condition 1 + 2. The linked clock is handled by
> using runtime PM clocks. Handling it via runtime PM requires setting
> up a struct device for each of these clocks with a driver attached
> to use the correct runtime PM operations. Thus the complete handling
> of these clocks has been moved into its own driver.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel at collabora.com>

> +static void rk_clk_gate_link_remove(struct platform_device *pdev)
> +{
> +	struct rockchip_gate_link_platdata *pdata;
> +	struct device *dev = &pdev->dev;
> +	struct clk *clk, *linked_clk;
> +
> +	pdata = dev_get_platdata(dev);
> +	clk = rockchip_clk_get_lookup(pdata->ctx, pdata->clkbr->id);
> +	linked_clk = rockchip_clk_get_lookup(pdata->ctx, pdata->clkbr->linked_clk_id);
> +	rockchip_clk_set_lookup(pdata->ctx, ERR_PTR(-ENODEV), pdata->clkbr->id);
> +	clk_unregister_gate(clk);
> +	pm_clk_remove_clk(dev, linked_clk);
> +}
> +
> +static const struct dev_pm_ops rk_clk_gate_link_pm_ops = {
> +	SET_RUNTIME_PM_OPS(pm_clk_suspend, pm_clk_resume, NULL)
> +};
> +
> +struct platform_driver rk_clk_gate_link_driver = {
> +	.probe		= rk_clk_gate_link_probe,
> +	.remove_new	= rk_clk_gate_link_remove,

what's the use-case for remove?

We don't allow the main clock driver to be unbound, so I guess we might
want to do the same here? On a system-level they're getting registered
automatically but never unregistered, so the only case here would be
a manual unbind - but I'd think that would cause mayhem anyway?






More information about the Linux-rockchip mailing list