clk: mmp: add clock framework for mmp
Subsystems (4)
v4 cover clk: mmp: add clock framework for mmp
From: Chao Xie <[email protected]>
v1->v2:
replace __raw_xxx with xxx_relax
use ioremap to remap the registers. Finaly it will use device tree to get the physical address.
do not use macro to register clocks, and directly call the functions.
v2->v3:
pxa910 will have APB extension clock, so some peripharals will have clocks in APB extension base.
change pxa168-pwm to be pxa910-pwm for pxa910. It will fit the current pwm driver.
v3->v4:
remove addtional clock name definition
replace left __raw_xxx
Chao Xie (5):
clk: mmp: add mmp specific clocks
clk: mmp: add clock definition for pxa168
clk: mmp: add clock definition for pxa910
clk: mmp: add clock definition for mmp2
arm: mmp: make all SOCs use common clock by default
arch/arm/mach-mmp/Kconfig | 3 + drivers/clk/Makefile | 3 + drivers/clk/mmp/Makefile | 9 + drivers/clk/mmp/clk-apbc.c | 152 ++++++++++++ drivers/clk/mmp/clk-apmu.c | 97 ++++++++ drivers/clk/mmp/clk-frac.c | 153 ++++++++++++ drivers/clk/mmp/clk-mmp2.c | 527 ++++++++++++++++++++++++++++++++++++++++++ drivers/clk/mmp/clk-pxa168.c | 402 ++++++++++++++++++++++++++++++++ drivers/clk/mmp/clk-pxa910.c | 369 +++++++++++++++++++++++++++++ drivers/clk/mmp/clk.h | 35 +++ 10 files changed, 1750 insertions(+), 0 deletions(-) create mode 100644 drivers/clk/mmp/Makefile create mode 100644 drivers/clk/mmp/clk-apbc.c create mode 100644 drivers/clk/mmp/clk-apmu.c create mode 100644 drivers/clk/mmp/clk-frac.c create mode 100644 drivers/clk/mmp/clk-mmp2.c create mode 100644 drivers/clk/mmp/clk-pxa168.c create mode 100644 drivers/clk/mmp/clk-pxa910.c create mode 100644 drivers/clk/mmp/clk.h
PATCH v4 1/5 clk: mmp: add mmp specific clocks
From: Chao Xie <[email protected]>
add mmp specific clocks including apbc cloks, apmu clocks, and pll2, fraction clocks
--- drivers/clk/Makefile | 3 + drivers/clk/mmp/Makefile | 5 ++ drivers/clk/mmp/clk-apbc.c | 152 +++++++++++++++++++++++++++++++++++++++++++ drivers/clk/mmp/clk-apmu.c | 97 ++++++++++++++++++++++++++++ drivers/clk/mmp/clk-frac.c | 153 ++++++++++++++++++++++++++++++++++++++++++++ drivers/clk/mmp/clk.h | 35 ++++++++++ 6 files changed, 445 insertions(+), 0 deletions(-) create mode 100644 drivers/clk/mmp/Makefile create mode 100644 drivers/clk/mmp/clk-apbc.c create mode 100644 drivers/clk/mmp/clk-apmu.c create mode 100644 drivers/clk/mmp/clk-frac.c create mode 100644 drivers/clk/mmp/clk.h
drivers/clk/Makefile +3 -0
@@ -10,6 +10,9 @@ obj-$(CONFIG_ARCH_SOCFPGA) += socfpga/ obj-$(CONFIG_PLAT_SPEAR) += spear/ obj-$(CONFIG_ARCH_U300) += clk-u300.o obj-$(CONFIG_ARCH_INTEGRATOR) += versatile/ +ifeq ($(CONFIG_COMMON_CLK), y) +obj-$(CONFIG_ARCH_MMP) += mmp/ +endif # Chip specific obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
drivers/clk/mmp/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for mmp specific clk +# + +obj-y += clk-apbc.o clk-apmu.o clk-frac.o
drivers/clk/mmp/clk-apbc.c new file +152 -0
152 lines not on this page · raw message
drivers/clk/mmp/clk-apmu.c new file +97 -0
97 lines not on this page · raw message
drivers/clk/mmp/clk-frac.c new file +153 -0
153 lines not on this page · raw message
drivers/clk/mmp/clk.h new file +35 -0
@@ -0,0 +1,35 @@ +#ifndef __MACH_MMP_CLK_H +#define __MACH_MMP_CLK_H + +#include <linux/clk-provider.h> +#include <linux/clkdev.h> + +#define APBC_NO_BUS_CTRL BIT(0) +#define APBC_POWER_CTRL BIT(1) + +struct clk_factor_masks { +unsigned int factor; +unsigned int num_mask; +unsigned int den_mask; +unsigned int num_shift; +unsigned int den_shift; +}; + +struct clk_factor_tbl { +unsigned int num; +unsigned int den; +}; + +extern struct clk *mmp_clk_register_pll2 (const char *name, +const char *parent_name,unsigned long flags); +extern struct clk *mmp_clk_register_apbc (const char *name, +const char *parent_name,void __iomem *base, +unsigned int delay,unsigned int apbc_flags,spinlock_t *lock); +extern struct clk *mmp_clk_register_apmu (const char *name, +const char *parent_name,void __iomem *base,u32 enable_mask, +spinlock_t *lock); +extern struct clk *mmp_clk_register_factor (const char *name, +const char *parent_name,unsigned long flags, +void __iomem *base,struct clk_factor_masks *masks, +struct clk_factor_tbl *ftbl,unsigned int ftbl_cnt); +#endif
Signature · 1 line
1.7.0.4
Re: [PATCH V4 1/5] clk: mmp: add mmp specific clocks
Quoted 7 lines · Chao Xie
From: Chao Xie <[email protected]>
add mmp specific clocks including apbc cloks, apmu clocks, and pll2, fraction clocks
Signed-off-by Chao Xie <[email protected]>
PATCH v4 2/5 clk: mmp: add clock definition for pxa168
In reply to Chao XieFrom: Chao Xie <[email protected]>
Initialize the clocks for pxa168
--- drivers/clk/mmp/Makefile | 2 + drivers/clk/mmp/clk-pxa168.c | 402 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 404 insertions(+), 0 deletions(-) create mode 100644 drivers/clk/mmp/clk-pxa168.c
drivers/clk/mmp/Makefile +2 -0
@@ -3,3 +3,5 @@ # obj-y += clk-apbc.o clk-apmu.o clk-frac.o + +obj-$(CONFIG_CPU_PXA168) += clk-pxa168.o
drivers/clk/mmp/clk-pxa168.c new file +402 -0
402 lines not on this page · raw message
Signature · 1 line
1.7.0.4
Re: [PATCH V4 2/5] clk: mmp: add clock definition for pxa168
Quoted 15 lines · Chao Xie
drivers/clk/mmp/clk-pxa168.c new file +15
-0+void __init pxa168_clk_init (void ) +{ +struct clk *clk; +struct clk *uart_pll; +void __iomem *mpmu_base; +void __iomem *apmu_base; +void __iomem *apbc_base; + + mpmu_base =ioremap (APB_PHYS_BASE +0x50000 ,SZ_4K ); +if (mpmu_base ==NULL ) { +pr_err ("error to ioremap MPMU base\n" ); +return ; + } + + apmu_base =ioremap (AXI_PHYS_BASE +0x82800 ,SZ_4K );
drivers/clk/mmp/clk-pxa168.c line 93
Quoted 10 lines
drivers/clk/mmp/clk-pxa168.c new file +10
-0+if (apmu_base ==NULL ) { +pr_err ("error to ioremap APMU base\n" ); +return ; + } + + apbc_base =ioremap (APB_PHYS_BASE +0x15000 ,SZ_4K ); +if (apbc_base ==NULL ) { +pr_err ("error to ioremap APBC base\n" ); +return ; + }
I hadn't noticed this before, but you are hardcoded physical address locations in the driver, which is not so good since we're trying to move all those locations to device tree. Maybe someone else has an idea to do this better.
drivers/clk/mmp/clk-pxa168.c line 105
Quoted 11 lines
drivers/clk/mmp/clk-pxa168.c new file +11
-0+ clk =clk_register_fixed_rate (NULL ,"clk32" ,NULL ,CLK_IS_ROOT ,3200 ); +clk_register_clkdev (clk,"clk32" ,NULL ); + + clk = +clk_register_fixed_rate (NULL ,"vctcxo" ,NULL ,CLK_IS_ROOT , +26000000 ); +clk_register_clkdev (clk,"vctcxo" ,NULL ); + + clk = +clk_register_fixed_rate (NULL ,"pll1" ,NULL ,CLK_IS_ROOT ,624000000 ); +clk_register_clkdev (clk,"pll1" ,NULL );
Ok, so you've managed to remove the array, good!
I'm still not overly happy with the style of newline after "=", that is very unusual, and only saves you two characters per line. I'd say just move them each into one line as you did in the first one here. It's less important to align the arguments to the opening braces if you are trying to stay in the 80 character limit. Another option would be to rename the variable to just 'c' instead of 'clk' ;-)
Arnd
Arnd
Re: [PATCH V4 2/5] clk: mmp: add clock definition for pxa168
Quoted 52 lines · Arnd Bergmann
Quoted 15 lines · Chao Xie
drivers/clk/mmp/clk-pxa168.c new file +15
-0+void __init pxa168_clk_init (void ) +{ +struct clk *clk; +struct clk *uart_pll; +void __iomem *mpmu_base; +void __iomem *apmu_base; +void __iomem *apbc_base; + + mpmu_base =ioremap (APB_PHYS_BASE +0x50000 ,SZ_4K ); +if (mpmu_base ==NULL ) { +pr_err ("error to ioremap MPMU base\n" ); +return ; + } + + apmu_base =ioremap (AXI_PHYS_BASE +0x82800 ,SZ_4K );drivers/clk/mmp/clk-pxa168.c line 93
Quoted 10 lines
drivers/clk/mmp/clk-pxa168.c new file +10
-0+if (apmu_base ==NULL ) { +pr_err ("error to ioremap APMU base\n" ); +return ; + } + + apbc_base =ioremap (APB_PHYS_BASE +0x15000 ,SZ_4K ); +if (apbc_base ==NULL ) { +pr_err ("error to ioremap APBC base\n" ); +return ; + }I hadn't noticed this before, but you are hardcoded physical address locations in the driver, which is not so good since we're trying to move all those locations to device tree. Maybe someone else has an idea to do this better.
drivers/clk/mmp/clk-pxa168.c line 105
Quoted 11 lines
drivers/clk/mmp/clk-pxa168.c new file +11
-0+ clk =clk_register_fixed_rate (NULL ,"clk32" ,NULL ,CLK_IS_ROOT ,3200 ); +clk_register_clkdev (clk,"clk32" ,NULL ); + + clk = +clk_register_fixed_rate (NULL ,"vctcxo" ,NULL ,CLK_IS_ROOT , +26000000 ); +clk_register_clkdev (clk,"vctcxo" ,NULL ); + + clk = +clk_register_fixed_rate (NULL ,"pll1" ,NULL ,CLK_IS_ROOT ,624000000 ); +clk_register_clkdev (clk,"pll1" ,NULL );Ok, so you've managed to remove the array, good!
I'm still not overly happy with the style of newline after "=", that is very unusual, and only saves you two characters per line. I'd say just move them each into one line as you did in the first one here. It's less important to align the arguments to the opening braces if you are trying to stay in the 80 character limit. Another option would be to rename the variable to just 'c' instead of 'clk' ;-)
Quoted 4 lines
Arnd
Arnd
hi
The clock tree is formatted into a table, and i used perl to generate the code based on the table. In order to make the indent clearly, i used the scripts/Lindent to automatically format the .c file. I have tried to searched the parameter for indent, but i do not find that anything can remove the the style of newline after "=", so in order to not format the file line by line, i just accept the results of indent.
Do you have any idea about it?
Re: [PATCH V4 2/5] clk: mmp: add clock definition for pxa168
Quoted 8 lines · Chao Xie
The clock tree is formatted into a table, and i used perl to generate the code based on the table. In order to make the indent clearly, i used the
scripts/Lindentto automatically format the .c file. I have tried to searched the parameter for indent, but i do not find that anything can remove the the style of newline after "=", so in order to not format the file line by line, i just accept the results of indent.
Do you have any idea about it?
No easy solution. I don't normally trust lindent. Especially if you want to bend the rules slightly, it's often better to manually edit the output of lindent.
Arnd
PATCH v4 3/5 clk: mmp: add clock definition for pxa910
In reply to Chao XieFrom: Chao Xie <[email protected]>
Initialize the clocks for pxa910
--- drivers/clk/mmp/Makefile | 1 + drivers/clk/mmp/clk-pxa910.c | 369 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 370 insertions(+), 0 deletions(-) create mode 100644 drivers/clk/mmp/clk-pxa910.c
drivers/clk/mmp/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-y += clk-apbc.o clk-apmu.o clk-frac.o obj-$(CONFIG_CPU_PXA168) += clk-pxa168.o +obj-$(CONFIG_CPU_PXA910) += clk-pxa910.o
drivers/clk/mmp/clk-pxa910.c new file +369 -0
369 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v4 4/5 clk: mmp: add clock definition for mmp2
In reply to Chao XieFrom: Chao Xie <[email protected]>
Initialize the clocks for mmp2
--- drivers/clk/mmp/Makefile | 1 + drivers/clk/mmp/clk-mmp2.c | 527 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 528 insertions(+), 0 deletions(-) create mode 100644 drivers/clk/mmp/clk-mmp2.c
drivers/clk/mmp/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-y += clk-apbc.o clk-apmu.o clk-frac.o obj-$(CONFIG_CPU_PXA168) += clk-pxa168.o obj-$(CONFIG_CPU_PXA910) += clk-pxa910.o +obj-$(CONFIG_CPU_MMP2) += clk-mmp2.o
drivers/clk/mmp/clk-mmp2.c new file +527 -0
527 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v4 5/5 arm: mmp: make all SOCs use common clock by default
In reply to Chao XieFrom: Chao Xie <[email protected]>
--- arch/arm/mach-mmp/Kconfig | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
arch/arm/mach-mmp/Kconfig +3 -0
@@ -108,18 +108,21 @@ endmenu config CPU_PXA168 bool select CPU_MOHAWK + select COMMON_CLK help Select code specific to PXA168 config CPU_PXA910 bool select CPU_MOHAWK + select COMMON_CLK help Select code specific to PXA910 config CPU_MMP2 bool select CPU_PJ4 + select COMMON_CLK help Select code specific to MMP2. MMP2 is ARMv7 compatible.
Signature · 1 line
1.7.0.4
Re: [PATCH V4 5/5] arm: mmp: make all SOCs use common clock by default
Quoted 7 lines · Chao Xie
From: Chao Xie <[email protected]>
Signed-off-by Chao Xie <[email protected]>--- arch/arm/mach-mmp/Kconfig | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)