power: pmic: Add support for MAX77696 PMIC
PATCH v2 1/2 power: pmic: Add support for MAX77696 PMIC
From: Fabio Estevam <[email protected]>
Add support for MAX77696 PMIC.
---
Changes since v1:
- Fix the range of PMIC registers
drivers/power/pmic/Makefile | 1 + drivers/power/pmic/pmic_max77696.c | 32 ++++++++++++++++++++ include/power/max77696_pmic.h | 61 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 drivers/power/pmic/pmic_max77696.c create mode 100644 include/power/max77696_pmic.h
drivers/power/pmic/Makefile +1 -0
@@ -9,6 +9,7 @@ obj-$(CONFIG_DM_PMIC) += pmic-uclass.o obj-$(CONFIG_DM_PMIC_MAX77686) += max77686.o obj-$(CONFIG_DM_PMIC_SANDBOX) += sandbox.o i2c_pmic_emul.o obj-$(CONFIG_POWER_LTC3676) += pmic_ltc3676.o +obj-$(CONFIG_POWER_MAX77696) += pmic_max77696.o obj-$(CONFIG_POWER_MAX8998) += pmic_max8998.o obj-$(CONFIG_POWER_MAX8997) += pmic_max8997.o obj-$(CONFIG_POWER_MUIC_MAX8997) += muic_max8997.o
drivers/power/pmic/pmic_max77696.c new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright (C) 2015 Freescale Semiconductor, Inc. +* Fabio Estevam <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <errno.h> +#include <i2c.h> +#include <power/pmic.h> +#include <power/max77696_pmic.h> + +int power_max77696_init (unsigned char bus) +{ +static const char name[] ="MAX77696" ; +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 =PMIC_NUM_OF_REGS ; + p->hw.i2c.addr =CONFIG_POWER_MAX77696_I2C_ADDR ; + p->hw.i2c.tx_num =1 ; + p->bus = bus; + +return 0 ; +}
include/power/max77696_pmic.h new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 2/2 warp: Add MAX77696 support
From: Fabio Estevam <[email protected]>
Warp has a MAX77696 PMIC connected via I2C1 bus.
Add support for it.
---
Changes since v1:
- None
board/warp/warp.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/configs/warp.h | 11 +++++++++++ 2 files changed, 61 insertions(+)
board/warp/warp.c +50 -0
@@ -15,13 +15,17 @@#include <asm/arch/sys_proto.h> #include <asm/gpio.h> #include <asm/imx-common/iomux-v3.h> +#include <asm/imx-common/mxc_i2c.h> #include <asm/io.h> #include <linux/sizes.h> #include <common.h> #include <watchdog.h> #include <fsl_esdhc.h> +#include <i2c.h> #include <mmc.h> #include <usb.h> +#include <power/pmic.h> +#include <power/max77696_pmic.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -35,6 +39,11 @@ DECLARE_GLOBAL_DATA_PTR; PAD_CTL_SRE_FAST | PAD_CTL_HYS | \ PAD_CTL_LVE) +#define I2C_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \ + PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \ + PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \ + PAD_CTL_ODE | PAD_CTL_SRE_FAST) +int dram_init (void ) { gd->ram_size =get_ram_size ((void *)PHYS_SDRAM ,PHYS_SDRAM_SIZE );
@@ -88,6 +97,45 @@ int board_usb_phy_mode(int port)return USB_INIT_DEVICE ; } +/* I2C1 for PMIC */ +#define I2C_PMIC 0 +#define PC MUX_PAD_CTRL(I2C_PAD_CTRL) +struct i2c_pads_info i2c_pad_info1 = { + .sda = { + .i2c_mode =MX6_PAD_I2C1_SDA__I2C1_SDA |PC , + .gpio_mode =MX6_PAD_I2C1_SDA__GPIO_3_13 |PC , + .gp =IMX_GPIO_NR (3 ,13 ), + }, + .scl = { + .i2c_mode =MX6_PAD_I2C1_SCL__I2C1_SCL |PC , + .gpio_mode =MX6_PAD_I2C1_SCL__GPIO_3_12 |PC , + .gp =IMX_GPIO_NR (3 ,12 ), + }, +}; + +int power_init_board (void ) +{ +struct pmic *p; +int ret; +unsigned int reg; + + ret =power_max77696_init (I2C_PMIC ); +if (ret) +return ret; + + p =pmic_get ("MAX77696" ); +if (!p) +return -EINVAL ; + + ret =pmic_reg_read (p,CID , ®); +if (ret) +return ret; + +printf ("PMIC: MAX77696 detected, rev=0x%x\n" , reg); + +return pmic_probe (p); +} +int board_early_init_f (void ) {setup_iomux_uart ();
@@ -99,6 +147,8 @@ int board_init(void)/* address of boot parameters */ gd->bd->bi_boot_params =PHYS_SDRAM +0x100 ; +setup_i2c (0 ,CONFIG_SYS_I2C_SPEED ,0x7f , &i2c_pad_info1); +return 0 ; }
include/configs/warp.h +11 -0
@@ -98,6 +98,17 @@#define CONFIG_CMD_FUSE #define CONFIG_MXC_OCOTP +/* I2C Configs */ +#define CONFIG_CMD_I2C +#define CONFIG_SYS_I2C +#define CONFIG_SYS_I2C_MXC +#define CONFIG_SYS_I2C_SPEED 100000 + +/* PMIC */ +#define CONFIG_POWER +#define CONFIG_POWER_I2C +#define CONFIG_POWER_MAX77696 +#define CONFIG_EXTRA_ENV_SETTINGS \ "script=boot.scr\0" \ "image=zImage\0" \
Signature · 1 line
1.9.1
PATCH v2 2/2 warp: Add MAX77696 support
Quoted 117 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Warp has a MAX77696 PMIC connected via I2C1 bus.
Add support for it.
Signed-off-by Fabio Estevam <[email protected]>---
Changes since v1:
- Noneboard/warp/warp.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/configs/warp.h | 11 +++++++++++ 2 files changed, 61 insertions(+)board/warp/warp.c +50
-0@@ -15,13 +15,17 @@#include <asm/arch/sys_proto.h> #include <asm/gpio.h> #include <asm/imx-common/iomux-v3.h> +#include <asm/imx-common/mxc_i2c.h> #include <asm/io.h> #include <linux/sizes.h> #include <common.h> #include <watchdog.h> #include <fsl_esdhc.h> +#include <i2c.h> #include <mmc.h> #include <usb.h> +#include <power/pmic.h> +#include <power/max77696_pmic.h> DECLARE_GLOBAL_DATA_PTR ;@@ -35,6 +39,11 @@ DECLARE_GLOBAL_DATA_PTR; PAD_CTL_SRE_FAST | PAD_CTL_HYS | \ PAD_CTL_LVE) +#define I2C_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \ + PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \ + PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \ + PAD_CTL_ODE | PAD_CTL_SRE_FAST) +int dram_init (void ) { gd->ram_size =get_ram_size ((void *)PHYS_SDRAM ,PHYS_SDRAM_SIZE );@@ -88,6 +97,45 @@ int board_usb_phy_mode(int port)return USB_INIT_DEVICE ; } +/* I2C1 for PMIC */ +#define I2C_PMIC 0 +#define PC MUX_PAD_CTRL(I2C_PAD_CTRL) +struct i2c_pads_info i2c_pad_info1 = { + .sda = { + .i2c_mode =MX6_PAD_I2C1_SDA__I2C1_SDA |PC , + .gpio_mode =MX6_PAD_I2C1_SDA__GPIO_3_13 |PC , + .gp =IMX_GPIO_NR (3 ,13 ), + }, + .scl = { + .i2c_mode =MX6_PAD_I2C1_SCL__I2C1_SCL |PC , + .gpio_mode =MX6_PAD_I2C1_SCL__GPIO_3_12 |PC , + .gp =IMX_GPIO_NR (3 ,12 ), + }, +}; + +int power_init_board (void ) +{ +struct pmic *p; +int ret; +unsigned int reg; + + ret =power_max77696_init (I2C_PMIC ); +if (ret) +return ret; + + p =pmic_get ("MAX77696" ); +if (!p) +return -EINVAL ; + + ret =pmic_reg_read (p,CID , ®); +if (ret) +return ret; + +printf ("PMIC: MAX77696 detected, rev=0x%x\n" , reg); + +return pmic_probe (p); +} +int board_early_init_f (void ) {setup_iomux_uart ();@@ -99,6 +147,8 @@ int board_init(void)/* address of boot parameters */ gd->bd->bi_boot_params =PHYS_SDRAM +0x100 ; +setup_i2c (0 ,CONFIG_SYS_I2C_SPEED ,0x7f , &i2c_pad_info1); +return 0 ; }include/configs/warp.h +4
-0@@ -98,6 +98,17 @@#define CONFIG_CMD_FUSE #define CONFIG_MXC_OCOTP +/* I2C Configs */ +#define CONFIG_CMD_I2C +#define CONFIG_SYS_I2C +#define CONFIG_SYS_I2C_MXC
include/configs/warp.h line 114
Quoted 10 lines
include/configs/warp.h +7
-0+#define CONFIG_SYS_I2C_SPEED 100000 + +/* PMIC */ +#define CONFIG_POWER +#define CONFIG_POWER_I2C +#define CONFIG_POWER_MAX77696 +#define CONFIG_EXTRA_ENV_SETTINGS \ "script=boot.scr\0" \ "image=zImage\0" \
Applied to u-boot-imx, thanks !
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 =====================================================================
PATCH v2 1/2 power: pmic: Add support for MAX77696 PMIC
In reply to Fabio EstevamQuoted 124 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Add support for MAX77696 PMIC.
Signed-off-by Fabio Estevam <[email protected]>---
Changes since v1:
- Fix the range of PMIC registersdrivers/power/pmic/Makefile | 1 + drivers/power/pmic/pmic_max77696.c | 32 ++++++++++++++++++++ include/power/max77696_pmic.h | 61 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 drivers/power/pmic/pmic_max77696.c create mode 100644 include/power/max77696_pmic.hdrivers/power/pmic/Makefile +1
-0@@ -9,6 +9,7 @@ obj-$(CONFIG_DM_PMIC) += pmic-uclass.o obj-$(CONFIG_DM_PMIC_MAX77686) += max77686.o obj-$(CONFIG_DM_PMIC_SANDBOX) += sandbox.o i2c_pmic_emul.o obj-$(CONFIG_POWER_LTC3676) += pmic_ltc3676.o +obj-$(CONFIG_POWER_MAX77696) += pmic_max77696.o obj-$(CONFIG_POWER_MAX8998) += pmic_max8998.o obj-$(CONFIG_POWER_MAX8997) += pmic_max8997.o obj-$(CONFIG_POWER_MUIC_MAX8997) += muic_max8997.odrivers/power/pmic/pmic_max77696.c new file +32
-0@@ -0,0 +1,32 @@ +/* +* Copyright (C) 2015 Freescale Semiconductor, Inc. +* Fabio Estevam <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <errno.h> +#include <i2c.h> +#include <power/pmic.h> +#include <power/max77696_pmic.h> + +int power_max77696_init (unsigned char bus) +{ +static const char name[] ="MAX77696" ; +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 =PMIC_NUM_OF_REGS ; + p->hw.i2c.addr =CONFIG_POWER_MAX77696_I2C_ADDR ; + p->hw.i2c.tx_num =1 ; + p->bus = bus; + +return 0 ; +}include/power/max77696_pmic.h new file +51
-0@@ -0,0 +1,61 @@ +/* +* Copyright (C) 2015 Freescale Semiconductor, Inc. +* Fabio Estevam <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __MAX77696_PMIC_H__ +#define __MAX77696_PMIC_H__ + +#define CONFIG_POWER_MAX77696_I2C_ADDR 0x3C + +enum { +L01_CNFG1 =0x43 , +L01_CNFG2 , +L02_CNFG1 , +L02_CNFG2 , +L03_CNFG1 , +L03_CNFG2 , +L04_CNFG1 , +L04_CNFG2 , +L05_CNFG1 , +L05_CNFG2 , +L06_CNFG1 , +L06_CNFG2 , +L07_CNFG1 , +L07_CNFG2 , +L08_CNFG1 , +L08_CNFG2 , +L09_CNFG1 , +L09_CNFG2 , +L10_CNFG1 , +L10_CNFG2 , +LDO_INT1 , +LDO_INT2 , +LDO_INT1M , +LDO_INT2M , +LDO_CNFG3 , +SW1_CNTRL , +SW2_CNTRL , +SW3_CNTRL , +SW4_CNTRL , +EPDCNFG , +EPDINTS , +EPDINT , +EPDINTM , +EPDVCOM , +EPDVEE , +EPDVNEG , +EPDVPOS , + EPDVDDH,
include/power/max77696_pmic.h line 61
Quoted 10 lines
include/power/max77696_pmic.h new file +10
-0+EPDSEQ , +EPDOKINTS , +CID =0x9c , +EPDDIS =0xb5 , + PMIC_NUM_OF_REGS, +}; + +int power_max77696_init (unsigned char bus); + +#endif
Applied to u-boot-imx, thanks !
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 =====================================================================