Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 367470
b: refs/heads/master
c: d433766
h: refs/heads/master
v: v3
  • Loading branch information
Hakan Berg authored and Lee Jones committed Mar 7, 2013
1 parent a535e5b commit 5d5e319
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 642776182c2412739f433d84da0ab8872a0509a8
refs/heads/master: d4337660d06945c9772182b5b8e72443ae3e475d
43 changes: 35 additions & 8 deletions trunk/drivers/power/ab8500_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@

/* UsbLineStatus register bit masks */
#define AB8500_USB_LINK_STATUS 0x78
#define AB8505_USB_LINK_STATUS 0xF8
#define AB8500_STD_HOST_SUSP 0x18

/* Watchdog timeout constant */
Expand Down Expand Up @@ -809,18 +810,27 @@ static int ab8500_charger_read_usb_type(struct ab8500_charger *di)
if (is_ab8500(di->parent)) {
ret = abx500_get_register_interruptible(di->dev, AB8500_USB,
AB8500_USB_LINE_STAT_REG, &val);
} else {
if (is_ab9540(di->parent) || is_ab8505(di->parent))
} else if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
ret = abx500_get_register_interruptible(di->dev,
AB8500_USB, AB8500_USB_LINK1_STAT_REG, &val);
} else {
dev_err(di->dev, "%s unsupported analog baseband\n", __func__);
return -ENXIO;
}
if (ret < 0) {
dev_err(di->dev, "%s ab8500 read failed\n", __func__);
return ret;
}

/* get the USB type */
val = (val & AB8500_USB_LINK_STATUS) >> 3;
if (is_ab8500(di->parent)) {
val = (val & AB8500_USB_LINK_STATUS) >> 3;
} else if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
val = (val & AB8505_USB_LINK_STATUS) >> 3;
} else {
dev_err(di->dev, "%s unsupported analog baseband\n", __func__);
return -ENXIO;
}
ret = ab8500_charger_max_usb_curr(di,
(enum ab8500_charger_link_status) val);

Expand Down Expand Up @@ -856,12 +866,16 @@ static int ab8500_charger_detect_usb_type(struct ab8500_charger *di)
return ret;
}

if (is_ab8500(di->parent))
if (is_ab8500(di->parent)) {
ret = abx500_get_register_interruptible(di->dev,
AB8500_USB, AB8500_USB_LINE_STAT_REG, &val);
else
} else if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
ret = abx500_get_register_interruptible(di->dev,
AB8500_USB, AB8500_USB_LINK1_STAT_REG, &val);
} else {
dev_err(di->dev, "%s unsupported analog baseband\n", __func__);
return -ENXIO;
}
if (ret < 0) {
dev_err(di->dev, "%s ab8500 read failed\n", __func__);
return ret;
Expand All @@ -875,7 +889,14 @@ static int ab8500_charger_detect_usb_type(struct ab8500_charger *di)
*/

/* get the USB type */
val = (val & AB8500_USB_LINK_STATUS) >> 3;
if (is_ab8500(di->parent)) {
val = (val & AB8500_USB_LINK_STATUS) >> 3;
} else if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
val = (val & AB8505_USB_LINK_STATUS) >> 3;
} else {
dev_err(di->dev, "%s unsupported analog baseband\n", __func__);
return -ENXIO;
}
if (val)
break;
}
Expand Down Expand Up @@ -2287,6 +2308,7 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work)
int detected_chargers;
int ret;
u8 val;
u8 link_status;

struct ab8500_charger *di = container_of(work,
struct ab8500_charger, usb_link_status_work);
Expand All @@ -2313,8 +2335,13 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work)
else
dev_dbg(di->dev, "Error reading USB link status\n");

if (is_ab9540(di->parent) || is_ab8505(di->parent))
link_status = AB8505_USB_LINK_STATUS;
else
link_status = AB8500_USB_LINK_STATUS;

if (detected_chargers & USB_PW_CONN) {
if (((val & AB8500_USB_LINK_STATUS) >> 3) == USB_STAT_NOT_VALID_LINK &&
if (((val & link_status) >> 3) == USB_STAT_NOT_VALID_LINK &&
di->invalid_charger_detect_state == 0) {
dev_dbg(di->dev, "Invalid charger detected, state= 0\n");
/*Enable charger*/
Expand All @@ -2337,7 +2364,7 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work)
ret = abx500_get_register_interruptible(di->dev, AB8500_USB,
AB8500_USB_LINE_STAT_REG, &val);
dev_dbg(di->dev, "USB link status= 0x%02x\n",
(val & AB8500_USB_LINK_STATUS) >> 3);
(val & link_status) >> 3);
di->invalid_charger_detect_state = 2;
}
} else {
Expand Down

0 comments on commit 5d5e319

Please sign in to comment.