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, 10 Jun 2014 11:44:49 +0200
From:	Juergen Borleis <jbe@...gutronix.de>
To:	linux-kernel@...r.kernel.org
Cc:	Dmitry Eremin-Solenikov <dbaryshkov@...il.com>,
	David Woodhouse <dwmw2@...radead.org>, kernel@...gutronix.de
Subject: [PATCH 3/7] bq27425: add support for different firmware chip types

Signed-off-by: Juergen Borleis <jbe@...gutronix.de>
---
 drivers/power/bq27x00_battery.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
index 58644de..39b5194 100644
--- a/drivers/power/bq27x00_battery.c
+++ b/drivers/power/bq27x00_battery.c
@@ -72,6 +72,7 @@
 
 /* bq27425 control commands */
 #define BQ27425_CONTROL			0x00
+# define BQ27425_DEVICE_TYPE		0x0001
 
 /* bq27425 register addresses are same as bq27x00 addresses minus 4 */
 #define BQ27425_REG_OFFSET		0x04
@@ -87,6 +88,7 @@ struct bq27x00_access_methods {
 };
 
 enum bq27x00_chip { BQ27000, BQ27500, BQ27425};
+enum bq27425_chip_type { BQ27425_unknown, BQ27425_g1, BQ27425_g2a};
 
 struct bq27x00_reg_cache {
 	int temperature;
@@ -106,6 +108,7 @@ struct bq27x00_device_info {
 	struct device 		*dev;
 	int			id;
 	enum bq27x00_chip	chip;
+	enum bq27425_chip_type	chip_type;
 
 	struct bq27x00_reg_cache cache;
 	int charge_design_full;
@@ -698,6 +701,28 @@ static int bq27x00_powersupply_init(struct bq27x00_device_info *di)
 {
 	int ret;
 
+	if (di->chip == BQ27425) {
+		/* detect chip type */
+		ret = di->bus.reads(di, BQ27425_DEVICE_TYPE);
+		if (ret < 0) {
+			dev_err(di->dev, "Fail to detect BQ27425's type\n");
+			/* try to continue */
+		} else {
+			switch (ret) {
+			case 0x0410:
+				di->chip_type = BQ27425_g1;
+				break;
+			case 0x0425:
+				di->chip_type = BQ27425_g2a;
+				break;
+			default:
+				dev_err(di->dev, "Unknown BQ27425 type: "
+						"%04X\n", ret);
+				/* try to continue */
+			}
+		}
+	}
+
 	di->bat.type = POWER_SUPPLY_TYPE_BATTERY;
 	if (di->chip == BQ27425) {
 		di->bat.properties = bq27425_battery_props;
-- 
2.0.0.rc2

--
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