| .. | .. |
|---|
| 1 | | -/* |
|---|
| 2 | | - * max8998_charger.c - Power supply consumer driver for the Maxim 8998/LP3974 |
|---|
| 3 | | - * |
|---|
| 4 | | - * Copyright (C) 2009-2010 Samsung Electronics |
|---|
| 5 | | - * MyungJoo Ham <myungjoo.ham@samsung.com> |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 9 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | | - * (at your option) any later version. |
|---|
| 11 | | - * |
|---|
| 12 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | | - * GNU General Public License for more details. |
|---|
| 16 | | - * |
|---|
| 17 | | - * You should have received a copy of the GNU General Public License |
|---|
| 18 | | - * along with this program; if not, write to the Free Software |
|---|
| 19 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 | | - */ |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
|---|
| 2 | +// |
|---|
| 3 | +// max8998_charger.c - Power supply consumer driver for the Maxim 8998/LP3974 |
|---|
| 4 | +// |
|---|
| 5 | +// Copyright (C) 2009-2010 Samsung Electronics |
|---|
| 6 | +// MyungJoo Ham <myungjoo.ham@samsung.com> |
|---|
| 21 | 7 | |
|---|
| 22 | 8 | #include <linux/err.h> |
|---|
| 23 | 9 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 37 | 23 | static enum power_supply_property max8998_battery_props[] = { |
|---|
| 38 | 24 | POWER_SUPPLY_PROP_PRESENT, /* the presence of battery */ |
|---|
| 39 | 25 | POWER_SUPPLY_PROP_ONLINE, /* charger is active or not */ |
|---|
| 26 | + POWER_SUPPLY_PROP_STATUS, /* charger is charging/discharging/full */ |
|---|
| 40 | 27 | }; |
|---|
| 41 | 28 | |
|---|
| 42 | 29 | /* Note that the charger control is done by a current regulator "CHARGER" */ |
|---|
| .. | .. |
|---|
| 63 | 50 | ret = max8998_read_reg(i2c, MAX8998_REG_STATUS2, ®); |
|---|
| 64 | 51 | if (ret) |
|---|
| 65 | 52 | return ret; |
|---|
| 66 | | - if (reg & (1 << 3)) |
|---|
| 67 | | - val->intval = 0; |
|---|
| 68 | | - else |
|---|
| 53 | + |
|---|
| 54 | + if (reg & (1 << 5)) |
|---|
| 69 | 55 | val->intval = 1; |
|---|
| 56 | + else |
|---|
| 57 | + val->intval = 0; |
|---|
| 58 | + |
|---|
| 59 | + break; |
|---|
| 60 | + case POWER_SUPPLY_PROP_STATUS: |
|---|
| 61 | + ret = max8998_read_reg(i2c, MAX8998_REG_STATUS2, ®); |
|---|
| 62 | + if (ret) |
|---|
| 63 | + return ret; |
|---|
| 64 | + |
|---|
| 65 | + if (!(reg & (1 << 5))) { |
|---|
| 66 | + val->intval = POWER_SUPPLY_STATUS_DISCHARGING; |
|---|
| 67 | + } else { |
|---|
| 68 | + if (reg & (1 << 6)) |
|---|
| 69 | + val->intval = POWER_SUPPLY_STATUS_FULL; |
|---|
| 70 | + else if (reg & (1 << 3)) |
|---|
| 71 | + val->intval = POWER_SUPPLY_STATUS_CHARGING; |
|---|
| 72 | + else |
|---|
| 73 | + val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; |
|---|
| 74 | + } |
|---|
| 70 | 75 | break; |
|---|
| 71 | 76 | default: |
|---|
| 72 | 77 | return -EINVAL; |
|---|