Commit 294a97da34529bb318996806651ac314b1734c1c

Authored by Łukasz Majewski
Committed by Anatolij Gustschin
1 parent eba423910c
Exists in master and in 57 other branches 8qm-imx_v2020.04_5.4.70_2.3.0, emb_lf-6.6.52-2.2.0, emb_lf_v2022.04, emb_lf_v2023.04, emb_lf_v2024.04, imx_v2015.04_4.1.15_1.0.0_ga, pitx_8mp_lf_v2020.04, smarc-8m-android-10.0.0_2.6.0, smarc-8m-android-11.0.0_2.0.0, smarc-8mp-android-11.0.0_2.0.0, smarc-emmc-imx_v2014.04_3.10.53_1.1.0_ga, smarc-emmc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx-l5.0.0_1.0.0-ga, smarc-imx6_v2018.03_4.14.98_2.0.0_ga, smarc-imx7_v2017.03_4.9.11_1.0.0_ga, smarc-imx7_v2018.03_4.14.98_2.0.0_ga, smarc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx_v2015.04_4.1.15_1.0.0_ga, smarc-imx_v2017.03_4.9.11_1.0.0_ga, smarc-imx_v2017.03_4.9.88_2.0.0_ga, smarc-imx_v2017.03_o8.1.0_1.3.0_8m, smarc-imx_v2018.03_4.14.78_1.0.0_ga, smarc-m6.0.1_2.1.0-ga, smarc-n7.1.2_2.0.0-ga, smarc-rel_imx_4.1.15_2.0.0_ga, smarc_8m-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8m-imx_v2019.04_4.19.35_1.1.0, smarc_8m_00d0-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2019.04_4.19.35_1.1.0, smarc_8mm-imx_v2020.04_5.4.24_2.1.0, smarc_8mp_lf_v2020.04, smarc_8mq-imx_v2020.04_5.4.24_2.1.0, smarc_8mq_lf_v2020.04, ti-u-boot-2015.07, u-boot-2013.01.y, v2013.10, v2013.10-smarct33, v2013.10-smartmen, v2014.01, v2014.04, v2014.04-smarct33, v2014.04-smarct33-emmc, v2014.04-smartmen, v2014.07, v2014.07-smarct33, v2014.07-smartmen, v2015.07-smarct33, v2015.07-smarct33-emmc, v2015.07-smarct4x, v2016.05-dlt, v2016.05-smarct3x, v2016.05-smarct3x-emmc, v2016.05-smarct4x, v2017.01-smarct3x, v2017.01-smarct3x-emmc, v2017.01-smarct4x

pmic:muic: Support for MUIC built into MAX8997 device

Support for MUIC (Micro USB Integrated Circuit) built into the MAX8997
power management device.

The MUIC device will work with redesigned PMIC framework.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Stefano Babic <sbabic@denx.de>

Showing 3 changed files with 152 additions and 0 deletions Side-by-side Diff

drivers/power/pmic/Makefile
... ... @@ -27,6 +27,7 @@
27 27  
28 28 COBJS-$(CONFIG_PMIC_MAX8998) += pmic_max8998.o
29 29 COBJS-$(CONFIG_PMIC_MAX8997) += pmic_max8997.o
  30 +COBJS-$(CONFIG_POWER_MUIC_MAX8997) += muic_max8997.o
30 31  
31 32 COBJS := $(COBJS-y)
32 33 SRCS := $(COBJS:.o=.c)
drivers/power/pmic/muic_max8997.c
  1 +/*
  2 + * Copyright (C) 2012 Samsung Electronics
  3 + * Lukasz Majewski <l.majewski@samsung.com>
  4 + *
  5 + * See file CREDITS for list of people who contributed to this
  6 + * project.
  7 + *
  8 + * This program is free software; you can redistribute it and/or
  9 + * modify it under the terms of the GNU General Public License as
  10 + * published by the Free Software Foundation; either version 2 of
  11 + * the License, or (at your option) any later version.
  12 + *
  13 + * This program is distributed in the hope that it will be useful,
  14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16 + * GNU General Public License for more details.
  17 + *
  18 + * You should have received a copy of the GNU General Public License
  19 + * along with this program; if not, write to the Free Software
  20 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21 + * MA 02111-1307 USA
  22 + */
  23 +
  24 +#include <common.h>
  25 +#include <power/pmic.h>
  26 +#include <power/power_chrg.h>
  27 +#include <power/max8997_muic.h>
  28 +#include <i2c.h>
  29 +#include <errno.h>
  30 +
  31 +static int power_chrg_get_type(struct pmic *p)
  32 +{
  33 + unsigned int val;
  34 + unsigned char charge_type, charger;
  35 +
  36 + if (pmic_probe(p))
  37 + return CHARGER_NO;
  38 +
  39 + pmic_reg_read(p, MAX8997_MUIC_STATUS2, &val);
  40 + charge_type = val & MAX8997_MUIC_CHG_MASK;
  41 +
  42 + switch (charge_type) {
  43 + case MAX8997_MUIC_CHG_NO:
  44 + charger = CHARGER_NO;
  45 + break;
  46 + case MAX8997_MUIC_CHG_USB:
  47 + case MAX8997_MUIC_CHG_USB_D:
  48 + charger = CHARGER_USB;
  49 + break;
  50 + case MAX8997_MUIC_CHG_TA:
  51 + case MAX8997_MUIC_CHG_TA_1A:
  52 + charger = CHARGER_TA;
  53 + break;
  54 + case MAX8997_MUIC_CHG_TA_500:
  55 + charger = CHARGER_TA_500;
  56 + break;
  57 + default:
  58 + charger = CHARGER_UNKNOWN;
  59 + break;
  60 + }
  61 +
  62 + return charger;
  63 +}
  64 +
  65 +static struct power_chrg power_chrg_muic_ops = {
  66 + .chrg_type = power_chrg_get_type,
  67 +};
  68 +
  69 +int power_muic_init(unsigned int bus)
  70 +{
  71 + static const char name[] = "MAX8997_MUIC";
  72 + struct pmic *p = pmic_alloc();
  73 +
  74 + if (!p) {
  75 + printf("%s: POWER allocation error!\n", __func__);
  76 + return -ENOMEM;
  77 + }
  78 +
  79 + debug("Board Micro USB Interface Controller init\n");
  80 +
  81 + p->name = name;
  82 + p->interface = PMIC_I2C;
  83 + p->number_of_regs = MUIC_NUM_OF_REGS;
  84 + p->hw.i2c.addr = MAX8997_MUIC_I2C_ADDR;
  85 + p->hw.i2c.tx_num = 1;
  86 + p->bus = bus;
  87 +
  88 + p->chrg = &power_chrg_muic_ops;
  89 + return 0;
  90 +}
include/power/max8997_muic.h
  1 +/*
  2 + * Copyright (C) 2012 Samsung Electronics
  3 + * Lukasz Majewski <l.majewski@samsung.com>
  4 + *
  5 + * See file CREDITS for list of people who contributed to this
  6 + * project.
  7 + *
  8 + * This program is free software; you can redistribute it and/or
  9 + * modify it under the terms of the GNU General Public License as
  10 + * published by the Free Software Foundation; either version 2 of
  11 + * the License, or (at your option) any later version.
  12 + *
  13 + * This program is distributed in the hope that it will be useful,
  14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16 + * GNU General Public License for more details.
  17 + *
  18 + * You should have received a copy of the GNU General Public License
  19 + * along with this program; if not, write to the Free Software
  20 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21 + * MA 02111-1307 USA
  22 + */
  23 +
  24 +#ifndef __MAX8997_MUIC_H_
  25 +#define __MAX8997_MUIC_H_
  26 +
  27 +#include <power/power_chrg.h>
  28 +
  29 +/* MAX8997_MUIC_STATUS2 */
  30 +#define MAX8997_MUIC_CHG_NO 0x00
  31 +#define MAX8997_MUIC_CHG_USB 0x01
  32 +#define MAX8997_MUIC_CHG_USB_D 0x02
  33 +#define MAX8997_MUIC_CHG_TA 0x03
  34 +#define MAX8997_MUIC_CHG_TA_500 0x04
  35 +#define MAX8997_MUIC_CHG_TA_1A 0x05
  36 +#define MAX8997_MUIC_CHG_MASK 0x07
  37 +
  38 +/* MAX 8997 MUIC registers */
  39 +enum {
  40 + MAX8997_MUIC_ID = 0x00,
  41 + MAX8997_MUIC_INT1 = 0x01,
  42 + MAX8997_MUIC_INT2 = 0x02,
  43 + MAX8997_MUIC_INT3 = 0x03,
  44 + MAX8997_MUIC_STATUS1 = 0x04,
  45 + MAX8997_MUIC_STATUS2 = 0x05,
  46 + MAX8997_MUIC_STATUS3 = 0x06,
  47 + MAX8997_MUIC_INTMASK1 = 0x07,
  48 + MAX8997_MUIC_INTMASK2 = 0x08,
  49 + MAX8997_MUIC_INTMASK3 = 0x09,
  50 + MAX8997_MUIC_CDETCTRL = 0x0A,
  51 + MAX8997_MUIC_CONTROL1 = 0x0C,
  52 + MAX8997_MUIC_CONTROL2 = 0x0D,
  53 + MAX8997_MUIC_CONTROL3 = 0x0E,
  54 +
  55 + MUIC_NUM_OF_REGS = 0x0F,
  56 +};
  57 +
  58 +#define MAX8997_MUIC_I2C_ADDR (0x4A >> 1)
  59 +
  60 +int power_muic_init(unsigned int bus);
  61 +#endif /* __MAX8997_MUIC_H_ */