2 * Copyright (C) 2013 Samsung Electronics
3 * Piotr Wilczek <p.wilczek@samsung.com>
5 * SPDX-License-Identifier: GPL-2.0+
9 #include <power/pmic.h>
10 #include <power/power_chrg.h>
11 #include <power/max77693_muic.h>
15 static int power_chrg_get_type(struct pmic *p)
18 unsigned int charge_type, charger;
20 /* if probe failed, return cable none */
24 pmic_reg_read(p, MAX77693_MUIC_STATUS2, &val);
26 charge_type = val & MAX77693_MUIC_CHG_MASK;
28 switch (charge_type) {
29 case MAX77693_MUIC_CHG_NO:
32 case MAX77693_MUIC_CHG_USB:
33 case MAX77693_MUIC_CHG_USB_D:
34 charger = CHARGER_USB;
36 case MAX77693_MUIC_CHG_TA:
37 case MAX77693_MUIC_CHG_TA_1A:
40 case MAX77693_MUIC_CHG_TA_500:
41 charger = CHARGER_TA_500;
44 charger = CHARGER_UNKNOWN;
51 static struct power_chrg power_chrg_muic_ops = {
52 .chrg_type = power_chrg_get_type,
55 int power_muic_init(unsigned int bus)
57 static const char name[] = "MAX77693_MUIC";
58 struct pmic *p = pmic_alloc();
61 printf("%s: POWER allocation error!\n", __func__);
65 debug("Board Micro USB Interface Controller init\n");
68 p->interface = PMIC_I2C;
69 p->number_of_regs = MUIC_NUM_OF_REGS;
70 p->hw.i2c.addr = MAX77693_MUIC_I2C_ADDR;
74 p->chrg = &power_chrg_muic_ops;