devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Kuske <jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Maxime Ripard
	<maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Cc: "Emilio López" <emilio-0Z03zUJReD5OxF6Tv1QG9Q@public.gmane.org>,
	"Mike Turquette"
	<mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	"Linus Walleij"
	<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	"Rob Herring" <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	"Chen-Yu Tsai" <wens-jdAy2FN1RRM@public.gmane.org>,
	"Vishnu Patekar"
	<vishnupatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Hans de Goede"
	<hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: [PATCH v2 06/10] clk: sunxi: Add H3 clocks support
Date: Mon, 18 May 2015 11:45:50 +0200	[thread overview]
Message-ID: <5559B4CE.2050703@gmail.com> (raw)
In-Reply-To: <20150517142749.GG4004@lukather>

Hi,

On 05/17/15 16:27, Maxime Ripard wrote:
> On Fri, May 15, 2015 at 06:38:56PM +0200, Jens Kuske wrote:
>> The H3 clock control unit is similar to the those of other sun8i family
>> members like the A23.
>>
>> It makes use of the new multiple parents option for the bus gates.
>> Some of the gates use the new AHB2 clock as parent, whose clock source
>> is muxable between AHB1 and PLL6/2. The documentation isn't totally clear
>> about which devices belong to AHB2 now, especially USB EHIC/OHIC, so it
>> is mostly based on Allwinner kernel source code.
>>
>> Signed-off-by: Jens Kuske <jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> ---
>>  Documentation/devicetree/bindings/clock/sunxi.txt |  6 +++
>>  drivers/clk/sunxi/clk-sunxi.c                     | 50 ++++++++++++++++++++++-
>>  2 files changed, 55 insertions(+), 1 deletion(-)
>>
>> diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
>> index 4fa11af..e367963 100644
>> --- a/Documentation/devicetree/bindings/clock/sunxi.txt
>> +++ b/Documentation/devicetree/bindings/clock/sunxi.txt
>> @@ -14,6 +14,7 @@ Required properties:
>>  	"allwinner,sun4i-a10-pll5-clk" - for the PLL5 clock
>>  	"allwinner,sun4i-a10-pll6-clk" - for the PLL6 clock
>>  	"allwinner,sun6i-a31-pll6-clk" - for the PLL6 clock on A31
>> +	"allwinner,sun8i-h3-pll6-clk" - for the PLL6 clock on H3
>>  	"allwinner,sun9i-a80-gt-clk" - for the GT bus clock on A80
>>  	"allwinner,sun4i-a10-cpu-clk" - for the CPU multiplexer clock
>>  	"allwinner,sun4i-a10-axi-clk" - for the AXI clock
>> @@ -28,6 +29,7 @@ Required properties:
>>  	"allwinner,sun7i-a20-ahb-gates-clk" - for the AHB gates on A20
>>  	"allwinner,sun6i-a31-ar100-clk" - for the AR100 on A31
>>  	"allwinner,sun6i-a31-ahb1-clk" - for the AHB1 clock on A31
>> +	"allwinner,sun8i-h3-ahb2-clk" - for the AHB2 clock on H3
>>  	"allwinner,sun6i-a31-ahb1-gates-clk" - for the AHB1 gates on A31
>>  	"allwinner,sun8i-a23-ahb1-gates-clk" - for the AHB1 gates on A23
>>  	"allwinner,sun9i-a80-ahb0-gates-clk" - for the AHB0 gates on A80
>> @@ -55,6 +57,7 @@ Required properties:
>>  	"allwinner,sun9i-a80-apb1-gates-clk" - for the APB1 gates on A80
>>  	"allwinner,sun6i-a31-apb2-gates-clk" - for the APB2 gates on A31
>>  	"allwinner,sun8i-a23-apb2-gates-clk" - for the APB2 gates on A23
>> +	"allwinner,sun8i-h3-bus-gates-clk" - for the bus gates on H3
>>  	"allwinner,sun5i-a13-mbus-clk" - for the MBUS clock on A13
>>  	"allwinner,sun4i-a10-mmc-clk" - for the MMC clock
>>  	"allwinner,sun9i-a80-mmc-clk" - for mmc module clocks on A80
>> @@ -95,6 +98,9 @@ The "allwinner,sun9i-a80-mmc-config-clk" clock also requires:
>>  For "allwinner,sun7i-a20-gmac-clk", the parent clocks shall be fixed rate
>>  dummy clocks at 25 MHz and 125 MHz, respectively. See example.
>>  
>> +For "allwinner,sun8i-h3-bus-gates-clk", the parent clocks shall be
>> +AHB1, AHB2, APB1 and APB2, in that order.
>> +
>>  Clock consumers should specify the desired clocks they use with a
>>  "clocks" phandle cell. Consumers that are using a gated clock should
>>  provide an additional ID in their clock property. This ID is the
>> diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
>> index afe560c..79364be 100644
>> --- a/drivers/clk/sunxi/clk-sunxi.c
>> +++ b/drivers/clk/sunxi/clk-sunxi.c
>> @@ -771,6 +771,10 @@ static const struct mux_data sun6i_a31_ahb1_mux_data __initconst = {
>>  	.shift = 12,
>>  };
>>  
>> +static const struct mux_data sun8i_h3_ahb2_mux_data __initconst = {
>> +	.shift = 0,
>> +};
>> +
>>  static void __init sunxi_mux_clk_setup(struct device_node *node,
>>  				       struct mux_data *data)
>>  {
>> @@ -886,7 +890,7 @@ static void __init sunxi_divider_clk_setup(struct device_node *node,
>>   * sunxi_gates_clk_setup() - Setup function for leaf gates on clocks
>>   */
>>  
>> -#define SUNXI_GATES_MAX_SIZE	64
>> +#define SUNXI_GATES_MAX_SIZE	160
>>  
>>  struct gates_data {
>>  	DECLARE_BITMAP(mask, SUNXI_GATES_MAX_SIZE);
>> @@ -990,6 +994,36 @@ static const struct gates_data sun8i_a23_apb2_gates_data __initconst = {
>>  	.mask = {0x1F0007},
>>  };
>>  
>> +#define BUS_GATE_PARENT_AHB1	0
>> +#define BUS_GATE_PARENT_AHB2	1
>> +#define BUS_GATE_PARENT_APB1	2
>> +#define BUS_GATE_PARENT_APB2	3
>> +
>> +static const u8 sun8i_h3_bus_gates_parents[] __initconst = {
>> +	BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1,
>> +	BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1,
>> +	BUS_GATE_PARENT_AHB1,
> 
>> BUS_GATE_PARENT_AHB2,
>> BUS_GATE_PARENT_AHB1,
>> +	BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1,
>> +	BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1,
>> +	BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1,
> 
>> +	BUS_GATE_PARENT_AHB2, BUS_GATE_PARENT_AHB2, BUS_GATE_PARENT_AHB2,
> 
>> +	BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1,
>> +	BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1,
>> +	BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1,
>> +	BUS_GATE_PARENT_AHB1, BUS_GATE_PARENT_AHB1,
> 
>> BUS_GATE_PARENT_APB1,
>> +	BUS_GATE_PARENT_APB1, BUS_GATE_PARENT_APB1, BUS_GATE_PARENT_APB1,
>> +	BUS_GATE_PARENT_APB1, BUS_GATE_PARENT_APB1, BUS_GATE_PARENT_APB1,
> 
>> +	BUS_GATE_PARENT_APB2, BUS_GATE_PARENT_APB2, BUS_GATE_PARENT_APB2,
>> +	BUS_GATE_PARENT_APB2, BUS_GATE_PARENT_APB2, BUS_GATE_PARENT_APB2,
>> +	BUS_GATE_PARENT_APB2, BUS_GATE_PARENT_APB2,
> 
>> BUS_GATE_PARENT_AHB1,
>> +	BUS_GATE_PARENT_AHB1
>> +}
> 
> I think something like this:
> 
> if (index < .. || index > ..)
>     clk_parent = "ahb1"
> if (index == .. || index < ...)
>     clk_parent = "ahb2"
> etc...
> 
> Would be both easier to maintain and to read.

At least as long as there aren't too many disjunct groups.
But it would mean duplicate setup functions for each SoC (or something
like sun8i_h3_bus_gate_get_parent(int index))

But since you want to rework the gate setup anyway I think I'll wait
until then. Currently I can't see how this should look like.

> 
>> +
>> +static const struct gates_data sun8i_h3_bus_gates_data __initconst = {
>> +	.mask = {0xffbe6760, 0x00701b39, 0x00007123, 0x001f0007, 0x00000081},
>> +	.parents = sun8i_h3_bus_gates_parents,
>> +};
>> +
>>  static void __init sunxi_gates_clk_setup(struct device_node *node,
>>  					 struct gates_data *data)
>>  {
>> @@ -1110,6 +1144,16 @@ static const struct divs_data sun6i_a31_pll6_divs_data __initconst = {
>>  	}
>>  };
>>  
>> +static const struct divs_data sun8i_h3_pll6_divs_data __initconst = {
>> +	.factors = &sun6i_a31_pll6_data,
>> +	.ndivs = 3,
>> +	.div = {
>> +		{ .fixed = 2 }, /* normal output, pll6 */
>> +		{ .self = 1 }, /* base factor clock, pll6 x2 */
>> +		{ .fixed = 4 }, /* divided output, pll6 /2 */
>> +	}
>> +};
> 
> This is exactly the same clock as A31's PLL6, it shouldn't be declared
> as a different one.

Um, sorry, but I can't see the /2 output at A31's pll6.

Or shall we add the /2 output to A31's PLL6 and simply ignore it on A31?
I don't think this is a good idea, what happens if we need to add an
additional output on A31 later.

Regards,
Jens

  reply	other threads:[~2015-05-18  9:45 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-15 16:38 [PATCH v2 00/10] ARM: sunxi: Introduce Allwinner H3 support Jens Kuske
     [not found] ` <1431707940-19372-1-git-send-email-jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-15 16:38   ` [PATCH v2 01/10] Documentation: sunxi: Update Allwinner SoC documentation Jens Kuske
     [not found]     ` <1431707940-19372-2-git-send-email-jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-17 12:52       ` Maxime Ripard
2015-05-15 16:38   ` [PATCH v2 02/10] clk: sunxi: Add support for multiple parents to gates Jens Kuske
     [not found]     ` <1431707940-19372-3-git-send-email-jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-17 12:50       ` Maxime Ripard
2015-05-18  9:11         ` Jens Kuske
     [not found]           ` <5559ACC6.6050202-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-19  7:53             ` Maxime Ripard
2015-05-15 16:38   ` [PATCH v2 03/10] clk: sunxi: Let divs clocks read the base factor clock name from devicetree Jens Kuske
     [not found]     ` <1431707940-19372-4-git-send-email-jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-16  2:10       ` Chen-Yu Tsai
     [not found]         ` <CAGb2v64y8+bdya3N=gK-YEie3A9nVM5nuxRZTVPXYSaN6WzPoQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-18  9:15           ` Jens Kuske
     [not found]             ` <5559ADBE.7060506-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-18 14:45               ` Chen-Yu Tsai
2015-05-17 13:06       ` Maxime Ripard
2015-05-18  9:22         ` Jens Kuske
     [not found]           ` <5559AF58.60508-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-19  8:26             ` Maxime Ripard
2015-05-15 16:38   ` [PATCH v2 04/10] pinctrl: sunxi: Prepare for building SoC specific drivers as modules Jens Kuske
     [not found]     ` <1431707940-19372-5-git-send-email-jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-17 14:19       ` Maxime Ripard
2015-05-18  9:32         ` Jens Kuske
2015-05-19  7:55           ` Maxime Ripard
2015-05-19  8:02             ` Chen-Yu Tsai
     [not found]               ` <CAGb2v6608XVsxN0f2DEmqmts1zDo223t+fBv46WjGQVQbw7+CA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-19  8:16                 ` Maxime Ripard
2015-05-19 14:58             ` Linus Walleij
2015-05-15 16:38   ` [PATCH v2 05/10] ARM: sunxi: Introduce Allwinner H3 support Jens Kuske
     [not found]     ` <1431707940-19372-6-git-send-email-jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-17 14:21       ` Maxime Ripard
2015-05-15 16:38   ` [PATCH v2 06/10] clk: sunxi: Add H3 clocks support Jens Kuske
     [not found]     ` <1431707940-19372-7-git-send-email-jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-17 14:27       ` Maxime Ripard
2015-05-18  9:45         ` Jens Kuske [this message]
     [not found]           ` <5559B4CE.2050703-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-19  8:50             ` Maxime Ripard
2015-05-15 16:38   ` [PATCH v2 07/10] pinctrl: sunxi: Add H3 PIO controller support Jens Kuske
     [not found]     ` <1431707940-19372-8-git-send-email-jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-16 15:32       ` Paul Bolle
2015-05-17 14:30       ` Maxime Ripard
2015-05-18  9:52         ` Jens Kuske
2015-05-19 14:04       ` Linus Walleij
     [not found]         ` <CACRpkdZnWavNK_o04-mNmA0eDV+ppQJz8Kt+-OF5M=jgysuO_g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-19 15:03           ` Maxime Ripard
2015-05-15 16:38   ` [PATCH v2 08/10] reset: sunxi: Add compatible for Allwinner H3 bus resets Jens Kuske
     [not found]     ` <1431707940-19372-9-git-send-email-jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-17 14:31       ` Maxime Ripard
2015-05-18  9:55         ` Jens Kuske
2015-05-15 16:38   ` [PATCH v2 09/10] ARM: dts: sunxi: Add Allwinner H3 DTSI Jens Kuske
2015-05-15 16:39   ` [PATCH v2 10/10] ARM: dts: sun8i: Add Orange Pi Plus support Jens Kuske

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=5559B4CE.2050703@gmail.com \
    --to=jenskuske-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=emilio-0Z03zUJReD5OxF6Tv1QG9Q@public.gmane.org \
    --cc=hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    --cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=vishnupatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=wens-jdAy2FN1RRM@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).