From patchwork Tue Sep 1 02:10:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Dannenberg X-Patchwork-Id: 7102411 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 545F0BEEC1 for ; Tue, 1 Sep 2015 02:11:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6481620692 for ; Tue, 1 Sep 2015 02:11:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03D7B20695 for ; Tue, 1 Sep 2015 02:11:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754738AbbIACLX (ORCPT ); Mon, 31 Aug 2015 22:11:23 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:57519 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754736AbbIACLV (ORCPT ); Mon, 31 Aug 2015 22:11:21 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id t812B0GN023225; Mon, 31 Aug 2015 21:11:00 -0500 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id t812B0rk010523; Mon, 31 Aug 2015 21:11:00 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.224.2; Mon, 31 Aug 2015 21:11:00 -0500 Received: from beast.tx.rr.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t812AkYU004175; Mon, 31 Aug 2015 21:10:55 -0500 From: Andreas Dannenberg To: Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , Laurentiu Palcu , Krzysztof Kozlowski CC: , , Andreas Dannenberg Subject: [PATCH 03/13] power: bq24257: Add basic support for bq24250/bq24251 Date: Mon, 31 Aug 2015 21:10:25 -0500 Message-ID: <1441073435-12349-4-git-send-email-dannenberg@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441073435-12349-1-git-send-email-dannenberg@ti.com> References: <1441073435-12349-1-git-send-email-dannenberg@ti.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds basic support for bq24250 and bq24251 which are very similar to the bq24257 the driver was originally written for. Basic support means the ability to select a device through Kconfig, DT and ACPI, an instance variable allowing to check which chip is active, and the reporting back of the selected device through the POWER_SUPPLY_PROP_MODEL_NAME power supply sysfs property. This patch by itself is not sufficient to actually use those two added devices in a real-world setting due to some feature differences which are addressed by other patches in this series. Signed-off-by: Andreas Dannenberg --- drivers/power/Kconfig | 5 +++-- drivers/power/bq24257_charger.c | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index 08beeed..0a2b033 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig @@ -396,11 +396,12 @@ config CHARGER_BQ24190 Say Y to enable support for the TI BQ24190 battery charger. config CHARGER_BQ24257 - tristate "TI BQ24257 battery charger driver" + tristate "TI BQ24250/251/257 battery charger driver" depends on I2C && GPIOLIB depends on REGMAP_I2C help - Say Y to enable support for the TI BQ24257 battery charger. + Say Y to enable support for the TI BQ24250, BQ24251, and BQ24257 battery + chargers. config CHARGER_BQ24735 tristate "TI BQ24735 battery charger support" diff --git a/drivers/power/bq24257_charger.c b/drivers/power/bq24257_charger.c index 0b34528..45232bd 100644 --- a/drivers/power/bq24257_charger.c +++ b/drivers/power/bq24257_charger.c @@ -13,6 +13,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * + * Datasheets: + * http://www.ti.com/product/bq24250 + * http://www.ti.com/product/bq24251 + * http://www.ti.com/product/bq24257 */ #include @@ -41,6 +45,12 @@ #define BQ24257_ILIM_SET_DELAY 1000 /* msec */ +enum bq2425x_chip { + BQ24250, + BQ24251, + BQ24257, +}; + enum bq24257_fields { F_WD_FAULT, F_WD_EN, F_STAT, F_FAULT, /* REG 1 */ F_RESET, F_IILIMIT, F_EN_STAT, F_EN_TERM, F_CE, F_HZ_MODE, /* REG 2 */ @@ -71,6 +81,9 @@ struct bq24257_device { struct device *dev; struct power_supply *charger; + enum bq2425x_chip chip; + char chip_name[I2C_NAME_SIZE]; + struct regmap *rmap; struct regmap_field *rmap_fields[F_MAX_FIELDS]; @@ -250,6 +263,10 @@ static int bq24257_power_supply_get_property(struct power_supply *psy, val->strval = BQ24257_MANUFACTURER; break; + case POWER_SUPPLY_PROP_MODEL_NAME: + val->strval = bq->chip_name; + break; + case POWER_SUPPLY_PROP_ONLINE: val->intval = state.power_good; break; @@ -574,6 +591,7 @@ static int bq24257_hw_init(struct bq24257_device *bq) static enum power_supply_property bq24257_power_supply_props[] = { POWER_SUPPLY_PROP_MANUFACTURER, + POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_HEALTH, @@ -686,6 +704,8 @@ static int bq24257_probe(struct i2c_client *client, bq->client = client; bq->dev = dev; + bq->chip = (enum bq2425x_chip)id->driver_data; + strncpy(bq->chip_name, id->name, I2C_NAME_SIZE); mutex_init(&bq->lock); @@ -828,19 +848,27 @@ static const struct dev_pm_ops bq24257_pm = { }; static const struct i2c_device_id bq24257_i2c_ids[] = { - { "bq24257", 0 }, + { "bq24250", BQ24250 }, + { "bq24251", BQ24251 }, + { "bq24257", BQ24257 }, {}, }; MODULE_DEVICE_TABLE(i2c, bq24257_i2c_ids); static const struct of_device_id bq24257_of_match[] = { - { .compatible = "ti,bq24257", }, + { + .compatible = "ti,bq24250", + .compatible = "ti,bq24251", + .compatible = "ti,bq24257", + }, { }, }; MODULE_DEVICE_TABLE(of, bq24257_of_match); static const struct acpi_device_id bq24257_acpi_match[] = { - {"BQ242570", 0}, + { "BQ242500", BQ24250 }, + { "BQ242510", BQ24251 }, + { "BQ242570", BQ24257 }, {}, }; MODULE_DEVICE_TABLE(acpi, bq24257_acpi_match);