* [U-Boot] [PATCH 1/3] configs: trats2: enable the max77686 regulator config
[not found] <CGME20180125070638epcas2p208e91c4ab6d16e860cbc2b386fa15ff7@epcas2p2.samsung.com>
@ 2018-01-25 7:06 ` Jaehoon Chung
2018-01-25 7:06 ` [U-Boot] [PATCH 2/3] power: pmic_max77686: remove the old pmic_max77686 file Jaehoon Chung
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jaehoon Chung @ 2018-01-25 7:06 UTC (permalink / raw)
To: u-boot
Enable the CONFIG_DM_REGULATOR_MAX77686 for using regulator driver.
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
---
configs/trats2_defconfig | 2 ++
1 file changed, 2 insertions(+)
diff --git a/configs/trats2_defconfig b/configs/trats2_defconfig
index aaa25a9bc7..dab62530e7 100644
--- a/configs/trats2_defconfig
+++ b/configs/trats2_defconfig
@@ -46,6 +46,8 @@ CONFIG_MMC_SDHCI_SDMA=y
CONFIG_MMC_SDHCI_S5P=y
CONFIG_DM_PMIC=y
CONFIG_DM_PMIC_MAX77686=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_MAX77686=y
CONFIG_USB=y
CONFIG_DM_USB=y
CONFIG_USB_GADGET=y
--
2.15.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH 2/3] power: pmic_max77686: remove the old pmic_max77686 file
2018-01-25 7:06 ` [U-Boot] [PATCH 1/3] configs: trats2: enable the max77686 regulator config Jaehoon Chung
@ 2018-01-25 7:06 ` Jaehoon Chung
2018-01-25 9:19 ` Lukasz Majewski
2018-01-25 7:06 ` [U-Boot] [PATCH 3/3] lib: fdtdec: drop the old compatible about max77686 Jaehoon Chung
2018-01-25 9:18 ` [U-Boot] [PATCH 1/3] configs: trats2: enable the max77686 regulator config Lukasz Majewski
2 siblings, 1 reply; 5+ messages in thread
From: Jaehoon Chung @ 2018-01-25 7:06 UTC (permalink / raw)
To: u-boot
max77686 pmic is supporting with max77686.c under pmic/ and regulator/
direnctroy. Remove pmic_max77686.c what didn't use anywhere.
Instead, enable CONFIG_DM_REGULATOR_MAX77686 and
CONFIG_DM_PMIC_MAX77686.
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
---
drivers/power/pmic/Makefile | 1 -
drivers/power/pmic/pmic_max77686.c | 304 -------------------------------------
2 files changed, 305 deletions(-)
delete mode 100644 drivers/power/pmic/pmic_max77686.c
diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile
index 7d6c583d34..265b7cb2f6 100644
--- a/drivers/power/pmic/Makefile
+++ b/drivers/power/pmic/Makefile
@@ -29,7 +29,6 @@ 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
-obj-$(CONFIG_POWER_MAX77686) += pmic_max77686.o
obj-$(CONFIG_POWER_PFUZE100) += pmic_pfuze100.o
obj-$(CONFIG_POWER_PFUZE3000) += pmic_pfuze3000.o
obj-$(CONFIG_POWER_TPS65217) += pmic_tps65217.o
diff --git a/drivers/power/pmic/pmic_max77686.c b/drivers/power/pmic/pmic_max77686.c
deleted file mode 100644
index 8e653316d1..0000000000
--- a/drivers/power/pmic/pmic_max77686.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Copyright (C) 2012 Samsung Electronics
- * Rajeshwari Shinde <rajeshwari.s@samsung.com>
- *
- * SPDX-License-Identifier: GPL-2.0+
- */
-
-#include <common.h>
-#include <fdtdec.h>
-#include <i2c.h>
-#include <power/pmic.h>
-#include <power/max77686_pmic.h>
-#include <errno.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-static const char max77686_buck_addr[] = {
- 0xff, 0x10, 0x12, 0x1c, 0x26, 0x30, 0x32, 0x34, 0x36, 0x38
-};
-
-static unsigned int max77686_ldo_volt2hex(int ldo, ulong uV)
-{
- unsigned int hex = 0;
-
- switch (ldo) {
- case 1:
- case 2:
- case 6:
- case 7:
- case 8:
- case 15:
- hex = (uV - 800000) / 25000;
- break;
- default:
- hex = (uV - 800000) / 50000;
- }
-
- if (hex >= 0 && hex <= MAX77686_LDO_VOLT_MAX_HEX)
- return hex;
-
- debug("%s: %ld is wrong voltage value for LDO%d\n", __func__, uV, ldo);
- return 0;
-}
-
-static int max77686_buck_volt2hex(int buck, ulong uV)
-{
- int hex = 0;
-
- if (buck < 5 || buck > 9) {
- debug("%s: buck %d is not supported\n", __func__, buck);
- return -EINVAL;
- }
-
- hex = (uV - 750000) / 50000;
-
- if (hex >= 0 && hex <= MAX77686_BUCK_VOLT_MAX_HEX)
- return hex;
-
- debug("%s: %ld is wrong voltage value for BUCK%d\n",
- __func__, uV, buck);
- return -EINVAL;
-}
-
-int max77686_set_ldo_voltage(struct pmic *p, int ldo, ulong uV)
-{
- unsigned int val, ret, hex, adr;
-
- if (ldo < 1 || ldo > 26) {
- printf("%s: %d is wrong ldo number\n", __func__, ldo);
- return -EINVAL;
- }
-
- adr = MAX77686_REG_PMIC_LDO1CTRL1 + ldo - 1;
- hex = max77686_ldo_volt2hex(ldo, uV);
-
- if (!hex)
- return -EINVAL;
-
- ret = pmic_reg_read(p, adr, &val);
- if (ret)
- return ret;
-
- val &= ~MAX77686_LDO_VOLT_MASK;
- val |= hex;
- ret |= pmic_reg_write(p, adr, val);
-
- return ret;
-}
-
-int max77686_set_buck_voltage(struct pmic *p, int buck, ulong uV)
-{
- unsigned int val, adr;
- int hex, ret;
-
- if (buck < 5 || buck > 9) {
- printf("%s: %d is an unsupported bucket number\n",
- __func__, buck);
- return -EINVAL;
- }
-
- adr = max77686_buck_addr[buck] + 1;
- hex = max77686_buck_volt2hex(buck, uV);
-
- if (hex < 0)
- return hex;
-
- ret = pmic_reg_read(p, adr, &val);
- if (ret)
- return ret;
-
- val &= ~MAX77686_BUCK_VOLT_MASK;
- ret |= pmic_reg_write(p, adr, val | hex);
-
- return ret;
-}
-
-int max77686_set_ldo_mode(struct pmic *p, int ldo, char opmode)
-{
- unsigned int val, ret, adr, mode;
-
- if (ldo < 1 || 26 < ldo) {
- printf("%s: %d is wrong ldo number\n", __func__, ldo);
- return -EINVAL;
- }
-
- adr = MAX77686_REG_PMIC_LDO1CTRL1 + ldo - 1;
-
- /* mode */
- switch (opmode) {
- case OPMODE_OFF:
- mode = MAX77686_LDO_MODE_OFF;
- break;
- case OPMODE_STANDBY:
- switch (ldo) {
- case 2:
- case 6:
- case 7:
- case 8:
- case 10:
- case 11:
- case 12:
- case 14:
- case 15:
- case 16:
- mode = MAX77686_LDO_MODE_STANDBY;
- break;
- default:
- mode = 0xff;
- }
- break;
- case OPMODE_LPM:
- mode = MAX77686_LDO_MODE_LPM;
- break;
- case OPMODE_ON:
- mode = MAX77686_LDO_MODE_ON;
- break;
- default:
- mode = 0xff;
- }
-
- if (mode == 0xff) {
- printf("%s: %d is not supported on LDO%d\n",
- __func__, opmode, ldo);
- return -ENOTSUPP;
- }
-
- ret = pmic_reg_read(p, adr, &val);
- if (ret)
- return ret;
-
- val &= ~MAX77686_LDO_MODE_MASK;
- val |= mode;
- ret |= pmic_reg_write(p, adr, val);
-
- return ret;
-}
-
-int max77686_set_buck_mode(struct pmic *p, int buck, char opmode)
-{
- unsigned int val, ret, mask, adr, size, mode, mode_shift;
-
- size = ARRAY_SIZE(max77686_buck_addr);
- if (buck >= size) {
- printf("%s: %d is wrong buck number\n", __func__, buck);
- return -EINVAL;
- }
-
- adr = max77686_buck_addr[buck];
-
- /* mask */
- switch (buck) {
- case 2:
- case 3:
- case 4:
- mode_shift = MAX77686_BUCK_MODE_SHIFT_2;
- break;
- default:
- mode_shift = MAX77686_BUCK_MODE_SHIFT_1;
- }
-
- mask = MAX77686_BUCK_MODE_MASK << mode_shift;
-
- /* mode */
- switch (opmode) {
- case OPMODE_OFF:
- mode = MAX77686_BUCK_MODE_OFF << mode_shift;
- break;
- case OPMODE_STANDBY:
- switch (buck) {
- case 1:
- case 2:
- case 3:
- case 4:
- mode = MAX77686_BUCK_MODE_STANDBY << mode_shift;
- break;
- default:
- mode = 0xff;
- }
- break;
- case OPMODE_LPM:
- switch (buck) {
- case 2:
- case 3:
- case 4:
- mode = MAX77686_BUCK_MODE_LPM << mode_shift;
- break;
- default:
- mode = 0xff;
- }
- break;
- case OPMODE_ON:
- mode = MAX77686_BUCK_MODE_ON << mode_shift;
- break;
- default:
- mode = 0xff;
- }
-
- if (mode == 0xff) {
- printf("%s: %d is not supported on BUCK%d\n",
- __func__, opmode, buck);
- return -ENOTSUPP;
- }
-
- ret = pmic_reg_read(p, adr, &val);
- if (ret)
- return ret;
-
- val &= ~mask;
- val |= mode;
- ret |= pmic_reg_write(p, adr, val);
-
- return ret;
-}
-
-int pmic_init(unsigned char bus)
-{
- static const char name[] = "MAX77686_PMIC";
- struct pmic *p = pmic_alloc();
-#if CONFIG_IS_ENABLED(OF_CONTROL)
- const void *blob = gd->fdt_blob;
- int node, parent, tmp;
-#endif
-
- if (!p) {
- printf("%s: POWER allocation error!\n", __func__);
- return -ENOMEM;
- }
-
-#if CONFIG_IS_ENABLED(OF_CONTROL)
- node = fdtdec_next_compatible(blob, 0, COMPAT_MAXIM_MAX77686_PMIC);
- if (node < 0) {
- debug("PMIC: No node for PMIC Chip in device tree\n");
- debug("node = %d\n", node);
- return -ENODEV;
- }
-
- parent = fdt_parent_offset(blob, node);
- if (parent < 0) {
- debug("%s: Cannot find node parent\n", __func__);
- return -ENODEV;
- }
-
- /* tmp since p->bus is unsigned */
- tmp = i2c_get_bus_num_fdt(parent);
- if (tmp < 0) {
- debug("%s: Cannot find I2C bus\n", __func__);
- return -ENODEV;
- }
- p->bus = tmp;
- p->hw.i2c.addr = fdtdec_get_int(blob, node, "reg", 9);
-#else
- p->bus = bus;
- p->hw.i2c.addr = MAX77686_I2C_ADDR;
-#endif
-
- p->name = name;
- p->interface = PMIC_I2C;
- p->number_of_regs = MAX77686_NUM_OF_REGS;
- p->hw.i2c.tx_num = 1;
-
- puts("Board PMIC init\n");
-
- return 0;
-}
--
2.15.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH 3/3] lib: fdtdec: drop the old compatible about max77686
2018-01-25 7:06 ` [U-Boot] [PATCH 1/3] configs: trats2: enable the max77686 regulator config Jaehoon Chung
2018-01-25 7:06 ` [U-Boot] [PATCH 2/3] power: pmic_max77686: remove the old pmic_max77686 file Jaehoon Chung
@ 2018-01-25 7:06 ` Jaehoon Chung
2018-01-25 9:18 ` [U-Boot] [PATCH 1/3] configs: trats2: enable the max77686 regulator config Lukasz Majewski
2 siblings, 0 replies; 5+ messages in thread
From: Jaehoon Chung @ 2018-01-25 7:06 UTC (permalink / raw)
To: u-boot
Drop the old compatible about max77686.
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
---
lib/fdtdec.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index df9d9ae433..58830aa370 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -48,7 +48,6 @@ static const char * const compat_names[COMPAT_COUNT] = {
COMPAT(SAMSUNG_EXYNOS_MIPI_DSI, "samsung,exynos-mipi-dsi"),
COMPAT(SAMSUNG_EXYNOS_DWMMC, "samsung,exynos-dwmmc"),
COMPAT(SAMSUNG_EXYNOS_MMC, "samsung,exynos-mmc"),
- COMPAT(MAXIM_MAX77686_PMIC, "maxim,max77686"),
COMPAT(GENERIC_SPI_FLASH, "spi-flash"),
COMPAT(MAXIM_98095_CODEC, "maxim,max98095-codec"),
COMPAT(SAMSUNG_EXYNOS5_I2C, "samsung,exynos5-hsi2c"),
--
2.15.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH 1/3] configs: trats2: enable the max77686 regulator config
2018-01-25 7:06 ` [U-Boot] [PATCH 1/3] configs: trats2: enable the max77686 regulator config Jaehoon Chung
2018-01-25 7:06 ` [U-Boot] [PATCH 2/3] power: pmic_max77686: remove the old pmic_max77686 file Jaehoon Chung
2018-01-25 7:06 ` [U-Boot] [PATCH 3/3] lib: fdtdec: drop the old compatible about max77686 Jaehoon Chung
@ 2018-01-25 9:18 ` Lukasz Majewski
2 siblings, 0 replies; 5+ messages in thread
From: Lukasz Majewski @ 2018-01-25 9:18 UTC (permalink / raw)
To: u-boot
On Thu, 25 Jan 2018 16:06:35 +0900
Jaehoon Chung <jh80.chung@samsung.com> wrote:
> Enable the CONFIG_DM_REGULATOR_MAX77686 for using regulator driver.
>
> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> ---
> configs/trats2_defconfig | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/configs/trats2_defconfig b/configs/trats2_defconfig
> index aaa25a9bc7..dab62530e7 100644
> --- a/configs/trats2_defconfig
> +++ b/configs/trats2_defconfig
> @@ -46,6 +46,8 @@ CONFIG_MMC_SDHCI_SDMA=y
> CONFIG_MMC_SDHCI_S5P=y
> CONFIG_DM_PMIC=y
> CONFIG_DM_PMIC_MAX77686=y
> +CONFIG_DM_REGULATOR=y
> +CONFIG_DM_REGULATOR_MAX77686=y
> CONFIG_USB=y
> CONFIG_DM_USB=y
> CONFIG_USB_GADGET=y
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180125/bb00069f/attachment.sig>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH 2/3] power: pmic_max77686: remove the old pmic_max77686 file
2018-01-25 7:06 ` [U-Boot] [PATCH 2/3] power: pmic_max77686: remove the old pmic_max77686 file Jaehoon Chung
@ 2018-01-25 9:19 ` Lukasz Majewski
0 siblings, 0 replies; 5+ messages in thread
From: Lukasz Majewski @ 2018-01-25 9:19 UTC (permalink / raw)
To: u-boot
On Thu, 25 Jan 2018 16:06:36 +0900
Jaehoon Chung <jh80.chung@samsung.com> wrote:
> max77686 pmic is supporting with max77686.c under pmic/ and regulator/
> direnctroy. Remove pmic_max77686.c what didn't use anywhere.
> Instead, enable CONFIG_DM_REGULATOR_MAX77686 and
> CONFIG_DM_PMIC_MAX77686.
>
> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> ---
> drivers/power/pmic/Makefile | 1 -
> drivers/power/pmic/pmic_max77686.c | 304
> ------------------------------------- 2 files changed, 305
> deletions(-) delete mode 100644 drivers/power/pmic/pmic_max77686.c
>
> diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile
> index 7d6c583d34..265b7cb2f6 100644
> --- a/drivers/power/pmic/Makefile
> +++ b/drivers/power/pmic/Makefile
> @@ -29,7 +29,6 @@ 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
> -obj-$(CONFIG_POWER_MAX77686) += pmic_max77686.o
> obj-$(CONFIG_POWER_PFUZE100) += pmic_pfuze100.o
> obj-$(CONFIG_POWER_PFUZE3000) += pmic_pfuze3000.o
> obj-$(CONFIG_POWER_TPS65217) += pmic_tps65217.o
> diff --git a/drivers/power/pmic/pmic_max77686.c
> b/drivers/power/pmic/pmic_max77686.c deleted file mode 100644
> index 8e653316d1..0000000000
> --- a/drivers/power/pmic/pmic_max77686.c
> +++ /dev/null
> @@ -1,304 +0,0 @@
> -/*
> - * Copyright (C) 2012 Samsung Electronics
> - * Rajeshwari Shinde <rajeshwari.s@samsung.com>
> - *
> - * SPDX-License-Identifier: GPL-2.0+
> - */
> -
> -#include <common.h>
> -#include <fdtdec.h>
> -#include <i2c.h>
> -#include <power/pmic.h>
> -#include <power/max77686_pmic.h>
> -#include <errno.h>
> -
> -DECLARE_GLOBAL_DATA_PTR;
> -
> -static const char max77686_buck_addr[] = {
> - 0xff, 0x10, 0x12, 0x1c, 0x26, 0x30, 0x32, 0x34, 0x36, 0x38
> -};
> -
> -static unsigned int max77686_ldo_volt2hex(int ldo, ulong uV)
> -{
> - unsigned int hex = 0;
> -
> - switch (ldo) {
> - case 1:
> - case 2:
> - case 6:
> - case 7:
> - case 8:
> - case 15:
> - hex = (uV - 800000) / 25000;
> - break;
> - default:
> - hex = (uV - 800000) / 50000;
> - }
> -
> - if (hex >= 0 && hex <= MAX77686_LDO_VOLT_MAX_HEX)
> - return hex;
> -
> - debug("%s: %ld is wrong voltage value for LDO%d\n",
> __func__, uV, ldo);
> - return 0;
> -}
> -
> -static int max77686_buck_volt2hex(int buck, ulong uV)
> -{
> - int hex = 0;
> -
> - if (buck < 5 || buck > 9) {
> - debug("%s: buck %d is not supported\n", __func__,
> buck);
> - return -EINVAL;
> - }
> -
> - hex = (uV - 750000) / 50000;
> -
> - if (hex >= 0 && hex <= MAX77686_BUCK_VOLT_MAX_HEX)
> - return hex;
> -
> - debug("%s: %ld is wrong voltage value for BUCK%d\n",
> - __func__, uV, buck);
> - return -EINVAL;
> -}
> -
> -int max77686_set_ldo_voltage(struct pmic *p, int ldo, ulong uV)
> -{
> - unsigned int val, ret, hex, adr;
> -
> - if (ldo < 1 || ldo > 26) {
> - printf("%s: %d is wrong ldo number\n", __func__,
> ldo);
> - return -EINVAL;
> - }
> -
> - adr = MAX77686_REG_PMIC_LDO1CTRL1 + ldo - 1;
> - hex = max77686_ldo_volt2hex(ldo, uV);
> -
> - if (!hex)
> - return -EINVAL;
> -
> - ret = pmic_reg_read(p, adr, &val);
> - if (ret)
> - return ret;
> -
> - val &= ~MAX77686_LDO_VOLT_MASK;
> - val |= hex;
> - ret |= pmic_reg_write(p, adr, val);
> -
> - return ret;
> -}
> -
> -int max77686_set_buck_voltage(struct pmic *p, int buck, ulong uV)
> -{
> - unsigned int val, adr;
> - int hex, ret;
> -
> - if (buck < 5 || buck > 9) {
> - printf("%s: %d is an unsupported bucket number\n",
> - __func__, buck);
> - return -EINVAL;
> - }
> -
> - adr = max77686_buck_addr[buck] + 1;
> - hex = max77686_buck_volt2hex(buck, uV);
> -
> - if (hex < 0)
> - return hex;
> -
> - ret = pmic_reg_read(p, adr, &val);
> - if (ret)
> - return ret;
> -
> - val &= ~MAX77686_BUCK_VOLT_MASK;
> - ret |= pmic_reg_write(p, adr, val | hex);
> -
> - return ret;
> -}
> -
> -int max77686_set_ldo_mode(struct pmic *p, int ldo, char opmode)
> -{
> - unsigned int val, ret, adr, mode;
> -
> - if (ldo < 1 || 26 < ldo) {
> - printf("%s: %d is wrong ldo number\n", __func__,
> ldo);
> - return -EINVAL;
> - }
> -
> - adr = MAX77686_REG_PMIC_LDO1CTRL1 + ldo - 1;
> -
> - /* mode */
> - switch (opmode) {
> - case OPMODE_OFF:
> - mode = MAX77686_LDO_MODE_OFF;
> - break;
> - case OPMODE_STANDBY:
> - switch (ldo) {
> - case 2:
> - case 6:
> - case 7:
> - case 8:
> - case 10:
> - case 11:
> - case 12:
> - case 14:
> - case 15:
> - case 16:
> - mode = MAX77686_LDO_MODE_STANDBY;
> - break;
> - default:
> - mode = 0xff;
> - }
> - break;
> - case OPMODE_LPM:
> - mode = MAX77686_LDO_MODE_LPM;
> - break;
> - case OPMODE_ON:
> - mode = MAX77686_LDO_MODE_ON;
> - break;
> - default:
> - mode = 0xff;
> - }
> -
> - if (mode == 0xff) {
> - printf("%s: %d is not supported on LDO%d\n",
> - __func__, opmode, ldo);
> - return -ENOTSUPP;
> - }
> -
> - ret = pmic_reg_read(p, adr, &val);
> - if (ret)
> - return ret;
> -
> - val &= ~MAX77686_LDO_MODE_MASK;
> - val |= mode;
> - ret |= pmic_reg_write(p, adr, val);
> -
> - return ret;
> -}
> -
> -int max77686_set_buck_mode(struct pmic *p, int buck, char opmode)
> -{
> - unsigned int val, ret, mask, adr, size, mode, mode_shift;
> -
> - size = ARRAY_SIZE(max77686_buck_addr);
> - if (buck >= size) {
> - printf("%s: %d is wrong buck number\n", __func__,
> buck);
> - return -EINVAL;
> - }
> -
> - adr = max77686_buck_addr[buck];
> -
> - /* mask */
> - switch (buck) {
> - case 2:
> - case 3:
> - case 4:
> - mode_shift = MAX77686_BUCK_MODE_SHIFT_2;
> - break;
> - default:
> - mode_shift = MAX77686_BUCK_MODE_SHIFT_1;
> - }
> -
> - mask = MAX77686_BUCK_MODE_MASK << mode_shift;
> -
> - /* mode */
> - switch (opmode) {
> - case OPMODE_OFF:
> - mode = MAX77686_BUCK_MODE_OFF << mode_shift;
> - break;
> - case OPMODE_STANDBY:
> - switch (buck) {
> - case 1:
> - case 2:
> - case 3:
> - case 4:
> - mode = MAX77686_BUCK_MODE_STANDBY <<
> mode_shift;
> - break;
> - default:
> - mode = 0xff;
> - }
> - break;
> - case OPMODE_LPM:
> - switch (buck) {
> - case 2:
> - case 3:
> - case 4:
> - mode = MAX77686_BUCK_MODE_LPM << mode_shift;
> - break;
> - default:
> - mode = 0xff;
> - }
> - break;
> - case OPMODE_ON:
> - mode = MAX77686_BUCK_MODE_ON << mode_shift;
> - break;
> - default:
> - mode = 0xff;
> - }
> -
> - if (mode == 0xff) {
> - printf("%s: %d is not supported on BUCK%d\n",
> - __func__, opmode, buck);
> - return -ENOTSUPP;
> - }
> -
> - ret = pmic_reg_read(p, adr, &val);
> - if (ret)
> - return ret;
> -
> - val &= ~mask;
> - val |= mode;
> - ret |= pmic_reg_write(p, adr, val);
> -
> - return ret;
> -}
> -
> -int pmic_init(unsigned char bus)
> -{
> - static const char name[] = "MAX77686_PMIC";
> - struct pmic *p = pmic_alloc();
> -#if CONFIG_IS_ENABLED(OF_CONTROL)
> - const void *blob = gd->fdt_blob;
> - int node, parent, tmp;
> -#endif
> -
> - if (!p) {
> - printf("%s: POWER allocation error!\n", __func__);
> - return -ENOMEM;
> - }
> -
> -#if CONFIG_IS_ENABLED(OF_CONTROL)
> - node = fdtdec_next_compatible(blob, 0,
> COMPAT_MAXIM_MAX77686_PMIC);
> - if (node < 0) {
> - debug("PMIC: No node for PMIC Chip in device
> tree\n");
> - debug("node = %d\n", node);
> - return -ENODEV;
> - }
> -
> - parent = fdt_parent_offset(blob, node);
> - if (parent < 0) {
> - debug("%s: Cannot find node parent\n", __func__);
> - return -ENODEV;
> - }
> -
> - /* tmp since p->bus is unsigned */
> - tmp = i2c_get_bus_num_fdt(parent);
> - if (tmp < 0) {
> - debug("%s: Cannot find I2C bus\n", __func__);
> - return -ENODEV;
> - }
> - p->bus = tmp;
> - p->hw.i2c.addr = fdtdec_get_int(blob, node, "reg", 9);
> -#else
> - p->bus = bus;
> - p->hw.i2c.addr = MAX77686_I2C_ADDR;
> -#endif
> -
> - p->name = name;
> - p->interface = PMIC_I2C;
> - p->number_of_regs = MAX77686_NUM_OF_REGS;
> - p->hw.i2c.tx_num = 1;
> -
> - puts("Board PMIC init\n");
> -
> - return 0;
> -}
Acked-by: Lukasz Majewski <lukma@denx.de>
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180125/48453930/attachment.sig>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-01-25 9:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20180125070638epcas2p208e91c4ab6d16e860cbc2b386fa15ff7@epcas2p2.samsung.com>
2018-01-25 7:06 ` [U-Boot] [PATCH 1/3] configs: trats2: enable the max77686 regulator config Jaehoon Chung
2018-01-25 7:06 ` [U-Boot] [PATCH 2/3] power: pmic_max77686: remove the old pmic_max77686 file Jaehoon Chung
2018-01-25 9:19 ` Lukasz Majewski
2018-01-25 7:06 ` [U-Boot] [PATCH 3/3] lib: fdtdec: drop the old compatible about max77686 Jaehoon Chung
2018-01-25 9:18 ` [U-Boot] [PATCH 1/3] configs: trats2: enable the max77686 regulator config Lukasz Majewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox