Skip to contentSkip to conversation

OMAP3+: introduce generic Adaptive Body Bias Support

PATCH Superseded Andrii Tseglytskyi 2 participants 7 messages May 13, 2013 – May 20, 2013 Arm (32-bit)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover OMAP3+: introduce generic Adaptive Body Bias Support

Adaptive Body Biasing (ABB) modulates transistor bias voltages dynamically in order to optimize switching speed versus leakage. Adaptive Body-Bias ldos are present for some voltage domains:
starting with OMAP3630. There are three modes of operation:

* Bypass - the default, it just follows the vdd voltage
* Foward Body-Bias - applies voltage bias to increase transistor performance at the cost of power. Used to operate safely at high OPPs.
* Reverse Body-Bias - applies voltage bias to decrease leakage and save power. Used to save power at lower OPPs.

The application of FBB/RBB technique is determined for each unique device in some process nodes, whereas, they are mandated on other process nodes.

OMAP5 silicon requires ABB to be properly configured on early boot stage. The following patch series adds generic ABB configuration and enables it for OMAP5 silicons.

v02: series contains minor comments fixes.

Andrii Tseglytskyi (2):
OMAP3+: introduce generic ABB support
OMAP5: add ABB setup for MPU voltage domain

 arch/arm/cpu/armv7/omap-common/Makefile        |    1 +
 arch/arm/cpu/armv7/omap-common/abb.c           |  139 ++++++++++++++++++++++++
 arch/arm/cpu/armv7/omap-common/clocks-common.c |    9 ++
 arch/arm/cpu/armv7/omap5/Makefile              |    1 +
 arch/arm/cpu/armv7/omap5/abb.c                 |   67 ++++++++++++
 arch/arm/cpu/armv7/omap5/prcm-regs.c           |    7 ++
 arch/arm/include/asm/arch-omap3/omap3.h        |    7 ++
 arch/arm/include/asm/arch-omap4/omap.h         |    7 ++
 arch/arm/include/asm/arch-omap5/omap.h         |   13 +++
 arch/arm/include/asm/omap_common.h             |   22 ++++
 10 files changed, 273 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/omap-common/abb.c
 create mode 100644 arch/arm/cpu/armv7/omap5/abb.c
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/2 OMAP3+: introduce generic ABB support

Adaptive Body Biasing (ABB) modulates transistor bias voltages dynamically in order to optimize switching speed versus leakage. Adaptive Body-Bias ldos are present for some voltage domains starting with OMAP3630. There are three modes of operation:

* Bypass - the default, it just follows the vdd voltage
* Foward Body-Bias - applies voltage bias to increase transistor performance at the cost of power. Used to operate safely at high OPPs.
* Reverse Body-Bias - applies voltage bias to decrease leakage and save power. Used to save power at lower OPPs.

---
 arch/arm/cpu/armv7/omap-common/Makefile |    1 +
 arch/arm/cpu/armv7/omap-common/abb.c    |  139 +++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7/omap5/Makefile       |    1 +
 arch/arm/cpu/armv7/omap5/abb.c          |   67 +++++++++++++++
 arch/arm/include/asm/arch-omap3/omap3.h |    7 ++
 arch/arm/include/asm/arch-omap4/omap.h  |    7 ++
 arch/arm/include/asm/arch-omap5/omap.h  |   13 +++
 arch/arm/include/asm/omap_common.h      |   22 +++++
 8 files changed, 257 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/omap-common/abb.c
 create mode 100644 arch/arm/cpu/armv7/omap5/abb.c
arch/arm/cpu/armv7/omap-common/Makefile +1 -0
index 55e82ba..c4b9809 100644
@@ -34,6 +34,7 @@ COBJS	+= hwinit-common.o
 COBJS	+= clocks-common.o
 COBJS	+= emif-common.o
 COBJS	+= vc.o
+COBJS	+= abb.o
 endif
 
 ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TI814X),)
arch/arm/cpu/armv7/omap-common/abb.c new file +139 -0

139 lines not on this page · raw message

arch/arm/cpu/armv7/omap5/Makefile +1 -0
index ce00e2c..6ff8dbb 100644
@@ -30,6 +30,7 @@ COBJS	+= emif.o
 COBJS	+= sdram.o
 COBJS	+= prcm-regs.o
 COBJS	+= hw_data.o
+COBJS	+= abb.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
arch/arm/cpu/armv7/omap5/abb.c new file +67 -0

67 lines not on this page · raw message

