diff options
author | Zhongbo Han <zhbhan@marvell.com> | 2015-06-12 20:01:24 +0800 |
---|---|---|
committer | Tim Wang <wangtt@marvell.com> | 2015-07-06 17:26:51 +0800 |
commit | 7337e90c85182debc3668426d5a5bfdea8369fca (patch) | |
tree | c61226de3dc3b8fa12d28a87a8d1df58f6e155b8 | |
parent | ccabb9fa54f8d0b4adf4785f400cf1aa124b6b72 (diff) | |
download | marvell-7337e90c85182debc3668426d5a5bfdea8369fca.tar.gz |
char: 88pm88x_vbus: dump charger status for debugging
dump USB_LIM_OK and VBUS_SW_OV status for debugging.
USB_LIM_OK = 1, 4V < VBUS < 6V.
otherwise, VBUS is out of limit range.
VBUS_SW_OV = 1, VBUS > 5.25V or VBUS_SW_EN = 0, VBUS switch is opened.
otherwise, VBUS is no over-voltage event.
Change-Id: I4edda4ab6d0a142b17d40f915e1506fdc1ab5172
Signed-off-by: Zhongbo Han <zhbhan@marvell.com>
-rw-r--r-- | drivers/char/88pm88x_vbus.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/char/88pm88x_vbus.c b/drivers/char/88pm88x_vbus.c index d09cd545b57..33928d4078c 100644 --- a/drivers/char/88pm88x_vbus.c +++ b/drivers/char/88pm88x_vbus.c @@ -32,6 +32,10 @@ #define PM88X_OTG_BST_VSET_MASK (0x7) #define PM88X_OTG_BST_VSET(x) ((x - 3750) / 250) +#define PM88X_CHG_STATUS2 (0x43) +#define PM88X_USB_LIM_OK (1 << 3) +#define PM88X_VBUS_SW_OV (1 << 0) + #define USB_OTG_MIN (4800) /* mV */ /* choose 0x100(87.5mV) as threshold */ @@ -441,6 +445,37 @@ static void pm88x_pxa_notify(struct work_struct *work) dev_dbg(info->chip->dev, "88pm88x vbus pxa usb is notified..\n"); } +static void dump_vbus_ov_status(struct pm88x_vbus_info *info) +{ + int ret; + unsigned int val; + bool usb_lim_ok, vbus_sw_ov, vbus_sw_en; + + ret = regmap_read(info->chip->battery_regmap, PM88X_CHG_STATUS2, &val); + if (ret) { + dev_err(info->chip->dev, "fail to read charger status: %d\n", ret); + return; + } + + usb_lim_ok = !!(val & PM88X_USB_LIM_OK); + vbus_sw_ov = !!(val & PM88X_VBUS_SW_OV); + + ret = regmap_read(info->chip->battery_regmap, PM88X_CHG_CONFIG4, &val); + if (ret) { + dev_err(info->chip->dev, "fail to read charger config 4: %d\n", ret); + return; + } + + vbus_sw_en = !!(val & PM88X_VBUS_SW_EN); + + /* + * usb_lim_ok = 1, 4V < VBUS < 6V + * vbus_sw_ov = 1, VBUS > 5.25V or VBUS_SW_EN = 0, VBUS switch is opened. + */ + dev_info(info->chip->dev, "usb_lim_ok:%d vbus_sw_ov:%d vbus_sw_en:%d\n", + usb_lim_ok, vbus_sw_ov, vbus_sw_en); +} + static irqreturn_t pm88x_vbus_handler(int irq, void *data) { int current_range; @@ -471,6 +506,7 @@ static irqreturn_t pm88x_vbus_handler(int irq, void *data) pm88x_vbus_sw_control(false); out: + dump_vbus_ov_status(info); /* allowing 7.5msec for the SW to close */ schedule_delayed_work(&info->pxa_notify, usecs_to_jiffies(7500)); return IRQ_HANDLED; |