Skip to contentSkip to conversation

pmic: ltc3676: add regulator config function

PATCH New Tim Harvey 2 participants 3 messages Mar 21, 2017

lore
Share & tools
lore

Tim Harvey

author
#0 lore raw

PATCH 1/1 pmic: ltc3676: add regulator config function

Add a convenience function for configuring the most common characteristics of an LTC3676 buck regulator.

---
 drivers/power/pmic/pmic_ltc3676.c | 16 ++++++++++++++++
 include/power/ltc3676_pmic.h      | 40 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)
drivers/power/pmic/pmic_ltc3676.c +16 -0
index 9b874cb..af795ea 100644
@@ -30,3 +30,19 @@ int power_ltc3676_init(unsigned char bus)
 
 	return 0;
 }
+
+void power_ltc3676_swconfig(struct pmic *p, enum ltc3676_sw sw,
+			    enum ltc3676_mode mode, enum ltc3676_phase phase,
+			    enum ltc3676_freq freq)
+{
+	u32 reg;
+
+	pmic_reg_read(p, LTC3676_BUCK1 + sw, &reg);
+	reg &= ~LTC3676_MODE_MASK;
+	reg |= (mode << LTC3676_MODE);
+	reg &= ~(1 << LTC3676_PHASE);
+	reg |= (phase << LTC3676_PHASE);
+	reg &= ~(1 << LTC3676_FREQ);
+	reg |= (freq << LTC3676_FREQ);
+	pmic_reg_write(p, LTC3676_BUCK1 + sw, reg);
+}
include/power/ltc3676_pmic.h +40 -0
index dcaa985..f5b0f3c 100644
@@ -42,10 +42,50 @@ enum {
  * SW Configuration
  */
 
+/* DVB<x> registers */
 #define LTC3676_DVB_MASK	0x1f
 #define LTC3676_PGOOD_MASK	(1<<5)
 #define LTC3676_REF_SELA	(0<<5)
 #define LTC3676_REF_SELB	(1<<5)
 
+/* BUCK<x> registers */
+#define LTC3676_MODE_MASK	0x60
+#define LTC3676_MODE		5
+#define LTC3676_STARTUP		4
+#define LTC3676_PHASE		3
+#define LTC3676_FREQ		2
+#define LTC3676_KEEPALIVE	1
+#define LTC3676_RATE		0
+
+enum ltc3676_sw {
+	SW1 = 0,
+	SW2 = 1,
+	SW3 = 2,
+	SW4 = 3
+};
+
+enum ltc3676_mode {
+	PFM = 0, /* pulse-skipping */
+	APF = 1, /* burst - auto switches */
+	PWM = 2, /* forced continuous */
+};
+
+enum ltc3676_phase {
+	PHASE1 = 0,
+	PHASE2 = 1,
+};
+
+enum ltc3676_freq {
+	F2250KHZ = 0,
+	F1125KHZ = 1,
+};
+
+enum ltc3676_rate {
+	SLOW = 0,
+	FAST = 1,
+};
+
 int power_ltc3676_init(unsigned char bus);
+void power_ltc3676_swconfig(struct pmic *, enum ltc3676_sw, enum ltc3676_mode,
+			    enum ltc3676_phase, enum ltc3676_freq);
 #endif
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 pmic: ltc3676: add regulator config function

Hi,

Quoted 2 lines · Tim Harvey

Add a convenience function for configuring the most common characteristics of an LTC3676 buck regulator.

I didn't know where this is used.

Quoted 12 lines
---
 drivers/power/pmic/pmic_ltc3676.c | 16 ++++++++++++++++
 include/power/ltc3676_pmic.h      | 40 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)
drivers/power/pmic/pmic_ltc3676.c +0 -0
index 9b874cb..af795ea 100644

drivers/power/pmic/pmic_ltc3676.c int power_ltc3676_init(unsigned char bus) · line 36

