Clock Framework & CPU Freq Updates
Subsystems (2)
v6 cover Clock Framework & CPU Freq Updates
This patchset contains following updates:
- Adding support for DDR
- Adding support for PLL frequency change
- Adding support for CPU Freq framework
Note: These patches were earlier sent as part of a larger patchset:
"Updating SPEAr Support"
Now it is divided into smaller patchsets. In order to apply these patches cleanly following order of patchsets must be maintained.
- SPEAr3xx & SPEAr6xx Fixes
- SPEAr3xx & SPEAr6xx: Single Image solution and padmux updates
- Adding SPEAr13xx support
- Adding devices support for all spear machines
- Clock Framework & CPU Freq Updates
Deepak Sikri (2):
ST SPEAr Clock Framework: Adding support for PLL frequency change ST SPEAr CPU freq: Adding support for CPU Freq framework
Viresh Kumar (1):
ST SPEAr Clock Framework: Adding support for DDR
arch/arm/Kconfig | 1 + arch/arm/mach-spear13xx/clock.c | 68 +++++++-- arch/arm/mach-spear3xx/clock.c | 100 ++++++++++-- arch/arm/mach-spear3xx/include/mach/misc_regs.h | 7 + arch/arm/mach-spear3xx/spear3xx.c | 5 + arch/arm/mach-spear6xx/clock.c | 100 ++++++++++-- arch/arm/mach-spear6xx/include/mach/misc_regs.h | 7 + arch/arm/mach-spear6xx/spear6xx.c | 5 + arch/arm/plat-spear/Makefile | 4 +- arch/arm/plat-spear/clock.c | 124 +++++++++++++--- arch/arm/plat-spear/cpufreq.c | 164 ++++++++++++++++++++ arch/arm/plat-spear/include/plat/clock.h | 44 ++++-- arch/arm/plat-spear/pll_clk.S | 187 +++++++++++++++++++++++ 13 files changed, 731 insertions(+), 85 deletions(-) create mode 100644 arch/arm/plat-spear/cpufreq.c create mode 100644 arch/arm/plat-spear/pll_clk.S
Signature · 1 line
1.7.2.2
PATCH v6 1/3 ST SPEAr Clock Framework: Adding support for DDR
Changing rate of clk, which is ancestor of DDR requires to put DDR in refresh mode before changing parents rate. For this DDR support is added in clock framework. Now at boot time all ancestors of DDR is marked specially and changing their rate must be first acked by ddr (i.e. ddr will run on that clock). This patch adds support for this.
--- arch/arm/mach-spear13xx/clock.c | 61 +++++++++--- arch/arm/mach-spear3xx/clock.c | 97 +++++++++++++++--- arch/arm/mach-spear3xx/include/mach/misc_regs.h | 7 ++ arch/arm/mach-spear6xx/clock.c | 97 +++++++++++++++--- arch/arm/mach-spear6xx/include/mach/misc_regs.h | 7 ++ arch/arm/plat-spear/clock.c | 124 +++++++++++++++++++---- arch/arm/plat-spear/include/plat/clock.h | 43 ++++++-- 7 files changed, 359 insertions(+), 77 deletions(-)
arch/arm/mach-spear13xx/clock.c +48 -13
@@ -23,19 +23,19 @@/* root clks */ /* 24 MHz oscillator clock */ static struct clk osc1_24m_clk = { - .flags =ALWAYS_ENABLED , + .flags =ALWAYS_ENABLED |SYSTEM_CLK , .rate =24000000 , };/* 32 KHz oscillator clock */ static struct clk osc2_32k_clk = { - .flags =ALWAYS_ENABLED , + .flags =ALWAYS_ENABLED |SYSTEM_CLK , .rate =32000 , };/* 25 MHz MIPHY oscillator clock */ static struct clk osc3_25m_clk = { - .flags =ALWAYS_ENABLED , + .flags =ALWAYS_ENABLED |SYSTEM_CLK , .rate =25000000 , };
@@ -99,7 +99,7 @@ struct pll_rate_tbl pll_rtbl[] = {/* pll1 clock */ static struct clk pll1_clk = { - .flags =ENABLED_ON_INIT , + .flags =ENABLED_ON_INIT |SYSTEM_CLK , .pclk_sel = &pll_pclk_sel, .pclk_sel_shift =PLL1_CLK_SHIFT , .en_reg =PLL1_CTR ,
@@ -113,7 +113,7 @@ static struct clk pll1_clk = {/* pll1div2 clock */ static struct clk pll1div2_clk = { - .flags =ALWAYS_ENABLED , + .flags =ALWAYS_ENABLED |SYSTEM_CLK , .pclk = &pll1_clk, .div_factor =2 , .recalc = &follow_parent,
@@ -121,7 +121,7 @@ static struct clk pll1div2_clk = {/* pll1div4 clock */ static struct clk pll1div4_clk = { - .flags =ALWAYS_ENABLED , + .flags =ALWAYS_ENABLED |SYSTEM_CLK , .pclk = &pll1_clk, .div_factor =4 , .recalc = &follow_parent,
@@ -136,6 +136,7 @@ static struct pll_clk_config pll2_config = {/* pll2 clock */ static struct clk pll2_clk = { + .flags =SYSTEM_CLK , .pclk_sel = &pll_pclk_sel, .pclk_sel_shift =PLL2_CLK_SHIFT , .en_reg =PLL2_CTR ,
@@ -156,6 +157,7 @@ static struct pll_clk_config pll3_config = {/* pll3 clock */ static struct clk pll3_clk = { + .flags =SYSTEM_CLK , .pclk_sel = &pll_pclk_sel, .pclk_sel_shift =PLL3_CLK_SHIFT , .en_reg =PLL3_CTR ,
@@ -184,7 +186,7 @@ struct pll_rate_tbl pll4_rtbl[] = {/* pll4 (DDR) clock */ static struct clk pll4_clk = { - .flags =ENABLED_ON_INIT , + .flags =ENABLED_ON_INIT |SYSTEM_CLK , .pclk = &osc1_24m_clk, .en_reg =PLL4_CTR , .en_reg_bit =PLL_ENABLE ,
@@ -197,22 +199,54 @@ static struct clk pll4_clk = {/* pll5 USB 48 MHz clock */ static struct clk pll5_clk = { - .flags =ALWAYS_ENABLED , + .flags =ALWAYS_ENABLED |SYSTEM_CLK , .pclk = &osc1_24m_clk, .rate =48000000 , };/* pll6 (MIPHY) clock */ static struct clk pll6_clk = { - .flags =ALWAYS_ENABLED , + .flags =ALWAYS_ENABLED |SYSTEM_CLK , .pclk = &osc3_25m_clk, .rate =25000000 , };/* clocks derived from pll1 clk */ +/* ddr clock */ +struct ddr_rate_tbl ddr_rate_tbl = { + .minrate =332000000 , + .maxrate =500000000 , +}; + +static struct pclk_info ddr_pclk_info[] = { + { + .pclk = &pll1_clk, + .pclk_val =MCTR_CLK_PLL1_VAL , + }, { + .pclk = &pll4_clk, + .pclk_val =MCTR_CLK_PLL4_VAL , + }, +}; + +/* ddr parent select structure */ +static struct pclk_sel ddr_pclk_sel = { + .pclk_info = ddr_pclk_info, + .pclk_count =ARRAY_SIZE (ddr_pclk_info), + .pclk_sel_reg =PERIP_CLK_CFG , + .pclk_sel_mask =MCTR_CLK_MASK , +}; + +static struct clk ddr_clk = { + .flags =ALWAYS_ENABLED |SYSTEM_CLK , + .recalc = &follow_parent, + .pclk_sel = &ddr_pclk_sel, + .pclk_sel_shift =MCTR_CLK_SHIFT , + .private_data = &ddr_rate_tbl, +}; +/* cpu clock */ static struct clk cpu_clk = { - .flags =ALWAYS_ENABLED , + .flags =ALWAYS_ENABLED |SYSTEM_CLK , .pclk = &pll1_clk, .div_factor =2 , .recalc = &follow_parent,
@@ -220,7 +254,7 @@ static struct clk cpu_clk = {/* ahb clock */ static struct clk ahb_clk = { - .flags =ALWAYS_ENABLED , + .flags =ALWAYS_ENABLED |SYSTEM_CLK , .pclk = &pll1_clk, .div_factor =6 , .recalc = &follow_parent,
@@ -228,7 +262,7 @@ static struct clk ahb_clk = {/* apb clock */ static struct clk apb_clk = { - .flags =ALWAYS_ENABLED , + .flags =ALWAYS_ENABLED |SYSTEM_CLK , .pclk = &pll1_clk, .div_factor =12 , .recalc = &follow_parent,
@@ -1048,6 +1082,7 @@ static struct clk_lookup spear_clk_lookups[] = { {.con_id = "pll6_clk", .clk = &pll6_clk}, /* clock derived from pll1 clk */ + {.con_id = "ddr_clk", .clk = &ddr_clk}, {.con_id = "cpu_clk", .clk = &cpu_clk}, {.con_id = "ahb_clk", .clk = &ahb_clk}, {.con_id = "apb_clk", .clk = &apb_clk},
@@ -1163,5 +1198,5 @@ void __init spear13xx_clk_init(void)for (i =0 ; i < cnt; i++)clk_register (&lookups[i]); -clk_init (); +clk_init (&ddr_clk); }
arch/arm/mach-spear3xx/clock.c +81 -16
176 lines not on this page · raw message
arch/arm/mach-spear3xx/include/mach/misc_regs.h +7 -0
@@ -46,6 +46,13 @@#define PLL2_MOD (MISC_BASE + 0x01C)#define PLL_CLK_CFG (MISC_BASE + 0x020) +/* PLL_CLK_CFG register masks */ +#define MCTR_CLK_SHIFT 28 +#define MCTR_CLK_MASK 0x7 +#define MCTR_CLK_HCLK_VAL 0x0 +#define MCTR_CLK_2HCLK_VAL 0x1 +#define MCTR_CLK_PLL2_VAL 0x3 +#define CORE_CLK_CFG (MISC_BASE + 0x024)/* CORE CLK CFG register masks */ #define PLL_HCLK_RATIO_SHIFT 10
arch/arm/mach-spear6xx/clock.c +81 -16
176 lines not on this page · raw message
arch/arm/mach-spear6xx/include/mach/misc_regs.h +7 -0
@@ -47,6 +47,13 @@#define PLL2_MOD (MISC_BASE + 0x01C)#define PLL_CLK_CFG (MISC_BASE + 0x020)#define CORE_CLK_CFG (MISC_BASE + 0x024) +/* PLL_CLK_CFG register masks */ +#define MCTR_CLK_SHIFT 28 +#define MCTR_CLK_MASK 0x7 +#define MCTR_CLK_HCLK_VAL 0x0 +#define MCTR_CLK_2HCLK_VAL 0x1 +#define MCTR_CLK_PLL2_VAL 0x3 +/* CORE CLK CFG register masks */ #define PLL_HCLK_RATIO_SHIFT 10#define PLL_HCLK_RATIO_MASK 0x3
arch/arm/plat-spear/clock.c +104 -20
253 lines not on this page · raw message
arch/arm/plat-spear/include/plat/clock.h +31 -12
75 lines not on this page · raw message
Signature · 1 line
1.7.2.2
PATCH v6 2/3 ST SPEAr Clock Framework: Adding support for PLL frequency change
In reply to Viresh KumarFrom: Deepak Sikri <[email protected]>
--- arch/arm/mach-spear3xx/spear3xx.c | 5 + arch/arm/mach-spear6xx/spear6xx.c | 5 + arch/arm/plat-spear/Makefile | 2 +- arch/arm/plat-spear/clock.c | 6 +- arch/arm/plat-spear/include/plat/clock.h | 1 + arch/arm/plat-spear/pll_clk.S | 187 ++++++++++++++++++++++++++++++ 6 files changed, 201 insertions(+), 5 deletions(-) create mode 100644 arch/arm/plat-spear/pll_clk.S
arch/arm/mach-spear3xx/spear3xx.c +5 -0
@@ -254,6 +254,11 @@ struct map_desc spear3xx_io_desc[] __initdata = { .pfn = __phys_to_pfn(SPEAR3XX_ICM3_MISC_REG_BASE), .length = SZ_4K, .type = MT_DEVICE + }, { + .virtual = IO_ADDRESS(SPEAR3XX_ICM3_SDRAM_CTRL_BASE), + .pfn = __phys_to_pfn(SPEAR3XX_ICM3_SDRAM_CTRL_BASE), + .length = SZ_4K, + .type = MT_DEVICE }, };
arch/arm/mach-spear6xx/spear6xx.c +5 -0
@@ -397,6 +397,11 @@ static struct map_desc spear6xx_io_desc[] __initdata = { .pfn = __phys_to_pfn(SPEAR6XX_ICM3_MISC_REG_BASE), .length = SZ_4K, .type = MT_DEVICE + }, { + .virtual = IO_ADDRESS(SPEAR6XX_ICM3_SDRAM_CTRL_BASE), + .pfn = __phys_to_pfn(SPEAR6XX_ICM3_SDRAM_CTRL_BASE), + .length = SZ_4K, + .type = MT_DEVICE }, };
arch/arm/plat-spear/Makefile +1 -1
@@ -3,7 +3,7 @@ # # Common support -obj-y := clock.o time.o +obj-y := clock.o pll_clk.o time.o obj-$(CONFIG_ARCH_SPEAR13XX) += padmux.o obj-$(CONFIG_ARCH_SPEAR3XX) += shirq.o padmux.o
arch/arm/plat-spear/clock.c +2 -4
@@ -616,11 +616,10 @@ int pll_clk_set_rate(struct clk *clk, unsigned long desired_rate)* call routine to put ddr in refresh mode, and * configure pll. */ -/* TBD */ +pll_set_rate (tbls[i].m, tbls[i].p, tbls[i].n); clk->rate = rate; } - -return ret; +return 0 ; } val = readl(config->mode_reg) &
@@ -646,7 +645,6 @@ int pll_clk_set_rate(struct clk *clk, unsigned long desired_rate) config->masks->norm_fdbk_m_shift;writel (val, config->cfg_reg); - clk->rate = rate;return 0 ;
arch/arm/plat-spear/include/plat/clock.h +1 -0
@@ -264,5 +264,6 @@ int aux_clk_set_rate(struct clk *clk, unsigned long desired_rate);unsigned long clcd_calc_rate (struct clk *clk,int index);int clcd_clk_recalc (struct clk *clk,unsigned long *rate,unsigned long prate);int clcd_clk_set_rate (struct clk *clk,unsigned long desired_rate); +void pll_set_rate (u16 pdiv,u8 nmul,u8 hclkdiv);#endif /* __PLAT_CLOCK_H */
arch/arm/plat-spear/pll_clk.S new file +187 -0
187 lines not on this page · raw message
Signature · 1 line
1.7.2.2
PATCH v6 3/3 ST SPEAr CPU freq: Adding support for CPU Freq framework
In reply to Viresh KumarFrom: Deepak Sikri <[email protected]>
--- arch/arm/Kconfig | 1 + arch/arm/mach-spear13xx/clock.c | 7 +- arch/arm/mach-spear3xx/clock.c | 5 +- arch/arm/mach-spear6xx/clock.c | 5 +- arch/arm/plat-spear/Makefile | 2 +- arch/arm/plat-spear/cpufreq.c | 164 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 176 insertions(+), 8 deletions(-) create mode 100644 arch/arm/plat-spear/cpufreq.c
arch/arm/Kconfig +1 -0
@@ -872,6 +872,7 @@ config PLAT_SPEAR select CLKDEV_LOOKUP select GENERIC_CLOCKEVENTS select HAVE_CLK + select ARCH_HAS_CPUFREQ help Support for ST's SPEAr platform (SPEAr3xx, SPEAr6xx and SPEAr13xx).
arch/arm/mach-spear13xx/clock.c +4 -3
@@ -91,6 +91,7 @@ static struct pll_clk_config pll1_config = {/* pll rate configuration table, in ascending order of rates */ struct pll_rate_tbl pll_rtbl[] = {/* PCLK 24MHz */ + {.mode =0 , .m =0x64 , .n =0x03 , .p =0x2 },/* 400 MHz */ {.mode =0 , .m =0x7D , .n =0x03 , .p =0x2 },/* 500 MHz */ {.mode =0 , .m =0xA6 , .n =0x03 , .p =0x2 },/* 664 MHz */ {.mode =0 , .m =0xC8 , .n =0x03 , .p =0x2 },/* 800 MHz */
@@ -107,7 +108,7 @@ static struct clk pll1_clk = { .calc_rate = &pll_calc_rate, .recalc = &pll_clk_recalc, .set_rate = &pll_clk_set_rate, - .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 3}, + .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 4}, .private_data = &pll1_config, };
@@ -144,7 +145,7 @@ static struct clk pll2_clk = { .calc_rate = &pll_calc_rate, .recalc = &pll_clk_recalc, .set_rate = &pll_clk_set_rate, - .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 3}, + .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 4}, .private_data = &pll2_config, };
@@ -165,7 +166,7 @@ static struct clk pll3_clk = { .calc_rate = &pll_calc_rate, .recalc = &pll_clk_recalc, .set_rate = &pll_clk_set_rate, - .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 3}, + .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 4}, .private_data = &pll3_config, };
arch/arm/mach-spear3xx/clock.c +3 -2
@@ -56,6 +56,7 @@ static struct pll_clk_masks pll_masks = {/* pll rate configuration table, in ascending order of rates */ struct pll_rate_tbl pll_rtbl[] = { + {.mode =0 , .m =0x53 , .n =0x0C , .p =0x1 },/* 166 MHz */ {.mode =0 , .m =0x85 , .n =0x0C , .p =0x1 },/* 266 MHz */ {.mode =0 , .m =0xA6 , .n =0x0C , .p =0x1 },/* 332 MHz */ };
@@ -76,7 +77,7 @@ static struct clk pll1_clk = { .calc_rate = &pll_calc_rate, .recalc = &pll_clk_recalc, .set_rate = &pll_clk_set_rate, - .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 1}, + .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 2}, .private_data = &pll1_config, };
@@ -96,7 +97,7 @@ static struct clk pll2_clk = { .calc_rate = &pll_calc_rate, .recalc = &pll_clk_recalc, .set_rate = &pll_clk_set_rate, - .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 1}, + .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 2}, .private_data = &pll2_config, };
arch/arm/mach-spear6xx/clock.c +3 -2
@@ -55,6 +55,7 @@ static struct pll_clk_masks pll_masks = {/* pll rate configuration table, in ascending order of rates */ struct pll_rate_tbl pll_rtbl[] = { + {.mode =0 , .m =0x53 , .n =0x0C , .p =0x1 },/* 166 MHz */ {.mode =0 , .m =0x85 , .n =0x0C , .p =0x1 },/* 266 MHz */ {.mode =0 , .m =0xA6 , .n =0x0C , .p =0x1 },/* 332 MHz */ };
@@ -75,7 +76,7 @@ static struct clk pll1_clk = { .calc_rate = &pll_calc_rate, .recalc = &pll_clk_recalc, .set_rate = &pll_clk_set_rate, - .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 1}, + .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 2}, .private_data = &pll1_config, };
@@ -95,7 +96,7 @@ static struct clk pll2_clk = { .calc_rate = &pll_calc_rate, .recalc = &pll_clk_recalc, .set_rate = &pll_clk_set_rate, - .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 1}, + .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 2}, .private_data = &pll2_config, };
arch/arm/plat-spear/Makefile +1 -1
@@ -7,7 +7,7 @@ obj-y := clock.o pll_clk.o time.o obj-$(CONFIG_ARCH_SPEAR13XX) += padmux.o obj-$(CONFIG_ARCH_SPEAR3XX) += shirq.o padmux.o - +obj-$(CONFIG_CPU_FREQ) += cpufreq.o obj-$(CONFIG_MACH_SPEAR310) += plgpio.o obj-$(CONFIG_MACH_SPEAR320) += plgpio.o
arch/arm/plat-spear/cpufreq.c new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
1.7.2.2