summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorJonghwa Lee <jonghwa3.lee@samsung.com>2013-10-11 21:49:51 +0900
committerMarek Szyprowski <m.szyprowski@samsung.com>2014-05-15 07:24:16 +0200
commit7edeeb8e510071c8b888444ba60103f62fad9158 (patch)
tree4f2da9341969580b0a454ab71ed83718d777fa1c /drivers/power
parent36c6cbf7649f73fefa4aa7670194cd7f16a12367 (diff)
downloadlinux-3.10-7edeeb8e510071c8b888444ba60103f62fad9158.tar.gz
linux-3.10-7edeeb8e510071c8b888444ba60103f62fad9158.tar.bz2
linux-3.10-7edeeb8e510071c8b888444ba60103f62fad9158.zip
charger: max77693: code cleaning
- Remove duplicated macro data. - Improve readability. Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/max77693_charger.c125
1 files changed, 5 insertions, 120 deletions
diff --git a/drivers/power/max77693_charger.c b/drivers/power/max77693_charger.c
index 71e94c170d5..71a009d5c94 100644
--- a/drivers/power/max77693_charger.c
+++ b/drivers/power/max77693_charger.c
@@ -39,125 +39,10 @@
#include <linux/mfd/max77693.h>
#include <linux/mfd/max77693-private.h>
#include <linux/power/charger-manager.h>
+#include <linux/power/max77693_charger.h>
#include <linux/extcon.h>
#include <plat/gpio-cfg.h>
-/* 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: