[U-Boot] [PATCH V3 4/7] board: samsung: universal_210: use the driver model for max8998

Simon Glass sjg at chromium.org
Thu Jan 19 14:57:26 CET 2017


Hi Jaehoon,

On 8 January 2017 at 22:47, Jaehoon Chung <jh80.chung at samsung.com> wrote:
> Revmoe the "ifndef CONFIG_DM_I2C".
> Intead, use the driver model for max8998.
>
> Signed-off-by: Jaehoon Chung <jh80.chung at samsung.com>
> ---
>  board/samsung/universal_c210/universal.c | 169 +++++++++++++++++--------------
>  1 file changed, 94 insertions(+), 75 deletions(-)
>
> diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c
> index c3946ee..0645843 100644
> --- a/board/samsung/universal_c210/universal.c
> +++ b/board/samsung/universal_c210/universal.c
> @@ -27,33 +27,21 @@
>  DECLARE_GLOBAL_DATA_PTR;
>
>  unsigned int board_rev;
> +static int init_pmic_lcd(void);
>
>  u32 get_board_rev(void)
>  {
>         return board_rev;
>  }
>
> -static int get_hwrev(void)
> +int exynos_power_init(void)
>  {
> -       return board_rev & 0xFF;
> +       return init_pmic_lcd();
>  }
>
> -int exynos_power_init(void)
> +static int get_hwrev(void)
>  {
> -#ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */
> -       int ret;
> -
> -       /*
> -        * For PMIC the I2C bus is named as I2C5, but it is connected
> -        * to logical I2C adapter 0
> -        */
> -       ret = pmic_init(I2C_0);
> -       if (ret)
> -               return ret;
> -
> -       init_pmic_lcd();
> -#endif
> -       return 0;
> +       return board_rev & 0xFF;
>  }
>
>  static unsigned short get_adc_value(int channel)
> @@ -83,23 +71,29 @@ static unsigned short get_adc_value(int channel)
>
>  static int adc_power_control(int on)
>  {
> -#ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */
> +       struct udevice *dev;
>         int ret;
> -       struct pmic *p = pmic_get("MAX8998_PMIC");
> -       if (!p)
> -               return -ENODEV;
> +       u8 reg;
>
> -       if (pmic_probe(p))
> -               return -1;
> +       ret = pmic_get("max8998-pmic", &dev);
> +       if (ret) {
> +               puts("Failed to get MAX8998!\n");
> +               return ret;
> +       }
>
> -       ret = pmic_set_output(p,
> -                             MAX8998_REG_ONOFF1,
> -                             MAX8998_LDO4, !!on);
> +       reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1);
> +       if (on)
> +               reg |= MAX8998_LDO4;
> +       else
> +               reg &= ~MAX8998_LDO4;
> +
> +       ret = pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg);
> +       if (ret) {
> +               puts("MAX8998 LDO setting error\n");
> +               return -EINVAL;
> +       }
>
> -       return ret;
> -#else
>         return 0;
> -#endif
>  }
>
>  static unsigned int get_hw_revision(void)
> @@ -147,39 +141,50 @@ static void check_hw_revision(void)
>  #ifdef CONFIG_USB_GADGET
>  static int s5pc210_phy_control(int on)
>  {
> -#ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */
> -       int ret = 0;
> -       struct pmic *p = pmic_get("MAX8998_PMIC");
> -       if (!p)
> -               return -ENODEV;
> +       struct udevice *dev;
> +       int ret;
> +       u8 reg;
>
> -       if (pmic_probe(p))
> -               return -1;
> +       ret = pmic_get("max8998-pmic", &dev);
> +       if (ret) {
> +               puts("Failed to get MAX8998!\n");
> +               return ret;
> +       }
>
>         if (on) {
> -               ret |= pmic_set_output(p,
> -                                      MAX8998_REG_BUCK_ACTIVE_DISCHARGE3,
> -                                      MAX8998_SAFEOUT1, LDO_ON);
> -               ret |= pmic_set_output(p, MAX8998_REG_ONOFF1,
> -                                     MAX8998_LDO3, LDO_ON);
> -               ret |= pmic_set_output(p, MAX8998_REG_ONOFF2,
> -                                     MAX8998_LDO8, LDO_ON);
> +               reg = pmic_reg_read(dev, MAX8998_REG_BUCK_ACTIVE_DISCHARGE3);
> +               reg |= MAX8998_SAFEOUT1;
> +               ret |= pmic_reg_write(dev,
> +                       MAX8998_REG_BUCK_ACTIVE_DISCHARGE3, reg);
> +
> +               reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1);
> +               reg |= MAX8998_LDO3;
> +               ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg);

Can you use pmic_clrsetbits()?

Regards,
Simon


More information about the U-Boot mailing list