From: Paul Osmialowski <pawelo@king.net.pl>
To: Michael Turquette <mturquette@baylibre.com>
Cc: Paul Osmialowski <pawelo@king.net.pl>,
Arnd Bergmann <arnd@arndb.de>,
Mark Rutland <mark.rutland@arm.com>,
Nicolas Pitre <nicolas.pitre@linaro.org>,
Linus Walleij <linus.walleij@linaro.org>,
Rob Herring <r.herring@freescale.com>,
Alexander Potashev <aspotashev@emcraft.com>,
Frank Li <Frank.Li@freescale.com>, Jiri Slaby <jslaby@suse.cz>,
linux-clk@vger.kernel.org, Russell King <linux@arm.linux.org.uk>,
Vinod Koul <vinod.koul@intel.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
linux-serial@vger.kernel.org,
Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>,
Anson Huang <b20788@freescale.com>,
devicetree@vger.kernel.org, Pawel Moll <pawel.moll@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Kumar Gala <galak@codeaurora.org>,
Yuri Tikhonov <yur@emcraft.com>,
linux-gpio@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v2 3/9] arm: twr-k70f120m: clock driver for Kinetis SoC
Date: Sun, 26 Jul 2015 22:24:08 +0200 (CEST) [thread overview]
Message-ID: <alpine.LNX.2.00.1507262211470.28341@localhost.localdomain> (raw)
In-Reply-To: <20150724034229.642.88156@quantum>
Hi Mike,
Thank you for spending time on this and pointing me into the right
direction. I'm wondering about going even further with it. Assuming that I
know everything about my board, I can skip run-time discovery phase (note
that the original driver was designed for other Kinetis-based boards too)
and move everything into DTS, somewhat like this:
/ {
osc0: clock {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <50000000>;
};
osc1: clock {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <12000000>;
};
rtc: clock {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <32768>;
};
mcgout: clock {
compatible = "fixed-factor-clock";
#clock-cells = <0>;
clocks = <&osc0>;
clock-mult = <12>;
clock-div = <5>;
};
core: clock {
compatible = "fixed-factor-clock";
#clock-cells = <0>;
clocks = <&mcgout>;
clock-mult = <1>;
clock-div = <1>;
};
bus: clock {
compatible = "fixed-factor-clock";
#clock-cells = <0>;
clocks = <&mcgout>;
clock-mult = <1>;
clock-div = <2>;
};
soc {
cmu@0x40047000 {
compatible = "fsl,kinetis-gate-clock";
reg = <0x40047000 0x1100>;
mcg_core_gate: clock-gate {
clocks = <&core>;
#clock-cells = <2>;
};
mcg_bus_gate: clock-gate {
clocks = <&bus>;
#clock-cells = <2>;
};
osc0_erclk_gate: clock-gate {
clocks = <&osc0>;
#clock-cells = <2>;
};
};
uart0: serial@4006a000 {
compatible = "fsl,kinetis-lpuart";
reg = <0x4006a000 0x1000>;
interrupts = <45>, <46>;
interrupt-names = "uart-stat", "uart-err";
clocks = <&mcg_core_gate 3 10>;
clock-names = "ipg";
dmas = <&edma 0 2>;
dma-names = "rx";
status = "disabled";
};
};
};
As you can see, mcg part is not required anymore.
I guess that the approach above would require split into soc-specific and
board-specific part (as I said, dividers arrangement is something board
specific), but I wonder what you thing about this proposal.
Thanks,
Paul
On Thu, 23 Jul 2015, Michael Turquette wrote:
> Quoting Paul Osmialowski (2015-07-04 14:50:03)
> > Hi Arnd,
> >
> > I'm attaching excerpt from Kinetis reference manual that may make
> > situation clearer.
>
> Hi Paul,
>
> Can you please post the patch in the body of the email instead of an
> attachment? It makes it easier to review. Another small nitpick is that
> the $SUBJECT for this patch might be better off as something like:
>
> clk: mcg and sim clock drivers for twr-k70f120m Kinetis SoC
>
> At least it helps me find the patch I care about when skimming the
> series ;-)
>
> >
> > These MCG and SIM registers are used only to determine configuration
> > (clock fixed rates and clock signal origins) at run time.
> >
> > Namely, the real MCGOUTCLK source (in the middle) which is the parent for
> > core clock (CCLK) and peripheral clock (PCLK) is determined at run time by
> > reading MCG registers, let me quote commit message from Emcraft git repo:
> >
> > * Determine in run-time what oscillator module (OSC0 or OSC1) is used
> > as clock source for the main PLL.
>
> According to [0] there are three options: a 32k RTC osc clock and osc0
> both feed into a mux. You should model this 32k clock with the
> fixed-rate binding.
>
> > * When OSC1 is selected, assume its frequency to be 12 MHz on all
> > boards (there is a 12 MHz oscillator on XTAL1/EXTAL1 on K70-SOM and
> > TWR-K70F120M boards).
> >
> > In my .dts I'm trying to possibly follow real clock hierarchy, but to go
> > anywhere behind MCGOUTCLK would require ability to rewrite .dtb e.g. by
> > U-boot. But that's too demanding for any potential users of this BSP. So
> > let's asume that MCGOUTCLK is the root clock and a parent for CCLK and
> > PCLK.
>
> I'm confused. The point of device tree is to solve problems like this;
> i.e. board-specific differences such as different oscillator
> frequencies.
>
> OSC0 and OSC1 should each be a fixed-rate clock in your board-specific
> TWR-K70F120M DTS (not a chip-specific file). They do not belong in the
> cmu node, and they should use the "fixed-clock" binding. The 32k RTC osc
> can probably go in your chip-specific .dtsi as a fixed-rate clock since
> it appears to mandated in the reference manual[0].
>
> These three fixed-rate clocks are your root clock nodes. Customers only
> need to worry about this if they spin a board, and then they will need
> to populate the frequencies of OSC0 and OSC1 in their board-specific
> .dts.
>
> Please break clk-kinetis.c into two files:
> drivers/clk/kinetis/clk-mcg.c
> drivers/clk/kinetis/clk-sim.c
>
> Below is what your binding/dts should look like:
>
> {
> osc0: clock {
> compatible = "fixed-clock";
> #clock-cells = <0>;
> clock-frequency = <50000000>;
> };
>
> osc1: clock {
> compatible = "fixed-clock";
> #clock-cells = <0>;
> clock-frequency = <12000000>;
> };
>
> rtc: clock {
> compatible = "fixed-clock";
> #clock-cells = <0>;
> clock-frequency = <32768>;
> };
>
> soc: soc {
> mcg: clock-controller@40064000 {
> compatible = "fsl,kinetis-mcg";
> clock-cells = <1>;
> reg = <0x40064000 0x14>;
> clocks = <&osc0>, <&osc1>, <&rtc>;
> clock-names = "osc0", "osc1", "rtc";
> };
>
> sim: clock-controller@40047000 {
> compatible = "fsl,kinetis-sim";
> clock-cells = <1>;
> reg = <0x40047000 0x1100>;
> clocks = <&mcg MCG_MCGOUTCLK_DIV1>, <&mcg MCG_MCGOUTCLK_DIV2>, <&mcg MCG_MCGOUTCLK_DIV3> <&mcg MCG_MCGOUTCLK_DIV4>;
> clock-names = "core", "bus", "flexbus", "flash";
> };
> };
>
> uart0: serial@4006a000 {
> compatible = "fsl,kinetis-lpuart";
> reg = <0x4006a000 0x1000>;
> clocks = <&sim SIM_SCGC4_UART1_CLK>;
> clock-names = "gate";
> };
>
> I removed the interrupts and dma stuff from the uart0 node for clarity.
> The above is the only style of binding that I have been accepting for
> some time; first declare the clock controller and establish its register
> space, and then consumers can consume clocks by providing the phandle to
> the controller plus an offset corresponding to a unique clock. The
> clock-names property makes it really easy to use with the clkdev stuff
> (e.g. clk_get()).
>
> I've covered this before on the mailing list so here is a link
> describing how the qcom bindings do it in detail:
>
> http://lkml.kernel.org/r/<20150416192014.19585.9663@quantum>
>
> Technically you could encode the same bits as sub-nodes of the mcg and
> sim nodes, but the shared header is how the magic happens with the
> driver so it's best to keep the clock controller binding small and
> light.
>
> I think this means you can also get rid of kinetis_of_clk_get_name and
> kinetis_clk_gate_get but my brain is tired so I'll leave that as an
> exercise to the reader.
>
> [0] http://cache.freescale.com/files/microcontrollers/doc/ref_manual/K70P256M150SF3RM.pdf
>
> Regards,
> Mike
>
> >
> > In my most recent version I added OSC0ERCLK explicitly as one more root
> > clock, since it is also used directly (through CG reg. 1 bit 0) by
> > Freescale fec network device whose in-tree driver I'm trying to make
> > usable for Kinetis.
> >
> > On Sat, 4 Jul 2015, Arnd Bergmann wrote:
> >
> > > On Friday 03 July 2015 00:08:27 Thomas Gleixner wrote:
> > >> On Thu, 2 Jul 2015, Paul Osmialowski wrote:
> > >>> On Thu, 2 Jul 2015, Arnd Bergmann wrote:
> > >>>
> > >>>> I wonder if you could move out the fixed rate clocks into their own
> > >>>> nodes. Are they actually controlled by the same block? If they are
> > >>>> just fixed, you can use the normal binding for fixed rate clocks
> > >>>> and only describe the clocks that are related to the driver.
> > >>>
> > >>> In my view having these clocks grouped together looks more convincing. After
> > >>> all, they all share the same I/O regs in order to read configuration.
> > >>
> > >> The fact that they share a register is not making them a group. That's
> > >> just a HW design decision and you need to deal with that by protecting
> > >> the register access, but not by trying to group them artificially at
> > >> the functional level.
> > >
> > > I'd disagree with that: The clock controller is the device that owns the
> > > registers and that should be one node in DT, as Paul's first version does.
> > >
> > > The part I'm still struggling with is understanding how the fixed-rate
> > > clocks are controlled through those registers. If they are indeed configured
> > > through the registers, the name is probably wrong and should be changed
> > > to whatever kind of non-fixed clock this is.
> > >
> > > Arnd
> > >
> >
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
next prev parent reply other threads:[~2015-07-26 20:24 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-30 12:27 [PATCH v2 0/9] [New BSP] Add initial support for Freescale Kinetis TWR-K70F120M development kit Paul Osmialowski
[not found] ` <1435667250-28299-1-git-send-email-pawelo-rhuoMcPwk82rDJvtcaxF/A@public.gmane.org>
2015-06-30 12:27 ` [PATCH v2 1/9] arm: allow copying of vector table to internal SRAM memory Paul Osmialowski
2015-06-30 12:27 ` [PATCH v2 4/9] arm: twr-k70f120m: timer driver for Kinetis SoC Paul Osmialowski
[not found] ` <1435667250-28299-5-git-send-email-pawelo-rhuoMcPwk82rDJvtcaxF/A@public.gmane.org>
2015-06-30 20:43 ` Arnd Bergmann
2015-07-01 11:44 ` Paul Osmialowski
2015-07-05 14:39 ` Rob Herring
2015-07-01 7:51 ` Thomas Gleixner
2015-07-01 8:42 ` Paul Osmialowski
2015-07-01 13:28 ` Thomas Gleixner
2015-07-01 14:20 ` Paul Osmialowski
2015-07-14 8:59 ` Linus Walleij
2015-06-30 12:27 ` [PATCH v2 9/9] arm: twr-k70f120m: use Freescale lpuart driver with " Paul Osmialowski
2015-06-30 12:27 ` [PATCH v2 2/9] arm: twr-k70f120m: basic support for Kinetis TWR-K70F120M Paul Osmialowski
2015-06-30 12:27 ` [PATCH v2 3/9] arm: twr-k70f120m: clock driver for Kinetis SoC Paul Osmialowski
2015-06-30 20:36 ` Arnd Bergmann
2015-07-01 15:57 ` Paul Osmialowski
[not found] ` <alpine.LNX.2.00.1507011756140.14440-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2015-07-02 10:08 ` Paul Osmialowski
2015-07-02 12:40 ` Arnd Bergmann
2015-07-02 21:42 ` Paul Osmialowski
2015-07-02 22:08 ` Thomas Gleixner
2015-07-03 17:40 ` Paul Osmialowski
2015-07-04 19:54 ` Arnd Bergmann
2015-07-04 21:50 ` Paul Osmialowski
2015-07-06 20:57 ` Paul Osmialowski
2015-07-24 3:42 ` Michael Turquette
2015-07-26 20:24 ` Paul Osmialowski [this message]
2015-07-28 16:03 ` Michael Turquette
2015-07-28 20:30 ` Paul Osmialowski
2015-07-29 23:05 ` Michael Turquette
2015-07-30 21:40 ` Paul Osmialowski
2015-08-01 0:58 ` Michael Turquette
2015-08-01 15:27 ` Paul Osmialowski
2015-08-05 19:27 ` Michael Turquette
2015-07-14 9:03 ` Linus Walleij
2015-07-15 7:31 ` Paul Osmialowski
2015-07-15 17:34 ` Paul Osmialowski
2015-06-30 12:27 ` [PATCH v2 5/9] arm: twr-k70f120m: IOMUX " Paul Osmialowski
2015-07-14 8:55 ` Linus Walleij
2015-06-30 12:27 ` [PATCH v2 6/9] arm: twr-k70f120m: extend Freescale eDMA driver with the ability to support " Paul Osmialowski
2015-07-05 6:45 ` Vinod Koul
2015-07-05 9:45 ` Paul Osmialowski
2015-06-30 12:27 ` [PATCH v2 7/9] arm: twr-k70f120m: use Freescale eDMA driver with " Paul Osmialowski
2015-06-30 20:49 ` Arnd Bergmann
2015-07-01 6:54 ` Paul Osmialowski
2015-06-30 12:27 ` [PATCH v2 8/9] arm: twr-k70f120m: extend Freescale lpuart driver with ability to support " Paul Osmialowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LNX.2.00.1507262211470.28341@localhost.localdomain \
--to=pawelo@king.net.pl \
--cc=Frank.Li@freescale.com \
--cc=arnd@arndb.de \
--cc=aspotashev@emcraft.com \
--cc=b20788@freescale.com \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=geert@linux-m68k.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=jslaby@suse.cz \
--cc=linus.walleij@linaro.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mark.rutland@arm.com \
--cc=mturquette@baylibre.com \
--cc=nicolas.pitre@linaro.org \
--cc=pawel.moll@arm.com \
--cc=r.herring@freescale.com \
--cc=robh+dt@kernel.org \
--cc=tglx@linutronix.de \
--cc=u.kleine-koenig@pengutronix.de \
--cc=vinod.koul@intel.com \
--cc=yur@emcraft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox