diff mbox

[U-Boot,v5,2/3] pmic:pfuze implement pmic_mode_init

Message ID 1422324844-1563-3-git-send-email-Peng.Fan@freescale.com
State Awaiting Upstream
Delegated to: Stefano Babic
Headers show

Commit Message

Peng Fan Jan. 27, 2015, 2:14 a.m. UTC
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.

Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>
---

Changes v5:
 Add Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>
 replace the constant 7 using macro SWITCH_SIZE which defined in header file.
 Include "errno.h" to avoid compile error.

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 | 38 ++++++++++++++++++++++++++++++++++++++
 board/freescale/common/pfuze.h |  1 +
 2 files changed, 39 insertions(+)

Comments

Stefano Babic Jan. 29, 2015, 5:48 p.m. UTC | #1
On 27/01/2015 03:14, Peng Fan wrote:
> 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.
> 
> Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
> Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>
> ---

Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic
Peng Fan Feb. 11, 2015, 1:59 a.m. UTC | #2
Hi, Stefano

On 1/30/2015 1:48 AM, Stefano Babic wrote:
> On 27/01/2015 03:14, Peng Fan wrote:
>> 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.
>>
>> Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
>> Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>
>> ---
> Applied to u-boot-imx, thanks !
I did not see this patch applied to u-boot-imx, I saw only patch 1/3 is 
applied. Do you miss this one?
>
> Best regards,
> Stefano Babic
>
>
>
Regards,
Peng.
Stefano Babic Feb. 11, 2015, 11:41 a.m. UTC | #3
Hi Peng,

On 11/02/2015 02:59, Peng Fan wrote:
> Hi, Stefano
> 
> On 1/30/2015 1:48 AM, Stefano Babic wrote:
>> On 27/01/2015 03:14, Peng Fan wrote:
>>> 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.
>>>
>>> Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
>>> Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>
>>> ---
>> Applied to u-boot-imx, thanks !
> I did not see this patch applied to u-boot-imx, I saw only patch 1/3 is
> applied. Do you miss this one?
>>

I see. I have applied only patches that are assigned to me (in
patchwork), in this case only Patch 1/3. Patch 2 and 3 were still
assigned to Przemyslaw (but we have his ACK). I assign the patches to me
and I will apply them.

However, something bad happened. No idea how it could happen, but
applying patch1/3, the define for SWITCH_SIZE disappeared - see in file.
I cannot find a valid reason for that. I fix it myself, and I start
rebuilding to check breakage before pushing on the server.

Best regards,
Stefano Babic
diff mbox

Patch

diff --git a/board/freescale/common/pfuze.c b/board/freescale/common/pfuze.c
index 2cd1794..4980bf7 100644
--- a/board/freescale/common/pfuze.c
+++ b/board/freescale/common/pfuze.c
@@ -5,9 +5,47 @@ 
  */
 
 #include <common.h>
+#include <errno.h>
 #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 * SWITCH_SIZE, mode);
+		if (ret < 0) {
+			printf("Set switch 0x%x mode error!\n",
+			       offset + i * SWITCH_SIZE);
+			return ret;
+		}
+	}
+
+	return ret;
+}
+
 struct pmic *pfuze_common_init(unsigned char i2cbus)
 {
 	struct pmic *p;
diff --git a/board/freescale/common/pfuze.h b/board/freescale/common/pfuze.h
index 7a4126c..53cfc99 100644
--- a/board/freescale/common/pfuze.h
+++ b/board/freescale/common/pfuze.h
@@ -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