clk: mxs: mach header cleanup
Subsystems (3)
cover clk: mxs: mach header cleanup
The series cleans up the mach header inclusion from mxs clk drivers, which is another step to multiplatform support.
Mike,
The series depends on some mxs platform cleanup patches on my tree. May I ask you ACK on the patches to have them go arm-soc tree?
Shawn
Shawn Guo (2):
clk: mxs: get base address from device tree
clk: mxs: remove the use of mach level IO accessor
arch/arm/boot/dts/imx23.dtsi | 1 + arch/arm/boot/dts/imx28.dtsi | 1 + drivers/clk/mxs/clk-imx23.c | 37 +++++++++++++++++++++++-------------- drivers/clk/mxs/clk-imx28.c | 38 +++++++++++++++++++++++--------------- 4 files changed, 48 insertions(+), 29 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/2 clk: mxs: get base address from device tree
Instead of using the static definitions, get clkctrl and digctl base addresses with mapping from device tree.
Use macro on variable is not nice, but it's done here to save huge pointless diff stat.
--- arch/arm/boot/dts/imx23.dtsi | 1 + arch/arm/boot/dts/imx28.dtsi | 1 + drivers/clk/mxs/clk-imx23.c | 26 ++++++++++++++++++-------- drivers/clk/mxs/clk-imx28.c | 25 +++++++++++++++++-------- 4 files changed, 37 insertions(+), 16 deletions(-)
arch/arm/boot/dts/imx23.dtsi +1 -0
@@ -295,6 +295,7 @@ }; digctl at 8001c000 { + compatible = "fsl,imx23-digctl"; reg = <0x8001c000 2000>; status = "disabled"; };
arch/arm/boot/dts/imx28.dtsi +1 -0
@@ -647,6 +647,7 @@ }; digctl at 8001c000 { + compatible = "fsl,imx28-digctl"; reg = <0x8001c000 0x2000>; interrupts = <89>; status = "disabled";
drivers/clk/mxs/clk-imx23.c +18 -8
@@ -15,11 +15,16 @@#include <linux/init.h> #include <linux/io.h> #include <linux/of.h> +#include <linux/of_address.h> #include <mach/mx23.h> #include "clk.h" -#define DIGCTRL MX23_IO_ADDRESS(MX23_DIGCTL_BASE_ADDR) -#define CLKCTRL MX23_IO_ADDRESS(MX23_CLKCTRL_BASE_ADDR) +static void __iomem *clkctrl; +static void __iomem *digctrl; + +#define CLKCTRL clkctrl +#define DIGCTRL digctrl +#define PLLCTRL0 (CLKCTRL + 0x0000)#define CPU (CLKCTRL + 0x0020)#define HBUS (CLKCTRL + 0x0030)
@@ -100,6 +105,14 @@ int __init mx23_clocks_init(void)struct device_node *np;u32 i; + np =of_find_compatible_node (NULL ,NULL ,"fsl,imx23-digctl" ); + digctrl =of_iomap (np,0 ); +WARN_ON (!digctrl); + + np =of_find_compatible_node (NULL ,NULL ,"fsl,imx23-clkctrl" ); + clkctrl =of_iomap (np,0 ); +WARN_ON (!clkctrl); +clk_misc_init (); clks[ref_xtal] =mxs_clk_fixed ("ref_xtal" ,24000000 );
@@ -152,12 +165,9 @@ int __init mx23_clocks_init(void)return PTR_ERR (clks[i]); } - np =of_find_compatible_node (NULL ,NULL ,"fsl,imx23-clkctrl" ); -if (np) { - clk_data.clks = clks; - clk_data.clk_num =ARRAY_SIZE (clks); -of_clk_add_provider (np, of_clk_src_onecell_get, &clk_data); - } + clk_data.clks = clks; + clk_data.clk_num =ARRAY_SIZE (clks); +of_clk_add_provider (np, of_clk_src_onecell_get, &clk_data);for (i =0 ; i <ARRAY_SIZE (clks_init_on); i++)clk_prepare_enable (clks[clks_init_on[i]]);
drivers/clk/mxs/clk-imx28.c +17 -8
@@ -15,10 +15,13 @@#include <linux/init.h> #include <linux/io.h> #include <linux/of.h> +#include <linux/of_address.h> #include <mach/mx28.h> #include "clk.h" -#define CLKCTRL MX28_IO_ADDRESS(MX28_CLKCTRL_BASE_ADDR) +static void __iomem *clkctrl; +#define CLKCTRL clkctrl +#define PLL0CTRL0 (CLKCTRL + 0x0000)#define PLL1CTRL0 (CLKCTRL + 0x0020)#define PLL2CTRL0 (CLKCTRL + 0x0040)
@@ -52,7 +55,8 @@#define BP_FRAC0_IO1FRAC 16#define BP_FRAC0_IO0FRAC 24 -#define DIGCTRL MX28_IO_ADDRESS(MX28_DIGCTL_BASE_ADDR) +static void __iomem *digctrl; +#define DIGCTRL digctrl#define BP_SAIF_CLKMUX 10/*
@@ -155,6 +159,14 @@ int __init mx28_clocks_init(void)struct device_node *np;u32 i; + np =of_find_compatible_node (NULL ,NULL ,"fsl,imx28-digctl" ); + digctrl =of_iomap (np,0 ); +WARN_ON (!digctrl); + + np =of_find_compatible_node (NULL ,NULL ,"fsl,imx28-clkctrl" ); + clkctrl =of_iomap (np,0 ); +WARN_ON (!clkctrl); +clk_misc_init (); clks[ref_xtal] =mxs_clk_fixed ("ref_xtal" ,24000000 );
@@ -230,12 +242,9 @@ int __init mx28_clocks_init(void)return PTR_ERR (clks[i]); } - np =of_find_compatible_node (NULL ,NULL ,"fsl,imx28-clkctrl" ); -if (np) { - clk_data.clks = clks; - clk_data.clk_num =ARRAY_SIZE (clks); -of_clk_add_provider (np, of_clk_src_onecell_get, &clk_data); - } + clk_data.clks = clks; + clk_data.clk_num =ARRAY_SIZE (clks); +of_clk_add_provider (np, of_clk_src_onecell_get, &clk_data);clk_register_clkdev (clks[enet_out],NULL ,"enet_out" );
Signature · 1 line
1.7.9.5
PATCH 1/2 clk: mxs: get base address from device tree
2013/3/26 Shawn Guo <[email protected]>:
Quoted 6 lines
Instead of using the static definitions, get clkctrl and digctl base addresses with mapping from device tree.
Use macro on variable is not nice, but it's done here to save huge pointless diff stat.
[...]
drivers/clk/mxs/clk-imx23.c int __init mx23_clocks_init(void) · line 115
Quoted 12 lines
drivers/clk/mxs/clk-imx23.c +8
-0@@ -100,6 +105,14 @@ int __init mx23_clocks_init(void)struct device_node *np;u32 i; + np =of_find_compatible_node (NULL ,NULL ,"fsl,imx23-digctl" ); + digctrl =of_iomap (np,0 ); +WARN_ON (!digctrl); + + np =of_find_compatible_node (NULL ,NULL ,"fsl,imx23-clkctrl" ); + clkctrl =of_iomap (np,0 ); +WARN_ON (!clkctrl); +
WARN? Won't the system die soon anyway if the addresses cannot be found?
Best Regards,
Micha? Miros?aw
PATCH 1/2 clk: mxs: get base address from device tree
Quoted 12 lines · Micha? Miros?aw
2013/3/26 Shawn Guo <[email protected]>:
Quoted 6 lines
Instead of using the static definitions, get clkctrl and digctl base addresses with mapping from device tree.
Use macro on variable is not nice, but it's done here to save huge pointless diff stat.
[...]
Quoted 4 lines
drivers/clk/mxs/clk-imx23.c +0
-0@@ -100,6 +105,14 @@ int __init mx23_clocks_init(void)struct device_node *np;u32 i;
Quoted 10 lines
drivers/clk/mxs/clk-imx23.c int __init mx23_clocks_init(void) · line 115
Quoted 8 lines
drivers/clk/mxs/clk-imx23.c +8
-0+ np =of_find_compatible_node (NULL ,NULL ,"fsl,imx23-digctl" ); + digctrl =of_iomap (np,0 ); +WARN_ON (!digctrl); + + np =of_find_compatible_node (NULL ,NULL ,"fsl,imx23-clkctrl" ); + clkctrl =of_iomap (np,0 ); +WARN_ON (!clkctrl); +WARN? Won't the system die soon anyway if the addresses cannot be found?
Probably. But this big fat warning is also good at telling where goes wrong at the first place, so I do not see much difference than using BUG.
Shawn
PATCH 2/2 clk: mxs: remove the use of mach level IO accessor
In reply to Shawn GuoIt removes the use of mach level IO accessor __mxs_setl/clrl, and hence removes mach header inclusion from clock driver.
--- drivers/clk/mxs/clk-imx23.c | 11 +++++------ drivers/clk/mxs/clk-imx28.c | 13 ++++++------- 2 files changed, 11 insertions(+), 13 deletions(-)
drivers/clk/mxs/clk-imx23.c +5 -6
@@ -16,7 +16,6 @@#include <linux/io.h> #include <linux/of.h> #include <linux/of_address.h> -#include <mach/mx23.h> #include "clk.h" static void __iomem *clkctrl;
@@ -52,10 +51,10 @@ static void __init clk_misc_init(void)u32 val;/* Gate off cpu clock in WFI for power saving */ -__mxs_setl (1 <<BP_CPU_INTERRUPT_WAIT ,CPU ); +writel_relaxed (1 <<BP_CPU_INTERRUPT_WAIT ,CPU +SET );/* Clear BYPASS for SAIF */ -__mxs_clrl (1 <<BP_CLKSEQ_BYPASS_SAIF ,CLKSEQ ); +writel_relaxed (1 <<BP_CLKSEQ_BYPASS_SAIF ,CLKSEQ +CLR );/* SAIF has to use frac div for functional operation */ val =readl_relaxed (SAIF );
@@ -66,14 +65,14 @@ static void __init clk_misc_init(void)* Source ssp clock from ref_io than ref_xtal, * as ref_xtal only provides 24 MHz as maximum. */ -__mxs_clrl (1 <<BP_CLKSEQ_BYPASS_SSP ,CLKSEQ ); +writel_relaxed (1 <<BP_CLKSEQ_BYPASS_SSP ,CLKSEQ +CLR );/* * 480 MHz seems too high to be ssp clock source directly, * so set frac to get a 288 MHz ref_io. */ -__mxs_clrl (0x3f <<BP_FRAC_IOFRAC ,FRAC ); -__mxs_setl (30 <<BP_FRAC_IOFRAC ,FRAC ); +writel_relaxed (0x3f <<BP_FRAC_IOFRAC ,FRAC +CLR ); +writel_relaxed (30 <<BP_FRAC_IOFRAC ,FRAC +SET ); }static const char *sel_pll[]__initconst = {"pll" ,"ref_xtal" , };
drivers/clk/mxs/clk-imx28.c +6 -7
@@ -16,7 +16,6 @@#include <linux/io.h> #include <linux/of.h> #include <linux/of_address.h> -#include <mach/mx28.h> #include "clk.h" static void __iomem *clkctrl;
@@ -75,8 +74,8 @@ int mxs_saif_clkmux_select(unsigned int clkmux)if (clkmux >0x3 )return -EINVAL ; -__mxs_clrl (0x3 <<BP_SAIF_CLKMUX ,DIGCTRL ); -__mxs_setl (clkmux <<BP_SAIF_CLKMUX ,DIGCTRL ); +writel_relaxed (0x3 <<BP_SAIF_CLKMUX ,DIGCTRL +CLR ); +writel_relaxed (clkmux <<BP_SAIF_CLKMUX ,DIGCTRL +SET );return 0 ; }
@@ -86,13 +85,13 @@ static void __init clk_misc_init(void)u32 val;/* Gate off cpu clock in WFI for power saving */ -__mxs_setl (1 <<BP_CPU_INTERRUPT_WAIT ,CPU ); +writel_relaxed (1 <<BP_CPU_INTERRUPT_WAIT ,CPU +SET );/* 0 is a bad default value for a divider */ -__mxs_setl (1 <<BP_ENET_DIV_TIME ,ENET ); +writel_relaxed (1 <<BP_ENET_DIV_TIME ,ENET +SET );/* Clear BYPASS for SAIF */ -__mxs_clrl (0x3 <<BP_CLKSEQ_BYPASS_SAIF0 ,CLKSEQ ); +writel_relaxed (0x3 <<BP_CLKSEQ_BYPASS_SAIF0 ,CLKSEQ +CLR );/* SAIF has to use frac div for functional operation */ val =readl_relaxed (SAIF0 );
@@ -112,7 +111,7 @@ static void __init clk_misc_init(void)* Source ssp clock from ref_io than ref_xtal, * as ref_xtal only provides 24 MHz as maximum. */ -__mxs_clrl (0xf <<BP_CLKSEQ_BYPASS_SSP0 ,CLKSEQ ); +writel_relaxed (0xf <<BP_CLKSEQ_BYPASS_SSP0 ,CLKSEQ +CLR );/* * 480 MHz seems too high to be ssp clock source directly,
Signature · 1 line
1.7.9.5
cover clk: mxs: mach header cleanup
In reply to Shawn GuoQuoting Shawn Guo (2013-03-26 06:59:32)
Quoted 10 lines
The series cleans up the mach header inclusion from mxs clk drivers, which is another step to multiplatform support.
Mike,
The series depends on some mxs platform cleanup patches on my tree. May I ask you ACK on the patches to have them go arm-soc tree?
Shawn
Hi Shawn,
Nice cleanup.
Quoted 12 lines
Shawn Guo (2):
clk: mxs: get base address from device tree
clk: mxs: remove the use of mach level IO accessorarch/arm/boot/dts/imx23.dtsi | 1 + arch/arm/boot/dts/imx28.dtsi | 1 + drivers/clk/mxs/clk-imx23.c | 37 +++++++++++++++++++++++-------------- drivers/clk/mxs/clk-imx28.c | 38 +++++++++++++++++++++++--------------- 4 files changed, 48 insertions(+), 29 deletions(-)Signature · 1 line
1.7.9.5