tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: clk_set_parent() by name ?



On Mon, Mar 19, 2018 at 04:03:56PM -0300, Jared McNeill wrote:
> On Mon, 19 Mar 2018, Manuel Bouyer wrote:
> 
> > Looking at what we have now, I see 2 ways for doing this:
> > - clk_set_parent(). But this one takes a "struct clk*" as parent,
> >  and I don't have this handy in the driver. There is clk_get(), but it
> >  need the ckock domain, which I also don't have it in the driver.
> >  There is no clk_get_domain()
> > - clk->set_parent(), which takes a clock name. But for this I need to
> >  use a struct sunxi_ccu_clk * instead of struct clk *.
> > 
> > So what should I do to solve this ? Introduce clk_get_domain() or
> > clk_set_parent_byname() in sys/dev/clk/, or use struct sunxi_ccu_clk in
> > the sunxi drivers ?
> 
> The dt should have references to the parent clocks - the hdmi node has:
> 
>    clocks = <&ccu CLK_AHB_HDMI0>, <&ccu CLK_HDMI>,
>             <&ccu 9>,
>             <&ccu 18>;
>    clock-names = "ahb", "mod", "pll-0", "pll-1";
> 
> So you can do something like:
> 
>    struct clk *clk_hdmi = fdtbus_clock_get(phandle, "mod");
>    struct clk *clk_video0 = fdtbus_clock_get(phandle, "pll-0");
>    struct clk *clk_video1 = fdtbus_clock_get(phandle, "pll-1");
> 
>    ...
> 
>    clk_set_parent(clk_hdmi, use_video0 ? clk_video0 : clk_video1);

But for the tcons we have:
                        clocks = <&ccu CLK_AHB_LCD0>,
                                 <&ccu CLK_TCON0_CH0>,
                                 <&ccu CLK_TCON0_CH1>;
                        clock-names = "ahb",
                                      "tcon-ch0",
                                      "tcon-ch1";

the tcon-ch0 and tcon-ch1 can source from A10_CLK_PLL_VIDEO0,
A10_CLK_PLL_VIDEO1, A10_CLK_PLL_VIDEO0X2 or A10_CLK_PLL_VIDEO1X2 which
we don't have in the device tree (well, some of them happens to be in the
hdmi node, but what if we don't use the hdmi ?)

Similary, for debe:
                        clocks = <&ccu CLK_AHB_DE_BE1>, <&ccu CLK_DE_BE1>,
                                 <&ccu CLK_DRAM_DE_BE1>;
                        clock-names = "ahb", "mod",
                                      "ram";
and CLK_DE_BE1 can source from A10_CLK_PLL_VIDEO0, A10_CLK_PLL_VIDEO1, or
A10_CLK_PLL_DDR_BASE, which we don't have in the fdt.

Also for hdmi it's more complicated because it can source from 4 different
clocks ...

I don't think clock mux parameters are supposed to be in the fdt.

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--


Home | Main Index | Thread Index | Old Index