Quoted 7 lines
drivers/power/pmic/pmic_ltc3676.c +4 -0
@@ -30,3 +30,19 @@ int power_ltc3676_init(unsigned char bus)
 
 	return 0;
 }
+
+void power_ltc3676_swconfig(struct pmic *p, enum ltc3676_sw sw,
+			    enum ltc3676_mode mode, enum ltc3676_phase phase,
+			    enum ltc3676_freq freq)

As i mentioned above, this function doesn't call anywhere.. Well, if i missed some your patches, let me know, plz.

drivers/power/pmic/pmic_ltc3676.c int power_ltc3676_init(unsigned char bus) · line 43

Quoted 7 lines
drivers/power/pmic/pmic_ltc3676.c +7 -0
+{
+	u32 reg;
+
+	pmic_reg_read(p, LTC3676_BUCK1 + sw, &reg);
+	reg &= ~LTC3676_MODE_MASK;
+	reg |= (mode << LTC3676_MODE);
+	reg &= ~(1 << LTC3676_PHASE);

For clearing bit, use the macro..

Quoted 17 lines
drivers/power/pmic/pmic_ltc3676.c +5 -0
+	reg |= (phase << LTC3676_PHASE);
+	reg &= ~(1 << LTC3676_FREQ);
+	reg |= (freq << LTC3676_FREQ);
+	pmic_reg_write(p, LTC3676_BUCK1 + sw, reg);
+}
include/power/ltc3676_pmic.h +1 -0
index dcaa985..f5b0f3c 100644
@@ -42,10 +42,50 @@ enum {
  * SW Configuration
  */
 
+/* DVB<x> registers */
 #define LTC3676_DVB_MASK	0x1f
 #define LTC3676_PGOOD_MASK	(1<<5)
 #define LTC3676_REF_SELA	(0<<5)

include/power/ltc3676_pmic.h enum { · line 58

Quoted 10 lines
include/power/ltc3676_pmic.h +8 -0
 #define LTC3676_REF_SELB	(1<<5)
 
+/* BUCK<x> registers */
+#define LTC3676_MODE_MASK	0x60
+#define LTC3676_MODE		5
+#define LTC3676_STARTUP		4
+#define LTC3676_PHASE		3
+#define LTC3676_FREQ		2
+#define LTC3676_KEEPALIVE	1
+#define LTC3676_RATE		0

Use the bit API..
#define LTC3676_MODE BIT(5)
#define LTC3676_STARTUP BIT(4)
...

Then you can change the code in power_ltc3676_swconfig().

Best Regards,
Jaehoon Chung

Quoted 34 lines
include/power/ltc3676_pmic.h +31 -0
+
+enum ltc3676_sw {
+	SW1 = 0,
+	SW2 = 1,
+	SW3 = 2,
+	SW4 = 3
+};
+
+enum ltc3676_mode {
+	PFM = 0, /* pulse-skipping */
+	APF = 1, /* burst - auto switches */
+	PWM = 2, /* forced continuous */
+};
+
+enum ltc3676_phase {
+	PHASE1 = 0,
+	PHASE2 = 1,
+};
+
+enum ltc3676_freq {
+	F2250KHZ = 0,
+	F1125KHZ = 1,
+};
+
+enum ltc3676_rate {
+	SLOW = 0,
+	FAST = 1,
+};
+
 int power_ltc3676_init(unsigned char bus);
+void power_ltc3676_swconfig(struct pmic *, enum ltc3676_sw, enum ltc3676_mode,
+			    enum ltc3676_phase, enum ltc3676_freq);
 #endif
author
#2 lore raw

PATCH 1/1 pmic: ltc3676: add regulator config function

Quoted 7 lines · Jaehoon Chung

Hi,

Quoted 2 lines · Tim Harvey

Add a convenience function for configuring the most common characteristics of an LTC3676 buck regulator.

I didn't know where this is used.

Hi Jaehoon,

I'm going to use it for the IMX6 based Gateworks Ventana boards to put the switching regulators in continuous PWM mode. So no users yet... as soon as its acceptable I'll send a board-support patch that uses it though:

(quoted diff) +0 -0

b/board/gateworks/gw_ventana/common.c
index 56a7b3e..8061c29 100644

board/gateworks/gw_ventana/common.c +6 -0
@@ -1350,6 +1350,12 @@ void setup_pmic(void)
                        /* set SW3 (VDD_ARM) */
                        pmic_reg_write(p, LTC3676_DVB3A, 0x1f);
                }
+
+               /* Use continuous PWM mode, 1Mhz on all regulators */
+               power_ltc3676_swconfig(p, SW1, PWM, PHASE1, F1125KHZ);
+               power_ltc3676_swconfig(p, SW2, PWM, PHASE1, F1125KHZ);
+               power_ltc3676_swconfig(p, SW3, PWM, PHASE1, F1125KHZ);
+               power_ltc3676_swconfig(p, SW4, PWM, PHASE1, F1125KHZ);
        }
 }
 
Quoted 67 lines
Quoted 13 lines
---
 drivers/power/pmic/pmic_ltc3676.c | 16 ++++++++++++++++
 include/power/ltc3676_pmic.h      | 40 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)
drivers/power/pmic/pmic_ltc3676.c +0 -0
index 9b874cb..af795ea 100644

drivers/power/pmic/pmic_ltc3676.c int power_ltc3676_init(unsigned char bus) · line 36

Quoted 7 lines
drivers/power/pmic/pmic_ltc3676.c +4 -0
@@ -30,3 +30,19 @@ int power_ltc3676_init(unsigned char bus)
 
      return 0;
 }
+
+void power_ltc3676_swconfig(struct pmic *p, enum ltc3676_sw sw,
+                         enum ltc3676_mode mode, enum ltc3676_phase phase,
+                         enum ltc3676_freq freq)

As i mentioned above, this function doesn't call anywhere.. Well, if i missed some your patches, let me know, plz.

drivers/power/pmic/pmic_ltc3676.c int power_ltc3676_init(unsigned char bus) · line 43

Quoted 7 lines
drivers/power/pmic/pmic_ltc3676.c +7 -0
+{
+     u32 reg;
+
+     pmic_reg_read(p, LTC3676_BUCK1 + sw, &reg);
+     reg &= ~LTC3676_MODE_MASK;
+     reg |= (mode << LTC3676_MODE);
+     reg &= ~(1 << LTC3676_PHASE);

For clearing bit, use the macro..

Quoted 17 lines
drivers/power/pmic/pmic_ltc3676.c +5 -0
+     reg |= (phase << LTC3676_PHASE);
+     reg &= ~(1 << LTC3676_FREQ);
+     reg |= (freq << LTC3676_FREQ);
+     pmic_reg_write(p, LTC3676_BUCK1 + sw, reg);
+}
include/power/ltc3676_pmic.h +1 -0
index dcaa985..f5b0f3c 100644
@@ -42,10 +42,50 @@ enum {
  * SW Configuration
  */
 
+/* DVB<x> registers */
 #define LTC3676_DVB_MASK     0x1f
 #define LTC3676_PGOOD_MASK   (1<<5)
 #define LTC3676_REF_SELA     (0<<5)

include/power/ltc3676_pmic.h enum { · line 58

Quoted 10 lines
include/power/ltc3676_pmic.h +8 -0
 #define LTC3676_REF_SELB     (1<<5)
 
+/* BUCK<x> registers */
+#define LTC3676_MODE_MASK    0x60
+#define LTC3676_MODE         5
+#define LTC3676_STARTUP              4
+#define LTC3676_PHASE                3
+#define LTC3676_FREQ         2
+#define LTC3676_KEEPALIVE    1
+#define LTC3676_RATE         0

Use the bit API..
#define LTC3676_MODE BIT(5)
#define LTC3676_STARTUP BIT(4)
...

Quoted 2 lines

Then you can change the code in power_ltc3676_swconfig().

ok - I will submit a v2

Thanks,

Tim