arch/arm/include/asm/arch-omap3/omap3.h +7 -0
index 2b5e9ae..c57599a 100644
@@ -253,4 +253,11 @@ struct gpio {
 
 #define OMAP3_EMU_HAL_START_HAL_CRITICAL	4
 
+/* ABB settings */
+#define OMAP_ABB_SETTLING_TIME		30
+#define OMAP_ABB_CLOCK_CYCLES		8
+
+/* ABB tranxdone mask */
+#define OMAP_ABB_MPU_TXDONE_MASK	(0x1 << 26)
+
 #endif
arch/arm/include/asm/arch-omap4/omap.h +7 -0
index ad984da..559ad26 100644
@@ -170,6 +170,13 @@ struct s32ktimer {
 #define CH_FLAGS_CHFLASH	(0x1 << 2)
 #define CH_FLAGS_CHMMCSD	(0x1 << 3)
 
+/* ABB settings */
+#define OMAP_ABB_SETTLING_TIME		50
+#define OMAP_ABB_CLOCK_CYCLES		16
+
+/* ABB tranxdone mask */
+#define OMAP_ABB_MPU_TXDONE_MASK	(0x1 << 7)
+
 #ifndef __ASSEMBLY__
 struct omap_boot_parameters {
 	char *boot_message;
arch/arm/include/asm/arch-omap5/omap.h +13 -0
index 887fcaa..caa1234 100644
@@ -243,6 +243,19 @@ struct s32ktimer {
 #define SRCODE_OVERRIDE_SEL_XS_SHIFT	0
 #define SRCODE_OVERRIDE_SEL_XS_MASK	(1 << 0)
 
+/* ABB settings */
+#define OMAP_ABB_SETTLING_TIME		50
+#define OMAP_ABB_CLOCK_CYCLES		16
+
+/* ABB tranxdone mask */
+#define OMAP_ABB_MPU_TXDONE_MASK		(0x1 << 7)
+
+/* ABB efuse masks */
+#define OMAP5_ABB_FUSE_VSET_MASK		(0x1F << 24)
+#define OMAP5_ABB_FUSE_ENABLE_MASK		(0x1 << 29)
+#define OMAP5_ABB_LDOVBBMPU_MUX_CTRL_MASK	(0x1 << 10)
+#define OMAP5_ABB_LDOVBBMPU_VSET_OUT_MASK	(0x1f << 0)
+
 #ifndef __ASSEMBLY__
 struct srcomp_params {
 	s8 divide_factor;
arch/arm/include/asm/omap_common.h +22 -0
index 091ddb5..4892c0a 100644
@@ -240,6 +240,8 @@ struct prcm_regs {
 	u32 cm_l3init_fsusb_clkctrl;
 	u32 cm_l3init_ocp2scp1_clkctrl;
 
+	u32 prm_irqstatus_mpu_2;
+
 	/* cm2.l4per */
 	u32 cm_l4per_clkstctrl;
 	u32 cm_l4per_dynamicdep;
@@ -325,6 +327,8 @@ struct prcm_regs {
 	u32 prm_sldo_mpu_ctrl;
 	u32 prm_sldo_mm_setup;
 	u32 prm_sldo_mm_ctrl;
+	u32 prm_abbldo_mpu_setup;
+	u32 prm_abbldo_mpu_ctrl;
 
 	u32 cm_div_m4_dpll_core;
 	u32 cm_div_m5_dpll_core;
@@ -347,6 +351,7 @@ struct prcm_regs {
 
 struct omap_sys_ctrl_regs {
 	u32 control_status;
+	u32 control_std_fuse_opp_vdd_mpu_2;
 	u32 control_core_mmr_lock1;
 	u32 control_core_mmr_lock2;
 	u32 control_core_mmr_lock3;
@@ -416,6 +421,7 @@ struct omap_sys_ctrl_regs {
 	u32 control_port_emif2_sdram_config;
 	u32 control_emif1_sdram_config_ext;
 	u32 control_emif2_sdram_config_ext;
+	u32 control_wkup_ldovbb_mpu_voltage_ctrl;
 	u32 control_smart1nopmio_padconf_0;
 	u32 control_smart1nopmio_padconf_1;
 	u32 control_padconf_mode;
@@ -542,6 +548,9 @@ 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);
+void abb_setup(u32 fuse, u32 ldovbb, u32 setup, u32 control,
+	       u32 txdone, u32 txdone_mask, u32 opp);
+s8 abb_setup_ldovbb(u32 fuse, u32 ldovbb);
 
 /* Max value for DPLL multiplier M */
 #define OMAP_DPLL_MAX_N	127
@@ -552,6 +561,19 @@ void do_scale_vcore(u32 vcore_reg, u32 volt_mv, struct pmic_data *pmic);
 #define OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL	2
 #define OMAP_INIT_CONTEXT_UBOOT_AFTER_CH	3
 
+/* ABB */
+#define OMAP_ABB_NOMINAL_OPP		0
+#define OMAP_ABB_FAST_OPP		1
+#define OMAP_ABB_SLOW_OPP		3
+#define OMAP_ABB_CONTROL_FAST_OPP_SEL_MASK		(0x1 << 0)
+#define OMAP_ABB_CONTROL_SLOW_OPP_SEL_MASK		(0x1 << 1)
+#define OMAP_ABB_CONTROL_OPP_CHANGE_MASK		(0x1 << 2)
+#define OMAP_ABB_CONTROL_SR2_IN_TRANSITION_MASK		(0x1 << 6)
+#define OMAP_ABB_SETUP_SR2EN_MASK			(0x1 << 0)
+#define OMAP_ABB_SETUP_ACTIVE_FBB_SEL_MASK		(0x1 << 2)
+#define OMAP_ABB_SETUP_ACTIVE_RBB_SEL_MASK		(0x1 << 1)
+#define OMAP_ABB_SETUP_SR2_WTCNT_VALUE_MASK		(0xff << 8)
+
 static inline u32 omap_revision(void)
 {
 	extern u32 *const omap_si_rev;
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v2 1/2 OMAP3+: introduce generic ABB support

On 19:49-20130513, Andrii Tseglytskyi wrote:
[...]

Quoted 32 lines
(quoted diff) +32 -0
+void abb_setup(u32 fuse, u32 ldovbb, u32 setup, u32 control,
+	       u32 txdone, u32 txdone_mask, u32 opp)
+{
+	u32 abb_type_mask, opp_sel_mask;
+
+	/* sanity check */
+	if (!setup || !control || !txdone)
+		return;
+
+	/* setup ABB only in case of Fast or Slow OPP */
+	switch (opp) {
+	case OMAP_ABB_FAST_OPP:
+		abb_type_mask = OMAP_ABB_SETUP_ACTIVE_FBB_SEL_MASK;
+		opp_sel_mask = OMAP_ABB_CONTROL_FAST_OPP_SEL_MASK;
+		break;
+	case OMAP_ABB_SLOW_OPP:
+		abb_type_mask = OMAP_ABB_SETUP_ACTIVE_RBB_SEL_MASK;
+		opp_sel_mask = OMAP_ABB_CONTROL_SLOW_OPP_SEL_MASK;
+		break;
+	default:
+	       return;
+	}
+
+	/*
+	 * For some OMAP silicons additional setup for LDOVBB register is
+	 * required. This is determined by data retrieved from corresponding
+	 * OPP EFUSE register. Data, which is retrieved from EFUSE - is
+	 * ABB enable/disable flag and VSET value, which must be copied
+	 * to LDOVBB register. If function call fails - return quietly,
+	 * it means no ABB is required for such silicon.
+	 *
+	 * For silicons, which don't require LDOVBB setup "fuse" and

Review

Quoted 10 lines
(quoted diff) +10 -0
+	 * "ldovbb" offsets are not defined. ABB will be initialized in
+	 * the common way for them.
+	 */
+	if (fuse && ldovbb) {
+		if (abb_setup_ldovbb(fuse, ldovbb))
+			return;
+	}
+
+	/* configure timings, based on oscillator value */
+	abb_setup_timings(setup);

Still missing txdone clear..
If txdone was set on entry, you'd escape a bit waiting for transition completion bit in SR2, However, by clearing TXDONE here, you can just wait for TXDONE.

Review

Quoted 5 lines
(quoted diff) +5 -0
+
+	/* select ABB type */
+	clrsetbits_le32(setup,
+			abb_type_mask | OMAP_ABB_SETUP_SR2EN_MASK,
+			abb_type_mask | OMAP_ABB_SETUP_SR2EN_MASK);

This is no better than set_bits! clearbits (addr, clr, set) -> the clr bits should clear *all* bits of the field. in this example ABB_TYPE should both be cleared, same in OPP_SEL.
See the following change on top of this series:

arch/arm/cpu/armv7/omap-common/abb.c +12 -4
index 73eadb2..31332fb 100644
@@ -115,14 +115,22 @@ void abb_setup(u32 fuse, u32 ldovbb, u32 setup, u32 control,
 	/* configure timings, based on oscillator value */
 	abb_setup_timings(setup);
 
+	/*
+	 * Clear any pending ABB tranxdones before we wait for txdone.
+	 * We do not know the mode in which we have been handed over
+	 * the system (warm/cold reboot), ROM code operations etc..
+	 * on a cold boot, we do not expect to see this set.
+	 */
+	setbits_le32(txdone, OMAP_ABB_MPU_TXDONE_MASK);
+
 	/* select ABB type */
-	clrsetbits_le32(setup,
-			abb_type_mask | OMAP_ABB_SETUP_SR2EN_MASK,
+	clrsetbits_le32(setup, OMAP_ABB_SETUP_ABB_SEL_MASK |
+			OMAP_ABB_SETUP_SR2EN_MASK,
 			abb_type_mask | OMAP_ABB_SETUP_SR2EN_MASK);
 
 	/* initiate ABB ldo change */
-	clrsetbits_le32(control,
-			opp_sel_mask | OMAP_ABB_CONTROL_OPP_CHANGE_MASK,
+	clrsetbits_le32(control, OMAP_ABB_CONTROL_OPP_SEL_MASK |
+			OMAP_ABB_CONTROL_OPP_CHANGE_MASK,
 			opp_sel_mask | OMAP_ABB_CONTROL_OPP_CHANGE_MASK);
 
 	/* wait until transition complete */
arch/arm/include/asm/omap_common.h +5 -1
index 4892c0a..c2fc180 100644
@@ -565,13 +565,17 @@ s8 abb_setup_ldovbb(u32 fuse, u32 ldovbb);
 #define OMAP_ABB_NOMINAL_OPP		0
 #define OMAP_ABB_FAST_OPP		1
 #define OMAP_ABB_SLOW_OPP		3
+#define OMAP_ABB_CONTROL_OPP_SEL_MASK			(0x3 << 0)
 #define OMAP_ABB_CONTROL_FAST_OPP_SEL_MASK		(0x1 << 0)
-#define OMAP_ABB_CONTROL_SLOW_OPP_SEL_MASK		(0x1 << 1)
+#define OMAP_ABB_CONTROL_SLOW_OPP_SEL_MASK		(0x3 << 0)
+#define OMAP_ABB_CONTROL_NOMINAL_OPP_SEL_MASK		(0x0 << 0)
 #define OMAP_ABB_CONTROL_OPP_CHANGE_MASK		(0x1 << 2)
 #define OMAP_ABB_CONTROL_SR2_IN_TRANSITION_MASK		(0x1 << 6)
 #define OMAP_ABB_SETUP_SR2EN_MASK			(0x1 << 0)
 #define OMAP_ABB_SETUP_ACTIVE_FBB_SEL_MASK		(0x1 << 2)
 #define OMAP_ABB_SETUP_ACTIVE_RBB_SEL_MASK		(0x1 << 1)
+#define OMAP_ABB_SETUP_ABB_SEL_MASK			(OMAP_ABB_SETUP_ACTIVE_RBB_SEL_MASK | \
+							 OMAP_ABB_SETUP_ACTIVE_FBB_SEL_MASK)
 #define OMAP_ABB_SETUP_SR2_WTCNT_VALUE_MASK		(0xff << 8)
 
 static inline u32 omap_revision(void)

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+	/* initiate ABB ldo change */
+	clrsetbits_le32(control,
+			opp_sel_mask | OMAP_ABB_CONTROL_OPP_CHANGE_MASK,
+			opp_sel_mask | OMAP_ABB_CONTROL_OPP_CHANGE_MASK);
+
+	/* wait until transition complete */
+	if (!wait_on_value(OMAP_ABB_CONTROL_SR2_IN_TRANSITION_MASK, 0,
+			   (void *)control, LDELAY))
+		puts("Error: ABB is in transition\n");

superfluous if you wait for txdone.

Quoted 80 lines
(quoted diff) +8 -0
+
+	if (!wait_on_value(OMAP_ABB_MPU_TXDONE_MASK, OMAP_ABB_MPU_TXDONE_MASK,
+			   (void *)txdone, LDELAY))
+		puts("Error: ABB txdone is not set\n");
+
+	/* clear ABB tranxdone */
+	setbits_le32(txdone, OMAP_ABB_MPU_TXDONE_MASK);
+}
arch/arm/cpu/armv7/omap5/Makefile +1 -0
index ce00e2c..6ff8dbb 100644
@@ -30,6 +30,7 @@ COBJS	+= emif.o
 COBJS	+= sdram.o
 COBJS	+= prcm-regs.o
 COBJS	+= hw_data.o
+COBJS	+= abb.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
arch/arm/cpu/armv7/omap5/abb.c new file +54 -0
new file mode 100644
index 0000000..cb33cb8
@@ -0,0 +1,67 @@
+/*
+ *
+ * Adaptive Body Bias programming sequence for OMAP5 family
+ *
+ * (C) Copyright 2013
+ * Texas Instruments, <www.ti.com>
+ *
+ * Andrii Tseglytskyi <[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/omap_common.h>
+#include <asm/io.h>
+
+/*
+ * Setup LDOVBB for OMAP5.
+ * On OMAP5+ some ABB settings are fused. They are handled
+ * in the following way:
+ *
+ * 1. corresponding EFUSE register contains ABB enable bit
+ *    and VSET value
+ * 2. If ABB enable bit is set to 1, than ABB should be
+ *    enabled, otherwise ABB should be disabled
+ * 3. If ABB is enabled, than VSET value should be copied
+ *    to corresponding MUX control register
+ */
+s8 abb_setup_ldovbb(u32 fuse, u32 ldovbb)
+{
+	u32 vset;
+
+	/*
+	 * ABB parameters must be properly fused
+	 * otherwise ABB should be disabled
+	 */
+	vset = readl(fuse);
+	if (!(vset & OMAP5_ABB_FUSE_ENABLE_MASK))

arch/arm/cpu/armv7/omap5/abb.c line 64

Quoted 10 lines
arch/arm/cpu/armv7/omap5/abb.c new file +10 -0
+		return -1;
+
+	/* prepare VSET value for LDOVBB mux register */
+	vset &= OMAP5_ABB_FUSE_VSET_MASK;
+	vset >>= ffs(OMAP5_ABB_FUSE_VSET_MASK) - 1;
+	vset <<= ffs(OMAP5_ABB_LDOVBBMPU_VSET_OUT_MASK) - 1;
+	vset |= OMAP5_ABB_LDOVBBMPU_MUX_CTRL_MASK;
+
+	/* setup LDOVBB using fused value */
+	clrsetbits_le32(ldovbb, vset, vset);

here as well -> please why clrbits need to be clearing all field - suggest looking in all usages.

Quoted 136 lines
arch/arm/cpu/armv7/omap5/abb.c new file +3 -0
+
+	return 0;
+}
arch/arm/include/asm/arch-omap3/omap3.h +7 -0
index 2b5e9ae..c57599a 100644
@@ -253,4 +253,11 @@ struct gpio {
 
 #define OMAP3_EMU_HAL_START_HAL_CRITICAL	4
 
+/* ABB settings */
+#define OMAP_ABB_SETTLING_TIME		30
+#define OMAP_ABB_CLOCK_CYCLES		8
+
+/* ABB tranxdone mask */
+#define OMAP_ABB_MPU_TXDONE_MASK	(0x1 << 26)
+
 #endif
arch/arm/include/asm/arch-omap4/omap.h +7 -0
index ad984da..559ad26 100644
@@ -170,6 +170,13 @@ struct s32ktimer {
 #define CH_FLAGS_CHFLASH	(0x1 << 2)
 #define CH_FLAGS_CHMMCSD	(0x1 << 3)
 
+/* ABB settings */
+#define OMAP_ABB_SETTLING_TIME		50
+#define OMAP_ABB_CLOCK_CYCLES		16
+
+/* ABB tranxdone mask */
+#define OMAP_ABB_MPU_TXDONE_MASK	(0x1 << 7)
+
 #ifndef __ASSEMBLY__
 struct omap_boot_parameters {
 	char *boot_message;
arch/arm/include/asm/arch-omap5/omap.h +13 -0
index 887fcaa..caa1234 100644
@@ -243,6 +243,19 @@ struct s32ktimer {
 #define SRCODE_OVERRIDE_SEL_XS_SHIFT	0
 #define SRCODE_OVERRIDE_SEL_XS_MASK	(1 << 0)
 
+/* ABB settings */
+#define OMAP_ABB_SETTLING_TIME		50
+#define OMAP_ABB_CLOCK_CYCLES		16
+
+/* ABB tranxdone mask */
+#define OMAP_ABB_MPU_TXDONE_MASK		(0x1 << 7)
+
+/* ABB efuse masks */
+#define OMAP5_ABB_FUSE_VSET_MASK		(0x1F << 24)
+#define OMAP5_ABB_FUSE_ENABLE_MASK		(0x1 << 29)
+#define OMAP5_ABB_LDOVBBMPU_MUX_CTRL_MASK	(0x1 << 10)
+#define OMAP5_ABB_LDOVBBMPU_VSET_OUT_MASK	(0x1f << 0)
+
 #ifndef __ASSEMBLY__
 struct srcomp_params {
 	s8 divide_factor;
arch/arm/include/asm/omap_common.h +22 -0
index 091ddb5..4892c0a 100644
@@ -240,6 +240,8 @@ struct prcm_regs {
 	u32 cm_l3init_fsusb_clkctrl;
 	u32 cm_l3init_ocp2scp1_clkctrl;
 
+	u32 prm_irqstatus_mpu_2;
+
 	/* cm2.l4per */
 	u32 cm_l4per_clkstctrl;
 	u32 cm_l4per_dynamicdep;
@@ -325,6 +327,8 @@ struct prcm_regs {
 	u32 prm_sldo_mpu_ctrl;
 	u32 prm_sldo_mm_setup;
 	u32 prm_sldo_mm_ctrl;
+	u32 prm_abbldo_mpu_setup;
+	u32 prm_abbldo_mpu_ctrl;
 
 	u32 cm_div_m4_dpll_core;
 	u32 cm_div_m5_dpll_core;
@@ -347,6 +351,7 @@ struct prcm_regs {
 
 struct omap_sys_ctrl_regs {
 	u32 control_status;
+	u32 control_std_fuse_opp_vdd_mpu_2;
 	u32 control_core_mmr_lock1;
 	u32 control_core_mmr_lock2;
 	u32 control_core_mmr_lock3;
@@ -416,6 +421,7 @@ struct omap_sys_ctrl_regs {
 	u32 control_port_emif2_sdram_config;
 	u32 control_emif1_sdram_config_ext;
 	u32 control_emif2_sdram_config_ext;
+	u32 control_wkup_ldovbb_mpu_voltage_ctrl;
 	u32 control_smart1nopmio_padconf_0;
 	u32 control_smart1nopmio_padconf_1;
 	u32 control_padconf_mode;
@@ -542,6 +548,9 @@ 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);
+void abb_setup(u32 fuse, u32 ldovbb, u32 setup, u32 control,
+	       u32 txdone, u32 txdone_mask, u32 opp);
+s8 abb_setup_ldovbb(u32 fuse, u32 ldovbb);
 
 /* Max value for DPLL multiplier M */
 #define OMAP_DPLL_MAX_N	127
@@ -552,6 +561,19 @@ void do_scale_vcore(u32 vcore_reg, u32 volt_mv, struct pmic_data *pmic);
 #define OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL	2
 #define OMAP_INIT_CONTEXT_UBOOT_AFTER_CH	3
 
+/* ABB */
+#define OMAP_ABB_NOMINAL_OPP		0
+#define OMAP_ABB_FAST_OPP		1
+#define OMAP_ABB_SLOW_OPP		3
+#define OMAP_ABB_CONTROL_FAST_OPP_SEL_MASK		(0x1 << 0)
+#define OMAP_ABB_CONTROL_SLOW_OPP_SEL_MASK		(0x1 << 1)
+#define OMAP_ABB_CONTROL_OPP_CHANGE_MASK		(0x1 << 2)
+#define OMAP_ABB_CONTROL_SR2_IN_TRANSITION_MASK		(0x1 << 6)
+#define OMAP_ABB_SETUP_SR2EN_MASK			(0x1 << 0)
+#define OMAP_ABB_SETUP_ACTIVE_FBB_SEL_MASK		(0x1 << 2)
+#define OMAP_ABB_SETUP_ACTIVE_RBB_SEL_MASK		(0x1 << 1)
+#define OMAP_ABB_SETUP_SR2_WTCNT_VALUE_MASK		(0xff << 8)
+
 static inline u32 omap_revision(void)
 {
 	extern u32 *const omap_si_rev;
Signature · 6 lines
1.7.9.5

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Signature · 2 lines
Regards,
Nishanth Menon
#3 lore raw

PATCH v2 1/2 OMAP3+: introduce generic ABB support

Hi,

Thank you for review.

On 05/17/2013 04:11 PM, Nishanth Menon wrote:

[snip]

Quoted 13 lines · Andrii Tseglytskyi

[...]

Review

Quoted 7 lines
(quoted diff) +7 -0
+	if (fuse && ldovbb) {
+		if (abb_setup_ldovbb(fuse, ldovbb))
+			return;
+	}
+
+	/* configure timings, based on oscillator value */
+	abb_setup_timings(setup);

Still missing txdone clear..
If txdone was set on entry, you'd escape a bit waiting for transition completion bit in SR2, However, by clearing TXDONE here, you can just wait for TXDONE.

We touch ABB first time here. I can add check/clear txdone here to double check that everything is fine,
but this may be superfluous.

Quoted 9 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+
+	/* select ABB type */
+	clrsetbits_le32(setup,
+			abb_type_mask | OMAP_ABB_SETUP_SR2EN_MASK,
+			abb_type_mask | OMAP_ABB_SETUP_SR2EN_MASK);

This is no better than set_bits! clearbits (addr, clr, set) -> the clr bits should clear *all* bits of the field. in this example ABB_TYPE should both be cleared, same in OPP_SEL.
See the following change on top of this series:

Yep. should be:

clrsetbits_le32(setup,
OMAP_ABB_SETUP_ACTIVE_FBB_SEL_MASK

|OMAP_ABB_SETUP_ACTIVE_RBB_SEL_MASK | OMAP_ABB_SETUP_SR2EN_MASK,
                    abb_type_mask | OMAP_ABB_SETUP_SR2EN_MASK)

But I propose to rework this in the following way:
- at the beginning of setup function clear both ABB registers (setup and control),

     writel(0, setup);
     writel(0, control);

- use setbits_le32 everywhere.

This guarantees that there will be no trash values in ABB registers and increases code readability.
Your opinion?

Quoted 55 lines
arch/arm/cpu/armv7/omap-common/abb.c +12 -4
index 73eadb2..31332fb 100644
@@ -115,14 +115,22 @@ void abb_setup(u32 fuse, u32 ldovbb, u32 setup, u32 control,
  	/* configure timings, based on oscillator value */
  	abb_setup_timings(setup);
 
+	/*
+	 * Clear any pending ABB tranxdones before we wait for txdone.
+	 * We do not know the mode in which we have been handed over
+	 * the system (warm/cold reboot), ROM code operations etc..
+	 * on a cold boot, we do not expect to see this set.
+	 */
+	setbits_le32(txdone, OMAP_ABB_MPU_TXDONE_MASK);
+
  	/* select ABB type */
-	clrsetbits_le32(setup,
-			abb_type_mask | OMAP_ABB_SETUP_SR2EN_MASK,
+	clrsetbits_le32(setup, OMAP_ABB_SETUP_ABB_SEL_MASK |
+			OMAP_ABB_SETUP_SR2EN_MASK,
  			abb_type_mask | OMAP_ABB_SETUP_SR2EN_MASK);
 
  	/* initiate ABB ldo change */
-	clrsetbits_le32(control,
-			opp_sel_mask | OMAP_ABB_CONTROL_OPP_CHANGE_MASK,
+	clrsetbits_le32(control, OMAP_ABB_CONTROL_OPP_SEL_MASK |
+			OMAP_ABB_CONTROL_OPP_CHANGE_MASK,
  			opp_sel_mask | OMAP_ABB_CONTROL_OPP_CHANGE_MASK);
 
  	/* wait until transition complete */
arch/arm/include/asm/omap_common.h +5 -1
index 4892c0a..c2fc180 100644
@@ -565,13 +565,17 @@ s8 abb_setup_ldovbb(u32 fuse, u32 ldovbb);
  #define OMAP_ABB_NOMINAL_OPP		0
  #define OMAP_ABB_FAST_OPP		1
  #define OMAP_ABB_SLOW_OPP		3
+#define OMAP_ABB_CONTROL_OPP_SEL_MASK			(0x3 << 0)
  #define OMAP_ABB_CONTROL_FAST_OPP_SEL_MASK		(0x1 << 0)
-#define OMAP_ABB_CONTROL_SLOW_OPP_SEL_MASK		(0x1 << 1)
+#define OMAP_ABB_CONTROL_SLOW_OPP_SEL_MASK		(0x3 << 0)
+#define OMAP_ABB_CONTROL_NOMINAL_OPP_SEL_MASK		(0x0 << 0)
  #define OMAP_ABB_CONTROL_OPP_CHANGE_MASK		(0x1 << 2)
  #define OMAP_ABB_CONTROL_SR2_IN_TRANSITION_MASK		(0x1 << 6)
  #define OMAP_ABB_SETUP_SR2EN_MASK			(0x1 << 0)
  #define OMAP_ABB_SETUP_ACTIVE_FBB_SEL_MASK		(0x1 << 2)
  #define OMAP_ABB_SETUP_ACTIVE_RBB_SEL_MASK		(0x1 << 1)
+#define OMAP_ABB_SETUP_ABB_SEL_MASK			(OMAP_ABB_SETUP_ACTIVE_RBB_SEL_MASK | \
+							 OMAP_ABB_SETUP_ACTIVE_FBB_SEL_MASK)
  #define OMAP_ABB_SETUP_SR2_WTCNT_VALUE_MASK		(0xff << 8)
 
  static inline u32 omap_revision(void)
Quoted 11 lines

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+	/* initiate ABB ldo change */
+	clrsetbits_le32(control,
+			opp_sel_mask | OMAP_ABB_CONTROL_OPP_CHANGE_MASK,
+			opp_sel_mask | OMAP_ABB_CONTROL_OPP_CHANGE_MASK);
+
+	/* wait until transition complete */
+	if (!wait_on_value(OMAP_ABB_CONTROL_SR2_IN_TRANSITION_MASK, 0,
+			   (void *)control, LDELAY))
+		puts("Error: ABB is in transition\n");

superfluous if you wait for txdone.

Agree. Can be removed.

[snip]

Quoted 4 lines
arch/arm/include/asm/omap_common.h +2 -0
+	/* setup LDOVBB using fused value */
+	clrsetbits_le32(ldovbb, vset, vset);

here as well -> please why clrbits need to be clearing all field - suggest looking in all usages.

This is a mistake :( Should be clrsetbits_le32(ldovbb, OMAP5_ABB_LDOVBBMPU_VSET_OUT_MASK, vset) Thank you for catching this!

Quoted 7 lines
Quoted 7 lines
(quoted diff) +3 -0
+
+	return 0;
+}

____________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

[snip]

Regards,
Andrii

#4 lore raw

PATCH v2 1/2 OMAP3+: introduce generic ABB support

Quoted 21 lines · Andrii Tseglytskyi

On 05/17/2013 04:11 PM, Nishanth Menon wrote:

[snip]

Quoted 12 lines · Andrii Tseglytskyi

[...]

Review

Quoted 8 lines
(quoted diff) +7 -0
+       if (fuse && ldovbb) {
+               if (abb_setup_ldovbb(fuse, ldovbb))
+                       return;
+       }
+
+       /* configure timings, based on oscillator value */
+       abb_setup_timings(setup);
Quoted 4 lines

Still missing txdone clear..
If txdone was set on entry, you'd escape a bit waiting for transition completion bit in SR2, However, by clearing TXDONE here, you can just wait for TXDONE.

Quoted 3 lines

We touch ABB first time here. I can add check/clear txdone here to double check that everything is fine,
but this may be superfluous.

PRM register may be reset OR not depending on type of reset and SoC, Though this might be the first line of code to execute in bootloader that touches this register, there is no guarentee that there is no pending TRANXDONE interrupt in the register. if there is TRANXDONE interrupt, it is not something we desire. Hence the suggestion to clear.

Quoted 21 lines
Quoted 10 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+
+       /* select ABB type */
+       clrsetbits_le32(setup,
+                       abb_type_mask | OMAP_ABB_SETUP_SR2EN_MASK,
+                       abb_type_mask | OMAP_ABB_SETUP_SR2EN_MASK);

This is no better than set_bits! clearbits (addr, clr, set) -> the clr bits should clear *all* bits of the field. in this example ABB_TYPE should both be cleared, same in OPP_SEL.
See the following change on top of this series:

Yep. should be:

clrsetbits_le32(setup,
OMAP_ABB_SETUP_ACTIVE_FBB_SEL_MASK

|OMAP_ABB_SETUP_ACTIVE_RBB_SEL_MASK | OMAP_ABB_SETUP_SR2EN_MASK,
                   abb_type_mask | OMAP_ABB_SETUP_SR2EN_MASK)

But I propose to rework this in the following way:
- at the beginning of setup function clear both ABB registers (setup and control),

Quoted 9 lines
    writel(0, setup);
    writel(0, control);

- use setbits_le32 everywhere.

This guarantees that there will be no trash values in ABB registers and increases code readability.
Your opinion?

Case 1) if we have been given control by another bootloader which had already setup ABB, writing 0 will not impact the current setting as the transition trigger is OPP_CHANGE
case 2) we are the only bootloader in the system. writing 0 is ok as well.

So, am ok if you reset the registers prior to programming them. --
Regards,
Nishanth Menon

#5 lore raw

PATCH v2 2/2 OMAP5: add ABB setup for MPU voltage domain

In reply to Andrii Tseglytskyi

Patch adds a call of abb_setup() function, and proper registers definitions needed for ABB setup sequence. ABB is initialized for MPU voltage domain.

---
 arch/arm/cpu/armv7/omap-common/clocks-common.c |    9 +++++++++
 arch/arm/cpu/armv7/omap5/prcm-regs.c           |    7 +++++++
 2 files changed, 16 insertions(+)
arch/arm/cpu/armv7/omap-common/clocks-common.c +9 -0
index 2b955c7..bdecaf8 100644
@@ -533,6 +533,15 @@ void scale_vcores(struct vcores_data const *vcores)
 	do_scale_vcore(vcores->mpu.addr, vcores->mpu.value,
 					  vcores->mpu.pmic);
 
+	/* Configure MPU ABB LDO after scale */
+	abb_setup((*ctrl)->control_std_fuse_opp_vdd_mpu_2,
+		  (*ctrl)->control_wkup_ldovbb_mpu_voltage_ctrl,
+		  (*prcm)->prm_abbldo_mpu_setup,
+		  (*prcm)->prm_abbldo_mpu_ctrl,
+		  (*prcm)->prm_irqstatus_mpu_2,
+		  OMAP_ABB_MPU_TXDONE_MASK,
+		  OMAP_ABB_FAST_OPP);
+
 	do_scale_vcore(vcores->mm.addr, vcores->mm.value,
 					  vcores->mm.pmic);
 
arch/arm/cpu/armv7/omap5/prcm-regs.c +7 -0
index b8a61fe..b4b624e 100644
@@ -311,6 +311,7 @@ struct prcm_regs const omap5_es1_prcm = {
 
 struct omap_sys_ctrl_regs const omap5_ctrl = {
 	.control_status				= 0x4A002134,
+	.control_std_fuse_opp_vdd_mpu_2		= 0x4A0021B4,
 	.control_paconf_global			= 0x4A002DA0,
 	.control_paconf_mode			= 0x4A002DA4,
 	.control_smart1io_padconf_0		= 0x4A002DA8,
@@ -358,6 +359,7 @@ struct omap_sys_ctrl_regs const omap5_ctrl = {
 	.control_port_emif2_sdram_config	= 0x4AE0C118,
 	.control_emif1_sdram_config_ext		= 0x4AE0C144,
 	.control_emif2_sdram_config_ext		= 0x4AE0C148,
+	.control_wkup_ldovbb_mpu_voltage_ctrl	= 0x4AE0C318,
 	.control_smart1nopmio_padconf_0		= 0x4AE0CDA0,
 	.control_smart1nopmio_padconf_1		= 0x4AE0CDA4,
 	.control_padconf_mode			= 0x4AE0CDA8,
@@ -709,6 +711,9 @@ struct prcm_regs const omap5_es2_prcm = {
 	.cm_l3init_fsusb_clkctrl = 0x4a0096d0,
 	.cm_l3init_ocp2scp1_clkctrl = 0x4a0096e0,
 
+	/* prm irqstatus regs */
+	.prm_irqstatus_mpu_2 = 0x4ae06014,
+
 	/* l4 wkup regs */
 	.cm_abe_pll_ref_clksel = 0x4ae0610c,
 	.cm_sys_clksel = 0x4ae06110,
@@ -739,6 +744,8 @@ struct prcm_regs const omap5_es2_prcm = {
 	.prm_sldo_mpu_ctrl = 0x4ae07cd0,
 	.prm_sldo_mm_setup = 0x4ae07cd4,
 	.prm_sldo_mm_ctrl = 0x4ae07cd8,
+	.prm_abbldo_mpu_setup = 0x4ae07cdc,
+	.prm_abbldo_mpu_ctrl = 0x4ae07ce0,
 };
 
 struct prcm_regs const dra7xx_prcm = {
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v2 2/2 OMAP5: add ABB setup for MPU voltage domain

Quoted 72 lines · Andrii Tseglytskyi

Patch adds a call of abb_setup() function, and proper registers definitions needed for ABB setup sequence. ABB is initialized for MPU voltage domain.

---
 arch/arm/cpu/armv7/omap-common/clocks-common.c |    9 +++++++++
 arch/arm/cpu/armv7/omap5/prcm-regs.c           |    7 +++++++
 2 files changed, 16 insertions(+)
arch/arm/cpu/armv7/omap-common/clocks-common.c +9 -0
index 2b955c7..bdecaf8 100644
@@ -533,6 +533,15 @@ void scale_vcores(struct vcores_data const *vcores)
 	do_scale_vcore(vcores->mpu.addr, vcores->mpu.value,
 					  vcores->mpu.pmic);
 
+	/* Configure MPU ABB LDO after scale */
+	abb_setup((*ctrl)->control_std_fuse_opp_vdd_mpu_2,
+		  (*ctrl)->control_wkup_ldovbb_mpu_voltage_ctrl,
+		  (*prcm)->prm_abbldo_mpu_setup,
+		  (*prcm)->prm_abbldo_mpu_ctrl,
+		  (*prcm)->prm_irqstatus_mpu_2,
+		  OMAP_ABB_MPU_TXDONE_MASK,
+		  OMAP_ABB_FAST_OPP);
+
 	do_scale_vcore(vcores->mm.addr, vcores->mm.value,
 					  vcores->mm.pmic);
 
arch/arm/cpu/armv7/omap5/prcm-regs.c +7 -0
index b8a61fe..b4b624e 100644
@@ -311,6 +311,7 @@ struct prcm_regs const omap5_es1_prcm = {
 
 struct omap_sys_ctrl_regs const omap5_ctrl = {
 	.control_status				= 0x4A002134,
+	.control_std_fuse_opp_vdd_mpu_2		= 0x4A0021B4,
 	.control_paconf_global			= 0x4A002DA0,
 	.control_paconf_mode			= 0x4A002DA4,
 	.control_smart1io_padconf_0		= 0x4A002DA8,
@@ -358,6 +359,7 @@ struct omap_sys_ctrl_regs const omap5_ctrl = {
 	.control_port_emif2_sdram_config	= 0x4AE0C118,
 	.control_emif1_sdram_config_ext		= 0x4AE0C144,
 	.control_emif2_sdram_config_ext		= 0x4AE0C148,
+	.control_wkup_ldovbb_mpu_voltage_ctrl	= 0x4AE0C318,
 	.control_smart1nopmio_padconf_0		= 0x4AE0CDA0,
 	.control_smart1nopmio_padconf_1		= 0x4AE0CDA4,
 	.control_padconf_mode			= 0x4AE0CDA8,
@@ -709,6 +711,9 @@ struct prcm_regs const omap5_es2_prcm = {
 	.cm_l3init_fsusb_clkctrl = 0x4a0096d0,
 	.cm_l3init_ocp2scp1_clkctrl = 0x4a0096e0,
 
+	/* prm irqstatus regs */
+	.prm_irqstatus_mpu_2 = 0x4ae06014,
+
 	/* l4 wkup regs */
 	.cm_abe_pll_ref_clksel = 0x4ae0610c,
 	.cm_sys_clksel = 0x4ae06110,
@@ -739,6 +744,8 @@ struct prcm_regs const omap5_es2_prcm = {
 	.prm_sldo_mpu_ctrl = 0x4ae07cd0,
 	.prm_sldo_mm_setup = 0x4ae07cd4,
 	.prm_sldo_mm_ctrl = 0x4ae07cd8,
+	.prm_abbldo_mpu_setup = 0x4ae07cdc,
+	.prm_abbldo_mpu_ctrl = 0x4ae07ce0,
 };
 
 struct prcm_regs const dra7xx_prcm = {
Signature · 1 line
1.7.9.5

Overall ok with this, though, I'd like to wait a week before acking this formally(I should get samples where I can test this out) - further there is comments that I'd like to share on #1/2

Signature · 2 lines
Regards,
Nishanth Menon