Hi Javier, 2014-02-06 Javier Martinez Canillas <martinez.javier@xxxxxxxxx>: > Hello Matthias, > > On Wed, Feb 5, 2014 at 6:02 PM, Matthias Brugger <matthias.bgg@xxxxxxxxx> wrote: >> Hi, >> >> I'm stuck with dts problem. Whenever I try to find a clock for my >> device, the of_get_clk returns an error "Kernel panic - not syncing: >> Can't get timer clock" >> >> My DTS looks like this (reduced to relevant parts for easier reading): >> > > Could you give more details about your platform? > > I would take a look to Documentation/devicetree/bindings/clock/<your > platform>-clock.txt to be sure that you are using the bindings > correctly. > This is part of some effort to port Linux to a new SoC, so no documentation up to now... Anyway I found the error. I forgot to add my SoC to arch/arm/Makefile so that my SoC specific init funtion weren't called. So my device tree wasn't populated and therefore the clock had no properties. >> #include <dt-bindings/interrupt-controller/irq.h> >> #include <dt-bindings/interrupt-controller/arm-gic.h> >> #include "skeleton.dtsi" >> >> / { >> >> [...] >> >> soc { >> #address-cells = <1>; >> #size-cells = <1>; >> compatible = "simple-bus"; >> ranges; >> >> gic: interrupt-controller@10212000 { >> compatible = "arm,cortex-a9-gic"; >> interrupt-controller; >> #interrupt-cells = <3>; >> reg = <0x10211000 0x1000>, >> <0x10212000 0x1000>; >> }; >> >> osc: oscillator { >> compatible = "fixed-clock"; >> #clock-cells = <1>; > > Looking at Documentation/devicetree/bindings/clock/fixed-clock.txt it says: > > #clock-cells : from common clock binding; shall be set to 0 Yes, you are right. > > while your are setting your clock-cells to 1. > >> clock-frequency = <15000000>; >> clock-output-names = "osc"; >> }; >> >> timer: timer-mysoc { >> compatible = "mysoc,mysoc-timer"; >> reg = <0x10008000 0x30>; >> interrupts = <GIC_SPI 113 IRQ_TYPE_EDGE_RISING>; >> clocks = <&osc 0>; >> clock-names = "system15m"; >> }; >> }; > > Documentation/devicetree/bindings/clock/clock-bindings.txt also says: > > ==Clock consumers== > > Required properties: > clocks: List of phandle and clock specifier pairs, one pair > for each clock input to the device. Note: if the > clock provider specifies '0' for #clock-cells, then > only the phandle portion of the pair will appear. > > So my educated guess is that you should use #clock-cells = <0>; your > your clock provider device node and clocks = <&osc> on your clock > consumer device node. Thats true. > > By looking at DTS and DTSI that uses the fixed-clock binding I see > that all platforms don't have their clocks providers device nodes > under soc {} but on a separate clocks {} node. I didn't find on the > clock-bindings.txt DT bindings documentation that this is a > requirement so probably that is not issue in your case but still > something to keep in mind. > The code I posted is nearly similar to the example in Documentation/devicetree/bindings/clock/clock-bindings.txt. Anyway it seems that of_clk_get searches for the "#clock-cells" cells in the list "clocks". I suppose that the "clocks" list is populated by the node present under clocks {}. Thanks a lot for your hints. Matthias >> }; >> >> >> my /drivers/clocksource/mysoc-timer.c looks like this (reduced to >> relevant parts for easier reading): >> >> [...] >> >> static void __init mysoc_timer_init(struct device_node *node) >> { >> unsigned long rate = 0; >> struct clk *clk; >> int ret, irq; >> u32 val; >> >> gpt_base = of_iomap(node, 0); >> if (!gpt_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); >> >> } >> CLOCKSOURCE_OF_DECLARE(mtk_mt6589, "mysoc,mysoc-timer", >> mysoc_timer_init); >> >> >> What I'm missing? I seems as if the clock "osc" is not found in the >> device tree. Any idea why. Building the DTB works without errors, but >> I suppose that doesn't mean too much anyway. >> >> Cheers, >> Matthias >> >> -- >> motzblog.wordpress.com > > Hope it helps, > > Javier -- motzblog.wordpress.com _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies