aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHakan Berg <hakan.berg@stericsson.com>2012-07-26 05:10:35 -0400
committerLee Jones <lee.jones@linaro.org>2013-03-06 23:35:45 -0500
commitd4337660d06945c9772182b5b8e72443ae3e475d (patch)
treebcd10cb5ad03c7c9fa164b88126a7ff699fc0a35 /drivers
parent642776182c2412739f433d84da0ab8872a0509a8 (diff)
ab8500-charger: Add AB8505_USB_LINK_STATUS
The AB8505 does not have the same address for USB link-status as has ab8500. Add AB8505_USB_LINK_STATUS and code to switch to correct constant. Signed-off-by: Hakan Berg <hakan.berg@stericsson.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Reviewed-by: Mian Yousaf KAUKAB <mian.yousaf.kaukab@stericsson.com> Reviewed-by: Marcus COOPER <marcus.xm.cooper@stericsson.com> Reviewed-by: Rabin VINCENT <rabin.vincent@stericsson.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/power/ab8500_charger.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index 547f6ea1b695..b5c7a3975024 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -80,6 +80,7 @@
80 80
81/* UsbLineStatus register bit masks */ 81/* UsbLineStatus register bit masks */
82#define AB8500_USB_LINK_STATUS 0x78 82#define AB8500_USB_LINK_STATUS 0x78
83#define AB8505_USB_LINK_STATUS 0xF8
83#define AB8500_STD_HOST_SUSP 0x18 84#define AB8500_STD_HOST_SUSP 0x18
84 85
85/* Watchdog timeout constant */ 86/* Watchdog timeout constant */
@@ -809,10 +810,12 @@ static int ab8500_charger_read_usb_type(struct ab8500_charger *di)
809 if (is_ab8500(di->parent)) { 810 if (is_ab8500(di->parent)) {
810 ret = abx500_get_register_interruptible(di->dev, AB8500_USB, 811 ret = abx500_get_register_interruptible(di->dev, AB8500_USB,
811 AB8500_USB_LINE_STAT_REG, &val); 812 AB8500_USB_LINE_STAT_REG, &val);
812 } else { 813 } else if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
813 if (is_ab9540(di->parent) || is_ab8505(di->parent))
814 ret = abx500_get_register_interruptible(di->dev, 814 ret = abx500_get_register_interruptible(di->dev,
815 AB8500_USB, AB8500_USB_LINK1_STAT_REG, &val); 815 AB8500_USB, AB8500_USB_LINK1_STAT_REG, &val);
816 } else {
817 dev_err(di->dev, "%s unsupported analog baseband\n", __func__);
818 return -ENXIO;
816 } 819 }
817 if (ret < 0) { 820 if (ret < 0) {
818 dev_err(di->dev, "%s ab8500 read failed\n", __func__); 821 dev_err(di->dev, "%s ab8500 read failed\n", __func__);
@@ -820,7 +823,14 @@ static int ab8500_charger_read_usb_type(struct ab8500_charger *di)
820 } 823 }
821 824
822 /* get the USB type */ 825 /* get the USB type */
823 val = (val & AB8500_USB_LINK_STATUS) >> 3; 826 if (is_ab8500(di->parent)) {
827 val = (val & AB8500_USB_LINK_STATUS) >> 3;
828 } else if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
829 val = (val & AB8505_USB_LINK_STATUS) >> 3;
830 } else {
831 dev_err(di->dev, "%s unsupported analog baseband\n", __func__);
832 return -ENXIO;
833 }
824 ret = ab8500_charger_max_usb_curr(di, 834 ret = ab8500_charger_max_usb_curr(di,
825 (enum ab8500_charger_link_status) val); 835 (enum ab8500_charger_link_status) val);
826 836
@@ -856,12 +866,16 @@ static int ab8500_charger_detect_usb_type(struct ab8500_charger *di)
856 return ret; 866 return ret;
857 } 867 }
858 868
859 if (is_ab8500(di->parent)) 869 if (is_ab8500(di->parent)) {
860 ret = abx500_get_register_interruptible(di->dev, 870 ret = abx500_get_register_interruptible(di->dev,
861 AB8500_USB, AB8500_USB_LINE_STAT_REG, &val); 871 AB8500_USB, AB8500_USB_LINE_STAT_REG, &val);
862 else 872 } else if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
863 ret = abx500_get_register_interruptible(di->dev, 873 ret = abx500_get_register_interruptible(di->dev,
864 AB8500_USB, AB8500_USB_LINK1_STAT_REG, &val); 874 AB8500_USB, AB8500_USB_LINK1_STAT_REG, &val);
875 } else {
876 dev_err(di->dev, "%s unsupported analog baseband\n", __func__);
877 return -ENXIO;
878 }
865 if (ret < 0) { 879 if (ret < 0) {
866 dev_err(di->dev, "%s ab8500 read failed\n", __func__); 880 dev_err(di->dev, "%s ab8500 read failed\n", __func__);
867 return ret; 881 return ret;
@@ -875,7 +889,14 @@ static int ab8500_charger_detect_usb_type(struct ab8500_charger *di)
875 */ 889 */
876 890
877 /* get the USB type */ 891 /* get the USB type */
878 val = (val & AB8500_USB_LINK_STATUS) >> 3; 892 if (is_ab8500(di->parent)) {
893 val = (val & AB8500_USB_LINK_STATUS) >> 3;
894 } else if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
895 val = (val & AB8505_USB_LINK_STATUS) >> 3;
896 } else {
897 dev_err(di->dev, "%s unsupported analog baseband\n", __func__);
898 return -ENXIO;
899 }
879 if (val) 900 if (val)
880 break; 901 break;
881 } 902 }
@@ -2287,6 +2308,7 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work)
2287 int detected_chargers; 2308 int detected_chargers;
2288 int ret; 2309 int ret;
2289 u8 val; 2310 u8 val;
2311 u8 link_status;
2290 2312
2291 struct ab8500_charger *di = container_of(work, 2313 struct ab8500_charger *di = container_of(work,
2292 struct ab8500_charger, usb_link_status_work); 2314 struct ab8500_charger, usb_link_status_work);
@@ -2313,8 +2335,13 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work)
2313 else 2335 else
2314 dev_dbg(di->dev, "Error reading USB link status\n"); 2336 dev_dbg(di->dev, "Error reading USB link status\n");
2315 2337
2338 if (is_ab9540(di->parent) || is_ab8505(di->parent))
2339 link_status = AB8505_USB_LINK_STATUS;
2340 else
2341 link_status = AB8500_USB_LINK_STATUS;
2342
2316 if (detected_chargers & USB_PW_CONN) { 2343 if (detected_chargers & USB_PW_CONN) {
2317 if (((val & AB8500_USB_LINK_STATUS) >> 3) == USB_STAT_NOT_VALID_LINK && 2344 if (((val & link_status) >> 3) == USB_STAT_NOT_VALID_LINK &&
2318 di->invalid_charger_detect_state == 0) { 2345 di->invalid_charger_detect_state == 0) {
2319 dev_dbg(di->dev, "Invalid charger detected, state= 0\n"); 2346 dev_dbg(di->dev, "Invalid charger detected, state= 0\n");
2320 /*Enable charger*/ 2347 /*Enable charger*/
@@ -2337,7 +2364,7 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work)
2337 ret = abx500_get_register_interruptible(di->dev, AB8500_USB, 2364 ret = abx500_get_register_interruptible(di->dev, AB8500_USB,
2338 AB8500_USB_LINE_STAT_REG, &val); 2365 AB8500_USB_LINE_STAT_REG, &val);
2339 dev_dbg(di->dev, "USB link status= 0x%02x\n", 2366 dev_dbg(di->dev, "USB link status= 0x%02x\n",
2340 (val & AB8500_USB_LINK_STATUS) >> 3); 2367 (val & link_status) >> 3);
2341 di->invalid_charger_detect_state = 2; 2368 di->invalid_charger_detect_state = 2;
2342 } 2369 }
2343 } else { 2370 } else {