[U-Boot] [PATCH 0/4] ventana: Add LTC3676 PMIC support

The Gateworks Ventana boards share much in common, but there are two differing PMIC's used on them. This patch series adds a new PMIC driver for the LTC3676 and supports them both within the common board support file.
Signed-off-By: Tim Harvey tharvey@gateworks.com
Tim Harvey (4): power: make pfuze100 be able to coexist with other pmics ventana: use non-generic pfuze100 init power: Add support for LTC3676 PMIC ventana: Add support for the LTC3676 PMIC
board/gateworks/gw_ventana/gw_ventana.c | 78 ++++++++++++++++++++++++--------- drivers/power/pmic/Makefile | 1 + drivers/power/pmic/pmic_ltc3676.c | 32 ++++++++++++++ drivers/power/pmic/pmic_pfuze100.c | 2 +- include/configs/gw_ventana.h | 2 + include/power/ltc3676_pmic.h | 51 +++++++++++++++++++++ include/power/pfuze100_pmic.h | 1 + 7 files changed, 145 insertions(+), 22 deletions(-) create mode 100644 drivers/power/pmic/pmic_ltc3676.c create mode 100644 include/power/ltc3676_pmic.h

Avoid uding pmic_init() as this forces the model of only allowing a single PMIC driver to be built at a time.
Signed-off-by: Tim Harvey tharvey@gateworks.com --- drivers/power/pmic/pmic_pfuze100.c | 2 +- include/power/pfuze100_pmic.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/power/pmic/pmic_pfuze100.c b/drivers/power/pmic/pmic_pfuze100.c index 22c1f15..21f12d2 100644 --- a/drivers/power/pmic/pmic_pfuze100.c +++ b/drivers/power/pmic/pmic_pfuze100.c @@ -11,7 +11,7 @@ #include <power/pmic.h> #include <power/pfuze100_pmic.h>
-int pmic_init(unsigned char bus) +int power_pfuze100_init(unsigned char bus) { static const char name[] = "PFUZE100_PMIC"; struct pmic *p = pmic_alloc(); diff --git a/include/power/pfuze100_pmic.h b/include/power/pfuze100_pmic.h index 2a9032a..444aba6 100644 --- a/include/power/pfuze100_pmic.h +++ b/include/power/pfuze100_pmic.h @@ -93,4 +93,5 @@ enum { #define SWBST_MODE_AUTO (2 << 2) #define SWBST_MODE_APS (2 << 3)
+int power_pfuze100_init(unsigned char bus); #endif

Hi Tim,
On 23/04/2014 06:53, Tim Harvey wrote:
Avoid uding pmic_init() as this forces the model of only allowing a single PMIC driver to be built at a time.
Signed-off-by: Tim Harvey tharvey@gateworks.com
drivers/power/pmic/pmic_pfuze100.c | 2 +- include/power/pfuze100_pmic.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/power/pmic/pmic_pfuze100.c b/drivers/power/pmic/pmic_pfuze100.c index 22c1f15..21f12d2 100644 --- a/drivers/power/pmic/pmic_pfuze100.c +++ b/drivers/power/pmic/pmic_pfuze100.c @@ -11,7 +11,7 @@ #include <power/pmic.h> #include <power/pfuze100_pmic.h>
-int pmic_init(unsigned char bus) +int power_pfuze100_init(unsigned char bus) { static const char name[] = "PFUZE100_PMIC"; struct pmic *p = pmic_alloc(); diff --git a/include/power/pfuze100_pmic.h b/include/power/pfuze100_pmic.h index 2a9032a..444aba6 100644 --- a/include/power/pfuze100_pmic.h +++ b/include/power/pfuze100_pmic.h @@ -93,4 +93,5 @@ enum { #define SWBST_MODE_AUTO (2 << 2) #define SWBST_MODE_APS (2 << 3)
+int power_pfuze100_init(unsigned char bus);
This is a change in the PMIC framework API and must be documented.
Currently, we support multiple instances of the same PMIC, but not different PMIC on the same board.
We could add a CONFIG_MULTIPLE_PMIC, that must be added to the documentation, and each driver will define pmic_init() if it is not define:
#ifndef CONFIG_MULTIPLE_PMIC #define pmic_init power_pfuze100_init #endif
Best regards, Stefano Babic

On Thu, Apr 24, 2014 at 1:03 AM, Stefano Babic sbabic@denx.de wrote:
Hi Tim,
On 23/04/2014 06:53, Tim Harvey wrote:
Avoid uding pmic_init() as this forces the model of only allowing a single PMIC driver to be built at a time.
Signed-off-by: Tim Harvey tharvey@gateworks.com
drivers/power/pmic/pmic_pfuze100.c | 2 +- include/power/pfuze100_pmic.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/power/pmic/pmic_pfuze100.c b/drivers/power/pmic/pmic_pfuze100.c index 22c1f15..21f12d2 100644 --- a/drivers/power/pmic/pmic_pfuze100.c +++ b/drivers/power/pmic/pmic_pfuze100.c @@ -11,7 +11,7 @@ #include <power/pmic.h> #include <power/pfuze100_pmic.h>
-int pmic_init(unsigned char bus) +int power_pfuze100_init(unsigned char bus) { static const char name[] = "PFUZE100_PMIC"; struct pmic *p = pmic_alloc(); diff --git a/include/power/pfuze100_pmic.h b/include/power/pfuze100_pmic.h index 2a9032a..444aba6 100644 --- a/include/power/pfuze100_pmic.h +++ b/include/power/pfuze100_pmic.h @@ -93,4 +93,5 @@ enum { #define SWBST_MODE_AUTO (2 << 2) #define SWBST_MODE_APS (2 << 3)
+int power_pfuze100_init(unsigned char bus);
This is a change in the PMIC framework API and must be documented.
Currently, we support multiple instances of the same PMIC, but not different PMIC on the same board.
Stefano,
Hmm... I see several pmic's that use their own namespace for init:
grep init include/power/*.h shows a few (power_bat_init, power_fg_init, power_muic_init, pmic_init_max77693). And if you look at trats.c or trats2.c boards you will see how they call several of them. Granted, both of those do also call a generic pmic_init() thats implemented by pmic_max77686 'or' pmic_max8977. So in the case of those two boards, they have several pmic's, one that uses the generic pmic_init() namespace, and 2 others that use their own unique namespace.
Regards,
Tim
We could add a CONFIG_MULTIPLE_PMIC, that must be added to the documentation, and each driver will define pmic_init() if it is not define:
#ifndef CONFIG_MULTIPLE_PMIC #define pmic_init power_pfuze100_init #endif
Best regards, Stefano Babic

Hi Tim,
On 24/04/2014 10:19, Tim Harvey wrote:
This is a change in the PMIC framework API and must be documented.
Currently, we support multiple instances of the same PMIC, but not different PMIC on the same board.
Stefano,
Hmm... I see several pmic's that use their own namespace for init:
grep init include/power/*.h shows a few (power_bat_init, power_fg_init, power_muic_init, pmic_init_max77693). And if you look at trats.c or trats2.c boards you will see how they call several of them.
Thanks for pointing it out, I have missed them.
Granted, both of those do also call a generic pmic_init() thats implemented by pmic_max77686 'or' pmic_max8977. So in the case of those two boards, they have several pmic's, one that uses the generic pmic_init() namespace, and 2 others that use their own unique namespace.
I see. Please drop my comment.
Best regards, Stefano

On 23/04/2014 06:53, Tim Harvey wrote:
Avoid uding pmic_init() as this forces the model of only allowing a single PMIC driver to be built at a time.
Signed-off-by: Tim Harvey tharvey@gateworks.com
drivers/power/pmic/pmic_pfuze100.c | 2 +- include/power/pfuze100_pmic.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/power/pmic/pmic_pfuze100.c b/drivers/power/pmic/pmic_pfuze100.c index 22c1f15..21f12d2 100644 --- a/drivers/power/pmic/pmic_pfuze100.c +++ b/drivers/power/pmic/pmic_pfuze100.c @@ -11,7 +11,7 @@ #include <power/pmic.h> #include <power/pfuze100_pmic.h>
-int pmic_init(unsigned char bus) +int power_pfuze100_init(unsigned char bus) { static const char name[] = "PFUZE100_PMIC"; struct pmic *p = pmic_alloc(); diff --git a/include/power/pfuze100_pmic.h b/include/power/pfuze100_pmic.h index 2a9032a..444aba6 100644 --- a/include/power/pfuze100_pmic.h +++ b/include/power/pfuze100_pmic.h @@ -93,4 +93,5 @@ enum { #define SWBST_MODE_AUTO (2 << 2) #define SWBST_MODE_APS (2 << 3)
+int power_pfuze100_init(unsigned char bus); #endif
Applied to u-boot-imx, thanks !
Best regards, Stefano Babic

Signed-off-by: Tim Harvey tharvey@gateworks.com --- board/gateworks/gw_ventana/gw_ventana.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/board/gateworks/gw_ventana/gw_ventana.c b/board/gateworks/gw_ventana/gw_ventana.c index c130e2c..48e90e0 100644 --- a/board/gateworks/gw_ventana/gw_ventana.c +++ b/board/gateworks/gw_ventana/gw_ventana.c @@ -1077,10 +1077,11 @@ int misc_init_r(void) }
/* configure PFUZE100 PMIC (not used on all Ventana baseboards) */ - if ((board_type == GW54xx || board_type == GW54proto) && - !pmic_init(I2C_PMIC)) { + power_pfuze100_init(I2C_PMIC); + if (board_type == GW54xx || board_type == GW54proto) { struct pmic *p = pmic_get("PFUZE100_PMIC"); u32 reg; + if (p && !pmic_probe(p)) { pmic_reg_read(p, PFUZE100_DEVICEID, ®); printf("PMIC: PFUZE100 ID=0x%02x\n", reg);

On 23/04/2014 06:53, Tim Harvey wrote:
Signed-off-by: Tim Harvey tharvey@gateworks.com
board/gateworks/gw_ventana/gw_ventana.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/board/gateworks/gw_ventana/gw_ventana.c b/board/gateworks/gw_ventana/gw_ventana.c index c130e2c..48e90e0 100644 --- a/board/gateworks/gw_ventana/gw_ventana.c +++ b/board/gateworks/gw_ventana/gw_ventana.c @@ -1077,10 +1077,11 @@ int misc_init_r(void) }
/* configure PFUZE100 PMIC (not used on all Ventana baseboards) */
- if ((board_type == GW54xx || board_type == GW54proto) &&
!pmic_init(I2C_PMIC)) {
- power_pfuze100_init(I2C_PMIC);
- if (board_type == GW54xx || board_type == GW54proto) { struct pmic *p = pmic_get("PFUZE100_PMIC"); u32 reg;
- if (p && !pmic_probe(p)) { pmic_reg_read(p, PFUZE100_DEVICEID, ®); printf("PMIC: PFUZE100 ID=0x%02x\n", reg);
Applied to u-boot-imx, thanks !
Best regards, Stefano Babic

The LTC3676 PMIC includes four DC/DC converters, and three 300mA LDO Regulators (two Adjustable). The DC/DC converters are adjustable based on a resistor devider (board-specific).
This adds support for the LTC3676 by creating a namespace unique init function that uses the PMIC API to allocate a pmic and defines the registers.
Signed-off-by: Tim Harvey tharvey@gateworks.com --- drivers/power/pmic/Makefile | 1 + drivers/power/pmic/pmic_ltc3676.c | 32 ++++++++++++++++++++++++ include/power/ltc3676_pmic.h | 51 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 drivers/power/pmic/pmic_ltc3676.c create mode 100644 include/power/ltc3676_pmic.h
diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile index 4129bda..920bbdc 100644 --- a/drivers/power/pmic/Makefile +++ b/drivers/power/pmic/Makefile @@ -5,6 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
+obj-$(CONFIG_POWER_LTC3676) += pmic_ltc3676.o obj-$(CONFIG_POWER_MAX8998) += pmic_max8998.o obj-$(CONFIG_POWER_MAX8997) += pmic_max8997.o obj-$(CONFIG_POWER_MUIC_MAX8997) += muic_max8997.o diff --git a/drivers/power/pmic/pmic_ltc3676.c b/drivers/power/pmic/pmic_ltc3676.c new file mode 100644 index 0000000..9b874cb --- /dev/null +++ b/drivers/power/pmic/pmic_ltc3676.c @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2014 Gateworks Corporation + * Tim Harvey tharvey@gateworks.com + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <errno.h> +#include <i2c.h> +#include <power/pmic.h> +#include <power/ltc3676_pmic.h> + +int power_ltc3676_init(unsigned char bus) +{ + static const char name[] = "LTC3676_PMIC"; + struct pmic *p = pmic_alloc(); + + if (!p) { + printf("%s: POWER allocation error!\n", __func__); + return -ENOMEM; + } + + p->name = name; + p->interface = PMIC_I2C; + p->number_of_regs = LTC3676_NUM_OF_REGS; + p->hw.i2c.addr = CONFIG_POWER_LTC3676_I2C_ADDR; + p->hw.i2c.tx_num = 1; + p->bus = bus; + + return 0; +} diff --git a/include/power/ltc3676_pmic.h b/include/power/ltc3676_pmic.h new file mode 100644 index 0000000..dcaa985 --- /dev/null +++ b/include/power/ltc3676_pmic.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2014 Gateworks Corporation + * Tim Harvey tharvey@gateworks.com + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __LTC3676_PMIC_H_ +#define __LTC3676_PMIC_H_ + +/* LTC3676 registers */ +enum { + LTC3676_BUCK1 = 0x01, + LTC3676_BUCK2 = 0x02, + LTC3676_BUCK3 = 0x03, + LTC3676_BUCK4 = 0x04, + LTC3676_LDOA = 0x05, + LTC3676_LDOB = 0x06, + LTC3676_SQD1 = 0x07, + LTC3676_SQD2 = 0x08, + LTC3676_CNTRL = 0x09, + LTC3676_DVB1A = 0x0A, + LTC3676_DVB1B = 0x0B, + LTC3676_DVB2A = 0x0C, + LTC3676_DVB2B = 0x0D, + LTC3676_DVB3A = 0x0E, + LTC3676_DVB3B = 0x0F, + LTC3676_DVB4A = 0x10, + LTC3676_DVB4B = 0x11, + LTC3676_MSKIRQ = 0x12, + LTC3676_MSKPG = 0x13, + LTC3676_USER = 0x14, + LTC3676_HRST = 0x1E, + LTC3676_CLIRQ = 0x1F, + LTC3676_IRQSTAT = 0x15, + LTC3676_PGSTATL = 0x16, + LTC3676_PGSTATR = 0x17, + LTC3676_NUM_OF_REGS = 0x20, +}; + +/* + * SW Configuration + */ + +#define LTC3676_DVB_MASK 0x1f +#define LTC3676_PGOOD_MASK (1<<5) +#define LTC3676_REF_SELA (0<<5) +#define LTC3676_REF_SELB (1<<5) + +int power_ltc3676_init(unsigned char bus); +#endif

Hi Tim,
On 23/04/2014 06:53, Tim Harvey wrote:
The LTC3676 PMIC includes four DC/DC converters, and three 300mA LDO Regulators (two Adjustable). The DC/DC converters are adjustable based on a resistor devider (board-specific).
This adds support for the LTC3676 by creating a namespace unique init function that uses the PMIC API to allocate a pmic and defines the registers.
Signed-off-by: Tim Harvey tharvey@gateworks.com
drivers/power/pmic/Makefile | 1 + drivers/power/pmic/pmic_ltc3676.c | 32 ++++++++++++++++++++++++ include/power/ltc3676_pmic.h | 51 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 drivers/power/pmic/pmic_ltc3676.c create mode 100644 include/power/ltc3676_pmic.h
diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile index 4129bda..920bbdc 100644 --- a/drivers/power/pmic/Makefile +++ b/drivers/power/pmic/Makefile @@ -5,6 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
+obj-$(CONFIG_POWER_LTC3676) += pmic_ltc3676.o obj-$(CONFIG_POWER_MAX8998) += pmic_max8998.o obj-$(CONFIG_POWER_MAX8997) += pmic_max8997.o obj-$(CONFIG_POWER_MUIC_MAX8997) += muic_max8997.o diff --git a/drivers/power/pmic/pmic_ltc3676.c b/drivers/power/pmic/pmic_ltc3676.c new file mode 100644 index 0000000..9b874cb --- /dev/null +++ b/drivers/power/pmic/pmic_ltc3676.c @@ -0,0 +1,32 @@ +/*
- Copyright (C) 2014 Gateworks Corporation
- Tim Harvey tharvey@gateworks.com
- SPDX-License-Identifier: GPL-2.0+
- */
+#include <common.h> +#include <errno.h> +#include <i2c.h> +#include <power/pmic.h> +#include <power/ltc3676_pmic.h>
+int power_ltc3676_init(unsigned char bus) +{
- static const char name[] = "LTC3676_PMIC";
- struct pmic *p = pmic_alloc();
- if (!p) {
printf("%s: POWER allocation error!\n", __func__);
return -ENOMEM;
- }
- p->name = name;
- p->interface = PMIC_I2C;
- p->number_of_regs = LTC3676_NUM_OF_REGS;
- p->hw.i2c.addr = CONFIG_POWER_LTC3676_I2C_ADDR;
- p->hw.i2c.tx_num = 1;
- p->bus = bus;
- return 0;
+} diff --git a/include/power/ltc3676_pmic.h b/include/power/ltc3676_pmic.h new file mode 100644 index 0000000..dcaa985 --- /dev/null +++ b/include/power/ltc3676_pmic.h @@ -0,0 +1,51 @@ +/*
- Copyright (C) 2014 Gateworks Corporation
- Tim Harvey tharvey@gateworks.com
- SPDX-License-Identifier: GPL-2.0+
- */
+#ifndef __LTC3676_PMIC_H_ +#define __LTC3676_PMIC_H_
+/* LTC3676 registers */ +enum {
- LTC3676_BUCK1 = 0x01,
- LTC3676_BUCK2 = 0x02,
- LTC3676_BUCK3 = 0x03,
- LTC3676_BUCK4 = 0x04,
- LTC3676_LDOA = 0x05,
- LTC3676_LDOB = 0x06,
- LTC3676_SQD1 = 0x07,
- LTC3676_SQD2 = 0x08,
- LTC3676_CNTRL = 0x09,
- LTC3676_DVB1A = 0x0A,
- LTC3676_DVB1B = 0x0B,
- LTC3676_DVB2A = 0x0C,
- LTC3676_DVB2B = 0x0D,
- LTC3676_DVB3A = 0x0E,
- LTC3676_DVB3B = 0x0F,
- LTC3676_DVB4A = 0x10,
- LTC3676_DVB4B = 0x11,
- LTC3676_MSKIRQ = 0x12,
- LTC3676_MSKPG = 0x13,
- LTC3676_USER = 0x14,
- LTC3676_HRST = 0x1E,
- LTC3676_CLIRQ = 0x1F,
- LTC3676_IRQSTAT = 0x15,
- LTC3676_PGSTATL = 0x16,
- LTC3676_PGSTATR = 0x17,
- LTC3676_NUM_OF_REGS = 0x20,
+};
+/*
- SW Configuration
- */
+#define LTC3676_DVB_MASK 0x1f +#define LTC3676_PGOOD_MASK (1<<5) +#define LTC3676_REF_SELA (0<<5) +#define LTC3676_REF_SELB (1<<5)
+int power_ltc3676_init(unsigned char bus); +#endif
Acked-by: Stefano Babic sbabic@denx.de
Best regards, Stefano Babic

Hi Tim,
On 23/04/2014 06:53, Tim Harvey wrote:
The LTC3676 PMIC includes four DC/DC converters, and three 300mA LDO Regulators (two Adjustable). The DC/DC converters are adjustable based on a resistor devider (board-specific).
This adds support for the LTC3676 by creating a namespace unique init function that uses the PMIC API to allocate a pmic and defines the registers.
Signed-off-by: Tim Harvey tharvey@gateworks.com
Applied to u-boot-imx, thanks !
Best regards, Stefano Babic

The LTC3676 PMIC is used instead of the PFUZE100 PMIC on the GW51xx/GW52xx/GW53xx Ventana baseboards. In order to support the IMX6Q SoC at 1GHz on those baseboards, we need to adjust the voltage scaling for the SW1 and SW3 DC/DC converters on the LTC3676 for 1225mV. Note that the scalar values for the LTC3676 are board-specific as they relate to a resistor devider chosen by the board design.
Signed-off-by: Tim Harvey tharvey@gateworks.com --- board/gateworks/gw_ventana/gw_ventana.c | 79 ++++++++++++++++++++++++--------- include/configs/gw_ventana.h | 2 + 2 files changed, 59 insertions(+), 22 deletions(-)
diff --git a/board/gateworks/gw_ventana/gw_ventana.c b/board/gateworks/gw_ventana/gw_ventana.c index 48e90e0..29fcebe 100644 --- a/board/gateworks/gw_ventana/gw_ventana.c +++ b/board/gateworks/gw_ventana/gw_ventana.c @@ -30,6 +30,7 @@ #include <mtd_node.h> #include <netdev.h> #include <power/pmic.h> +#include <power/ltc3676_pmic.h> #include <power/pfuze100_pmic.h> #include <i2c.h> #include <fdt_support.h> @@ -733,6 +734,60 @@ struct ventana gpio_cfg[] = { }, };
+/* setup board specific PMIC */ +static void setup_board_pmic(int board) +{ + struct pmic *p; + u32 reg; + + /* configure PFUZE100 PMIC */ + if (board_type == GW54xx || board_type == GW54proto) { + power_pfuze100_init(I2C_PMIC); + p = pmic_get("PFUZE100_PMIC"); + if (p && !pmic_probe(p)) { + pmic_reg_read(p, PFUZE100_DEVICEID, ®); + printf("PMIC: PFUZE100 ID=0x%02x\n", reg); + + /* Set VGEN1 to 1.5V and enable */ + pmic_reg_read(p, PFUZE100_VGEN1VOL, ®); + reg &= ~(LDO_VOL_MASK); + reg |= (LDOA_1_50V | LDO_EN); + pmic_reg_write(p, PFUZE100_VGEN1VOL, reg); + + /* Set SWBST to 5.0V and enable */ + pmic_reg_read(p, PFUZE100_SWBSTCON1, ®); + reg &= ~(SWBST_MODE_MASK | SWBST_VOL_MASK); + reg |= (SWBST_5_00V | SWBST_MODE_AUTO); + pmic_reg_write(p, PFUZE100_SWBSTCON1, reg); + } + } + + /* configure LTC3676 PMIC */ + else { + power_ltc3676_init(I2C_PMIC); + p = pmic_get("LTC3676_PMIC"); + if (p && !pmic_probe(p)) { + puts("PMIC: LTC3676\n"); + /* set board-specific scalar to 1225mV for IMX6Q@1GHz */ + if (is_cpu_type(MXC_CPU_MX6Q)) { + /* mask PGOOD during SW1 transition */ + reg = 0x1d | LTC3676_PGOOD_MASK; + pmic_reg_write(p, LTC3676_DVB1B, reg); + /* set SW1 (VDD_SOC) to 1259mV */ + reg = 0x1d; + pmic_reg_write(p, LTC3676_DVB1A, reg); + + /* mask PGOOD during SW3 transition */ + reg = 0x1d | LTC3676_PGOOD_MASK; + pmic_reg_write(p, LTC3676_DVB3B, reg); + /*set SW3 (VDD_ARM) to 1259mV */ + reg = 0x1d; + pmic_reg_write(p, LTC3676_DVB3A, reg); + } + } + } +} + /* setup GPIO pinmux and default configuration per baseboard */ static void setup_board_gpio(int board) { @@ -1076,29 +1131,9 @@ int misc_init_r(void) setenv("serial#", str); }
- /* configure PFUZE100 PMIC (not used on all Ventana baseboards) */ - power_pfuze100_init(I2C_PMIC); - if (board_type == GW54xx || board_type == GW54proto) { - struct pmic *p = pmic_get("PFUZE100_PMIC"); - u32 reg; - - if (p && !pmic_probe(p)) { - pmic_reg_read(p, PFUZE100_DEVICEID, ®); - printf("PMIC: PFUZE100 ID=0x%02x\n", reg); - - /* Set VGEN1 to 1.5V and enable */ - pmic_reg_read(p, PFUZE100_VGEN1VOL, ®); - reg &= ~(LDO_VOL_MASK); - reg |= (LDOA_1_50V | LDO_EN); - pmic_reg_write(p, PFUZE100_VGEN1VOL, reg);
- /* Set SWBST to 5.0V and enable */ - pmic_reg_read(p, PFUZE100_SWBSTCON1, ®); - reg &= ~(SWBST_MODE_MASK | SWBST_VOL_MASK); - reg |= (SWBST_5_00V | SWBST_MODE_AUTO); - pmic_reg_write(p, PFUZE100_SWBSTCON1, reg); - } - } + /* setup pmic */ + setup_board_pmic(board_type);
/* setup baseboard specific GPIO pinmux and config */ setup_board_gpio(board_type); diff --git a/include/configs/gw_ventana.h b/include/configs/gw_ventana.h index 3398390..b984f27 100644 --- a/include/configs/gw_ventana.h +++ b/include/configs/gw_ventana.h @@ -136,6 +136,8 @@ #define CONFIG_POWER_I2C #define CONFIG_POWER_PFUZE100 #define CONFIG_POWER_PFUZE100_I2C_ADDR 0x08 +#define CONFIG_POWER_LTC3676 +#define CONFIG_POWER_LTC3676_I2C_ADDR 0x3c
/* Various command support */ #include <config_cmd_default.h>

On 23/04/2014 06:53, Tim Harvey wrote:
The LTC3676 PMIC is used instead of the PFUZE100 PMIC on the GW51xx/GW52xx/GW53xx Ventana baseboards. In order to support the IMX6Q SoC at 1GHz on those baseboards, we need to adjust the voltage scaling for the SW1 and SW3 DC/DC converters on the LTC3676 for 1225mV. Note that the scalar values for the LTC3676 are board-specific as they relate to a resistor devider chosen by the board design.
Signed-off-by: Tim Harvey tharvey@gateworks.com
board/gateworks/gw_ventana/gw_ventana.c | 79 ++++++++++++++++++++++++--------- include/configs/gw_ventana.h | 2 + 2 files changed, 59 insertions(+), 22 deletions(-)
diff --git a/board/gateworks/gw_ventana/gw_ventana.c b/board/gateworks/gw_ventana/gw_ventana.c index 48e90e0..29fcebe 100644 --- a/board/gateworks/gw_ventana/gw_ventana.c +++ b/board/gateworks/gw_ventana/gw_ventana.c @@ -30,6 +30,7 @@ #include <mtd_node.h> #include <netdev.h> #include <power/pmic.h> +#include <power/ltc3676_pmic.h> #include <power/pfuze100_pmic.h> #include <i2c.h> #include <fdt_support.h> @@ -733,6 +734,60 @@ struct ventana gpio_cfg[] = { }, };
+/* setup board specific PMIC */ +static void setup_board_pmic(int board) +{
- struct pmic *p;
- u32 reg;
- /* configure PFUZE100 PMIC */
- if (board_type == GW54xx || board_type == GW54proto) {
power_pfuze100_init(I2C_PMIC);
p = pmic_get("PFUZE100_PMIC");
if (p && !pmic_probe(p)) {
pmic_reg_read(p, PFUZE100_DEVICEID, ®);
printf("PMIC: PFUZE100 ID=0x%02x\n", reg);
/* Set VGEN1 to 1.5V and enable */
pmic_reg_read(p, PFUZE100_VGEN1VOL, ®);
reg &= ~(LDO_VOL_MASK);
reg |= (LDOA_1_50V | LDO_EN);
pmic_reg_write(p, PFUZE100_VGEN1VOL, reg);
/* Set SWBST to 5.0V and enable */
pmic_reg_read(p, PFUZE100_SWBSTCON1, ®);
reg &= ~(SWBST_MODE_MASK | SWBST_VOL_MASK);
reg |= (SWBST_5_00V | SWBST_MODE_AUTO);
pmic_reg_write(p, PFUZE100_SWBSTCON1, reg);
}
- }
- /* configure LTC3676 PMIC */
- else {
power_ltc3676_init(I2C_PMIC);
p = pmic_get("LTC3676_PMIC");
if (p && !pmic_probe(p)) {
puts("PMIC: LTC3676\n");
/* set board-specific scalar to 1225mV for IMX6Q@1GHz */
if (is_cpu_type(MXC_CPU_MX6Q)) {
/* mask PGOOD during SW1 transition */
reg = 0x1d | LTC3676_PGOOD_MASK;
pmic_reg_write(p, LTC3676_DVB1B, reg);
/* set SW1 (VDD_SOC) to 1259mV */
reg = 0x1d;
pmic_reg_write(p, LTC3676_DVB1A, reg);
/* mask PGOOD during SW3 transition */
reg = 0x1d | LTC3676_PGOOD_MASK;
pmic_reg_write(p, LTC3676_DVB3B, reg);
/*set SW3 (VDD_ARM) to 1259mV */
reg = 0x1d;
pmic_reg_write(p, LTC3676_DVB3A, reg);
}
}
- }
+}
There is already a power_init_board(), defined as __weak, that you can use here.
/* setup GPIO pinmux and default configuration per baseboard */ static void setup_board_gpio(int board) { @@ -1076,29 +1131,9 @@ int misc_init_r(void) setenv("serial#", str); }
/* configure PFUZE100 PMIC (not used on all Ventana baseboards) */
power_pfuze100_init(I2C_PMIC);
if (board_type == GW54xx || board_type == GW54proto) {
struct pmic *p = pmic_get("PFUZE100_PMIC");
u32 reg;
if (p && !pmic_probe(p)) {
pmic_reg_read(p, PFUZE100_DEVICEID, ®);
printf("PMIC: PFUZE100 ID=0x%02x\n", reg);
/* Set VGEN1 to 1.5V and enable */
pmic_reg_read(p, PFUZE100_VGEN1VOL, ®);
reg &= ~(LDO_VOL_MASK);
reg |= (LDOA_1_50V | LDO_EN);
pmic_reg_write(p, PFUZE100_VGEN1VOL, reg);
/* Set SWBST to 5.0V and enable */
pmic_reg_read(p, PFUZE100_SWBSTCON1, ®);
reg &= ~(SWBST_MODE_MASK | SWBST_VOL_MASK);
reg |= (SWBST_5_00V | SWBST_MODE_AUTO);
pmic_reg_write(p, PFUZE100_SWBSTCON1, reg);
}
}
/* setup pmic */
setup_board_pmic(board_type);
/* setup baseboard specific GPIO pinmux and config */ setup_board_gpio(board_type);
diff --git a/include/configs/gw_ventana.h b/include/configs/gw_ventana.h index 3398390..b984f27 100644 --- a/include/configs/gw_ventana.h +++ b/include/configs/gw_ventana.h @@ -136,6 +136,8 @@ #define CONFIG_POWER_I2C #define CONFIG_POWER_PFUZE100 #define CONFIG_POWER_PFUZE100_I2C_ADDR 0x08 +#define CONFIG_POWER_LTC3676 +#define CONFIG_POWER_LTC3676_I2C_ADDR 0x3c
/* Various command support */ #include <config_cmd_default.h>
Best regards, Stefano Babic

The LTC3676 PMIC is used instead of the PFUZE100 PMIC on the GW51xx/GW52xx/GW53xx Ventana baseboards. In order to support the IMX6Q SoC at 1GHz on those baseboards, we need to adjust the voltage scaling for the SW1 and SW3 DC/DC converters on the LTC3676 for 1225mV. Note that the scalar values for the LTC3676 are board-specific as they relate to a resistor devider chosen by the board design.
Signed-off-by: Tim Harvey tharvey@gateworks.com --- board/gateworks/gw_ventana/gw_ventana.c | 78 +++++++++++++++++++++++---------- include/configs/gw_ventana.h | 2 + 2 files changed, 57 insertions(+), 23 deletions(-)
diff --git a/board/gateworks/gw_ventana/gw_ventana.c b/board/gateworks/gw_ventana/gw_ventana.c index 48e90e0..cf42fcf 100644 --- a/board/gateworks/gw_ventana/gw_ventana.c +++ b/board/gateworks/gw_ventana/gw_ventana.c @@ -30,6 +30,7 @@ #include <mtd_node.h> #include <netdev.h> #include <power/pmic.h> +#include <power/ltc3676_pmic.h> #include <power/pfuze100_pmic.h> #include <i2c.h> #include <fdt_support.h> @@ -733,6 +734,60 @@ struct ventana gpio_cfg[] = { }, };
+/* setup board specific PMIC */ +int power_init_board(void) +{ + struct pmic *p; + u32 reg; + + /* configure PFUZE100 PMIC */ + if (board_type == GW54xx || board_type == GW54proto) { + power_pfuze100_init(I2C_PMIC); + p = pmic_get("PFUZE100_PMIC"); + if (p && !pmic_probe(p)) { + pmic_reg_read(p, PFUZE100_DEVICEID, ®); + printf("PMIC: PFUZE100 ID=0x%02x\n", reg); + + /* Set VGEN1 to 1.5V and enable */ + pmic_reg_read(p, PFUZE100_VGEN1VOL, ®); + reg &= ~(LDO_VOL_MASK); + reg |= (LDOA_1_50V | LDO_EN); + pmic_reg_write(p, PFUZE100_VGEN1VOL, reg); + + /* Set SWBST to 5.0V and enable */ + pmic_reg_read(p, PFUZE100_SWBSTCON1, ®); + reg &= ~(SWBST_MODE_MASK | SWBST_VOL_MASK); + reg |= (SWBST_5_00V | SWBST_MODE_AUTO); + pmic_reg_write(p, PFUZE100_SWBSTCON1, reg); + } + } + + /* configure LTC3676 PMIC */ + else { + power_ltc3676_init(I2C_PMIC); + p = pmic_get("LTC3676_PMIC"); + if (p && !pmic_probe(p)) { + puts("PMIC: LTC3676\n"); + /* set board-specific scalar to 1225mV for IMX6Q@1GHz */ + if (is_cpu_type(MXC_CPU_MX6Q)) { + /* mask PGOOD during SW1 transition */ + reg = 0x1d | LTC3676_PGOOD_MASK; + pmic_reg_write(p, LTC3676_DVB1B, reg); + /* set SW1 (VDD_SOC) to 1259mV */ + reg = 0x1d; + pmic_reg_write(p, LTC3676_DVB1A, reg); + + /* mask PGOOD during SW3 transition */ + reg = 0x1d | LTC3676_PGOOD_MASK; + pmic_reg_write(p, LTC3676_DVB3B, reg); + /*set SW3 (VDD_ARM) to 1259mV */ + reg = 0x1d; + pmic_reg_write(p, LTC3676_DVB3A, reg); + } + } + } +} + /* setup GPIO pinmux and default configuration per baseboard */ static void setup_board_gpio(int board) { @@ -1076,29 +1131,6 @@ int misc_init_r(void) setenv("serial#", str); }
- /* configure PFUZE100 PMIC (not used on all Ventana baseboards) */ - power_pfuze100_init(I2C_PMIC); - if (board_type == GW54xx || board_type == GW54proto) { - struct pmic *p = pmic_get("PFUZE100_PMIC"); - u32 reg; - - if (p && !pmic_probe(p)) { - pmic_reg_read(p, PFUZE100_DEVICEID, ®); - printf("PMIC: PFUZE100 ID=0x%02x\n", reg); - - /* Set VGEN1 to 1.5V and enable */ - pmic_reg_read(p, PFUZE100_VGEN1VOL, ®); - reg &= ~(LDO_VOL_MASK); - reg |= (LDOA_1_50V | LDO_EN); - pmic_reg_write(p, PFUZE100_VGEN1VOL, reg); - - /* Set SWBST to 5.0V and enable */ - pmic_reg_read(p, PFUZE100_SWBSTCON1, ®); - reg &= ~(SWBST_MODE_MASK | SWBST_VOL_MASK); - reg |= (SWBST_5_00V | SWBST_MODE_AUTO); - pmic_reg_write(p, PFUZE100_SWBSTCON1, reg); - } - }
/* setup baseboard specific GPIO pinmux and config */ setup_board_gpio(board_type); diff --git a/include/configs/gw_ventana.h b/include/configs/gw_ventana.h index 3398390..b984f27 100644 --- a/include/configs/gw_ventana.h +++ b/include/configs/gw_ventana.h @@ -136,6 +136,8 @@ #define CONFIG_POWER_I2C #define CONFIG_POWER_PFUZE100 #define CONFIG_POWER_PFUZE100_I2C_ADDR 0x08 +#define CONFIG_POWER_LTC3676 +#define CONFIG_POWER_LTC3676_I2C_ADDR 0x3c
/* Various command support */ #include <config_cmd_default.h>

On 05/05/2014 17:22, Tim Harvey wrote:
The LTC3676 PMIC is used instead of the PFUZE100 PMIC on the GW51xx/GW52xx/GW53xx Ventana baseboards. In order to support the IMX6Q SoC at 1GHz on those baseboards, we need to adjust the voltage scaling for the SW1 and SW3 DC/DC converters on the LTC3676 for 1225mV. Note that the scalar values for the LTC3676 are board-specific as they relate to a resistor devider chosen by the board design.
Signed-off-by: Tim Harvey tharvey@gateworks.com
Applied after fixing:
board/gateworks/gw_ventana/gw_ventana.c: In function 'power_init_board': board/gateworks/gw_ventana/gw_ventana.c:788:1: warning: control reaches end of non-void function [-Wreturn-type]
Best regards, Stefano Babic
participants (2)
-
Stefano Babic
-
Tim Harvey