diff mbox

[U-Boot] pmic: ltc3676: add regulator config function

Message ID CAJ+vNU2HzgkrofUJWTnuwAW=eRV9a0Qn6uvtkLH_TqGCk8gKRg@mail.gmail.com
State Changes Requested
Delegated to: Stefano Babic
Headers show

Commit Message

Tim Harvey March 21, 2017, 10:27 p.m. UTC
On Tue, Mar 21, 2017 at 3:09 PM, Jaehoon Chung <jh80.chung@samsung.com> wrote:
> Hi,
>
> On 03/21/2017 11:47 PM, Tim Harvey wrote:
>> 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:


>
>>
>> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
>> ---
>>  drivers/power/pmic/pmic_ltc3676.c | 16 ++++++++++++++++
>>  include/power/ltc3676_pmic.h      | 40 +++++++++++++++++++++++++++++++++++++++
>>  2 files changed, 56 insertions(+)
>>
>> diff --git a/drivers/power/pmic/pmic_ltc3676.c b/drivers/power/pmic/pmic_ltc3676.c
>> index 9b874cb..af795ea 100644
>> --- a/drivers/power/pmic/pmic_ltc3676.c
>> +++ b/drivers/power/pmic/pmic_ltc3676.c
>> @@ -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.
>
>> +{
>> +     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..
>
>> +     reg |= (phase << LTC3676_PHASE);
>> +     reg &= ~(1 << LTC3676_FREQ);
>> +     reg |= (freq << LTC3676_FREQ);
>> +     pmic_reg_write(p, LTC3676_BUCK1 + sw, reg);
>> +}
>> diff --git a/include/power/ltc3676_pmic.h b/include/power/ltc3676_pmic.h
>> index dcaa985..f5b0f3c 100644
>> --- a/include/power/ltc3676_pmic.h
>> +++ b/include/power/ltc3676_pmic.h
>> @@ -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
>
> Use the bit API..
> #define LTC3676_MODE BIT(5)
> #define LTC3676_STARTUP BIT(4)
> ...
>
> Then you can change the code in power_ltc3676_swconfig().
>

ok - I will submit a v2

Thanks,

Tim
diff mbox

Patch

diff --git a/board/gateworks/gw_ventana/common.c
b/board/gateworks/gw_ventana/common.c
index 56a7b3e..8061c29 100644
--- a/board/gateworks/gw_ventana/common.c
+++ b/board/gateworks/gw_ventana/common.c
@@ -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);
        }
 }