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/battery.h>
27 #include <power/max8997_pmic.h>
30 static struct battery battery_trats;
32 static int power_battery_charge(struct pmic *bat)
34 struct power_battery *p_bat = bat->pbat;
35 struct battery *battery = p_bat->bat;
38 if (bat->chrg->chrg_state(p_bat->chrg, CHARGER_ENABLE, 450))
41 for (k = 0; bat->chrg->chrg_bat_present(p_bat->chrg) &&
42 bat->chrg->chrg_type(p_bat->muic) &&
43 battery->state_of_chrg < 100; k++) {
46 bat->fg->fg_battery_update(p_bat->fg, bat);
49 debug(" %d [V]", battery->voltage_uV);
56 bat->chrg->chrg_state(p_bat->chrg, CHARGER_DISABLE, 0);
61 static int power_battery_init_trats(struct pmic *bat_,
67 bat_->pbat->chrg = chrg_;
68 bat_->pbat->muic = muic_;
71 bat_->chrg = chrg_->chrg;
72 bat_->chrg->chrg_type = muic_->chrg->chrg_type;
76 static struct power_battery power_bat_trats = {
77 .bat = &battery_trats,
78 .battery_init = power_battery_init_trats,
79 .battery_charge = power_battery_charge,
82 int power_bat_init(unsigned char bus)
84 static const char name[] = "BAT_TRATS";
85 struct pmic *p = pmic_alloc();
88 printf("%s: POWER allocation error!\n", __func__);
92 debug("Board BAT init\n");
94 p->interface = PMIC_NONE;
98 p->pbat = &power_bat_trats;