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