blob: 6329e028b67a23e52b93dbc7cd4d2443bad9d7b3 [file] [log] [blame]
Piotr Wilczeka88aab62013-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 Marczak7f39b062014-01-22 11:24:11 +010011#include <power/max77693_pmic.h>
Piotr Wilczeka88aab62013-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
Simon Glass78a36c32014-05-20 06:01:35 -060020 if (bat->chrg->chrg_state(p_bat->chrg, PMIC_CHARGER_ENABLE, 450))
Jaehoon Chung505cf472016-12-15 20:49:50 +090021 return -EINVAL;
Piotr Wilczeka88aab62013-09-20 15:01:25 +020022
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}