Re: [PATCH 09/10] clk: ns2: add clock support for Broadcom Northstar 2 SoC

2015-10-13 Thread Scott Branden

Hi Jon,

Comment below.

On 15-10-12 11:19 AM, Jon Mason wrote:

On Fri, Oct 09, 2015 at 05:33:52PM -0700, Stephen Boyd wrote:

On 10/02, Jon Mason wrote:

diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index 23800a1..2790f21 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -2,6 +2,7 @@ menu "Platform selection"

  config ARCH_BCM_IPROC
bool "Broadcom iProc SoC Family"
+   select COMMON_CLK_IPROC


Given that this is a visible option, I'd expect the defconfig to
enable this.


After looking at this again, it is completely unnecessary.  Removed.




help
  This enables support for Broadcom iProc based SoCs

diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index d08b3e5..ea81eaa 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -47,7 +47,8 @@ obj-$(CONFIG_COMMON_CLK_WM831X)   += clk-wm831x.o
  obj-$(CONFIG_COMMON_CLK_XGENE)+= clk-xgene.o
  obj-$(CONFIG_COMMON_CLK_PWM)  += clk-pwm.o
  obj-$(CONFIG_COMMON_CLK_AT91) += at91/
-obj-$(CONFIG_ARCH_BCM) += bcm/
+obj-$(CONFIG_CLK_BCM_KONA) += bcm/
+obj-$(CONFIG_COMMON_CLK_IPROC) += bcm/


Also, perhaps we need some sort of Kconfig thing for overall bcm
clock drivers, so that we don't have duplicate Makefile rules.

config COMMON_CLK_BCM
bool "Support for Broadcom clocks"


Will do.


Is that really necessary at all  I think something like this work instead?

-obj-$(CONFIG_ARCH_BCM) += bcm/
+obj-y  += bcm/





Thanks,
Jon




--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/10] clk: ns2: add clock support for Broadcom Northstar 2 SoC

2015-10-13 Thread Stephen Boyd
On 10/13/2015 09:51 AM, Scott Branden wrote:
>
> Is that really necessary at all  I think something like this work
> instead?
>
> -obj-$(CONFIG_ARCH_BCM)+= bcm/
> +obj-y+= bcm/
>
>

Yes that's fine too, as long as we don't add any obj-y inside bcm/Makefile

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/10] clk: ns2: add clock support for Broadcom Northstar 2 SoC

2015-10-12 Thread Jon Mason
On Fri, Oct 09, 2015 at 05:19:15PM -0700, Stephen Boyd wrote:
> On 10/02, Jon Mason wrote:
> > diff --git a/drivers/clk/bcm/clk-ns2.c b/drivers/clk/bcm/clk-ns2.c
> > new file mode 100644
> > index 000..1d08281
> > --- /dev/null
> > +++ b/drivers/clk/bcm/clk-ns2.c
> > @@ -0,0 +1,290 @@
> > +/*
> > + * Copyright (C) 2015 Broadcom Corporation
> > + *
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License as
> > + * published by the Free Software Foundation version 2.
> > + *
> > + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> > + * kind, whether express or implied; without even the implied warranty
> > + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> 
> clkdev looks unused here too?
> 
> > +#include 
> > +#include 
> 
> And this one?

Yes, already caught this when you mentioned the other file :)

> 
> > +
> > +#include 
> > +#include "clk-iproc.h"
> > +
> > +#define reg_val(o, s, w) { .offset = o, .shift = s, .width = w, }
> 
> I guess we missed this one already, but this isn't a macro
> resembling a function. Kernel style is to capitalize this sort of
> macro.

I agree, but I was following prior example in
drivers/clk/bcm/clk-cygnus.c.  I can make the changes here and do a
patch for that file making the necessary changes as well.  Just let me
know your preference.

Thanks,
Jon

> 
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/10] clk: ns2: add clock support for Broadcom Northstar 2 SoC

2015-10-12 Thread Jon Mason
On Fri, Oct 09, 2015 at 05:33:52PM -0700, Stephen Boyd wrote:
> On 10/02, Jon Mason wrote:
> > diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
> > index 23800a1..2790f21 100644
> > --- a/arch/arm64/Kconfig.platforms
> > +++ b/arch/arm64/Kconfig.platforms
> > @@ -2,6 +2,7 @@ menu "Platform selection"
> >  
> >  config ARCH_BCM_IPROC
> > bool "Broadcom iProc SoC Family"
> > +   select COMMON_CLK_IPROC
> 
> Given that this is a visible option, I'd expect the defconfig to
> enable this.

After looking at this again, it is completely unnecessary.  Removed.

> 
> > help
> >   This enables support for Broadcom iProc based SoCs
> >  
> > diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> > index d08b3e5..ea81eaa 100644
> > --- a/drivers/clk/Makefile
> > +++ b/drivers/clk/Makefile
> > @@ -47,7 +47,8 @@ obj-$(CONFIG_COMMON_CLK_WM831X)   += clk-wm831x.o
> >  obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o
> >  obj-$(CONFIG_COMMON_CLK_PWM)   += clk-pwm.o
> >  obj-$(CONFIG_COMMON_CLK_AT91)  += at91/
> > -obj-$(CONFIG_ARCH_BCM) += bcm/
> > +obj-$(CONFIG_CLK_BCM_KONA) += bcm/
> > +obj-$(CONFIG_COMMON_CLK_IPROC) += bcm/
> 
> Also, perhaps we need some sort of Kconfig thing for overall bcm
> clock drivers, so that we don't have duplicate Makefile rules.
> 
>   config COMMON_CLK_BCM
>   bool "Support for Broadcom clocks"

Will do.

Thanks,
Jon


> 
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/10] clk: ns2: add clock support for Broadcom Northstar 2 SoC

2015-10-09 Thread Stephen Boyd
On 10/02, Jon Mason wrote:
> diff --git a/drivers/clk/bcm/clk-ns2.c b/drivers/clk/bcm/clk-ns2.c
> new file mode 100644
> index 000..1d08281
> --- /dev/null
> +++ b/drivers/clk/bcm/clk-ns2.c
> @@ -0,0 +1,290 @@
> +/*
> + * Copyright (C) 2015 Broadcom Corporation
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation version 2.
> + *
> + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> + * kind, whether express or implied; without even the implied warranty
> + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

clkdev looks unused here too?

> +#include 
> +#include 

And this one?

> +
> +#include 
> +#include "clk-iproc.h"
> +
> +#define reg_val(o, s, w) { .offset = o, .shift = s, .width = w, }

I guess we missed this one already, but this isn't a macro
resembling a function. Kernel style is to capitalize this sort of
macro.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/10] clk: ns2: add clock support for Broadcom Northstar 2 SoC

2015-10-09 Thread Stephen Boyd
On 10/02, Jon Mason wrote:
> diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
> index 23800a1..2790f21 100644
> --- a/arch/arm64/Kconfig.platforms
> +++ b/arch/arm64/Kconfig.platforms
> @@ -2,6 +2,7 @@ menu "Platform selection"
>  
>  config ARCH_BCM_IPROC
>   bool "Broadcom iProc SoC Family"
> + select COMMON_CLK_IPROC

Given that this is a visible option, I'd expect the defconfig to
enable this.

>   help
> This enables support for Broadcom iProc based SoCs
>  
> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> index d08b3e5..ea81eaa 100644
> --- a/drivers/clk/Makefile
> +++ b/drivers/clk/Makefile
> @@ -47,7 +47,8 @@ obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
>  obj-$(CONFIG_COMMON_CLK_XGENE)   += clk-xgene.o
>  obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o
>  obj-$(CONFIG_COMMON_CLK_AT91)+= at91/
> -obj-$(CONFIG_ARCH_BCM)   += bcm/
> +obj-$(CONFIG_CLK_BCM_KONA)   += bcm/
> +obj-$(CONFIG_COMMON_CLK_IPROC)   += bcm/

Also, perhaps we need some sort of Kconfig thing for overall bcm
clock drivers, so that we don't have duplicate Makefile rules.

config COMMON_CLK_BCM
bool "Support for Broadcom clocks"

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/10] clk: ns2: add clock support for Broadcom Northstar 2 SoC

2015-10-02 Thread Jon Mason
The Broadcom Northstar 2 SoC is architected under the iProc
architecture. It has the following PLLs: GENPLL SCR, GENPLL SW,
LCPLL DDR, LCPLL Ports, all derived from an onboard crystal.

Signed-off-by: Jon Mason 
---
 arch/arm64/Kconfig.platforms|   1 +
 drivers/clk/Makefile|   3 +-
 drivers/clk/bcm/Makefile|   1 +
 drivers/clk/bcm/clk-ns2.c   | 290 
 include/dt-bindings/clock/bcm-ns2.h |  72 +
 5 files changed, 366 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/bcm/clk-ns2.c
 create mode 100644 include/dt-bindings/clock/bcm-ns2.h

diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index 23800a1..2790f21 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -2,6 +2,7 @@ menu "Platform selection"
 
 config ARCH_BCM_IPROC
bool "Broadcom iProc SoC Family"
+   select COMMON_CLK_IPROC
help
  This enables support for Broadcom iProc based SoCs
 
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index d08b3e5..ea81eaa 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -47,7 +47,8 @@ obj-$(CONFIG_COMMON_CLK_WM831X)   += clk-wm831x.o
 obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o
 obj-$(CONFIG_COMMON_CLK_PWM)   += clk-pwm.o
 obj-$(CONFIG_COMMON_CLK_AT91)  += at91/
-obj-$(CONFIG_ARCH_BCM) += bcm/
+obj-$(CONFIG_CLK_BCM_KONA) += bcm/
+obj-$(CONFIG_COMMON_CLK_IPROC) += bcm/
 obj-$(CONFIG_ARCH_BERLIN)  += berlin/
 obj-$(CONFIG_ARCH_HISI)+= hisilicon/
 obj-$(CONFIG_ARCH_MXC) += imx/
diff --git a/drivers/clk/bcm/Makefile b/drivers/clk/bcm/Makefile
index e258b28..2d1cbc5 100644
--- a/drivers/clk/bcm/Makefile
+++ b/drivers/clk/bcm/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_CLK_BCM_KONA)  += clk-kona-setup.o
 obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm281xx.o
 obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm21664.o
 obj-$(CONFIG_COMMON_CLK_IPROC) += clk-iproc-armpll.o clk-iproc-pll.o 
clk-iproc-asiu.o
+obj-$(CONFIG_COMMON_CLK_IPROC) += clk-ns2.o
 obj-$(CONFIG_ARCH_BCM_CYGNUS)  += clk-cygnus.o
 obj-$(CONFIG_ARCH_BCM_NSP) += clk-nsp.o
 obj-$(CONFIG_ARCH_BCM_5301X)   += clk-nsp.o
diff --git a/drivers/clk/bcm/clk-ns2.c b/drivers/clk/bcm/clk-ns2.c
new file mode 100644
index 000..1d08281
--- /dev/null
+++ b/drivers/clk/bcm/clk-ns2.c
@@ -0,0 +1,290 @@
+/*
+ * Copyright (C) 2015 Broadcom Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "clk-iproc.h"
+
+#define reg_val(o, s, w) { .offset = o, .shift = s, .width = w, }
+
+#define aon_val(o, pw, ps, is) { .offset = o, .pwr_width = pw, \
+   .pwr_shift = ps, .iso_shift = is }
+
+#define reset_val(o, rs, prs) { .offset = o, .reset_shift = rs, \
+   .p_reset_shift = prs }
+
+#define df_val(o, kis, kiw, kps, kpw, kas, kaw) { .offset = o, .ki_shift = 
kis,\
+   .ki_width = kiw, .kp_shift = kps, .kp_width = kpw, .ka_shift = kas,\
+   .ka_width = kaw }
+
+#define vco_ctrl_val(uo, lo) { .u_offset = uo, .l_offset = lo }
+
+#define enable_val(o, es, hs, bs) { .offset = o, .enable_shift = es, \
+   .hold_shift = hs, .bypass_shift = bs }
+
+static const struct iproc_pll_ctrl genpll_scr = {
+   .flags = IPROC_CLK_AON | IPROC_CLK_PLL_SPLIT_STAT_CTRL,
+   .aon = aon_val(0x0, 1, 15, 12),
+   .reset = reset_val(0x4, 2, 1),
+   .dig_filter = df_val(0x0, 9, 3, 5, 4, 2, 3),
+   .ndiv_int = reg_val(0x8, 4, 10),
+   .pdiv = reg_val(0x8, 0, 4),
+   .vco_ctrl = vco_ctrl_val(0x10, 0xc),
+   .status = reg_val(0x0, 27, 1),
+};
+
+
+static const struct iproc_clk_ctrl genpll_scr_clk[] = {
+   /* bypass_shift, the last value passed into enable_val(), is not defined
+* in NS2.  However, it doesn't appear to be used anywhere, so setting
+* it to 0.
+*/
+   [BCM_NS2_GENPLL_SCR_SCR_CLK] = {
+   .channel = BCM_NS2_GENPLL_SCR_SCR_CLK,
+   .flags = IPROC_CLK_AON,
+   .enable = enable_val(0x0, 18, 12, 0),
+   .mdiv = reg_val(0x18, 0, 8),
+   },
+   [BCM_NS2_GENPLL_SCR_FS_CLK] = {
+   .channel = BCM_NS2_GENPLL_SCR_FS_CLK,
+   .flags = IPROC_CLK_AON,
+   .enable = enable_val(0x0, 19, 13, 0),
+   .mdiv = reg_val(0x18, 8, 8),
+   },
+   [BCM_NS2_GENPLL_SCR_AUDIO_CLK] =