Skip to contentSkip to conversation

pmic:pfuze support buck regulator mode switch

PATCH Superseded Peng Fan 4 participants 8 messages Jan 16, 2015 – Jan 24, 2015

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

v4 cover pmic:pfuze support buck regulator mode switch

Hi, Przemyslaw

There is a few return value comments that from Fabio, I correct them and send out v4 version. Others are same to the v1 version patch set. If this patch set is fine, please give you Acked-by. Sorry for the troubles.

This patch set is to support buck regulator can
working in different switching modes. To improve
system efficiency the buck regulators can operate
in different switching modes.

patch 1/3 is to add related bit definitions and registers. patch 2/3 is to implement the switching mode init function. patch 3/3 is to add related mode init function in board code.

mx6slevk board is not included in this patch set, since power and i2c interface are not implemented for it. Future patch will cover this to add PAD setting, power_init_board and etc.

Peng Fan (3):
pmic:pfuz100 add switch mode and more registers
pmic:pfuze implement pmic_mode_init
imx:mx6 set normal APS and standby PFM mode

 board/freescale/common/pfuze.c                | 36 ++++++++++++++++++
 board/freescale/common/pfuze.h                |  1 +
 board/freescale/mx6qsabreauto/mx6qsabreauto.c |  6 +++
 board/freescale/mx6sabresd/mx6sabresd.c       |  6 ++-
 board/freescale/mx6sxsabresd/mx6sxsabresd.c   |  6 ++-
 include/power/pfuze100_pmic.h                 | 53 +++++++++++++++++++++++++++
 6 files changed, 106 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.4
author
#1 lore raw

PATCH v4 1/3 pmic:pfuz100 add switch mode and more registers

Add more pfuze register offset.
And switch mode definition.

---

Changes v4:
none

Changes v3:
none

Changes v2:
none

 include/power/pfuze100_pmic.h | 53 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
include/power/pfuze100_pmic.h +53 -0
index 1118489..7474afb 100644
@@ -16,14 +16,34 @@ enum {
 
 	PFUZE100_SW1ABVOL	= 0x20,
 	PFUZE100_SW1ABSTBY	= 0x21,
+	PFUZE100_SW1ABOFF	= 0x22,
+	PFUZE100_SW1ABMODE	= 0x23,
 	PUZE_100_SW1ABCONF	= 0x24,
 	PFUZE100_SW1CVOL	= 0x2e,
 	PFUZE100_SW1CSTBY	= 0x2f,
+	PFUZE100_SW1COFF	= 0x30,
+	PFUZE100_SW1CMODE	= 0x31,
 	PFUZE100_SW1CCONF	= 0x32,
 	PFUZE100_SW2VOL		= 0x35,
+	PFUZE100_SW2STBY	= 0x36,
+	PFUZE100_SW2OFF		= 0x37,
+	PFUZE100_SW2MODE	= 0x38,
+	PFUZE100_SW2CONF	= 0x39,
 	PFUZE100_SW3AVOL	= 0x3c,
+	PFUZE100_SW3ASTBY	= 0x3D,
+	PFUZE100_SW3AOFF	= 0x3E,
+	PFUZE100_SW3AMODE	= 0x3F,
+	PFUZE100_SW3ACONF	= 0x40,
 	PFUZE100_SW3BVOL	= 0x43,
+	PFUZE100_SW3BSTBY	= 0x44,
+	PFUZE100_SW3BOFF	= 0x45,
+	PFUZE100_SW3BMODE	= 0x46,
+	PFUZE100_SW3BCONF	= 0x47,
 	PFUZE100_SW4VOL		= 0x4a,
+	PFUZE100_SW4STBY	= 0x4b,
+	PFUZE100_SW4OFF		= 0x4c,
+	PFUZE100_SW4MODE	= 0x4d,
+	PFUZE100_SW4CONF	= 0x4e,
 	PFUZE100_SWBSTCON1	= 0x66,
 	PFUZE100_VREFDDRCON	= 0x6a,
 	PFUZE100_VSNVSVOL	= 0x6b,
@@ -177,5 +197,38 @@ enum {
 #define SWBST_MODE_AUTO	(2 << 2)
 #define SWBST_MODE_APS	(2 << 3)
 
+/*
+ * Regulator Mode Control
+ *
+ * OFF: The regulator is switched off and the output voltage is discharged.
+ * PFM: In this mode, the regulator is always in PFM mode, which is useful
+ *     @light loads for optimized efficiency.
+ * PWM: In this mode, the regulator is always in PWM mode operation
+ *	regardless of load conditions.
+ * APS: In this mode, the regulator moves automatically between pulse
+ *	skipping mode and PWM mode depending on load conditions.
+ *
+ * SWxMODE[3:0]
+ * Normal Mode  |  Standby Mode	|      value
+ *   OFF		OFF		0x0
+ *   PWM		OFF		0x1
+ *   PFM		OFF		0x3
+ *   APS		OFF		0x4
+ *   PWM		PWM		0x5
+ *   PWM		APS		0x6
+ *   APS		APS		0x8
+ *   APS		PFM		0xc
+ *   PWM		PFM		0xd
+ */
+#define OFF_OFF		0x0
+#define PWM_OFF		0x1
+#define PFM_OFF		0x3
+#define APS_OFF		0x4
+#define PWM_PWM		0x5
+#define PWM_APS		0x6
+#define APS_APS		0x8
+#define APS_PFM		0xc
+#define PWM_PFM		0xd
+
 int power_pfuze100_init(unsigned char bus);
 #endif
Signature · 1 line
1.8.4
#2 lore raw

PATCH v4 1/3 pmic:pfuz100 add switch mode and more registers

Hi Peng,

Quoted 87 lines · Peng Fan

Add more pfuze register offset.
And switch mode definition.

---

Changes v4:
none

Changes v3:
none

Changes v2:
none

 include/power/pfuze100_pmic.h | 53 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
include/power/pfuze100_pmic.h +45 -0
index 1118489..7474afb 100644
@@ -16,14 +16,34 @@ enum {
 
 	PFUZE100_SW1ABVOL	= 0x20,
 	PFUZE100_SW1ABSTBY	= 0x21,
+	PFUZE100_SW1ABOFF	= 0x22,
+	PFUZE100_SW1ABMODE	= 0x23,
 	PUZE_100_SW1ABCONF	= 0x24,
 	PFUZE100_SW1CVOL	= 0x2e,
 	PFUZE100_SW1CSTBY	= 0x2f,
+	PFUZE100_SW1COFF	= 0x30,
+	PFUZE100_SW1CMODE	= 0x31,
 	PFUZE100_SW1CCONF	= 0x32,
 	PFUZE100_SW2VOL		= 0x35,
+	PFUZE100_SW2STBY	= 0x36,
+	PFUZE100_SW2OFF		= 0x37,
+	PFUZE100_SW2MODE	= 0x38,
+	PFUZE100_SW2CONF	= 0x39,
 	PFUZE100_SW3AVOL	= 0x3c,
+	PFUZE100_SW3ASTBY	= 0x3D,
+	PFUZE100_SW3AOFF	= 0x3E,
+	PFUZE100_SW3AMODE	= 0x3F,
+	PFUZE100_SW3ACONF	= 0x40,
 	PFUZE100_SW3BVOL	= 0x43,
+	PFUZE100_SW3BSTBY	= 0x44,
+	PFUZE100_SW3BOFF	= 0x45,
+	PFUZE100_SW3BMODE	= 0x46,
+	PFUZE100_SW3BCONF	= 0x47,
 	PFUZE100_SW4VOL		= 0x4a,
+	PFUZE100_SW4STBY	= 0x4b,
+	PFUZE100_SW4OFF		= 0x4c,
+	PFUZE100_SW4MODE	= 0x4d,
+	PFUZE100_SW4CONF	= 0x4e,
 	PFUZE100_SWBSTCON1	= 0x66,
 	PFUZE100_VREFDDRCON	= 0x6a,
 	PFUZE100_VSNVSVOL	= 0x6b,
@@ -177,5 +197,38 @@ enum {
 #define SWBST_MODE_AUTO	(2 << 2)
 #define SWBST_MODE_APS	(2 << 3)
 
+/*
+ * Regulator Mode Control
+ *
+ * OFF: The regulator is switched off and the output voltage is discharged.
+ * PFM: In this mode, the regulator is always in PFM mode, which is useful
+ *      at light loads for optimized efficiency.
+ * PWM: In this mode, the regulator is always in PWM mode operation
+ *	regardless of load conditions.
+ * APS: In this mode, the regulator moves automatically between pulse
+ *	skipping mode and PWM mode depending on load conditions.
+ *
+ * SWxMODE[3:0]
+ * Normal Mode  |  Standby Mode	|      value
+ *   OFF		OFF		0x0
+ *   PWM		OFF		0x1
+ *   PFM		OFF		0x3
+ *   APS		OFF		0x4
+ *   PWM		PWM		0x5
+ *   PWM		APS		0x6
+ *   APS		APS		0x8
+ *   APS		PFM		0xc
+ *   PWM		PFM		0xd
+ */
+#define OFF_OFF		0x0
+#define PWM_OFF		0x1

include/power/pfuze100_pmic.h enum { · line 234

Quoted 10 lines
include/power/pfuze100_pmic.h +8 -0
+#define PFM_OFF		0x3
+#define APS_OFF		0x4
+#define PWM_PWM		0x5
+#define PWM_APS		0x6
+#define APS_APS		0x8
+#define APS_PFM		0xc
+#define PWM_PFM		0xd
+
 int power_pfuze100_init(unsigned char bus);
 #endif

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
author
#3 lore raw

PATCH v4 2/3 pmic:pfuze implement pmic_mode_init

In reply to Peng Fan

This patch is to implement pmic_mode_init function, and add prototype in header file.

This function is to set switching mode for pmic buck regulators to improve system efficiency.

Mode:
OFF: The regulator is switched off and the output voltage is discharged.
PFM: In this mode, the regulator is always in PFM mode, which
is useful at light loads for optimized efficiency.
PWM: In this mode, the regulator is always in PWM mode operation
regardless of load conditions.
APS: In this mode, the regulator moves automatically between
pulse skipping mode and PWM mode depending on load conditions.

---

Changes v4:
Take Fabio's comments, fix return value using -EINVAL when error.

Changes v3:
delete the new feature, it is fine to use the original v1 patch version

Changes v2:
implement new feature to configure one regulator

 board/freescale/common/pfuze.c | 36 ++++++++++++++++++++++++++++++++++++
 board/freescale/common/pfuze.h |  1 +
 2 files changed, 37 insertions(+)
board/freescale/common/pfuze.c +36 -0
index 2cd1794..c2a0105 100644
@@ -8,6 +8,42 @@
 #include <power/pmic.h>
 #include <power/pfuze100_pmic.h>
 
+int pfuze_mode_init(struct pmic *p, u32 mode)
+{
+	unsigned char offset, i, switch_num;
+	u32 id, ret;
+
+	pmic_reg_read(p, PFUZE100_DEVICEID, &id);
+	id = id & 0xf;
+
+	if (id == 0) {
+		switch_num = 6;
+		offset = PFUZE100_SW1CMODE;
+	} else if (id == 1) {
+		switch_num = 4;
+		offset = PFUZE100_SW2MODE;
+	} else {
+		printf("Not supported, id=%d\n", id);
+		return -EINVAL;
+	}
+
+	ret = pmic_reg_write(p, PFUZE100_SW1ABMODE, mode);
+	if (ret < 0) {
+		printf("Set SW1AB mode error!\n");
+		return ret;
+	}
+
+	for (i = 0; i < switch_num - 1; i++) {
+		ret = pmic_reg_write(p, offset + i * 7, mode);
+		if (ret < 0) {
+			printf("Set switch%x mode error!\n", offset + i * 7);
+			return ret;
+		}
+	}
+
+	return ret;
+}
+
 struct pmic *pfuze_common_init(unsigned char i2cbus)
 {
 	struct pmic *p;
board/freescale/common/pfuze.h +1 -0
index 7a4126c..53cfc99 100644
@@ -8,5 +8,6 @@
 #define __PFUZE_BOARD_HELPER__
 
 struct pmic *pfuze_common_init(unsigned char i2cbus);
+int pfuze_mode_init(struct pmic *p, u32 mode);
 
 #endif
Signature · 1 line
1.8.4
#4 lore raw

PATCH v4 2/3 pmic:pfuze implement pmic_mode_init

Quoted 56 lines · Peng Fan

This patch is to implement pmic_mode_init function, and add prototype in header file.

This function is to set switching mode for pmic buck regulators to improve system efficiency.

Mode:
OFF: The regulator is switched off and the output voltage is discharged.
PFM: In this mode, the regulator is always in PFM mode, which
is useful at light loads for optimized efficiency.
PWM: In this mode, the regulator is always in PWM mode operation
regardless of load conditions.
APS: In this mode, the regulator moves automatically between
pulse skipping mode and PWM mode depending on load conditions.

---

Changes v4:
Take Fabio's comments, fix return value using -EINVAL when error.

Changes v3:
delete the new feature, it is fine to use the original v1 patch version

Changes v2:
implement new feature to configure one regulator

 board/freescale/common/pfuze.c | 36 ++++++++++++++++++++++++++++++++++++
 board/freescale/common/pfuze.h |  1 +
 2 files changed, 37 insertions(+)
board/freescale/common/pfuze.c +17 -0
index 2cd1794..c2a0105 100644
@@ -8,6 +8,42 @@
 #include <power/pmic.h>
 #include <power/pfuze100_pmic.h>
 
+int pfuze_mode_init(struct pmic *p, u32 mode)
+{
+	unsigned char offset, i, switch_num;
+	u32 id, ret;
+
+	pmic_reg_read(p, PFUZE100_DEVICEID, &id);
+	id = id & 0xf;
+
+	if (id == 0) {
+		switch_num = 6;
+		offset = PFUZE100_SW1CMODE;
+	} else if (id == 1) {
+		switch_num = 4;
+		offset = PFUZE100_SW2MODE;
+	} else {
+		printf("Not supported, id=%d\n", id);
+		return -EINVAL;

board/freescale/common/pfuze.c line 37

Quoted 10 lines
board/freescale/common/pfuze.c +10 -0
+	}
+
+	ret = pmic_reg_write(p, PFUZE100_SW1ABMODE, mode);
+	if (ret < 0) {
+		printf("Set SW1AB mode error!\n");
+		return ret;
+	}
+
+	for (i = 0; i < switch_num - 1; i++) {
+		ret = pmic_reg_write(p, offset + i * 7, mode);

Even if it looks clear why, I would suggest a define into pfuze100_pmic.h such as "SIZEOF_SWITCH (or what you prefer)" and drop the constant here.

Quoted 18 lines
board/freescale/common/pfuze.c +9 -0
+		if (ret < 0) {
+			printf("Set switch%x mode error!\n", offset + i * 7);
+			return ret;
+		}
+	}
+
+	return ret;
+}
+
 struct pmic *pfuze_common_init(unsigned char i2cbus)
 {
 	struct pmic *p;
board/freescale/common/pfuze.h +0 -0
index 7a4126c..53cfc99 100644

board/freescale/common/pfuze.h line 13

Quoted 6 lines
board/freescale/common/pfuze.h +1 -0
@@ -8,5 +8,6 @@
 #define __PFUZE_BOARD_HELPER__
 
 struct pmic *pfuze_common_init(unsigned char i2cbus);
+int pfuze_mode_init(struct pmic *p, u32 mode);
 
 #endif

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#5 lore raw

PATCH v4 2/3 pmic:pfuze implement pmic_mode_init

Hi, Stefano

Quoted 62 lines · Stefano Babic
Quoted 61 lines · Peng Fan

This patch is to implement pmic_mode_init function, and add prototype in header file.

This function is to set switching mode for pmic buck regulators to improve system efficiency.

Mode:
OFF: The regulator is switched off and the output voltage is discharged.
PFM: In this mode, the regulator is always in PFM mode, which
is useful at light loads for optimized efficiency.
PWM: In this mode, the regulator is always in PWM mode operation
regardless of load conditions.
APS: In this mode, the regulator moves automatically between
pulse skipping mode and PWM mode depending on load conditions.

---

Changes v4:
Take Fabio's comments, fix return value using -EINVAL when error.

Changes v3:
delete the new feature, it is fine to use the original v1 patch version

Changes v2:
implement new feature to configure one regulator

  board/freescale/common/pfuze.c | 36 ++++++++++++++++++++++++++++++++++++
  board/freescale/common/pfuze.h |  1 +
  2 files changed, 37 insertions(+)
board/freescale/common/pfuze.c +22 -0
index 2cd1794..c2a0105 100644
@@ -8,6 +8,42 @@
  #include <power/pmic.h>
  #include <power/pfuze100_pmic.h>
 
+int pfuze_mode_init(struct pmic *p, u32 mode)
+{
+	unsigned char offset, i, switch_num;
+	u32 id, ret;
+
+	pmic_reg_read(p, PFUZE100_DEVICEID, &id);
+	id = id & 0xf;
+
+	if (id == 0) {
+		switch_num = 6;
+		offset = PFUZE100_SW1CMODE;
+	} else if (id == 1) {
+		switch_num = 4;
+		offset = PFUZE100_SW2MODE;
+	} else {
+		printf("Not supported, id=%d\n", id);
+		return -EINVAL;
+	}
+
+	ret = pmic_reg_write(p, PFUZE100_SW1ABMODE, mode);
+	if (ret < 0) {
+		printf("Set SW1AB mode error!\n");
Quoted 8 lines

board/freescale/common/pfuze.c line 37

Quoted 5 lines
board/freescale/common/pfuze.c +5 -0
+		return ret;
+	}
+
+	for (i = 0; i < switch_num - 1; i++) {
+		ret = pmic_reg_write(p, offset + i * 7, mode);

Even if it looks clear why, I would suggest a define into pfuze100_pmic.h such as "SIZEOF_SWITCH (or what you prefer)" and drop the constant here.

The switch_num is dynamically set according to deviceid. I think hardcode it using a macro is not a good idea.

Quoted 20 lines
Quoted 20 lines
board/freescale/common/pfuze.c +9 -0
+		if (ret < 0) {
+			printf("Set switch%x mode error!\n", offset + i * 7);
+			return ret;
+		}
+	}
+
+	return ret;
+}
+
  struct pmic *pfuze_common_init(unsigned char i2cbus)
  {
  	struct pmic *p;
board/freescale/common/pfuze.h +0 -0
index 7a4126c..53cfc99 100644
@@ -8,5 +8,6 @@
  #define __PFUZE_BOARD_HELPER__
 
Quoted 8 lines

board/freescale/common/pfuze.h line 13

Quoted 5 lines
board/freescale/common/pfuze.h +1 -0
  struct pmic *pfuze_common_init(unsigned char i2cbus);
+int pfuze_mode_init(struct pmic *p, u32 mode);
 
  #endif

Best regards,
Stefano Babic

Regards,
Peng.

author
#6 lore raw

PATCH v4 3/3 imx:mx6 set normal APS and standby PFM mode

In reply to Peng Fan

To normal mode, use APS switching mode.
To standy mode, use PFM switching mode.

---

Changes v4:
none

Changes v3:
Following Fabio's comments, correct return value

Changes v2:
none

 board/freescale/mx6qsabreauto/mx6qsabreauto.c | 6 ++++++
 board/freescale/mx6sabresd/mx6sabresd.c       | 6 +++++-
 board/freescale/mx6sxsabresd/mx6sxsabresd.c   | 6 +++++-
 3 files changed, 16 insertions(+), 2 deletions(-)
board/freescale/mx6qsabreauto/mx6qsabreauto.c +6 -0
index 59387ff..b12e74e 100644
@@ -29,6 +29,7 @@
 #include <asm/arch/crm_regs.h>
 #include <pca953x.h>
 #include <power/pmic.h>
+#include <power/pfuze100_pmic.h>
 #include "../common/pfuze.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -515,11 +516,16 @@ int board_spi_cs_gpio(unsigned bus, unsigned cs)
 int power_init_board(void)
 {
 	struct pmic *p;
+	unsigned int ret;
 
 	p = pfuze_common_init(I2C_PMIC);
 	if (!p)
 		return -ENODEV;
 
+	ret = pfuze_mode_init(p, APS_PFM);
+	if (ret < 0)
+		return ret;
+
 	return 0;
 }
 
board/freescale/mx6sabresd/mx6sabresd.c +5 -1
index 2f7198d..bb2dd96 100644
@@ -631,12 +631,16 @@ int board_init(void)
 int power_init_board(void)
 {
 	struct pmic *p;
-	unsigned int reg;
+	unsigned int reg, ret;
 
 	p = pfuze_common_init(I2C_PMIC);
 	if (!p)
 		return -ENODEV;
 
+	ret = pfuze_mode_init(p, APS_PFM);
+	if (ret < 0)
+		return ret;
+
 	/* Increase VGEN3 from 2.5 to 2.8V */
 	pmic_reg_read(p, PFUZE100_VGEN3VOL, &reg);
 	reg &= ~LDO_VOL_MASK;
board/freescale/mx6sxsabresd/mx6sxsabresd.c +5 -1
index 5cc58ac..49e4658 100644
@@ -199,12 +199,16 @@ static struct i2c_pads_info i2c_pad_info1 = {
 int power_init_board(void)
 {
 	struct pmic *p;
-	unsigned int reg;
+	unsigned int reg, ret;
 
 	p = pfuze_common_init(I2C_PMIC);
 	if (!p)
 		return -ENODEV;
 
+	ret = pfuze_mode_init(p, APS_PFM);
+	if (ret < 0)
+		return ret;
+
 	/* Enable power of VGEN5 3V3, needed for SD3 */
 	pmic_reg_read(p, PFUZE100_VGEN5VOL, &reg);
 	reg &= ~LDO_VOL_MASK;
Signature · 1 line
1.8.4
#7 lore raw

v4 cover pmic:pfuze support buck regulator mode switch

In reply to Peng Fan

Hello Peng,

Quoted 5 lines · Peng Fan

Hi, Przemyslaw

There is a few return value comments that from Fabio, I correct them and send out v4 version. Others are same to the v1 version patch set. If this patch set is fine, please give you Acked-by. Sorry for the troubles.

No troubles, just normal review process:)

Quoted 20 lines

This patch set is to support buck regulator can
working in different switching modes. To improve
system efficiency the buck regulators can operate
in different switching modes.

patch 1/3 is to add related bit definitions and registers. patch 2/3 is to implement the switching mode init function. patch 3/3 is to add related mode init function in board code.

mx6slevk board is not included in this patch set, since power and i2c interface are not implemented for it. Future patch will cover this to add PAD setting, power_init_board and etc.

Peng Fan (3):
pmic:pfuz100 add switch mode and more registers pmic:pfuze implement pmic_mode_init imx:mx6 set normal APS and standby PFM mode

Quoted 8 lines
  board/freescale/common/pfuze.c                | 36 ++++++++++++++++++
  board/freescale/common/pfuze.h                |  1 +
  board/freescale/mx6qsabreauto/mx6qsabreauto.c |  6 +++
  board/freescale/mx6sabresd/mx6sabresd.c       |  6 ++-
  board/freescale/mx6sxsabresd/mx6sxsabresd.c   |  6 ++-
  include/power/pfuze100_pmic.h                 | 53 +++++++++++++++++++++++++++
  6 files changed, 106 insertions(+), 2 deletions(-)

For the series, Acked-by: Przemyslaw Marczak <[email protected]>

Best regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com