]>
Commit | Line | Data |
---|---|---|
a88aab6b PW |
1 | /* |
2 | * Copyright (C) 2013 Samsung Electronics | |
3 | * Piotr Wilczek <[email protected]> | |
4 | * | |
5 | * SPDX-License-Identifier: GPL-2.0+ | |
6 | */ | |
7 | ||
8 | #include <common.h> | |
9 | #include <power/pmic.h> | |
10 | #include <power/battery.h> | |
7f39b067 | 11 | #include <power/max77693_pmic.h> |
a88aab6b PW |
12 | #include <errno.h> |
13 | ||
14 | static struct battery battery_trats; | |
15 | ||
16 | static int power_battery_charge(struct pmic *bat) | |
17 | { | |
18 | struct power_battery *p_bat = bat->pbat; | |
19 | ||
78a36c3e | 20 | if (bat->chrg->chrg_state(p_bat->chrg, PMIC_CHARGER_ENABLE, 450)) |
505cf475 | 21 | return -EINVAL; |
a88aab6b PW |
22 | |
23 | return 0; | |
24 | } | |
25 | ||
26 | static 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 | ||
41 | static 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 | ||
47 | int 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 | } |