lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 25 Sep 2012 10:12:40 -0600
From:	mathieu.poirier@...aro.org
To:	linux-kernel@...r.kernel.org, cbou@...l.ru, dwmw2@...radead.org
Cc:	mathieu.poirier@...aro.org
Subject: [PATCH 43/57] power: charging: Add AB8505_USB_LINK_STATUS

From: Hakan Berg <hakan.berg@...ricsson.com>

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@...ricsson.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@...aro.org>
Reviewed-by: Mian Yousaf KAUKAB <mian.yousaf.kaukab@...ricsson.com>
Reviewed-by: Marcus COOPER <marcus.xm.cooper@...ricsson.com>
Reviewed-by: Rabin VINCENT <rabin.vincent@...ricsson.com>
---
 drivers/power/ab8500_charger.c |   46 ++++++++++++++++++++++++++++++++-------
 1 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index 18931e4..9449a33 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -77,6 +77,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 */
@@ -801,10 +802,12 @@ 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__);
@@ -812,7 +815,14 @@ static int ab8500_charger_read_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;
+	}
 	ret = ab8500_charger_max_usb_curr(di,
 		(enum ab8500_charger_link_status) val);
 
@@ -848,12 +858,17 @@ 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;
@@ -867,7 +882,15 @@ 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;
 	}
@@ -2277,6 +2300,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);
@@ -2303,9 +2327,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");
@@ -2338,7 +2366,7 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work)
 						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 {
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