From cef9ca7cf597f64b0798ef1a31d24d54e7325e63 Mon Sep 17 00:00:00 2001 From: Jonghwa Lee Date: Fri, 11 Oct 2013 21:49:51 +0900 Subject: [PATCH] charger: max77693: code cleaning - Remove duplicated macro data. - Improve readability. Signed-off-by: Jonghwa Lee --- drivers/power/max77693_charger.c | 125 ++------------------------------- include/linux/power/max77693_charger.h | 23 +++--- 2 files changed, 18 insertions(+), 130 deletions(-) diff --git a/drivers/power/max77693_charger.c b/drivers/power/max77693_charger.c index 71e94c1..71a009d 100644 --- a/drivers/power/max77693_charger.c +++ b/drivers/power/max77693_charger.c @@ -39,125 +39,10 @@ #include #include #include +#include #include #include -/* MAX77693 Registers(defined @max77693-private.h) */ - -/* MAX77693_CHG_REG_CHG_INT */ -#define MAX77693_BYP_I (1 << 0) -#define MAX77693_THM_I (1 << 2) -#define MAX77693_BAT_I (1 << 3) -#define MAX77693_CHG_I (1 << 4) -#define MAX77693_CHGIN_I (1 << 6) - -/* MAX77693_CHG_REG_CHG_INT_MASK */ -#define MAX77693_BYP_IM (1 << 0) -#define MAX77693_THM_IM (1 << 2) -#define MAX77693_BAT_IM (1 << 3) -#define MAX77693_CHG_IM (1 << 4) -#define MAX77693_CHGIN_IM (1 << 6) - -/* MAX77693_CHG_REG_CHG_INT_OK */ -#define MAX77693_BYP_OK 0x01 -#define MAX77693_BYP_OK_SHIFT 0 -#define MAX77693_THM_OK 0x04 -#define MAX77693_THM_OK_SHIFT 2 -#define MAX77693_BAT_OK 0x08 -#define MAX77693_BAT_OK_SHIFT 3 -#define MAX77693_CHG_OK 0x10 -#define MAX77693_CHG_OK_SHIFT 4 -#define MAX77693_CHGIN_OK 0x40 -#define MAX77693_CHGIN_OK_SHIFT 6 -#define MAX77693_DETBAT 0x80 -#define MAX77693_DETBAT_SHIFT 7 - -/* MAX77693_CHG_REG_CHG_DTLS_00 */ -#define MAX77693_THM_DTLS 0x07 -#define MAX77693_THM_DTLS_SHIFT 0 -#define MAX77693_CHGIN_DTLS 0x60 -#define MAX77693_CHGIN_DTLS_SHIFT 5 - -/* MAX77693_CHG_REG_CHG_DTLS_01 */ -#define MAX77693_CHG_DTLS 0x0F -#define MAX77693_CHG_DTLS_SHIFT 0 -#define MAX77693_BAT_DTLS 0x70 -#define MAX77693_BAT_DTLS_SHIFT 4 - -/* MAX77693_CHG_REG_CHG_DTLS_02 */ -#define MAX77693_BYP_DTLS 0x0F -#define MAX77693_BYP_DTLS_SHIFT 0 -#define MAX77693_BYP_DTLS0 0x1 -#define MAX77693_BYP_DTLS1 0x2 -#define MAX77693_BYP_DTLS2 0x4 -#define MAX77693_BYP_DTLS3 0x8 - -/* MAX77693_CHG_REG_CHG_CNFG_00 */ -#define MAX77693_MODE_DEFAULT 0x04 -#define MAX77693_MODE_CHGR 0x01 -#define MAX77693_MODE_OTG 0x02 -#define MAX77693_MODE_BUCK 0x04 - -/* MAX77693_CHG_REG_CHG_CNFG_02 */ -#define MAX77693_CHG_CC 0x3F - -/* MAX77693_CHG_REG_CHG_CNFG_04 */ -#define MAX77693_CHG_MINVSYS_MASK 0xE0 -#define MAX77693_CHG_MINVSYS_SHIFT 5 -#define MAX77693_CHG_MINVSYS_3_6V 0x06 -#define MAX77693_CHG_CV_PRM_MASK 0x1F -#define MAX77693_CHG_CV_PRM_SHIFT 0 -#define MAX77693_CHG_CV_PRM_4_20V 0x16 -#define MAX77693_CHG_CV_PRM_4_35V 0x1D -#define MAX77693_CHG_CV_PRM_4_40V 0x1F - -/* MAX77693_CHG_REG_CHG_CNFG_06 */ -#define MAX77693_CHG_CHGPROT 0x0C -#define MAX77693_CHG_CHGPROT_SHIFT 2 -#define MAX77693_CHG_CHGPROT_UNLOCK 0x03 - -/* MAX77693_CHG_REG_CHG_CNFG_09 */ -#define MAX77693_CHG_CHGIN_LIM 0x7F - -/* MAX77693_MUIC_REG_CDETCTRL1 */ -#define MAX77693_CHGTYPMAN 0x02 -#define MAX77693_CHGTYPMAN_SHIFT 1 - -/* MAX77693_MUIC_REG_STATUS2 */ -#define MAX77693_VBVOLT 0x40 -#define MAX77693_VBVOLT_SHIFT 6 -#define MAX77693_DXOVP 0x20 -#define MAX77693_DXOVP_SHIFT 5 -#define MAX77693_CHGDETRUN 0x08 -#define MAX77693_CHGDETRUN_SHIFT 3 -#define MAX77693_CHGTYPE 0x07 -#define MAX77693_CHGTYPE_SHIFT 0 - -/* irq */ -#define IRQ_DEBOUNCE_TIME 20 /* msec */ - -/* charger unlock */ -#define CHG_UNLOCK_RETRY 10 -#define CHG_UNLOCK_DELAY 100 - -/* power stabe guarantee */ -#define STABLE_POWER_DELAY 500 - -/* charger type detection */ -#define DET_ERR_RETRY 5 -#define DET_ERR_DELAY 200 - -/* soft charging */ -#define SOFT_CHG_START_CURR 100 /* mA */ -#define SOFT_CHG_START_DUR 100 /* ms */ -#define SOFT_CHG_CURR_STEP 100 /* mA */ -#define SOFT_CHG_STEP_DUR 20 /* ms */ - -/* soft regulation */ -#define SW_REG_CURR_STEP_MA 100 -#define SW_REG_START_DELAY 500 -#define SW_REG_STEP_DELAY 100 - struct max77693_charger_data { struct max77693_dev *max77693; @@ -218,19 +103,19 @@ static int max77693_get_vbus_state(struct max77693_charger_data *chg_data) MAX77693_CHGIN_DTLS_SHIFT); switch (reg_data) { - case 0x00: + case POWER_SUPPLY_VBUS_UVLO : /* V chgin < UVLO */ state = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE; break; - case 0x01: + case POWER_SUPPLY_VBUS_WEAK : /* V chgin < V batt + minimum threshold */ state = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE; break; - case 0x02: + case POWER_SUPPLY_VBUS_OVLO : /* V chgin > OVLO */ state = POWER_SUPPLY_HEALTH_OVERVOLTAGE; break; - case 0x03: + case POWER_SUPPLY_VBUS_GOOD : state = POWER_SUPPLY_HEALTH_GOOD; break; default: diff --git a/include/linux/power/max77693_charger.h b/include/linux/power/max77693_charger.h index 0ad2f39..6f2b677 100644 --- a/include/linux/power/max77693_charger.h +++ b/include/linux/power/max77693_charger.h @@ -18,13 +18,8 @@ #ifndef __MAX77693_CHARGER_H #define __MAX77693_CHARGER_H __FILE__ #include -#include -#include #include -#define ENABLE 1 -#define DISABLE 0 - /* macro */ #define MAX(x, y) ((x) > (y) ? (x) : (y)) #define MIN(x, y) ((x) < (y) ? (x) : (y)) @@ -128,6 +123,14 @@ #define MAX77693_CHG_MINVSYS_SHIFT 5 #define MAX77693_CHG_PRM_MASK 0x1F #define MAX77693_CHG_PRM_SHIFT 0 +#define MAX77693_CHG_CV_PRM_4_20V 0x16 +#define MAX77693_CHG_CV_PRM_4_35V 0x1D +#define MAX77693_CHG_CV_PRM_4_40V 0x1F + +/* MAX77693_CHG_REG_CHG_CNFG_06 */ +#define MAX77693_CHG_CHGPROT 0x0C +#define MAX77693_CHG_CHGPROT_SHIFT 2 +#define MAX77693_CHG_CHGPROT_UNLOCK 0x03 /* MAX77693_CHG_REG_CHG_CNFG_09 */ #define MAX77693_CHG_CHGIN_LIM 0x7F @@ -150,6 +153,10 @@ /* irq */ #define IRQ_DEBOUNCE_TIME 20 /* msec */ +/* charger unlock */ +#define CHG_UNLOCK_RETRY 10 +#define CHG_UNLOCK_DELAY 100 + /* charger type detection */ #define DET_ERR_RETRY 5 #define DET_ERR_DELAY 200 @@ -163,15 +170,11 @@ #define DEFAULT_AC_CURRENT 1600 /* mA */ #define DEFAULT_USB_CURRENT 500 /* mA */ -#ifndef CONFIG_MACH_SLP_ADONIS enum { - POWER_SUPPLY_VBUS_UNKNOWN = 0, - POWER_SUPPLY_VBUS_UVLO, + POWER_SUPPLY_VBUS_UVLO = 0, POWER_SUPPLY_VBUS_WEAK, POWER_SUPPLY_VBUS_OVLO, POWER_SUPPLY_VBUS_GOOD, }; -#endif -extern sec_battery_platform_data_t sec_battery_pdata; #endif -- 2.7.4