RE: [PATCH v7 06/10] clk: Add Sunplus SP7021 clock driver

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

 



> > > > +
> > > > +CLK_OF_DECLARE_DRIVER(sp_clkc, "sunplus,sp7021-clkc", sp_clk_setup);
> > >
> > > Why CLK_OF_DECLARE_DRIVER? There should be a comment but better would be
> > > to make a platform driver instead. If the platform driver can't be used,
> > > we need to know what other device driver is probing based on this clkc
> > > compatible string.
> >
> > Dear Stephen,
> >
> > Sorry, I don't understand your comment.
> > Did you mean, like below:
> >
> > static int sp7021_clk_probe(struct platform_device *pdev)
> > {
> >         ......
> >         sp_clk_data->num = CLK_MAX;
> >         return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, sp_clk_data);
> > }
> >
> > static const struct of_device_id sp7021_clk_dt_ids[] = {
> >         { .compatible = "sunplus,sp7021-clkc", },
> >         { }
> > };
> > MODULE_DEVICE_TABLE(of, sp7021_clk_dt_ids);
> >
> > static struct platform_driver sp7021_clk_driver = {
> >         .probe  = sp7021_clk_probe,
> >         .driver = {
> >                 .name = "sp7021-clk",
> >                 .of_match_table = sp7021_clk_dt_ids,
> >         },
> > };
> > builtin_platform_driver(sp7021_clk_driver);
> >
> >
> > But, It's doesn't work.
> 
> Why doesn't it work?
> 
> > Most other clk drivers used CLK_OF_DECLARE_DRIVER or CLK_OF_DECLARE.
> > I just take these as the reference and it's working.
> 
> CLK_OF_DECLARE is for clks that need to be registered so the main
> irqchip and/or clocksource/clockevent can operate properly.
> CLK_OF_DECLARE_DRIVER is for the case that there's another driver that
> will attach to the device node that has the compatible string.

After some trace, I found:
In our dts, 'clkc' node defined @ clocks:
	clocks {
		...
		clkc: clock-controller@9c000000 {
			#clock-cells = <1>;
			compatible = "sunplus,sp7021-clkc";
			reg = <0x9c000000 0x280>; // G0:CLKEN ~ G4:PLL
			clocks = <&extclk>, <&clkc PLL_SYS>;
			clock-names = "extclk", "pllsys";
		};
	};
	soc {
		...
	}
In this case, clk driver write as platform driver not work (sp7021_clk_probe not called)
But, CLK_OF_DECLARE and CLK_OF_DECLARE_DRIVER both worked (called from clk_of_init)

Then, I move the 'clkc' mode from 'clocks' to 'soc':
	clocks {
		...
	};
	soc {
		...
		clkc: clock-controller@9c000000 {
			#clock-cells = <1>;
			compatible = "sunplus,sp7021-clkc";
			reg = <0x9c000000 0x280>; // G0:CLKEN ~ G4:PLL
			clocks = <&extclk>, <&clkc PLL_SYS>;
			clock-names = "extclk", "pllsys";
		};
	}
In this case, clk driver write as platform driver worked (called from platform_probe)
CLK_OF_DECLARE and CLK_OF_DECLARE_DRIVER also both worked. (still called from clk_of_init, more early than platform_probe)

It looks like CLK_OF_DECLARE/CLK_OF_DECLARE_DRIVER is better than platform driver.
Why you prefer platform driver?






[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux