2 * Copyright (C) 2012 Samsung Electronics
3 * Lukasz Majewski <l.majewski@samsung.com>
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
25 #include <power/pmic.h>
26 #include <power/power_chrg.h>
27 #include <power/max8997_muic.h>
31 static int power_chrg_get_type(struct pmic *p)
34 unsigned char charge_type, charger;
39 pmic_reg_read(p, MAX8997_MUIC_STATUS2, &val);
40 charge_type = val & MAX8997_MUIC_CHG_MASK;
42 switch (charge_type) {
43 case MAX8997_MUIC_CHG_NO:
46 case MAX8997_MUIC_CHG_USB:
47 case MAX8997_MUIC_CHG_USB_D:
48 charger = CHARGER_USB;
50 case MAX8997_MUIC_CHG_TA:
51 case MAX8997_MUIC_CHG_TA_1A:
54 case MAX8997_MUIC_CHG_TA_500:
55 charger = CHARGER_TA_500;
58 charger = CHARGER_UNKNOWN;
65 static struct power_chrg power_chrg_muic_ops = {
66 .chrg_type = power_chrg_get_type,
69 int power_muic_init(unsigned int bus)
71 static const char name[] = "MAX8997_MUIC";
72 struct pmic *p = pmic_alloc();
75 printf("%s: POWER allocation error!\n", __func__);
79 debug("Board Micro USB Interface Controller init\n");
82 p->interface = PMIC_I2C;
83 p->number_of_regs = MUIC_NUM_OF_REGS;
84 p->hw.i2c.addr = MAX8997_MUIC_I2C_ADDR;
88 p->chrg = &power_chrg_muic_ops;