Commit 27a8ff46 authored by Bruno Meneguele's avatar Bruno Meneguele Committed by Sebastian Reichel

power: supply: bq24735: reorganize ChargeOption command macros

Rename ChargeOption macros to match the others for ChargeCurrent and
ChargeVoltage and also separate the command & masks macros from the bits of
interest macros for each command.  This macro doesn't introduce any
functional change, only code re-org.
Signed-off-by: default avatarBruno Meneguele <bruno.meneguele@smartgreen.net>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 2f5caa26
...@@ -31,9 +31,8 @@ ...@@ -31,9 +31,8 @@
#include <linux/power/bq24735-charger.h> #include <linux/power/bq24735-charger.h>
#define BQ24735_CHG_OPT 0x12 /* BQ24735 available commands and their respective masks */
#define BQ24735_CHG_OPT_CHARGE_DISABLE (1 << 0) #define BQ24735_CHARGE_OPT 0x12
#define BQ24735_CHG_OPT_AC_PRESENT (1 << 4)
#define BQ24735_CHARGE_CURRENT 0x14 #define BQ24735_CHARGE_CURRENT 0x14
#define BQ24735_CHARGE_CURRENT_MASK 0x1fc0 #define BQ24735_CHARGE_CURRENT_MASK 0x1fc0
#define BQ24735_CHARGE_VOLTAGE 0x15 #define BQ24735_CHARGE_VOLTAGE 0x15
...@@ -43,6 +42,10 @@ ...@@ -43,6 +42,10 @@
#define BQ24735_MANUFACTURER_ID 0xfe #define BQ24735_MANUFACTURER_ID 0xfe
#define BQ24735_DEVICE_ID 0xff #define BQ24735_DEVICE_ID 0xff
/* ChargeOptions bits of interest */
#define BQ24735_CHARGE_OPT_CHG_DISABLE (1 << 0)
#define BQ24735_CHARGE_OPT_AC_PRESENT (1 << 4)
struct bq24735 { struct bq24735 {
struct power_supply *charger; struct power_supply *charger;
struct power_supply_desc charger_desc; struct power_supply_desc charger_desc;
...@@ -167,8 +170,8 @@ static inline int bq24735_enable_charging(struct bq24735 *charger) ...@@ -167,8 +170,8 @@ static inline int bq24735_enable_charging(struct bq24735 *charger)
if (ret) if (ret)
return ret; return ret;
return bq24735_update_word(charger->client, BQ24735_CHG_OPT, return bq24735_update_word(charger->client, BQ24735_CHARGE_OPT,
BQ24735_CHG_OPT_CHARGE_DISABLE, 0); BQ24735_CHARGE_OPT_CHG_DISABLE, 0);
} }
static inline int bq24735_disable_charging(struct bq24735 *charger) static inline int bq24735_disable_charging(struct bq24735 *charger)
...@@ -176,9 +179,9 @@ static inline int bq24735_disable_charging(struct bq24735 *charger) ...@@ -176,9 +179,9 @@ static inline int bq24735_disable_charging(struct bq24735 *charger)
if (charger->pdata->ext_control) if (charger->pdata->ext_control)
return 0; return 0;
return bq24735_update_word(charger->client, BQ24735_CHG_OPT, return bq24735_update_word(charger->client, BQ24735_CHARGE_OPT,
BQ24735_CHG_OPT_CHARGE_DISABLE, BQ24735_CHARGE_OPT_CHG_DISABLE,
BQ24735_CHG_OPT_CHARGE_DISABLE); BQ24735_CHARGE_OPT_CHG_DISABLE);
} }
static bool bq24735_charger_is_present(struct bq24735 *charger) static bool bq24735_charger_is_present(struct bq24735 *charger)
...@@ -188,14 +191,14 @@ static bool bq24735_charger_is_present(struct bq24735 *charger) ...@@ -188,14 +191,14 @@ static bool bq24735_charger_is_present(struct bq24735 *charger)
} else { } else {
int ac = 0; int ac = 0;
ac = bq24735_read_word(charger->client, BQ24735_CHG_OPT); ac = bq24735_read_word(charger->client, BQ24735_CHARGE_OPT);
if (ac < 0) { if (ac < 0) {
dev_dbg(&charger->client->dev, dev_dbg(&charger->client->dev,
"Failed to read charger options : %d\n", "Failed to read charger options : %d\n",
ac); ac);
return false; return false;
} }
return (ac & BQ24735_CHG_OPT_AC_PRESENT) ? true : false; return (ac & BQ24735_CHARGE_OPT_AC_PRESENT) ? true : false;
} }
return false; return false;
...@@ -208,11 +211,11 @@ static int bq24735_charger_is_charging(struct bq24735 *charger) ...@@ -208,11 +211,11 @@ static int bq24735_charger_is_charging(struct bq24735 *charger)
if (!bq24735_charger_is_present(charger)) if (!bq24735_charger_is_present(charger))
return 0; return 0;
ret = bq24735_read_word(charger->client, BQ24735_CHG_OPT); ret = bq24735_read_word(charger->client, BQ24735_CHARGE_OPT);
if (ret < 0) if (ret < 0)
return ret; return ret;
return !(ret & BQ24735_CHG_OPT_CHARGE_DISABLE); return !(ret & BQ24735_CHARGE_OPT_CHG_DISABLE);
} }
static void bq24735_update(struct bq24735 *charger) static void bq24735_update(struct bq24735 *charger)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment