blob: 94015aa41a14db1fb64e16aab3b5f51c6c874ffc [file] [log] [blame]
Piotr Wilczeka3c20612013-09-20 15:01:25 +02001/*
2 * Copyright (C) 2013 Samsung Electronics
3 * Piotr Wilczek <p.wilczek@samsung.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <common.h>
9#include <power/pmic.h>
10#include <power/battery.h>
Przemyslaw Marczake5ef07f2014-01-22 11:24:11 +010011#include <power/max77693_pmic.h>
Piotr Wilczeka3c20612013-09-20 15:01:25 +020012#include <errno.h>
13
14static struct battery battery_trats;
15
16static int power_battery_charge(struct pmic *bat)
17{
18 struct power_battery *p_bat = bat->pbat;
19
20 if (bat->chrg->chrg_state(p_bat->chrg, CHARGER_ENABLE, 450))
21 return -1;
22
23 return 0;
24}
25
26static int power_battery_init_trats2(struct pmic *bat_,
27 struct pmic *fg_,
28 struct pmic *chrg_,
29 struct pmic *muic_)
30{
31 bat_->pbat->fg = fg_;
32 bat_->pbat->chrg = chrg_;
33 bat_->pbat->muic = muic_;
34
35 bat_->fg = fg_->fg;
36 bat_->chrg = chrg_->chrg;
37 bat_->chrg->chrg_type = muic_->chrg->chrg_type;
38 return 0;
39}
40
41static struct power_battery power_bat_trats2 = {
42 .bat = &battery_trats,
43 .battery_init = power_battery_init_trats2,
44 .battery_charge = power_battery_charge,
45};
46
47int power_bat_init(unsigned char bus)
48{
49 static const char name[] = "BAT_TRATS2";
50 struct pmic *p = pmic_alloc();
51
52 if (!p) {
53 printf("%s: POWER allocation error!\n", __func__);
54 return -ENOMEM;
55 }
56
57 debug("Board BAT init\n");
58
59 p->interface = PMIC_NONE;
60 p->name = name;
61 p->bus = bus;
62
63 p->pbat = &power_bat_trats2;
64 return 0;
65}