Re: [U-Boot] [PATCH v1 1/2] OMAP3+: introduce generic ABB support

2013-05-17 Thread Nishanth Menon
On 10:08-20130515, Tom Rini wrote:
 On Wed, May 15, 2013 at 03:42:45PM +0300, Andrii Tseglytskyi wrote:
  Hi,
  
  Tom, Nishant,  could you please review this series ?
 
 Reviewed-by: Tom Rini tr...@ti.com
I think the right thread was:
PATCH v02 0/2] OMAP3+: introduce generic Adaptive Body Bias Support
? seems line V2 is the updated series..


-- 
Regards,
Nishanth Menon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v1 1/2] OMAP3+: introduce generic ABB support

2013-05-15 Thread Andrii Tseglytskyi

Hi,

Tom, Nishant,  could you please review this series ?

Thank you in advance.
Regards,
Andrii

On 05/13/2013 05:15 PM, Andrii Tseglytskyi wrote:

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.

Signed-off-by: Andrii Tseglytskyi andrii.tseglyts...@ti.com
---
  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  |   65 +++
  arch/arm/include/asm/arch-omap3/omap3.h |9 ++
  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

diff --git a/arch/arm/cpu/armv7/omap-common/Makefile 
b/arch/arm/cpu/armv7/omap-common/Makefile
index 55e82ba..c4b9809 100644
--- a/arch/arm/cpu/armv7/omap-common/Makefile
+++ b/arch/arm/cpu/armv7/omap-common/Makefile
@@ -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),)

diff --git a/arch/arm/cpu/armv7/omap-common/abb.c 
b/arch/arm/cpu/armv7/omap-common/abb.c
new file mode 100644
index 000..7ade110
--- /dev/null
+++ b/arch/arm/cpu/armv7/omap-common/abb.c
@@ -0,0 +1,139 @@
+/*
+ *
+ * Adaptive Body Bias programming sequence for OMAP family
+ *
+ * (C) Copyright 2013
+ * Texas Instruments, www.ti.com
+ *
+ * Andrii Tseglytskyi R andrii.tseglyts...@ti.com
+ *
+ * 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
+#include asm/arch/sys_proto.h
+
+__weak s8 abb_setup_ldovbb(u32 fuse, u32 ldovbb)
+{
+   return -1;
+}
+
+static void abb_setup_timings(u32 setup)
+{
+   u32 sys_rate, sr2_cnt, clk_cycles;
+
+   /*
+* SR2_WTCNT_VALUE is the settling time for the ABB ldo after a
+* transition and must be programmed with the correct time at boot.
+* The value programmed into the register is the number of SYS_CLK
+* clock cycles that match a given wall time profiled for the ldo.
+* This value depends on:
+* settling time of ldo in micro-seconds (varies per OMAP family),
+* of clock cycles per SYS_CLK period (varies per OMAP family),
+* the SYS_CLK frequency in MHz (varies per board)
+* The formula is:
+*
+* ldo settling time (in micro-seconds)
+* SR2_WTCNT_VALUE = --
+*  (# system clock cycles) * (sys_clk period)
+*
+* Put another way:
+*
+* SR2_WTCNT_VALUE = settling time / (# SYS_CLK cycles / SYS_CLK rate))
+*
+* To avoid dividing by zero multiply both # clock cycles and
+* settling time by 10 such that the final result is the one we want.
+*/
+
+   /* calculate SR2_WTCNT_VALUE */
+   sys_rate = DIV_ROUND(V_OSCK, 100);
+   clk_cycles = DIV_ROUND(OMAP_ABB_CLOCK_CYCLES * 10, sys_rate);
+   sr2_cnt = DIV_ROUND(OMAP_ABB_SETTLING_TIME * 10, clk_cycles);
+
+   setbits_le32(setup,
+sr2_cnt  (ffs(OMAP_ABB_SETUP_SR2_WTCNT_VALUE_MASK) - 1));
+}
+
+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)
+   

Re: [U-Boot] [PATCH v1 1/2] OMAP3+: introduce generic ABB support

2013-05-15 Thread Tom Rini
On Wed, May 15, 2013 at 03:42:45PM +0300, Andrii Tseglytskyi wrote:
 Hi,
 
 Tom, Nishant,  could you please review this series ?

Reviewed-by: Tom Rini tr...@ti.com

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v1 1/2] OMAP3+: introduce generic ABB support

2013-05-13 Thread Nishanth Menon
Few minor comments follow:
On 17:15-20130513, Andrii Tseglytskyi wrote:
snip
 diff --git a/arch/arm/cpu/armv7/omap-common/abb.c 
 b/arch/arm/cpu/armv7/omap-common/abb.c
 new file mode 100644
 index 000..7ade110
 --- /dev/null
 +++ b/arch/arm/cpu/armv7/omap-common/abb.c
 @@ -0,0 +1,139 @@
snip
 + /* - On OMAP5+ silicons some ABB setting are fused
/*
 *
please
 +  *  in corresponding OPP control registers. Also additional
 +  *  setup for LDOVBB is required. Initialization
 +  *  sequence contains specific part which handles this.
 +  *  If function call fails - return quitely, it means
 +  *  no ABB is required for silicon.
 +  *
 +  * - OMAP3 and OMAP4 don't have any fused settings for ABB.
 +  *   EFUSE and LDOVBB registers are also not defined for them.
 +  *   ABB will be initialized in the common way without
 +  *   ldovbb setup.
OMAP4 does have ABB efuse offset for OPP_TURBO. LDOVBB override is not
used. please rephrase accordingly.
 +  */
 + if (fuse  ldovbb) {
 + if (abb_setup_ldovbb(fuse, ldovbb))
 + return;
 + }
snip
 +s8 abb_setup_ldovbb(u32 fuse, u32 ldovbb)
 +{
 + u32 vset;
 +
 + /* ABB parameters must be properly fused
 +  * otherwise ABB should be disabled */
please fix comment style.
 + vset = readl(fuse);
 + if (!(vset  OMAP5_ABB_FUSE_ENABLE_MASK))
 + 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);
 +
 + return 0;
 +}
 diff --git a/arch/arm/include/asm/arch-omap3/omap3.h 
 b/arch/arm/include/asm/arch-omap3/omap3.h
 index 2b5e9ae..66361d5 100644
 --- a/arch/arm/include/asm/arch-omap3/omap3.h
 +++ b/arch/arm/include/asm/arch-omap3/omap3.h
 @@ -253,4 +253,13 @@ struct gpio {
  
  #define OMAP3_EMU_HAL_START_HAL_CRITICAL 4
  
 +/*
 + * ABB settings
 + */
could be one line :)
 +#define OMAP_ABB_SETTLING_TIME   30
 +#define OMAP_ABB_CLOCK_CYCLES8
snip
otherwise looks ok to me.


-- 
Regards,
Nishanth Menon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v1 1/2] OMAP3+: introduce generic ABB support

2013-05-13 Thread Andrii Tseglytskyi

On 05/13/2013 05:58 PM, Nishanth Menon wrote:

Few minor comments follow:
On 17:15-20130513, Andrii Tseglytskyi wrote:
snip

diff --git a/arch/arm/cpu/armv7/omap-common/abb.c 
b/arch/arm/cpu/armv7/omap-common/abb.c
new file mode 100644
index 000..7ade110
--- /dev/null
+++ b/arch/arm/cpu/armv7/omap-common/abb.c
@@ -0,0 +1,139 @@

snip

+   /* - On OMAP5+ silicons some ABB setting are fused

/*
  *
please

+*  in corresponding OPP control registers. Also additional
+*  setup for LDOVBB is required. Initialization
+*  sequence contains specific part which handles this.
+*  If function call fails - return quitely, it means
+*  no ABB is required for silicon.
+*
+* - OMAP3 and OMAP4 don't have any fused settings for ABB.
+*   EFUSE and LDOVBB registers are also not defined for them.
+*   ABB will be initialized in the common way without
+*   ldovbb setup.

OMAP4 does have ABB efuse offset for OPP_TURBO. LDOVBB override is not
used. please rephrase accordingly.


OK.


+*/
+   if (fuse  ldovbb) {
+   if (abb_setup_ldovbb(fuse, ldovbb))
+   return;
+   }

snip

+s8 abb_setup_ldovbb(u32 fuse, u32 ldovbb)
+{
+   u32 vset;
+
+   /* ABB parameters must be properly fused
+* otherwise ABB should be disabled */

please fix comment style.


OK


+   vset = readl(fuse);
+   if (!(vset  OMAP5_ABB_FUSE_ENABLE_MASK))
+   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);
+
+   return 0;
+}
diff --git a/arch/arm/include/asm/arch-omap3/omap3.h 
b/arch/arm/include/asm/arch-omap3/omap3.h
index 2b5e9ae..66361d5 100644
--- a/arch/arm/include/asm/arch-omap3/omap3.h
+++ b/arch/arm/include/asm/arch-omap3/omap3.h
@@ -253,4 +253,13 @@ struct gpio {
  
  #define OMAP3_EMU_HAL_START_HAL_CRITICAL	4
  
+/*

+ * ABB settings
+ */

could be one line :)
Yeah it could. The reason why I did this - all comments in this file 
have such style.

Anyway, agree with you.



+#define OMAP_ABB_SETTLING_TIME 30
+#define OMAP_ABB_CLOCK_CYCLES  8

snip
otherwise looks ok to me.




Thank you,

Regards,
Andrii
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot