ARM: OMAP4+: Cleanup clocks, control and emif code
Subsystems (2)
v2 cover ARM: OMAP4+: Cleanup clocks, control and emif code
This series is intended to cleanup code which is duplicated across soc specific files. This is accomplished by moving soc specifc data to one place and having the code common. This helps in avoiding un necessary cpu checks and minimal code addition for future socs.
Tested this on OMAP5 ES1.0, OMAP4460 Panda boards and verified MAKEALL for all armv7 boards.
Lokesh Vutla (4):
ARM: OMAP4+: emif: Detect SDRAM from SDRAM config register
ARM: OMAP4+: Cleanup emif specific files
ARM: OMAP4+: Make control module register structure generic
ARM: OMAP5: Clean up iosettings code
R Sricharan (3):
ARM: OMAP4+: Change the PRCM structure prototype common for all Socs
ARM: OMAP4+: Cleanup the clocks layer
ARM: OMAP4+: Clean up the pmic code
arch/arm/cpu/armv7/omap-common/clocks-common.c | 283 ++++++++---- arch/arm/cpu/armv7/omap-common/emif-common.c | 71 ++- arch/arm/cpu/armv7/omap-common/hwinit-common.c | 8 +- arch/arm/cpu/armv7/omap-common/vc.c | 11 +- arch/arm/cpu/armv7/omap4/Makefile | 3 +- arch/arm/cpu/armv7/omap4/clocks.c | 517 ---------------------- arch/arm/cpu/armv7/omap4/hw_data.c | 502 +++++++++++++++++++++ arch/arm/cpu/armv7/omap4/hwinit.c | 36 +- arch/arm/cpu/armv7/omap4/prcm-regs.c | 315 +++++++++++++ arch/arm/cpu/armv7/omap4/sdram_elpida.c | 16 +- arch/arm/cpu/armv7/omap5/Makefile | 3 +- arch/arm/cpu/armv7/omap5/clocks.c | 494 --------------------- arch/arm/cpu/armv7/omap5/hw_data.c | 494 +++++++++++++++++++++ arch/arm/cpu/armv7/omap5/hwinit.c | 131 +++--- arch/arm/cpu/armv7/omap5/prcm-regs.c | 380 ++++++++++++++++ arch/arm/cpu/armv7/omap5/sdram.c | 119 +++-- arch/arm/include/asm/arch-omap4/clocks.h | 562 ++---------------------- arch/arm/include/asm/arch-omap4/omap.h | 33 +- arch/arm/include/asm/arch-omap4/sys_proto.h | 3 +- arch/arm/include/asm/arch-omap5/clocks.h | 506 +-------------------- arch/arm/include/asm/arch-omap5/omap.h | 96 +--- arch/arm/include/asm/arch-omap5/sys_proto.h | 4 +- arch/arm/include/asm/emif.h | 18 +- arch/arm/include/asm/omap_common.h | 482 ++++++++++++++++++++ drivers/mmc/omap_hsmmc.c | 25 +- include/configs/omap5_evm.h | 1 + 26 files changed, 2659 insertions(+), 2454 deletions(-) delete mode 100644 arch/arm/cpu/armv7/omap4/clocks.c create mode 100644 arch/arm/cpu/armv7/omap4/hw_data.c create mode 100644 arch/arm/cpu/armv7/omap4/prcm-regs.c delete mode 100644 arch/arm/cpu/armv7/omap5/clocks.c create mode 100644 arch/arm/cpu/armv7/omap5/hw_data.c create mode 100644 arch/arm/cpu/armv7/omap5/prcm-regs.c
Signature · 1 line
1.7.9.5
PATCH v2 1/7 ARM: OMAP4+: emif: Detect SDRAM from SDRAM config register
From: Lokesh Vutla <[email protected]>
Now SDRAM initialization is done on the basis of omap revision. Instead this should be done on basis of SDRAM type read from EMIF_SDRAM_CONFIG register. This will be helpful to avoid unnessecary cpu checks for new boards
---
[V2] Addressed Tom Rini's <[email protected]> comments
arch/arm/cpu/armv7/omap-common/clocks-common.c | 3 ++- arch/arm/cpu/armv7/omap-common/emif-common.c | 21 +++++++++++++++++---- arch/arm/cpu/armv7/omap5/clocks.c | 3 ++- arch/arm/cpu/armv7/omap5/hwinit.c | 2 +- arch/arm/include/asm/emif.h | 6 ++++++ 5 files changed, 28 insertions(+), 7 deletions(-)
arch/arm/cpu/armv7/omap-common/clocks-common.c +2 -1
@@ -36,6 +36,7 @@#include <asm/arch/sys_proto.h> #include <asm/utils.h> #include <asm/omap_gpio.h> +#include <asm/emif.h> #ifndef CONFIG_SPL_BUILD /*
@@ -299,7 +300,7 @@ static void setup_dplls(void)* Core DPLL will be locked after setting up EMIF * using the FREQ_UPDATE method(freq_update_core()) */ -if (omap_revision () !=OMAP5432_ES1_0 ) +if (emif_sdram_type () ==EMIF_SDRAM_TYPE_LPDDR2 )do_setup_dpll (&prcm->cm_clkmode_dpll_core, params,DPLL_NO_LOCK ,"core" );else
arch/arm/cpu/armv7/omap-common/emif-common.c +17 -4
@@ -66,6 +66,19 @@ inline u32 emif_num(u32 base)return 0 ; } +/* +* Get SDRAM type connected to EMIF. +* Assuming similar SDRAM parts are connected to both EMIF's +* which is typically the case. So it is sufficient to get +* SDRAM type from EMIF1. +*/ +u32 emif_sdram_type () +{ +struct emif_reg_struct *emif = (struct emif_reg_struct *)EMIF1_BASE ; + +return (readl (&emif->emif_sdram_config) & +EMIF_REG_SDRAM_TYPE_MASK ) >>EMIF_REG_SDRAM_TYPE_SHIFT ; +}static inline u32 get_mr (u32 base,u32 cs,u32 mr_addr) {
@@ -1079,7 +1092,7 @@ static void do_sdram_init(u32 base)* OPP to another) */ if (!(in_sdram ||warm_reset ())) { -if (omap_revision () !=OMAP5432_ES1_0 ) +if (emif_sdram_type () ==EMIF_SDRAM_TYPE_LPDDR2 )lpddr2_init (base, regs);else ddr3_init (base, regs);
@@ -1264,7 +1277,7 @@ void dmm_init(u32 base)void sdram_init (void ) {u32 in_sdram, size_prog, size_detect; -u32 omap_rev =omap_revision (); +u32 sdram_type =emif_sdram_type ();debug (">>sdram_init()\n" );
@@ -1275,7 +1288,7 @@ void sdram_init(void)debug ("in_sdram = %d\n" , in_sdram);if (!(in_sdram ||warm_reset ())) { -if (omap_rev !=OMAP5432_ES1_0 ) +if (sdram_type ==EMIF_SDRAM_TYPE_LPDDR2 )bypass_dpll (&prcm->cm_clkmode_dpll_core);else writel (CM_DLL_CTRL_NO_OVERRIDE , &prcm->cm_dll_ctrl);
@@ -1298,7 +1311,7 @@ void sdram_init(void) }/* for the shadow registers to take effect */ -if (omap_rev !=OMAP5432_ES1_0 ) +if (sdram_type ==EMIF_SDRAM_TYPE_LPDDR2 )freq_update_core ();/* Do some testing after the init */
arch/arm/cpu/armv7/omap5/clocks.c +2 -1
@@ -36,6 +36,7 @@#include <asm/arch/sys_proto.h> #include <asm/utils.h> #include <asm/omap_gpio.h> +#include <asm/emif.h> #ifndef CONFIG_SPL_BUILD /*
@@ -279,7 +280,7 @@ void scale_vcores(void)do_scale_vcore (SMPS_REG_ADDR_12_MPU , volt_mpu);do_scale_vcore (SMPS_REG_ADDR_45_IVA , volt_mm); -if (omap_revision () ==OMAP5432_ES1_0 ) { +if (emif_sdram_type () ==EMIF_SDRAM_TYPE_DDR3 ) {/* Configure LDO SRAM "magic" bits */ writel (2 , &prcm->prm_sldo_core_setup);writel (2 , &prcm->prm_sldo_mpu_setup);
arch/arm/cpu/armv7/omap5/hwinit.c +1 -1
@@ -191,7 +191,7 @@ void do_io_settings(void) (sc_fast <<17 ) | (sc_fast <<14 );writel (io_settings, &(ioregs_base->control_smart3io_padconf_1)); -if (omap_revision () <=OMAP5430_ES1_0 ) +if (emif_sdram_type () ==EMIF_SDRAM_TYPE_LPDDR2 )io_settings_lpddr2 ();else io_settings_ddr3 ();
arch/arm/include/asm/emif.h +6 -0
@@ -1027,6 +1027,11 @@ extern const u32 ddr3_ext_phy_ctrl_const_base[EMIF_EXT_PHY_CTRL_CONST_REG];#define MR8_IO_WIDTH_SHIFT 0x6#define MR8_IO_WIDTH_MASK (0x3 << 0x6) +/* SDRAM TYPE */ +#define EMIF_SDRAM_TYPE_DDR2 0x2 +#define EMIF_SDRAM_TYPE_DDR3 0x3 +#define EMIF_SDRAM_TYPE_LPDDR2 0x4 +struct lpddr2_addressing {u8 num_banks;u8 t_REFI_us_x10;
@@ -1156,4 +1161,5 @@ extern u32 *const emif_sizes;#endif void config_data_eye_leveling_samples (u32 emif_base); +u32 emif_sdram_type (void );#endif
Signature · 1 line
1.7.9.5
PATCH v2 1/7 ARM: OMAP4+: emif: Detect SDRAM from SDRAM config register
Quoted 9 lines · R Sricharan
From: Lokesh Vutla <[email protected]>
Now SDRAM initialization is done on the basis of omap revision. Instead this should be done on basis of SDRAM type read from
EMIF_SDRAM_CONFIGregister. This will be helpful to avoid unnessecary cpu checks for new boardsSigned-off-by R Sricharan <[email protected]>Signed-off-by Lokesh Vutla <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130204/96ff239f/attachment.pgp>
PATCH v2 2/7 ARM: OMAP4+: Change the PRCM structure prototype common for all Socs
In reply to R SricharanThe current PRCM structure prototype directly matches the hardware register layout. So there is a need to change this for every new silicon revision which has register space changes.
Avoiding this by making the prototye generic and populating the register addresses seperately for all Socs.
---
[V2] Addressed Tom Rini's <[email protected]> comments
arch/arm/cpu/armv7/omap-common/clocks-common.c | 106 ++--- arch/arm/cpu/armv7/omap-common/emif-common.c | 4 +- arch/arm/cpu/armv7/omap-common/hwinit-common.c | 3 + arch/arm/cpu/armv7/omap-common/vc.c | 11 +- arch/arm/cpu/armv7/omap4/Makefile | 2 + arch/arm/cpu/armv7/omap4/clocks.c | 199 +++++---- arch/arm/cpu/armv7/omap4/hw_data.c | 38 ++ arch/arm/cpu/armv7/omap4/prcm-regs.c | 295 +++++++++++++ arch/arm/cpu/armv7/omap5/Makefile | 2 + arch/arm/cpu/armv7/omap5/clocks.c | 215 +++++----- arch/arm/cpu/armv7/omap5/hw_data.c | 38 ++ arch/arm/cpu/armv7/omap5/prcm-regs.c | 306 ++++++++++++++ arch/arm/include/asm/arch-omap4/clocks.h | 524 +++--------------------- arch/arm/include/asm/arch-omap4/omap.h | 3 +- arch/arm/include/asm/arch-omap4/sys_proto.h | 2 +- arch/arm/include/asm/arch-omap5/clocks.h | 460 +-------------------- arch/arm/include/asm/arch-omap5/omap.h | 3 +- arch/arm/include/asm/arch-omap5/sys_proto.h | 2 +- arch/arm/include/asm/omap_common.h | 304 ++++++++++++++ 19 files changed, 1312 insertions(+), 1205 deletions(-) create mode 100644 arch/arm/cpu/armv7/omap4/hw_data.c create mode 100644 arch/arm/cpu/armv7/omap4/prcm-regs.c create mode 100644 arch/arm/cpu/armv7/omap5/hw_data.c create mode 100644 arch/arm/cpu/armv7/omap5/prcm-regs.c
arch/arm/cpu/armv7/omap-common/clocks-common.c +53 -53
@@ -61,7 +61,7 @@ static inline u32 __get_sys_clk_index(void) ind =OMAP_SYS_CLK_IND_38_4_MHZ ; else {/* SYS_CLKSEL - 1 to match the dpll param array indices */ - ind = (readl (&prcm->cm_sys_clksel) & + ind = (readl ((*prcm)->cm_sys_clksel) &CM_SYS_CLKSEL_SYS_CLKSEL_MASK ) -1 ; }return ind;
@@ -76,7 +76,7 @@ u32 get_sys_clk_freq(void)return sys_clk_array[index]; } -static inline void do_bypass_dpll (u32 *const base) +static inline void do_bypass_dpll (u32 const base) {struct dpll_regs *dpll_regs = (struct dpll_regs *)base;
@@ -86,17 +86,17 @@ static inline void do_bypass_dpll(u32 *const base) CM_CLKMODE_DPLL_EN_SHIFT); } -static inline void wait_for_bypass (u32 *const base) +static inline void wait_for_bypass (u32 const base) {struct dpll_regs *const dpll_regs = (struct dpll_regs *)base;if (!wait_on_value (ST_DPLL_CLK_MASK ,0 , &dpll_regs->cm_idlest_dpll,LDELAY )) { -printf ("Bypassing DPLL failed %p\n" , base); +printf ("Bypassing DPLL failed %x\n" , base); } } -static inline void do_lock_dpll (u32 *const base) +static inline void do_lock_dpll (u32 const base) {struct dpll_regs *const dpll_regs = (struct dpll_regs *)base;
@@ -105,18 +105,18 @@ static inline void do_lock_dpll(u32 *const base) DPLL_EN_LOCK << CM_CLKMODE_DPLL_EN_SHIFT); } -static inline void wait_for_lock (u32 *const base) +static inline void wait_for_lock (u32 const base) {struct dpll_regs *const dpll_regs = (struct dpll_regs *)base;if (!wait_on_value (ST_DPLL_CLK_MASK ,ST_DPLL_CLK_MASK , &dpll_regs->cm_idlest_dpll,LDELAY )) { -printf ("DPLL locking failed for %p\n" , base); +printf ("DPLL locking failed for %x\n" , base);hang (); } } -inline u32 check_for_lock (u32 *const base) +inline u32 check_for_lock (u32 const base) {struct dpll_regs *const dpll_regs = (struct dpll_regs *)base;u32 lock =readl (&dpll_regs->cm_idlest_dpll) &ST_DPLL_CLK_MASK ;
@@ -124,7 +124,7 @@ inline u32 check_for_lock(u32 *const base)return lock; } -static void do_setup_dpll (u32 *const base,const struct dpll_params *params, +static void do_setup_dpll (u32 const base,const struct dpll_params *params,u8 lock,char *dpll) {u32 temp,M ,N ;
@@ -236,24 +236,24 @@ void configure_mpu_dpll(void)*/ if ((omap_rev >=OMAP4460_ES1_0 ) && (omap_rev <OMAP5430_ES1_0 )) { mpu_dpll_regs = - (struct dpll_regs *)&prcm->cm_clkmode_dpll_mpu; -bypass_dpll (&prcm->cm_clkmode_dpll_mpu); -clrbits_le32 (&prcm->cm_mpu_mpu_clkctrl, + (struct dpll_regs *)((*prcm)->cm_clkmode_dpll_mpu); +bypass_dpll ((*prcm)->cm_clkmode_dpll_mpu); +clrbits_le32 ((*prcm)->cm_mpu_mpu_clkctrl,MPU_CLKCTRL_CLKSEL_EMIF_DIV_MODE_MASK ); -setbits_le32 (&prcm->cm_mpu_mpu_clkctrl, +setbits_le32 ((*prcm)->cm_mpu_mpu_clkctrl,MPU_CLKCTRL_CLKSEL_ABE_DIV_MODE_MASK );clrbits_le32 (&mpu_dpll_regs->cm_clksel_dpll,CM_CLKSEL_DCC_EN_MASK ); } -setbits_le32 (&prcm->cm_mpu_mpu_clkctrl, +setbits_le32 ((*prcm)->cm_mpu_mpu_clkctrl,MPU_CLKCTRL_CLKSEL_EMIF_DIV_MODE_MASK ); -setbits_le32 (&prcm->cm_mpu_mpu_clkctrl, +setbits_le32 ((*prcm)->cm_mpu_mpu_clkctrl,MPU_CLKCTRL_CLKSEL_ABE_DIV_MODE_MASK ); params =get_mpu_dpll_params (); -do_setup_dpll (&prcm->cm_clkmode_dpll_mpu, params,DPLL_LOCK ,"mpu" ); +do_setup_dpll ((*prcm)->cm_clkmode_dpll_mpu, params,DPLL_LOCK ,"mpu" );debug ("MPU DPLL locked\n" ); }
@@ -277,12 +277,12 @@ static void setup_usb_dpll(void) den = (params->n +1 ) *250 *1000 ; num += den -1 ; sd_div = num / den; -clrsetbits_le32 (&prcm->cm_clksel_dpll_usb, +clrsetbits_le32 ((*prcm)->cm_clksel_dpll_usb,CM_CLKSEL_DPLL_DPLL_SD_DIV_MASK , sd_div <<CM_CLKSEL_DPLL_DPLL_SD_DIV_SHIFT );/* Now setup the dpll with the regular function */ - do_setup_dpll(&prcm->cm_clkmode_dpll_usb, params, DPLL_LOCK, "usb"); + do_setup_dpll((*prcm)->cm_clkmode_dpll_usb, params, DPLL_LOCK, "usb"); }#endif
@@ -301,21 +301,21 @@ static void setup_dplls(void)* using the FREQ_UPDATE method(freq_update_core()) */ if (emif_sdram_type () ==EMIF_SDRAM_TYPE_LPDDR2 ) -do_setup_dpll (&prcm->cm_clkmode_dpll_core, params, +do_setup_dpll ((*prcm)->cm_clkmode_dpll_core, params,DPLL_NO_LOCK ,"core" );else -do_setup_dpll (&prcm->cm_clkmode_dpll_core, params, +do_setup_dpll ((*prcm)->cm_clkmode_dpll_core, params,DPLL_LOCK ,"core" );/* Set the ratios for CORE_CLK, L3_CLK, L4_CLK */ temp = (CLKSEL_CORE_X2_DIV_1 <<CLKSEL_CORE_SHIFT ) | (CLKSEL_L3_CORE_DIV_2 <<CLKSEL_L3_SHIFT ) | (CLKSEL_L4_L3_DIV_2 <<CLKSEL_L4_SHIFT ); -writel (temp, &prcm->cm_clksel_core); +writel (temp, (*prcm)->cm_clksel_core);debug ("Core DPLL configured\n" );/* lock PER dpll */ params =get_per_dpll_params (); -do_setup_dpll (&prcm->cm_clkmode_dpll_per, +do_setup_dpll ((*prcm)->cm_clkmode_dpll_per, params,DPLL_LOCK ,"per" );debug ("PER DPLL locked\n" );
@@ -334,11 +334,11 @@ static void setup_non_essential_dplls(void)const struct dpll_params *params;/* IVA */ -clrsetbits_le32 (&prcm->cm_bypclk_dpll_iva, +clrsetbits_le32 ((*prcm)->cm_bypclk_dpll_iva,CM_BYPCLK_DPLL_IVA_CLKSEL_MASK ,DPLL_IVA_CLKSEL_CORE_X2_DIV_2 ); params =get_iva_dpll_params (); -do_setup_dpll (&prcm->cm_clkmode_dpll_iva, params,DPLL_LOCK ,"iva" ); +do_setup_dpll ((*prcm)->cm_clkmode_dpll_iva, params,DPLL_LOCK ,"iva" );/* Configure ABE dpll */ params =get_abe_dpll_params ();
@@ -350,23 +350,23 @@ static void setup_non_essential_dplls(void)* We need to enable some additional options to achieve * 196.608MHz from 32768 Hz */ -setbits_le32 (&prcm->cm_clkmode_dpll_abe, +setbits_le32 ((*prcm)->cm_clkmode_dpll_abe,CM_CLKMODE_DPLL_DRIFTGUARD_EN_MASK |CM_CLKMODE_DPLL_RELOCK_RAMP_EN_MASK |CM_CLKMODE_DPLL_LPMODE_EN_MASK |CM_CLKMODE_DPLL_REGM4XEN_MASK );/* Spend 4 REFCLK cycles at each stage */ -clrsetbits_le32 (&prcm->cm_clkmode_dpll_abe, +clrsetbits_le32 ((*prcm)->cm_clkmode_dpll_abe,CM_CLKMODE_DPLL_RAMP_RATE_MASK ,1 <<CM_CLKMODE_DPLL_RAMP_RATE_SHIFT );#endif /* Select the right reference clk */ -clrsetbits_le32 (&prcm->cm_abe_pll_ref_clksel, +clrsetbits_le32 ((*prcm)->cm_abe_pll_ref_clksel,CM_ABE_PLL_REF_CLKSEL_CLKSEL_MASK , abe_ref_clk <<CM_ABE_PLL_REF_CLKSEL_CLKSEL_SHIFT );/* Lock the dpll */ - do_setup_dpll(&prcm->cm_clkmode_dpll_abe, params, DPLL_LOCK, "abe"); + do_setup_dpll((*prcm)->cm_clkmode_dpll_abe, params, DPLL_LOCK, "abe"); }#endif
@@ -417,14 +417,14 @@ void do_scale_vcore(u32 vcore_reg, u32 volt_mv)printf ("Scaling voltage failed for 0x%x\n" , vcore_reg); } -static inline void enable_clock_domain (u32 *const clkctrl_reg,u32 enable_mode) +static inline void enable_clock_domain (u32 const clkctrl_reg,u32 enable_mode) {clrsetbits_le32 (clkctrl_reg,CD_CLKCTRL_CLKTRCTRL_MASK , enable_mode <<CD_CLKCTRL_CLKTRCTRL_SHIFT ); -debug ("Enable clock domain - %p\n" , clkctrl_reg); +debug ("Enable clock domain - %x\n" , clkctrl_reg); } -static inline void wait_for_clk_enable (u32 *clkctrl_addr) +static inline void wait_for_clk_enable (u32 clkctrl_addr) {u32 clkctrl, idlest =MODULE_CLKCTRL_IDLEST_DISABLED ;u32 bound =LDELAY ;
@@ -436,19 +436,19 @@ static inline void wait_for_clk_enable(u32 *clkctrl_addr) idlest = (clkctrl &MODULE_CLKCTRL_IDLEST_MASK ) >>MODULE_CLKCTRL_IDLEST_SHIFT ;if (--bound ==0 ) { -printf ("Clock enable failed for 0x%p idlest 0x%x\n" , +printf ("Clock enable failed for 0x%x idlest 0x%x\n" , clkctrl_addr, clkctrl);return ; } } } -static inline void enable_clock_module (u32 *const clkctrl_addr,u32 enable_mode, +static inline void enable_clock_module (u32 const clkctrl_addr,u32 enable_mode,u32 wait_for_enable) {clrsetbits_le32 (clkctrl_addr,MODULE_CLKCTRL_MODULEMODE_MASK , enable_mode <<MODULE_CLKCTRL_MODULEMODE_SHIFT ); -debug ("Enable clock module - %p\n" , clkctrl_addr); +debug ("Enable clock module - %x\n" , clkctrl_addr);if (wait_for_enable)wait_for_clk_enable (clkctrl_addr); }
@@ -461,10 +461,10 @@ void freq_update_core(void) core_dpll_params =get_core_dpll_params ();/* Put EMIF clock domain in sw wakeup mode */ -enable_clock_domain (&prcm->cm_memif_clkstctrl, +enable_clock_domain ((*prcm)->cm_memif_clkstctrl,CD_CLKCTRL_CLKTRCTRL_SW_WKUP ); -wait_for_clk_enable (&prcm->cm_memif_emif_1_clkctrl); -wait_for_clk_enable (&prcm->cm_memif_emif_2_clkctrl); +wait_for_clk_enable ((*prcm)->cm_memif_emif_1_clkctrl); +wait_for_clk_enable ((*prcm)->cm_memif_emif_2_clkctrl); freq_config1 =SHADOW_FREQ_CONFIG1_FREQ_UPDATE_MASK |SHADOW_FREQ_CONFIG1_DLL_RESET_MASK ;
@@ -476,9 +476,9 @@ void freq_update_core(void) SHADOW_FREQ_CONFIG1_M2_DIV_SHIFT) &SHADOW_FREQ_CONFIG1_M2_DIV_MASK ; -writel (freq_config1, &prcm->cm_shadow_freq_config1); +writel (freq_config1, (*prcm)->cm_shadow_freq_config1);if (!wait_on_value (SHADOW_FREQ_CONFIG1_FREQ_UPDATE_MASK ,0 , - &prcm->cm_shadow_freq_config1,LDELAY )) { + (u32 *) (*prcm)->cm_shadow_freq_config1,LDELAY )) {puts ("FREQ UPDATE procedure failed!!" );hang (); }
@@ -490,20 +490,20 @@ void freq_update_core(void)*/ if (omap_rev !=OMAP5430_ES1_0 ) {/* Put EMIF clock domain back in hw auto mode */ -enable_clock_domain (&prcm->cm_memif_clkstctrl, +enable_clock_domain ((*prcm)->cm_memif_clkstctrl,CD_CLKCTRL_CLKTRCTRL_HW_AUTO ); -wait_for_clk_enable (&prcm->cm_memif_emif_1_clkctrl); -wait_for_clk_enable (&prcm->cm_memif_emif_2_clkctrl); +wait_for_clk_enable ((*prcm)->cm_memif_emif_1_clkctrl); +wait_for_clk_enable ((*prcm)->cm_memif_emif_2_clkctrl); } } -void bypass_dpll (u32 *const base) +void bypass_dpll (u32 const base) {do_bypass_dpll (base);wait_for_bypass (base); } -void lock_dpll (u32 *const base) +void lock_dpll (u32 const base) {do_lock_dpll (base);wait_for_lock (base);
@@ -512,39 +512,39 @@ void lock_dpll(u32 *const base)void setup_clocks_for_console (void ) {/* Do not add any spl_debug prints in this function */ -clrsetbits_le32 (&prcm->cm_l4per_clkstctrl,CD_CLKCTRL_CLKTRCTRL_MASK , +clrsetbits_le32 ((*prcm)->cm_l4per_clkstctrl,CD_CLKCTRL_CLKTRCTRL_MASK ,CD_CLKCTRL_CLKTRCTRL_SW_WKUP <<CD_CLKCTRL_CLKTRCTRL_SHIFT );/* Enable all UARTs - console will be on one of them */ -clrsetbits_le32 (&prcm->cm_l4per_uart1_clkctrl, +clrsetbits_le32 ((*prcm)->cm_l4per_uart1_clkctrl,MODULE_CLKCTRL_MODULEMODE_MASK ,MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<MODULE_CLKCTRL_MODULEMODE_SHIFT ); -clrsetbits_le32 (&prcm->cm_l4per_uart2_clkctrl, +clrsetbits_le32 ((*prcm)->cm_l4per_uart2_clkctrl,MODULE_CLKCTRL_MODULEMODE_MASK ,MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<MODULE_CLKCTRL_MODULEMODE_SHIFT ); -clrsetbits_le32 (&prcm->cm_l4per_uart3_clkctrl, +clrsetbits_le32 ((*prcm)->cm_l4per_uart3_clkctrl,MODULE_CLKCTRL_MODULEMODE_MASK ,MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<MODULE_CLKCTRL_MODULEMODE_SHIFT ); -clrsetbits_le32 (&prcm->cm_l4per_uart3_clkctrl, +clrsetbits_le32 ((*prcm)->cm_l4per_uart3_clkctrl,MODULE_CLKCTRL_MODULEMODE_MASK ,MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<MODULE_CLKCTRL_MODULEMODE_SHIFT ); -clrsetbits_le32 (&prcm->cm_l4per_clkstctrl,CD_CLKCTRL_CLKTRCTRL_MASK , +clrsetbits_le32 ((*prcm)->cm_l4per_clkstctrl,CD_CLKCTRL_CLKTRCTRL_MASK ,CD_CLKCTRL_CLKTRCTRL_HW_AUTO <<CD_CLKCTRL_CLKTRCTRL_SHIFT ); } -void do_enable_clocks (u32 *const *clk_domains, -u32 *const *clk_modules_hw_auto, -u32 *const *clk_modules_explicit_en, +void do_enable_clocks (u32 const *clk_domains, +u32 const *clk_modules_hw_auto, +u32 const *clk_modules_explicit_en,u8 wait_for_enable) {u32 i, max =100 ;
arch/arm/cpu/armv7/omap-common/emif-common.c +2 -2
@@ -1289,9 +1289,9 @@ void sdram_init(void)if (!(in_sdram ||warm_reset ())) {if (sdram_type ==EMIF_SDRAM_TYPE_LPDDR2 ) -bypass_dpll (&prcm->cm_clkmode_dpll_core); +bypass_dpll ((*prcm)->cm_clkmode_dpll_core);else -writel (CM_DLL_CTRL_NO_OVERRIDE , &prcm->cm_dll_ctrl); +writel (CM_DLL_CTRL_NO_OVERRIDE , (*prcm)->cm_dll_ctrl); }if (!in_sdram)
arch/arm/cpu/armv7/omap-common/hwinit-common.c +3 -0
@@ -34,6 +34,7 @@#include <asm/emif.h> #include <asm/cache.h> #include <asm/system.h> +#include <asm/omap_common.h> #define ARMV7_DCACHE_WRITEBACK 0xe#define ARMV7_DOMAIN_CLIENT 1
@@ -122,6 +123,8 @@ void spl_display_print(void)void s_init (void ) {init_omap_revision (); +hw_data_init (); +#ifdef CONFIG_SPL_BUILD if (warm_reset () && (omap_revision () <=OMAP5430_ES1_0 ))force_emif_self_refresh ();
arch/arm/cpu/armv7/omap-common/vc.c +6 -5
@@ -81,13 +81,13 @@ void omap_vc_init(u16 speed_khz) cycles_low -=7 ; val = (cycles_hi <<PRM_VC_CFG_I2C_CLK_SCLH_SHIFT ) | (cycles_low <<PRM_VC_CFG_I2C_CLK_SCLL_SHIFT ); -writel (val, &prcm->prm_vc_cfg_i2c_clk); +writel (val, (*prcm)->prm_vc_cfg_i2c_clk); val =CONFIG_OMAP_VC_I2C_HS_MCODE <<PRM_VC_CFG_I2C_MODE_HSMCODE_SHIFT ;/* No HS mode for now */ val &= ~PRM_VC_CFG_I2C_MODE_HSMODEEN_BIT ; -writel (val, &prcm->prm_vc_cfg_i2c_mode); +writel (val, (*prcm)->prm_vc_cfg_i2c_mode); }/**
@@ -113,14 +113,15 @@ int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data) reg_val = sa <<PRM_VC_VAL_BYPASS_SLAVEADDR_SHIFT | reg_addr <<PRM_VC_VAL_BYPASS_REGADDR_SHIFT | reg_data <<PRM_VC_VAL_BYPASS_DATA_SHIFT ; -writel (reg_val, &prcm->prm_vc_val_bypass); +writel (reg_val, (*prcm)->prm_vc_val_bypass);/* Signal VC to send data */ -writel (reg_val |PRM_VC_VAL_BYPASS_VALID_BIT , &prcm->prm_vc_val_bypass); +writel (reg_val |PRM_VC_VAL_BYPASS_VALID_BIT , + (*prcm)->prm_vc_val_bypass);/* Wait on VC to complete transmission */ do { - reg_val = readl(&prcm->prm_vc_val_bypass) & + reg_val = readl((*prcm)->prm_vc_val_bypass) & PRM_VC_VAL_BYPASS_VALID_BIT; if (!reg_val) break;
arch/arm/cpu/armv7/omap4/Makefile +2 -0
@@ -29,6 +29,8 @@ COBJS += sdram_elpida.o COBJS += hwinit.o COBJS += clocks.o COBJS += emif.o +COBJS += prcm-regs.o +COBJS += hw_data.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS) $(SOBJS))
arch/arm/cpu/armv7/omap4/clocks.c +99 -100
273 lines not on this page · raw message
arch/arm/cpu/armv7/omap4/hw_data.c new file +38 -0
@@ -0,0 +1,38 @@ +/* +* +* HW data initialization for OMAP4 +* +* (C) Copyright 2013 +* Texas Instruments, <www.ti.com> +* +* Sricharan R <[email protected]> +* +* See file CREDITS for list of people who contributed to this +* project. +* +* 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; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ +#include <common.h> +#include <asm/arch/omap.h> +#include <asm/omap_common.h> + +struct prcm_regs const **prcm = + (struct prcm_regs const **)OMAP_SRAM_SCRATCH_PRCM_PTR ; + +void hw_data_init (void ) +{ + *prcm = &omap4_prcm; +}
arch/arm/cpu/armv7/omap4/prcm-regs.c new file +295 -0
295 lines not on this page · raw message
arch/arm/cpu/armv7/omap5/Makefile +2 -0
@@ -29,6 +29,8 @@ COBJS += hwinit.o COBJS += clocks.o COBJS += emif.o COBJS += sdram.o +COBJS += prcm-regs.o +COBJS += hw_data.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS) $(SOBJS))
arch/arm/cpu/armv7/omap5/clocks.c +107 -108
306 lines not on this page · raw message
arch/arm/cpu/armv7/omap5/hw_data.c new file +38 -0
@@ -0,0 +1,38 @@ +/* +* +* HW data initialization for OMAP5 +* +* (C) Copyright 2013 +* Texas Instruments, <www.ti.com> +* +* Sricharan R <[email protected]> +* +* See file CREDITS for list of people who contributed to this +* project. +* +* 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; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ +#include <common.h> +#include <asm/arch/omap.h> +#include <asm/omap_common.h> + +struct prcm_regs const **prcm = + (struct prcm_regs const **)OMAP_SRAM_SCRATCH_PRCM_PTR ; + +void hw_data_init (void ) +{ + *prcm = &omap5_es1_prcm; +}
arch/arm/cpu/armv7/omap5/prcm-regs.c new file +306 -0
306 lines not on this page · raw message
arch/arm/include/asm/arch-omap4/clocks.h +46 -478
556 lines not on this page · raw message
arch/arm/include/asm/arch-omap4/omap.h +2 -1
@@ -178,7 +178,8 @@ struct control_lpddr2io_regs {#define OMAP4_SRAM_SCRATCH_EMIF_SIZE (SRAM_SCRATCH_SPACE_ADDR + 0x4)#define OMAP4_SRAM_SCRATCH_EMIF_T_NUM (SRAM_SCRATCH_SPACE_ADDR + 0xC)#define OMAP4_SRAM_SCRATCH_EMIF_T_DEN (SRAM_SCRATCH_SPACE_ADDR + 0x10) -#define OMAP4_SRAM_SCRATCH_SPACE_END (SRAM_SCRATCH_SPACE_ADDR + 0x14) +#define OMAP_SRAM_SCRATCH_PRCM_PTR (SRAM_SCRATCH_SPACE_ADDR + 0x14) +#define OMAP4_SRAM_SCRATCH_SPACE_END (SRAM_SCRATCH_SPACE_ADDR + 0x18)/* ROM code defines */ /* Boot device */
arch/arm/include/asm/arch-omap4/sys_proto.h +1 -1
@@ -44,7 +44,7 @@ void sdelay(unsigned long);void set_pl310_ctrl_reg (u32 val);void setup_clocks_for_console (void );void prcm_init (void ); -void bypass_dpll (u32 *const base); +void bypass_dpll (u32 const base);void freq_update_core (void );u32 get_sys_clk_freq (void );u32 omap4_ddr_clk (void );
arch/arm/include/asm/arch-omap5/clocks.h +5 -455
488 lines not on this page · raw message
arch/arm/include/asm/arch-omap5/omap.h +2 -1
@@ -271,7 +271,8 @@ struct omap_sys_ctrl_regs {#define OMAP5_SRAM_SCRATCH_EMIF_SIZE (SRAM_SCRATCH_SPACE_ADDR + 0x4)#define OMAP5_SRAM_SCRATCH_EMIF_T_NUM (SRAM_SCRATCH_SPACE_ADDR + 0xC)#define OMAP5_SRAM_SCRATCH_EMIF_T_DEN (SRAM_SCRATCH_SPACE_ADDR + 0x10) -#define OMAP5_SRAM_SCRATCH_SPACE_END (SRAM_SCRATCH_SPACE_ADDR + 0x14) +#define OMAP_SRAM_SCRATCH_PRCM_PTR (SRAM_SCRATCH_SPACE_ADDR + 0x14) +#define OMAP5_SRAM_SCRATCH_SPACE_END (SRAM_SCRATCH_SPACE_ADDR + 0x18)/* Silicon revisions */ #define OMAP4430_SILICON_ID_INVALID 0xFFFFFFFF
arch/arm/include/asm/arch-omap5/sys_proto.h +1 -1
@@ -44,7 +44,7 @@ u32 wait_on_value(u32, u32, void *, u32);void sdelay (unsigned long );void setup_clocks_for_console (void );void prcm_init (void ); -void bypass_dpll (u32 *const base); +void bypass_dpll (u32 const base);void freq_update_core (void );u32 get_sys_clk_freq (void );u32 omap5_ddr_clk (void );
arch/arm/include/asm/omap_common.h +304 -0
280 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.9.5
Part of the diff is not shown here. View the raw message.
PATCH v2 2/7 ARM: OMAP4+: Change the PRCM structure prototype common for all Socs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 9 lines · R Sricharan
The current PRCM structure prototype directly matches the hardware register layout. So there is a need to change this for every new silicon revision which has register space changes.
Avoiding this by making the prototye generic and populating the register addresses seperately for all Socs.
Signed-off-by R Sricharan <[email protected]> Signed-off-by:Lokesh Vutla <[email protected]>
- --
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQIcBAEBAgAGBQJRD9QLAAoJENk4IS6UOR1WQvMP/3tDaBRmniOa/mdC2Z/fB5hp wyX31xZdoSofZZsGduXcPRCZ77+8iDGgpOwPM9ejwrM+vu1f/FxdGNsFq2uNvODV 1584SOh15YKQrd01L2DJJwvWcKptRQaEavjgpwzUOv86J97lfoRxZeu2mgJ8Uc9t ZWISVmgK2UHBLGd5H2Ij3eBKQHPCsJU08sIsDpAbNPa/3PzzHoEQaTt0lW2cV6DC CNwBGWuk8TYpp31qPxNsjYGQZDj0yH4N70VZdQjc038plS5jvKLQCYMx2/9HvXjj Pg/4nxVlWhddjuyqsduMetf94TCoQYLUZT0JFghtir9mE6xEZ0eq+REcTE6sB5rA qAg7DN2iq4lR1kufQcD6fx/ntSIMuWS/qHxOZhoL9vqhWmyzkZ41MJ417DhzGXxs dmWN5IMW63WwGS7lQUHOI6LdtXx4ZP/kkfR4HY8uWhaJ25CmUxmob2GcMSn+MVI+ ic2g7TztlcsdJj+g6frqAy5AKsSWsyY2KCQkB3SmS5BqVuBuhdsuGRMqk9d+UHFC tw6Hua6EHqZXc36EFIZ96hFmmjg5fcaEwdKlMWUa3/DAORdtqFM7f0cbmxd71AMc AFU8cgMZoYYU7Ep4H5pXoZ5x7EytZ6ll0MzvyYUrAQmm+ZMAC4zCJAne5pyWNToM lAjlCf5DcWN1/pEXL7Ky
=QhC5
-----END PGP SIGNATURE-----
PATCH v2 3/7 ARM: OMAP4+: Cleanup the clocks layer
In reply to R SricharanCurrently there is quite a lot of code which is duplicated in the clocks code for OMAP 4 and 5 Socs. Avoiding this here by moving the clocks data to a SOC specific place and the sharing the common code.
This helps in addition of a new Soc with minimal changes.
---
[V2] Addressed Tom Rini's <[email protected]> comments
arch/arm/cpu/armv7/omap-common/clocks-common.c | 89 +++++- arch/arm/cpu/armv7/omap4/clocks.c | 393 ----------------------- arch/arm/cpu/armv7/omap4/hw_data.c | 367 +++++++++++++++++++++- arch/arm/cpu/armv7/omap5/clocks.c | 396 ------------------------ arch/arm/cpu/armv7/omap5/hw_data.c | 355 +++++++++++++++++++++ arch/arm/include/asm/arch-omap4/clocks.h | 45 --- arch/arm/include/asm/arch-omap4/omap.h | 3 +- arch/arm/include/asm/arch-omap5/clocks.h | 50 --- arch/arm/include/asm/arch-omap5/omap.h | 3 +- arch/arm/include/asm/omap_common.h | 63 ++++ 10 files changed, 869 insertions(+), 895 deletions(-)
arch/arm/cpu/armv7/omap-common/clocks-common.c +81 -8
@@ -47,6 +47,16 @@#define puts (s)#endif +const u32 sys_clk_array[8 ] = { +12000000 ,/* 12 MHz */ +13000000 ,/* 13 MHz */ +16800000 ,/* 16.8 MHz */ +19200000 ,/* 19.2 MHz */ +26000000 ,/* 26 MHz */ +27000000 ,/* 27 MHz */ +38400000 ,/* 38.4 MHz */ +}; +static inline u32 __get_sys_clk_index (void ) {u32 ind;
@@ -76,6 +86,29 @@ u32 get_sys_clk_freq(void)return sys_clk_array[index]; } +void setup_post_dividers (u32 const base,const struct dpll_params *params) +{ +struct dpll_regs *const dpll_regs = (struct dpll_regs *)base; + +/* Setup post-dividers */ +if (params->m2 >=0 ) +writel (params->m2, &dpll_regs->cm_div_m2_dpll); +if (params->m3 >=0 ) +writel (params->m3, &dpll_regs->cm_div_m3_dpll); +if (params->m4_h11 >=0 ) +writel (params->m4_h11, &dpll_regs->cm_div_m4_h11_dpll); +if (params->m5_h12 >=0 ) +writel (params->m5_h12, &dpll_regs->cm_div_m5_h12_dpll); +if (params->m6_h13 >=0 ) +writel (params->m6_h13, &dpll_regs->cm_div_m6_h13_dpll); +if (params->m7_h14 >=0 ) +writel (params->m7_h14, &dpll_regs->cm_div_m7_h14_dpll); +if (params->h22 >=0 ) +writel (params->h22, &dpll_regs->cm_div_h22_dpll); +if (params->h23 >=0 ) +writel (params->h23, &dpll_regs->cm_div_h23_dpll); +} +static inline void do_bypass_dpll (u32 const base) {struct dpll_regs *dpll_regs = (struct dpll_regs *)base;
@@ -124,6 +157,46 @@ inline u32 check_for_lock(u32 const base)return lock; } +const struct dpll_params *get_mpu_dpll_params (struct dplls const *dpll_data) +{ +u32 sysclk_ind =get_sys_clk_index (); +return &dpll_data->mpu[sysclk_ind]; +} + +const struct dpll_params *get_core_dpll_params (struct dplls const *dpll_data) +{ +u32 sysclk_ind =get_sys_clk_index (); +return &dpll_data->core[sysclk_ind]; +} + +const struct dpll_params *get_per_dpll_params (struct dplls const *dpll_data) +{ +u32 sysclk_ind =get_sys_clk_index (); +return &dpll_data->per[sysclk_ind]; +} + +const struct dpll_params *get_iva_dpll_params (struct dplls const *dpll_data) +{ +u32 sysclk_ind =get_sys_clk_index (); +return &dpll_data->iva[sysclk_ind]; +} + +const struct dpll_params *get_usb_dpll_params (struct dplls const *dpll_data) +{ +u32 sysclk_ind =get_sys_clk_index (); +return &dpll_data->usb[sysclk_ind]; +} + +const struct dpll_params *get_abe_dpll_params (struct dplls const *dpll_data) +{ +#ifdef CONFIG_SYS_OMAP_ABE_SYSCK +u32 sysclk_ind =get_sys_clk_index (); +return &dpll_data->abe[sysclk_ind]; +#else +return dpll_data->abe; +#endif +} +static void do_setup_dpll (u32 const base,const struct dpll_params *params,u8 lock,char *dpll) {
@@ -184,7 +257,7 @@ u32 omap_ddr_clk(void) omap_rev =omap_revision (); sys_clk_khz =get_sys_clk_freq () /1000 ; - core_dpll_params =get_core_dpll_params (); + core_dpll_params =get_core_dpll_params (*dplls_data);debug ("sys_clk %d\n " , sys_clk_khz *1000 );
@@ -251,7 +324,7 @@ void configure_mpu_dpll(void)setbits_le32 ((*prcm)->cm_mpu_mpu_clkctrl,MPU_CLKCTRL_CLKSEL_ABE_DIV_MODE_MASK ); - params =get_mpu_dpll_params (); + params =get_mpu_dpll_params (*dplls_data);do_setup_dpll ((*prcm)->cm_clkmode_dpll_mpu, params,DPLL_LOCK ,"mpu" );debug ("MPU DPLL locked\n" );
@@ -272,7 +345,7 @@ static void setup_usb_dpll(void)* Use CLKINP in KHz and adjust the denominator accordingly so * that we have enough accuracy and at the same time no overflow */ - params =get_usb_dpll_params (); + params =get_usb_dpll_params (*dplls_data); num = params->m * sys_clk_khz; den = (params->n +1 ) *250 *1000 ; num += den -1 ;
@@ -294,7 +367,7 @@ static void setup_dplls(void)debug ("setup_dplls\n" );/* CORE dpll */ - params =get_core_dpll_params ();/* default - safest */ + params =get_core_dpll_params (*dplls_data);/* default - safest */ /* * Do not lock the core DPLL now. Just set it up. * Core DPLL will be locked after setting up EMIF
@@ -314,7 +387,7 @@ static void setup_dplls(void)debug ("Core DPLL configured\n" );/* lock PER dpll */ - params =get_per_dpll_params (); + params =get_per_dpll_params (*dplls_data);do_setup_dpll ((*prcm)->cm_clkmode_dpll_per, params,DPLL_LOCK ,"per" );debug ("PER DPLL locked\n" );
@@ -337,11 +410,11 @@ static void setup_non_essential_dplls(void)clrsetbits_le32 ((*prcm)->cm_bypclk_dpll_iva,CM_BYPCLK_DPLL_IVA_CLKSEL_MASK ,DPLL_IVA_CLKSEL_CORE_X2_DIV_2 ); - params =get_iva_dpll_params (); + params =get_iva_dpll_params (*dplls_data);do_setup_dpll ((*prcm)->cm_clkmode_dpll_iva, params,DPLL_LOCK ,"iva" );/* Configure ABE dpll */ - params =get_abe_dpll_params (); + params =get_abe_dpll_params (*dplls_data);#ifdef CONFIG_SYS_OMAP_ABE_SYSCK abe_ref_clk =CM_ABE_PLL_REF_CLKSEL_CLKSEL_SYSCLK ;#else
@@ -459,7 +532,7 @@ void freq_update_core(void)const struct dpll_params *core_dpll_params;u32 omap_rev =omap_revision (); - core_dpll_params =get_core_dpll_params (); + core_dpll_params =get_core_dpll_params (*dplls_data);/* Put EMIF clock domain in sw wakeup mode */ enable_clock_domain ((*prcm)->cm_memif_clkstctrl,CD_CLKCTRL_CLKTRCTRL_SW_WKUP );
arch/arm/cpu/armv7/omap4/clocks.c +0 -393
402 lines not on this page · raw message
arch/arm/cpu/armv7/omap4/hw_data.c +366 -1
378 lines not on this page · raw message
arch/arm/cpu/armv7/omap5/clocks.c +0 -396
405 lines not on this page · raw message
arch/arm/cpu/armv7/omap5/hw_data.c +355 -0
367 lines not on this page · raw message
arch/arm/include/asm/arch-omap4/clocks.h +0 -45
55 lines not on this page · raw message
arch/arm/include/asm/arch-omap4/omap.h +2 -1
@@ -179,7 +179,8 @@ struct control_lpddr2io_regs {#define OMAP4_SRAM_SCRATCH_EMIF_T_NUM (SRAM_SCRATCH_SPACE_ADDR + 0xC)#define OMAP4_SRAM_SCRATCH_EMIF_T_DEN (SRAM_SCRATCH_SPACE_ADDR + 0x10)#define OMAP_SRAM_SCRATCH_PRCM_PTR (SRAM_SCRATCH_SPACE_ADDR + 0x14) -#define OMAP4_SRAM_SCRATCH_SPACE_END (SRAM_SCRATCH_SPACE_ADDR + 0x18) +#define OMAP_SRAM_SCRATCH_DPLLS_PTR (SRAM_SCRATCH_SPACE_ADDR + 0x18) +#define OMAP4_SRAM_SCRATCH_SPACE_END (SRAM_SCRATCH_SPACE_ADDR + 0x1C)/* ROM code defines */ /* Boot device */
arch/arm/include/asm/arch-omap5/clocks.h +0 -50
58 lines not on this page · raw message
arch/arm/include/asm/arch-omap5/omap.h +2 -1
@@ -272,7 +272,8 @@ struct omap_sys_ctrl_regs {#define OMAP5_SRAM_SCRATCH_EMIF_T_NUM (SRAM_SCRATCH_SPACE_ADDR + 0xC)#define OMAP5_SRAM_SCRATCH_EMIF_T_DEN (SRAM_SCRATCH_SPACE_ADDR + 0x10)#define OMAP_SRAM_SCRATCH_PRCM_PTR (SRAM_SCRATCH_SPACE_ADDR + 0x14) -#define OMAP5_SRAM_SCRATCH_SPACE_END (SRAM_SCRATCH_SPACE_ADDR + 0x18) +#define OMAP_SRAM_SCRATCH_DPLLS_PTR (SRAM_SCRATCH_SPACE_ADDR + 0x18) +#define OMAP5_SRAM_SCRATCH_SPACE_END (SRAM_SCRATCH_SPACE_ADDR + 0x1C)/* Silicon revisions */ #define OMAP4430_SILICON_ID_INVALID 0xFFFFFFFF
arch/arm/include/asm/omap_common.h +63 -0
80 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v2 3/7 ARM: OMAP4+: Cleanup the clocks layer
Quoted 11 lines · R Sricharan
Currently there is quite a lot of code which is duplicated in the clocks code for OMAP 4 and 5 Socs. Avoiding this here by moving the clocks data to a SOC specific place and the sharing the common code.
This helps in addition of a new Soc with minimal changes.
Signed-off-by R Sricharan <[email protected]>Signed-off-by Lokesh Vutla <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130204/69402d2d/attachment.pgp>
PATCH v2 4/7 ARM: OMAP4+: Clean up the pmic code
In reply to R SricharanThe pmic code is duplicated for OMAP 4 and 5.
Instead move the data to Soc specific place and
share the code.
---
[V2] Addressed Tom Rini's <[email protected]> comments
arch/arm/cpu/armv7/omap-common/clocks-common.c | 83 +++++++++++----- arch/arm/cpu/armv7/omap4/Makefile | 1 - arch/arm/cpu/armv7/omap4/clocks.c | 123 ------------------------ arch/arm/cpu/armv7/omap4/hw_data.c | 70 ++++++++++++++ arch/arm/cpu/armv7/omap5/Makefile | 1 - arch/arm/cpu/armv7/omap5/clocks.c | 98 ------------------- arch/arm/cpu/armv7/omap5/hw_data.c | 43 +++++++++ arch/arm/include/asm/arch-omap4/clocks.h | 5 - arch/arm/include/asm/arch-omap4/omap.h | 3 +- arch/arm/include/asm/arch-omap5/clocks.h | 4 - arch/arm/include/asm/arch-omap5/omap.h | 3 +- arch/arm/include/asm/omap_common.h | 24 +++++ include/configs/omap5_evm.h | 1 + 13 files changed, 199 insertions(+), 260 deletions(-) delete mode 100644 arch/arm/cpu/armv7/omap4/clocks.c delete mode 100644 arch/arm/cpu/armv7/omap5/clocks.c
arch/arm/cpu/armv7/omap-common/clocks-common.c +57 -26
@@ -443,44 +443,45 @@ static void setup_non_essential_dplls(void) }#endif -void do_scale_tps62361 (int gpio,u32 reg,u32 volt_mv) +u32 get_offset_code (u32 volt_offset,struct pmic_data *pmic) { -u32 step; -int ret =0 ; - -/* See if we can first get the GPIO if needed */ -if (gpio >=0 ) - ret =gpio_request (gpio,"TPS62361_VSEL0_GPIO" ); -if (ret <0 ) { -printf ("%s: gpio %d request failed %d\n" , __func__, gpio, ret); - gpio =-1 ; - } - -/* Pull the GPIO low to select SET0 register, while we program SET1 */ -if (gpio >=0 ) -gpio_direction_output (gpio,0 ); +u32 offset_code; - step = volt_mv -TPS62361_BASE_VOLT_MV ; - step /=10 ; + volt_offset -= pmic->base_offset; -debug ("do_scale_tps62361: volt - %d step - 0x%x\n" , volt_mv, step); -if (omap_vc_bypass_send_value (TPS62361_I2C_SLAVE_ADDR , reg, step)) -puts ("Scaling voltage failed for vdd_mpu from TPS\n" ); + offset_code = (volt_offset + pmic->step -1 ) / pmic->step; -/* Pull the GPIO high to select SET1 register */ -if (gpio >=0 ) -gpio_direction_output (gpio,1 ); +/* +* Offset codes 1-6 all give the base voltage in Palmas +* Offset code 0 switches OFF the SMPS +*/ +return offset_code + pmic->start_code; } -void do_scale_vcore (u32 vcore_reg,u32 volt_mv) +void do_scale_vcore (u32 vcore_reg,u32 volt_mv,struct pmic_data *pmic) {u32 offset_code;u32 offset = volt_mv; +int ret =0 ; + +/* See if we can first get the GPIO if needed */ +if (pmic->gpio_en) + ret =gpio_request (pmic->gpio,"PMIC_GPIO" ); + +if (ret <0 ) { +printf ("%s: gpio %d request failed %d\n" , __func__, + pmic->gpio, ret); +return ; + } + +/* Pull the GPIO low to select SET0 register, while we program SET1 */ +if (pmic->gpio_en) +gpio_direction_output (pmic->gpio,0 );/* convert to uV for better accuracy in the calculations */ offset *=1000 ; - offset_code =get_offset_code (offset); + offset_code =get_offset_code (offset, pmic);debug ("do_scale_vcore: volt - %d offset_code - 0x%x\n" , volt_mv, offset_code);
@@ -488,6 +489,36 @@ void do_scale_vcore(u32 vcore_reg, u32 volt_mv)if (omap_vc_bypass_send_value (SMPS_I2C_SLAVE_ADDR , vcore_reg, offset_code))printf ("Scaling voltage failed for 0x%x\n" , vcore_reg); + +if (pmic->gpio_en) +gpio_direction_output (pmic->gpio,1 ); +} + +/* +* Setup the voltages for vdd_mpu, vdd_core, and vdd_iva +* We set the maximum voltages allowed here because Smart-Reflex is not +* enabled in bootloader. Voltage initialization in the kernel will set +* these to the nominal values after enabling Smart-Reflex +*/ +void scale_vcores (struct vcores_data const *vcores) +{ +omap_vc_init (PRM_VC_I2C_CHANNEL_FREQ_KHZ ); + +do_scale_vcore (vcores->core.addr, vcores->core.value, + vcores->core.pmic); + +do_scale_vcore (vcores->mpu.addr, vcores->mpu.value, + vcores->mpu.pmic); + +do_scale_vcore (vcores->mm.addr, vcores->mm.value, + vcores->mm.pmic); + +if (emif_sdram_type () ==EMIF_SDRAM_TYPE_DDR3 ) { +/* Configure LDO SRAM "magic" bits */ +writel (2 , (*prcm)->prm_sldo_core_setup); +writel (2 , (*prcm)->prm_sldo_mpu_setup); +writel (2 , (*prcm)->prm_sldo_mm_setup); + } }static inline void enable_clock_domain (u32 const clkctrl_reg,u32 enable_mode)
@@ -656,7 +687,7 @@ void prcm_init(void)case OMAP_INIT_CONTEXT_UBOOT_FROM_NOR :case OMAP_INIT_CONTEXT_UBOOT_AFTER_CH :enable_basic_clocks (); -scale_vcores (); +scale_vcores (*omap_vcores);setup_dplls ();#ifdef CONFIG_SYS_CLOCKS_ENABLE_ALL setup_non_essential_dplls ();
arch/arm/cpu/armv7/omap4/Makefile +0 -1
@@ -27,7 +27,6 @@ LIB = $(obj)lib$(SOC).o COBJS += sdram_elpida.o COBJS += hwinit.o -COBJS += clocks.o COBJS += emif.o COBJS += prcm-regs.o COBJS += hw_data.o
arch/arm/cpu/armv7/omap4/clocks.c deleted +0 -123
123 lines not on this page · raw message
arch/arm/cpu/armv7/omap4/hw_data.c +70 -0
105 lines not on this page · raw message
arch/arm/cpu/armv7/omap5/Makefile +0 -1
@@ -26,7 +26,6 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(SOC).o COBJS += hwinit.o -COBJS += clocks.o COBJS += emif.o COBJS += sdram.o COBJS += prcm-regs.o
arch/arm/cpu/armv7/omap5/clocks.c deleted +0 -98
98 lines not on this page · raw message
arch/arm/cpu/armv7/omap5/hw_data.c +43 -0
72 lines not on this page · raw message
arch/arm/include/asm/arch-omap4/clocks.h +0 -5
@@ -242,11 +242,6 @@#define DPLL_NO_LOCK 0#define DPLL_LOCK 1 -void scale_vcores (void ); -void do_scale_tps62361 (int gpio,u32 reg,u32 volt_mv); -u32 get_offset_code (u32 offset); -void do_scale_vcore (u32 vcore_reg,u32 volt_mv); -struct omap4_scrm_regs {u32 revision;/* 0x0000 */ u32 pad00[63 ];
arch/arm/include/asm/arch-omap4/omap.h +2 -1
@@ -180,7 +180,8 @@ struct control_lpddr2io_regs {#define OMAP4_SRAM_SCRATCH_EMIF_T_DEN (SRAM_SCRATCH_SPACE_ADDR + 0x10)#define OMAP_SRAM_SCRATCH_PRCM_PTR (SRAM_SCRATCH_SPACE_ADDR + 0x14)#define OMAP_SRAM_SCRATCH_DPLLS_PTR (SRAM_SCRATCH_SPACE_ADDR + 0x18) -#define OMAP4_SRAM_SCRATCH_SPACE_END (SRAM_SCRATCH_SPACE_ADDR + 0x1C) +#define OMAP_SRAM_SCRATCH_VCORES_PTR (SRAM_SCRATCH_SPACE_ADDR + 0x1C) +#define OMAP4_SRAM_SCRATCH_SPACE_END (SRAM_SCRATCH_SPACE_ADDR + 0x20)/* ROM code defines */ /* Boot device */
arch/arm/include/asm/arch-omap5/clocks.h +0 -4
@@ -234,8 +234,4 @@#define DPLL_NO_LOCK 0#define DPLL_LOCK 1 -void scale_vcores (void ); -void do_scale_tps62361 (int gpio,u32 reg,u32 volt_mv); -u32 get_offset_code (u32 offset); -void do_scale_vcore (u32 vcore_reg,u32 volt_mv);#endif /* _CLOCKS_OMAP5_H_ */
arch/arm/include/asm/arch-omap5/omap.h +2 -1
@@ -273,7 +273,8 @@ struct omap_sys_ctrl_regs {#define OMAP5_SRAM_SCRATCH_EMIF_T_DEN (SRAM_SCRATCH_SPACE_ADDR + 0x10)#define OMAP_SRAM_SCRATCH_PRCM_PTR (SRAM_SCRATCH_SPACE_ADDR + 0x14)#define OMAP_SRAM_SCRATCH_DPLLS_PTR (SRAM_SCRATCH_SPACE_ADDR + 0x18) -#define OMAP5_SRAM_SCRATCH_SPACE_END (SRAM_SCRATCH_SPACE_ADDR + 0x1C) +#define OMAP_SRAM_SCRATCH_VCORES_PTR (SRAM_SCRATCH_SPACE_ADDR + 0x1C) +#define OMAP5_SRAM_SCRATCH_SPACE_END (SRAM_SCRATCH_SPACE_ADDR + 0x20)/* Silicon revisions */ #define OMAP4430_SILICON_ID_INVALID 0xFFFFFFFF
arch/arm/include/asm/omap_common.h +24 -0
@@ -364,10 +364,31 @@ struct dplls {const struct dpll_params *usb; }; +struct pmic_data { +u32 base_offset; +u32 step; +u32 start_code; +unsigned gpio; +int gpio_en; +}; + +struct volts { +u32 value; +u32 addr; +struct pmic_data *pmic; +}; + +struct vcores_data { +struct volts mpu; +struct volts core; +struct volts mm; +}; +extern struct prcm_regs const **prcm;extern struct prcm_regs const omap5_es1_prcm;extern struct prcm_regs const omap4_prcm;extern struct dplls const **dplls_data; +extern struct vcores_data const **omap_vcores;extern const u32 sys_clk_array[8 ];void hw_data_init (void );
@@ -391,6 +412,9 @@ u32 get_sys_clk_index(void);void enable_basic_clocks (void );void enable_basic_uboot_clocks (void );void enable_non_essential_clocks (void ); +void scale_vcores (struct vcores_data const *); +u32 get_offset_code (u32 volt_offset,struct pmic_data *pmic); +void do_scale_vcore (u32 vcore_reg,u32 volt_mv,struct pmic_data *pmic);/* Max value for DPLL multiplier M */ #define OMAP_DPLL_MAX_N 127
include/configs/omap5_evm.h +1 -0
@@ -264,5 +264,6 @@#define CONFIG_SPL_BSS_MAX_SIZE 0x100000/* 1 MB */ #define CONFIG_SYS_SPL_MALLOC_START 0x84100000#define CONFIG_SYS_SPL_MALLOC_SIZE 0x100000/* 1 MB */ +#define CONFIG_SPL_GPIO_SUPPORT #endif /* __CONFIG_H */
Signature · 1 line
1.7.9.5
PATCH v2 4/7 ARM: OMAP4+: Clean up the pmic code
Quoted 6 lines · R Sricharan
The pmic code is duplicated for OMAP 4 and 5.
Instead move the data to Soc specific place and
share the code.Signed-off-by R Sricharan <[email protected]>Signed-off-by Lokesh Vutla <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130204/d9828887/attachment.pgp>
PATCH v2 5/7 ARM: OMAP4+: Cleanup emif specific files
In reply to R SricharanFrom: Lokesh Vutla <[email protected]>
Removing the duplicated code in ddr3 initialization. Also creating structure for lpddr2 mode registers to avoid unnessecary revision checks.
These change reduces code addition for future Socs.
--- arch/arm/cpu/armv7/omap-common/emif-common.c | 46 ++-------- arch/arm/cpu/armv7/omap4/sdram_elpida.c | 16 +++- arch/arm/cpu/armv7/omap5/sdram.c | 119 +++++++++++++++++--------- arch/arm/include/asm/emif.h | 12 ++- 4 files changed, 108 insertions(+), 85 deletions(-)
arch/arm/cpu/armv7/omap-common/emif-common.c +9 -37
@@ -123,11 +123,13 @@ void emif_reset_phy(u32 base)static void do_lpddr2_init (u32 base,u32 cs) {u32 mr_addr; +const struct lpddr2_mr_regs *mr_regs; +get_lpddr2_mr_regs (&mr_regs);/* Wait till device auto initialization is complete */ while (get_mr (base, cs,LPDDR2_MR0 ) &LPDDR2_MR0_DAI_MASK ) ; -set_mr (base, cs,LPDDR2_MR10 ,MR10_ZQ_ZQINIT ); +set_mr (base, cs,LPDDR2_MR10 , mr_regs->mr10);/* * tZQINIT = 1 us * Enough loops assuming a maximum of 2GHz
@@ -135,22 +137,18 @@ static void do_lpddr2_init(u32 base, u32 cs)sdelay (2000 ); -if (omap_revision () >=OMAP5430_ES1_0 ) -set_mr (base, cs,LPDDR2_MR1 ,MR1_BL_8_BT_SEQ_WRAP_EN_NWR_8 ); -else -set_mr (base, cs,LPDDR2_MR1 ,MR1_BL_8_BT_SEQ_WRAP_EN_NWR_3 ); - -set_mr (base, cs,LPDDR2_MR16 ,MR16_REF_FULL_ARRAY ); +set_mr (base, cs,LPDDR2_MR1 , mr_regs->mr1); +set_mr (base, cs,LPDDR2_MR16 , mr_regs->mr16);/* * Enable refresh along with writing MR2 * Encoding of RL in MR2 is (RL - 2) */ mr_addr =LPDDR2_MR2 |EMIF_REG_REFRESH_EN_MASK ; -set_mr (base, cs, mr_addr,RL_FINAL -2 ); +set_mr (base, cs, mr_addr, mr_regs->mr2); -if (omap_revision () >=OMAP5430_ES1_0 ) -set_mr (base, cs,LPDDR2_MR3 ,0x1 ); +if (mr_regs->mr3 >0 ) +set_mr (base, cs,LPDDR2_MR3 , mr_regs->mr3); }static void lpddr2_init (u32 base,const struct emif_regs *regs)
@@ -268,9 +266,6 @@ static void ddr3_leveling(u32 base, const struct emif_regs *regs)static void ddr3_init (u32 base,const struct emif_regs *regs) {struct emif_reg_struct *emif = (struct emif_reg_struct *)base; -u32 *ext_phy_ctrl_base =0 ; -u32 *emif_ext_phy_ctrl_base =0 ; -u32 i =0 ;/* * Set SDRAM_CONFIG and PHY control registers to locked frequency
@@ -290,27 +285,7 @@ static void ddr3_init(u32 base, const struct emif_regs *regs)writel (regs->ref_ctrl, &emif->emif_sdram_ref_ctrl);writel (regs->read_idle_ctrl, &emif->emif_read_idlectrl); - ext_phy_ctrl_base = (u32 *) &(regs->emif_ddr_ext_phy_ctrl_1); - emif_ext_phy_ctrl_base = (u32 *) &(emif->emif_ddr_ext_phy_ctrl_1); - -/* Configure external phy control timing registers */ -for (i =0 ; i <EMIF_EXT_PHY_CTRL_TIMING_REG ; i++) { -writel (*ext_phy_ctrl_base, emif_ext_phy_ctrl_base++); -/* Update shadow registers */ -writel (*ext_phy_ctrl_base++, emif_ext_phy_ctrl_base++); - } - -/* -* external phy 6-24 registers do not change with -* ddr frequency -*/ -for (i =0 ; i <EMIF_EXT_PHY_CTRL_CONST_REG ; i++) { -writel (ddr3_ext_phy_ctrl_const_base[i], - emif_ext_phy_ctrl_base++); -/* Update shadow registers */ -writel (ddr3_ext_phy_ctrl_const_base[i], - emif_ext_phy_ctrl_base++); - } +do_ext_phy_settings (base, regs);/* enable leveling */ writel (regs->emif_rd_wr_lvl_rmp_ctl, &emif->emif_rd_wr_lvl_rmp_ctl);
@@ -1109,9 +1084,6 @@ void emif_post_init_config(u32 base)struct emif_reg_struct *emif = (struct emif_reg_struct *)base;u32 omap_rev =omap_revision (); -if (omap_rev ==OMAP5430_ES1_0 ) -return ; -/* reset phy on ES2.0 */ if (omap_rev ==OMAP4430_ES2_0 )emif_reset_phy (base);
arch/arm/cpu/armv7/omap4/sdram_elpida.c +13 -3
@@ -90,9 +90,6 @@ const struct emif_regs emif_regs_elpida_400_mhz_2cs = { .emif_ddr_phy_ctlr_1 = 0x049ff418 }; -/* Dummy registers for OMAP44xx */ -const u32 ddr3_ext_phy_ctrl_const_base[EMIF_EXT_PHY_CTRL_CONST_REG ]; -const struct dmm_lisa_map_regs lisa_map_2G_x_1_x_2 = { .dmm_lisa_map_0 =0xFF020100 , .dmm_lisa_map_1 =0 ,
@@ -284,3 +281,16 @@ void emif_get_device_timings(u32 emif_nr, __attribute__((weak, alias("emif_get_device_timings_sdp")));#endif /* CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS */ + +const struct lpddr2_mr_regs mr_regs = { + .mr1 =MR1_BL_8_BT_SEQ_WRAP_EN_NWR_3 , + .mr2 =0x4 , + .mr3 =-1 , + .mr10 =MR10_ZQ_ZQINIT , + .mr16 =MR16_REF_FULL_ARRAY +}; + +void get_lpddr2_mr_regs (const struct lpddr2_mr_regs **regs) +{ + *regs = &mr_regs; +}
arch/arm/cpu/armv7/omap5/sdram.c +77 -42
156 lines not on this page · raw message
arch/arm/include/asm/emif.h +9 -3
@@ -698,9 +698,6 @@ struct dmm_lisa_map_regs {u32 dmm_lisa_map_3; }; -extern const u32 ext_phy_ctrl_const_base[EMIF_EXT_PHY_CTRL_CONST_REG ]; -extern const u32 ddr3_ext_phy_ctrl_const_base[EMIF_EXT_PHY_CTRL_CONST_REG ]; -#define CS0 0#define CS1 1/* The maximum frequency@which the LPDDR2 interface can operate in Hz*/
@@ -1134,6 +1131,14 @@ struct emif_regs {u32 emif_rd_wr_exec_thresh; }; +struct lpddr2_mr_regs { +s8 mr1; +s8 mr2; +s8 mr3; +s8 mr10; +s8 mr16; +}; +/* assert macros */ #if defined(DEBUG )#define emif_assert (c) ({ if (!(c)) for (;;); })
@@ -1153,6 +1158,7 @@ void emif_get_device_timings(u32 emif_nr,#endif void do_ext_phy_settings (u32 base,const struct emif_regs *regs); +void get_lpddr2_mr_regs (const struct lpddr2_mr_regs **regs);#ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS extern u32 *const T_num;
Signature · 1 line
1.7.9.5
PATCH v2 5/7 ARM: OMAP4+: Cleanup emif specific files
Quoted 10 lines · R Sricharan
From: Lokesh Vutla <[email protected]>
Removing the duplicated code in ddr3 initialization. Also creating structure for lpddr2 mode registers to avoid unnessecary revision checks.
These change reduces code addition for future Socs.
Signed-off-by R Sricharan <[email protected]>Signed-off-by Lokesh Vutla <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130204/d5ec12ed/attachment.pgp>
PATCH v2 6/7 ARM: OMAP4+: Make control module register structure generic
In reply to R SricharanFrom: Lokesh Vutla <[email protected]>
A seperate omap_sys_ctrl_regs structure is defined for omap4 & 5. If there is any change in control module for any of the ES versions, a new structure needs to be created. In order to remove this dependency, making the register structure generic for all the omap4+ boards.
--- arch/arm/cpu/armv7/omap-common/hwinit-common.c | 5 +- arch/arm/cpu/armv7/omap4/hw_data.c | 3 + arch/arm/cpu/armv7/omap4/hwinit.c | 36 ++++----- arch/arm/cpu/armv7/omap4/prcm-regs.c | 20 +++++ arch/arm/cpu/armv7/omap5/hw_data.c | 4 + arch/arm/cpu/armv7/omap5/hwinit.c | 102 +++++++++++------------- arch/arm/cpu/armv7/omap5/prcm-regs.c | 74 +++++++++++++++++ arch/arm/include/asm/arch-omap4/omap.h | 31 +------ arch/arm/include/asm/arch-omap5/omap.h | 84 +------------------ arch/arm/include/asm/omap_common.h | 91 +++++++++++++++++++++ drivers/mmc/omap_hsmmc.c | 25 +++--- 11 files changed, 269 insertions(+), 206 deletions(-)
arch/arm/cpu/armv7/omap-common/hwinit-common.c +1 -4
@@ -244,10 +244,7 @@ int checkboard(void)*/ u32 get_device_type (void ) { -struct omap_sys_ctrl_regs *ctrl = - (struct omap_sys_ctrl_regs *)SYSCTRL_GENERAL_CORE_BASE ; - -return (readl (&ctrl->control_status) & +return (readl ((*ctrl)->control_status) & (DEVICE_TYPE_MASK )) >>DEVICE_TYPE_SHIFT ; }
arch/arm/cpu/armv7/omap4/hw_data.c +3 -0
@@ -39,6 +39,8 @@ struct dplls const **dplls_data = (struct dplls const **)OMAP_SRAM_SCRATCH_DPLLS_PTR ;struct vcores_data const **omap_vcores = (struct vcores_data const **)OMAP_SRAM_SCRATCH_VCORES_PTR ; +struct omap_sys_ctrl_regs const **ctrl = + (struct omap_sys_ctrl_regs const **)OMAP4_SRAM_SCRATCH_SYS_CTRL ;/* * The M & N values in the following tables are created using the
@@ -470,4 +472,5 @@ void hw_data_init(void)printf ("\n INVALID OMAP REVISION " ); } + *ctrl = &omap4_ctrl; }
arch/arm/cpu/armv7/omap4/hwinit.c +16 -20
@@ -57,10 +57,6 @@ const struct gpio_bank *const omap_gpio_bank = gpio_bank_44xx;void do_io_settings (void ) {u32 lpddr2io; -struct control_lpddr2io_regs *lpddr2io_regs = - (struct control_lpddr2io_regs *)LPDDR2_IO_REGS_BASE ; -struct omap_sys_ctrl_regs *const ctrl = - (struct omap_sys_ctrl_regs *)SYSCTRL_GENERAL_CORE_BASE ;u32 omap4_rev =omap_revision ();
@@ -72,20 +68,20 @@ void do_io_settings(void) lpddr2io =CONTROL_LPDDR2IO_SLEW_315PS_DRV12_PULL_DOWN ;/* EMIF1 */ -writel (lpddr2io, &lpddr2io_regs->control_lpddr2io1_0); -writel (lpddr2io, &lpddr2io_regs->control_lpddr2io1_1); +writel (lpddr2io, (*ctrl)->control_lpddr2io1_0); +writel (lpddr2io, (*ctrl)->control_lpddr2io1_1);/* No pull for GR10 as per hw team's recommendation */ writel (lpddr2io & ~LPDDR2IO_GR10_WD_MASK , - &lpddr2io_regs->control_lpddr2io1_2); -writel (CONTROL_LPDDR2IO_3_VAL , &lpddr2io_regs->control_lpddr2io1_3); + (*ctrl)->control_lpddr2io1_2); +writel (CONTROL_LPDDR2IO_3_VAL , (*ctrl)->control_lpddr2io1_3);/* EMIF2 */ -writel (lpddr2io, &lpddr2io_regs->control_lpddr2io2_0); -writel (lpddr2io, &lpddr2io_regs->control_lpddr2io2_1); +writel (lpddr2io, (*ctrl)->control_lpddr2io2_0); +writel (lpddr2io, (*ctrl)->control_lpddr2io2_1);/* No pull for GR10 as per hw team's recommendation */ writel (lpddr2io & ~LPDDR2IO_GR10_WD_MASK , - &lpddr2io_regs->control_lpddr2io2_2); -writel (CONTROL_LPDDR2IO_3_VAL , &lpddr2io_regs->control_lpddr2io2_3); + (*ctrl)->control_lpddr2io2_2); +writel (CONTROL_LPDDR2IO_3_VAL , (*ctrl)->control_lpddr2io2_3);/* * Some of these settings (TRIM values) come from eFuse and are
@@ -93,16 +89,16 @@ void do_io_settings(void)* calibration of the device. Do the software over-ride only if * the device is not correctly trimmed */ -if (!(readl (&ctrl->control_std_fuse_opp_bgap) &0xFFFF )) { +if (!(readl ((*ctrl)->control_std_fuse_opp_bgap) &0xFFFF )) {writel (LDOSRAM_VOLT_CTRL_OVERRIDE , - &ctrl->control_ldosram_iva_voltage_ctrl); + (*ctrl)->control_ldosram_iva_voltage_ctrl);writel (LDOSRAM_VOLT_CTRL_OVERRIDE , - &ctrl->control_ldosram_mpu_voltage_ctrl); + (*ctrl)->control_ldosram_mpu_voltage_ctrl);writel (LDOSRAM_VOLT_CTRL_OVERRIDE , - &ctrl->control_ldosram_core_voltage_ctrl); + (*ctrl)->control_ldosram_core_voltage_ctrl); }/*
@@ -110,11 +106,11 @@ void do_io_settings(void)* i. unconditionally for all 4430 * ii. only if un-trimmed for 4460 */ -if (!readl (&ctrl->control_efuse_1)) -writel (CONTROL_EFUSE_1_OVERRIDE , &ctrl->control_efuse_1); +if (!readl ((*ctrl)->control_efuse_1)) +writel (CONTROL_EFUSE_1_OVERRIDE , (*ctrl)->control_efuse_1); -if ((omap4_rev <OMAP4460_ES1_0 ) || !readl (&ctrl->control_efuse_2)) - writel(CONTROL_EFUSE_2_OVERRIDE, &ctrl->control_efuse_2); +if ((omap4_rev <OMAP4460_ES1_0 ) || !readl ((*ctrl)->control_efuse_2)) + writel(CONTROL_EFUSE_2_OVERRIDE, (*ctrl)->control_efuse_2); }#endif /* CONFIG_SPL_BUILD */
arch/arm/cpu/armv7/omap4/prcm-regs.c +20 -0
@@ -293,3 +293,23 @@ struct prcm_regs const omap4_prcm = { .prm_vc_cfg_i2c_mode = 0x4a307ba8, .prm_vc_cfg_i2c_clk = 0x4a307bac, }; + +struct omap_sys_ctrl_regs const omap4_ctrl = { + .control_id_code =0x4A002204 , + .control_std_fuse_opp_bgap =0x4a002260 , + .control_status =0x4a0022c4 , + .control_ldosram_iva_voltage_ctrl =0x4A002320 , + .control_ldosram_mpu_voltage_ctrl =0x4A002324 , + .control_ldosram_core_voltage_ctrl =0x4A002328 , + .control_pbiaslite =0x4A100600 , + .control_lpddr2io1_0 =0x4A100638 , + .control_lpddr2io1_1 =0x4A10063C , + .control_lpddr2io1_2 =0x4A100640 , + .control_lpddr2io1_3 =0x4A100644 , + .control_lpddr2io2_0 =0x4A100648 , + .control_lpddr2io2_1 =0x4A10064C , + .control_lpddr2io2_2 =0x4A100650 , + .control_lpddr2io2_3 =0x4A100654 , + .control_efuse_1 =0x4A100700 , + .control_efuse_2 =0x4A100704 , +};
arch/arm/cpu/armv7/omap5/hw_data.c +4 -0
@@ -39,6 +39,8 @@ struct dplls const **dplls_data = (struct dplls const **)OMAP_SRAM_SCRATCH_DPLLS_PTR ;struct vcores_data const **omap_vcores = (struct vcores_data const **)OMAP_SRAM_SCRATCH_VCORES_PTR ; +struct omap_sys_ctrl_regs const **ctrl = + (struct omap_sys_ctrl_regs const **)OMAP5_SRAM_SCRATCH_SYS_CTRL ;static const struct dpll_params mpu_dpll_params_1_5ghz[NUM_SYS_CLKS ] = { {125 ,0 ,1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 },/* 12 MHz */
@@ -433,4 +435,6 @@ void hw_data_init(void)default :printf ("\n INVALID OMAP REVISION " ); } + + *ctrl = &omap5_ctrl; }
arch/arm/cpu/armv7/omap5/hwinit.c +46 -56
209 lines not on this page · raw message
arch/arm/cpu/armv7/omap5/prcm-regs.c +74 -0
77 lines not on this page · raw message
arch/arm/include/asm/arch-omap4/omap.h +2 -29
@@ -132,34 +132,6 @@ struct s32ktimer {#define DEVICE_TYPE_MASK (0x7 << DEVICE_TYPE_SHIFT)#define DEVICE_GP 0x3 -struct omap_sys_ctrl_regs { -unsigned int pad1[129 ]; -unsigned int control_id_code;/* 0x4A002204 */ -unsigned int pad11[22 ]; -unsigned int control_std_fuse_opp_bgap;/* 0x4a002260 */ -unsigned int pad2[24 ];/* 0x4a002264 */ -unsigned int control_status;/* 0x4a0022c4 */ -unsigned int pad3[22 ];/* 0x4a0022c8 */ -unsigned int control_ldosram_iva_voltage_ctrl;/* 0x4A002320 */ -unsigned int control_ldosram_mpu_voltage_ctrl;/* 0x4A002324 */ -unsigned int control_ldosram_core_voltage_ctrl;/* 0x4A002328 */ -unsigned int pad4[260277 ]; -unsigned int control_pbiaslite;/* 0x4A100600 */ -unsigned int pad5[63 ]; -unsigned int control_efuse_1;/* 0x4A100700 */ -unsigned int control_efuse_2;/* 0x4A100704 */ -}; - -struct control_lpddr2io_regs { -unsigned int control_lpddr2io1_0; -unsigned int control_lpddr2io1_1; -unsigned int control_lpddr2io1_2; -unsigned int control_lpddr2io1_3; -unsigned int control_lpddr2io2_0; -unsigned int control_lpddr2io2_1; -unsigned int control_lpddr2io2_2; -unsigned int control_lpddr2io2_3; -};#endif /* __ASSEMBLY__ */ /*
@@ -181,7 +153,8 @@ struct control_lpddr2io_regs {#define OMAP_SRAM_SCRATCH_PRCM_PTR (SRAM_SCRATCH_SPACE_ADDR + 0x14)#define OMAP_SRAM_SCRATCH_DPLLS_PTR (SRAM_SCRATCH_SPACE_ADDR + 0x18)#define OMAP_SRAM_SCRATCH_VCORES_PTR (SRAM_SCRATCH_SPACE_ADDR + 0x1C) -#define OMAP4_SRAM_SCRATCH_SPACE_END (SRAM_SCRATCH_SPACE_ADDR + 0x20) +#define OMAP4_SRAM_SCRATCH_SYS_CTRL (SRAM_SCRATCH_SPACE_ADDR + 0x20) +#define OMAP4_SRAM_SCRATCH_SPACE_END (SRAM_SCRATCH_SPACE_ADDR + 0x24)/* ROM code defines */ /* Boot device */
arch/arm/include/asm/arch-omap5/omap.h +2 -82
96 lines not on this page · raw message
arch/arm/include/asm/omap_common.h +91 -0
103 lines not on this page · raw message
drivers/mmc/omap_hsmmc.c +10 -15
@@ -50,18 +50,15 @@ static struct mmc hsmmc_dev[2];static void omap4_vmmc_pbias_config (struct mmc *mmc) {u32 value =0 ; -struct omap_sys_ctrl_regs *const ctrl = - (struct omap_sys_ctrl_regs *)SYSCTRL_GENERAL_CORE_BASE ; - - value =readl (&ctrl->control_pbiaslite); + value =readl ((*ctrl)->control_pbiaslite); value &= ~(MMC1_PBIASLITE_PWRDNZ |MMC1_PWRDNZ ); -writel (value, &ctrl->control_pbiaslite); +writel (value, (*ctrl)->control_pbiaslite);/* set VMMC to 3V */ twl6030_power_mmc_init (); - value =readl (&ctrl->control_pbiaslite); + value =readl ((*ctrl)->control_pbiaslite); value |=MMC1_PBIASLITE_VMODE |MMC1_PBIASLITE_PWRDNZ |MMC1_PWRDNZ ; -writel (value, &ctrl->control_pbiaslite); +writel (value, (*ctrl)->control_pbiaslite); }#endif
@@ -69,26 +66,24 @@ static void omap4_vmmc_pbias_config(struct mmc *mmc)static void omap5_pbias_config (struct mmc *mmc) {u32 value =0 ; -struct omap_sys_ctrl_regs *const ctrl = - (struct omap_sys_ctrl_regs *)SYSCTRL_GENERAL_CORE_BASE ; - value =readl (&ctrl->control_pbias); + value =readl ((*ctrl)->control_pbias); value &= ~(SDCARD_PWRDNZ |SDCARD_BIAS_PWRDNZ ); value |=SDCARD_BIAS_HIZ_MODE ; -writel (value, &ctrl->control_pbias); +writel (value, (*ctrl)->control_pbias);twl6035_mmc1_poweron_ldo (); - value =readl (&ctrl->control_pbias); + value =readl ((*ctrl)->control_pbias); value &= ~SDCARD_BIAS_HIZ_MODE ; value |=SDCARD_PBIASLITE_VMODE |SDCARD_PWRDNZ |SDCARD_BIAS_PWRDNZ ; -writel (value, &ctrl->control_pbias); +writel (value, (*ctrl)->control_pbias); - value =readl (&ctrl->control_pbias); + value =readl ((*ctrl)->control_pbias);if (value & (1 <<23 )) { value &= ~(SDCARD_PWRDNZ |SDCARD_BIAS_PWRDNZ ); value |=SDCARD_BIAS_HIZ_MODE ; -writel (value, &ctrl->control_pbias); +writel (value, (*ctrl)->control_pbias); } }#endif
Signature · 1 line
1.7.9.5
PATCH v2 6/7 ARM: OMAP4+: Make control module register structure generic
Quoted 10 lines · R Sricharan
From: Lokesh Vutla <[email protected]>
A seperate
omap_sys_ctrl_regsstructure is defined for omap4 & 5. If there is any change in control module for any of the ES versions, a new structure needs to be created. In order to remove this dependency, making the register structure generic for all the omap4+ boards.Signed-off-by R Sricharan <[email protected]>Signed-off-by Lokesh Vutla <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130204/5d4dd2f7/attachment.pgp>
PATCH v2 7/7 ARM: OMAP5: Clean up iosettings code
In reply to R SricharanFrom: Lokesh Vutla <[email protected]>
There is some code duplication in the ddr io settings code. This is avoided by moving the data to a Soc specific place and letting the code generic.
This avoids unnessecary code addition for future socs.
--- arch/arm/cpu/armv7/omap5/hw_data.c | 36 +++++++++++++ arch/arm/cpu/armv7/omap5/hwinit.c | 75 +++++++++++---------------- arch/arm/include/asm/arch-omap5/omap.h | 10 ++++ arch/arm/include/asm/arch-omap5/sys_proto.h | 1 + 4 files changed, 78 insertions(+), 44 deletions(-)
arch/arm/cpu/armv7/omap5/hw_data.c +36 -0
@@ -32,6 +32,7 @@#include <asm/arch/clocks.h> #include <asm/omap_gpio.h> #include <asm/io.h> +#include <asm/emif.h> struct prcm_regs const **prcm = (struct prcm_regs const **)OMAP_SRAM_SCRATCH_PRCM_PTR ;
@@ -414,6 +415,24 @@ void enable_non_essential_clocks(void) MODULE_CLKCTRL_MODULEMODE_SHIFT); } +const struct ctrl_ioregs ioregs_omap5430 = { + .ctrl_ddrch =DDR_IO_I_34OHM_SR_FASTEST_WD_DQ_NO_PULL_DQS_PULL_DOWN , + .ctrl_lpddr2ch =DDR_IO_I_34OHM_SR_FASTEST_WD_CK_CKE_NCS_CA_PULL_DOWN , + .ctrl_ddrio_0 =DDR_IO_0_DDR2_DQ_INT_EN_ALL_DDR3_CA_DIS_ALL , + .ctrl_ddrio_1 =DDR_IO_1_DQ_OUT_EN_ALL_DQ_INT_EN_ALL , + .ctrl_ddrio_2 =DDR_IO_2_CA_OUT_EN_ALL_CA_INT_EN_ALL , +}; + +const struct ctrl_ioregs ioregs_omap5432_es1 = { + .ctrl_ddrch =DDR_IO_I_40OHM_SR_FAST_WD_DQ_NO_PULL_DQS_NO_PULL , + .ctrl_lpddr2ch =0x0 , + .ctrl_ddr3ch =DDR_IO_I_40OHM_SR_SLOWEST_WD_DQ_NO_PULL_DQS_NO_PULL , + .ctrl_ddrio_0 =DDR_IO_0_VREF_CELLS_DDR3_VALUE , + .ctrl_ddrio_1 =DDR_IO_1_VREF_CELLS_DDR3_VALUE , + .ctrl_ddrio_2 =DDR_IO_2_VREF_CELLS_DDR3_VALUE , + .ctrl_emif_sdram_config_ext =SDRAM_CONFIG_EXT_RD_LVL_11_SAMPLES , +}; +void hw_data_init (void ) {u32 omap_rev =omap_revision ();
@@ -438,3 +457,20 @@ void hw_data_init(void) *ctrl = &omap5_ctrl; } + +void get_ioregs (const struct ctrl_ioregs **regs) +{ +u32 omap_rev =omap_revision (); + +switch (omap_rev) { +case OMAP5430_ES1_0 : + *regs = &ioregs_omap5430; +break ; +case OMAP5432_ES1_0 : + *regs = &ioregs_omap5432_es1; +break ; + +default : +printf ("\n INVALID OMAP REVISION " ); + } +}
arch/arm/cpu/armv7/omap5/hwinit.c +31 -44
91 lines not on this page · raw message
arch/arm/include/asm/arch-omap5/omap.h +10 -0
@@ -229,5 +229,15 @@ struct omap_boot_parameters {unsigned char reset_reason;unsigned char ch_flags; }; + +struct ctrl_ioregs { +u32 ctrl_ddrch; +u32 ctrl_lpddr2ch; +u32 ctrl_ddr3ch; +u32 ctrl_ddrio_0; +u32 ctrl_ddrio_1; +u32 ctrl_ddrio_2; +u32 ctrl_emif_sdram_config_ext; +};#endif /* __ASSEMBLY__ */ #endif
arch/arm/include/asm/arch-omap5/sys_proto.h +1 -0
@@ -58,6 +58,7 @@ void omap_vc_init(u16 speed_khz);int omap_vc_bypass_send_value (u8 sa,u8 reg_addr,u8 reg_data);u32 warm_reset (void );void force_emif_self_refresh (void ); +void get_ioregs (const struct ctrl_ioregs **regs);/* * This is used to verify if the configuration header
Signature · 1 line
1.7.9.5
PATCH v2 7/7 ARM: OMAP5: Clean up iosettings code
Quoted 9 lines · R Sricharan
From: Lokesh Vutla <[email protected]>
There is some code duplication in the ddr io settings code. This is avoided by moving the data to a Soc specific place and letting the code generic.
This avoids unnessecary code addition for future socs.
Signed-off-by Lokesh Vutla <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130204/1fd44f74/attachment.pgp>
v2 cover ARM: OMAP4+: Cleanup clocks, control and emif code
In reply to R SricharanQuoted 15 lines · R Sricharan
This series is intended to cleanup code which is duplicated across soc specific files. This is accomplished by moving soc specifc data to one place and having the code common. This helps in avoiding un necessary cpu checks and minimal code addition for future socs.
Tested this on OMAP5 ES1.0, OMAP4460 Panda boards and verified MAKEALL for all armv7 boards.
Lokesh Vutla (4):
ARM: OMAP4+: emif: Detect SDRAM from SDRAM config register
ARM: OMAP4+: Cleanup emif specific files
ARM: OMAP4+: Make control module register structure generic
ARM: OMAP5: Clean up iosettings code
Quoted 4 lines
R Sricharan (3):
ARM: OMAP4+: Change the PRCM structure prototype common for all Socs
ARM: OMAP4+: Cleanup the clocks layer
ARM: OMAP4+: Clean up the pmic code
Patch 2 of 7 didn't hit the mailing list yet.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130204/aa79d23e/attachment.pgp>