Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/807547/?format=api
{ "id": 807547, "url": "http://patchwork.ozlabs.org/api/patches/807547/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/patch/20170830094814.17758-9-hdegoede@redhat.com/", "project": { "id": 35, "url": "http://patchwork.ozlabs.org/api/projects/35/?format=api", "name": "Linux I2C development", "link_name": "linux-i2c", "list_id": "linux-i2c.vger.kernel.org", "list_email": "linux-i2c@vger.kernel.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170830094814.17758-9-hdegoede@redhat.com>", "list_archive_url": null, "date": "2017-08-30T09:48:11", "name": "[v3,08/11] power: supply: bq24190_charger: Export 5V boost converter as regulator", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "4e45b9a3a078c380e716c9e8c6e4b405109f8f84", "submitter": { "id": 1893, "url": "http://patchwork.ozlabs.org/api/people/1893/?format=api", "name": "Hans de Goede", "email": "hdegoede@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-i2c/patch/20170830094814.17758-9-hdegoede@redhat.com/mbox/", "series": [ { "id": 564, "url": "http://patchwork.ozlabs.org/api/series/564/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/list/?series=564", "date": "2017-08-30T09:48:14", "name": "Hookup typec power-negotation to the PMIC and charger", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/564/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/807547/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/807547/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linux-i2c-owner@vger.kernel.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-i2c-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "ext-mx04.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com", "ext-mx04.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=hdegoede@redhat.com" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xj1395j6Jz9sNn\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 19:50:45 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751808AbdH3Jss (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tWed, 30 Aug 2017 05:48:48 -0400", "from mx1.redhat.com ([209.132.183.28]:18476 \"EHLO mx1.redhat.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751760AbdH3Jsp (ORCPT <rfc822;linux-i2c@vger.kernel.org>);\n\tWed, 30 Aug 2017 05:48:45 -0400", "from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 22F80821C7;\n\tWed, 30 Aug 2017 09:48:45 +0000 (UTC)", "from shalem.localdomain.com (ovpn-116-238.ams2.redhat.com\n\t[10.36.116.238])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 80A5C87C9A;\n\tWed, 30 Aug 2017 09:48:42 +0000 (UTC)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 22F80821C7", "From": "Hans de Goede <hdegoede@redhat.com>", "To": "Darren Hart <dvhart@infradead.org>, Andy Shevchenko <andy@infradead.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Sebastian Reichel <sre@kernel.org>,\n\tGreg Kroah-Hartman <gregkh@linuxfoundation.org>,\n\tGuenter Roeck <linux@roeck-us.net>,\n\tHeikki Krogerus <heikki.krogerus@linux.intel.com>", "Cc": "Hans de Goede <hdegoede@redhat.com>,\n\tplatform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org,\n\tlinux-i2c@vger.kernel.org, Liam Breck <liam@networkimprov.net>,\n\tTony Lindgren <tony@atomide.com>, linux-pm@vger.kernel.org,\n\tdevel@driverdev.osuosl.org", "Subject": "[PATCH v3 08/11] power: supply: bq24190_charger: Export 5V boost\n\tconverter as regulator", "Date": "Wed, 30 Aug 2017 11:48:11 +0200", "Message-Id": "<20170830094814.17758-9-hdegoede@redhat.com>", "In-Reply-To": "<20170830094814.17758-1-hdegoede@redhat.com>", "References": "<20170830094814.17758-1-hdegoede@redhat.com>", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.15", "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.28]);\n\tWed, 30 Aug 2017 09:48:45 +0000 (UTC)", "Sender": "linux-i2c-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<linux-i2c.vger.kernel.org>", "X-Mailing-List": "linux-i2c@vger.kernel.org" }, "content": "Register the 5V boost converter as a regulator named \"usb_otg_vbus\".\n\nThis commit also adds support for bq24190_platform_data, through which\nnon device-tree platforms can pass the regulator_init_data (containing\nmappings for the consumer amongst other things).\n\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\n---\nChanges in v2:\n-Use \"usb_otg_vbus\" as default name for the regulator\n-Add support for passing regulator_init_data for non device-tree platforms\n-Register the regulator later, to avoid it showing up and shortly later\n disappearing again on probe errors (e.g. -EPROBE_DEFER).\n\nChanges in v3:\n-Add a bq24190_set_charge_mode helper and use that for the vbus_enable\n and vbus_disable callbacks to reduce code duplication\n---\n drivers/power/supply/bq24190_charger.c | 112 +++++++++++++++++++++++++++++++++\n include/linux/power/bq24190_charger.h | 18 ++++++\n 2 files changed, 130 insertions(+)\n create mode 100644 include/linux/power/bq24190_charger.h", "diff": "diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c\nindex fa711c106b63..e606a078b0dd 100644\n--- a/drivers/power/supply/bq24190_charger.c\n+++ b/drivers/power/supply/bq24190_charger.c\n@@ -16,6 +16,9 @@\n #include <linux/of_device.h>\n #include <linux/pm_runtime.h>\n #include <linux/power_supply.h>\n+#include <linux/power/bq24190_charger.h>\n+#include <linux/regulator/driver.h>\n+#include <linux/regulator/machine.h>\n #include <linux/workqueue.h>\n #include <linux/gpio.h>\n #include <linux/i2c.h>\n@@ -513,6 +516,111 @@ static int bq24190_sysfs_create_group(struct bq24190_dev_info *bdi)\n static inline void bq24190_sysfs_remove_group(struct bq24190_dev_info *bdi) {}\n #endif\n \n+#ifdef CONFIG_REGULATOR\n+static int bq24190_set_charge_mode(struct regulator_dev *dev, u8 val)\n+{\n+\tstruct bq24190_dev_info *bdi = rdev_get_drvdata(dev);\n+\tint ret;\n+\n+\tret = pm_runtime_get_sync(bdi->dev);\n+\tif (ret < 0) {\n+\t\tdev_warn(bdi->dev, \"pm_runtime_get failed: %i\\n\", ret);\n+\t\tpm_runtime_put_noidle(bdi->dev);\n+\t\treturn ret;\n+\t}\n+\n+\tret = bq24190_write_mask(bdi, BQ24190_REG_POC,\n+\t\t\t\t BQ24190_REG_POC_CHG_CONFIG_MASK,\n+\t\t\t\t BQ24190_REG_POC_CHG_CONFIG_SHIFT, val);\n+\n+\tpm_runtime_mark_last_busy(bdi->dev);\n+\tpm_runtime_put_autosuspend(bdi->dev);\n+\n+\treturn ret;\n+}\n+\n+static int bq24190_vbus_enable(struct regulator_dev *dev)\n+{\n+\treturn bq24190_set_charge_mode(dev, BQ24190_REG_POC_CHG_CONFIG_OTG);\n+}\n+\n+static int bq24190_vbus_disable(struct regulator_dev *dev)\n+{\n+\treturn bq24190_set_charge_mode(dev, BQ24190_REG_POC_CHG_CONFIG_CHARGE);\n+}\n+\n+static int bq24190_vbus_is_enabled(struct regulator_dev *dev)\n+{\n+\tstruct bq24190_dev_info *bdi = rdev_get_drvdata(dev);\n+\tint ret;\n+\tu8 val;\n+\n+\tret = pm_runtime_get_sync(bdi->dev);\n+\tif (ret < 0) {\n+\t\tdev_warn(bdi->dev, \"pm_runtime_get failed: %i\\n\", ret);\n+\t\tpm_runtime_put_noidle(bdi->dev);\n+\t\treturn ret;\n+\t}\n+\n+\tret = bq24190_read_mask(bdi, BQ24190_REG_POC,\n+\t\t\t\tBQ24190_REG_POC_CHG_CONFIG_MASK,\n+\t\t\t\tBQ24190_REG_POC_CHG_CONFIG_SHIFT, &val);\n+\n+\tpm_runtime_mark_last_busy(bdi->dev);\n+\tpm_runtime_put_autosuspend(bdi->dev);\n+\n+\treturn ret ? ret : val == BQ24190_REG_POC_CHG_CONFIG_OTG;\n+}\n+\n+static const struct regulator_ops bq24190_vbus_ops = {\n+\t.enable = bq24190_vbus_enable,\n+\t.disable = bq24190_vbus_disable,\n+\t.is_enabled = bq24190_vbus_is_enabled,\n+};\n+\n+static const struct regulator_desc bq24190_vbus_desc = {\n+\t.name = \"usb_otg_vbus\",\n+\t.type = REGULATOR_VOLTAGE,\n+\t.owner = THIS_MODULE,\n+\t.ops = &bq24190_vbus_ops,\n+\t.fixed_uV = 5000000,\n+\t.n_voltages = 1,\n+};\n+\n+static const struct regulator_init_data bq24190_vbus_init_data = {\n+\t.constraints = {\n+\t\t.valid_ops_mask = REGULATOR_CHANGE_STATUS,\n+\t},\n+};\n+\n+static int bq24190_register_vbus_regulator(struct bq24190_dev_info *bdi)\n+{\n+\tstruct bq24190_platform_data *pdata = bdi->dev->platform_data;\n+\tstruct regulator_config cfg = { };\n+\tstruct regulator_dev *reg;\n+\tint ret = 0;\n+\n+\tcfg.dev = bdi->dev;\n+\tif (pdata && pdata->regulator_init_data)\n+\t\tcfg.init_data = pdata->regulator_init_data;\n+\telse\n+\t\tcfg.init_data = &bq24190_vbus_init_data;\n+\tcfg.driver_data = bdi;\n+\treg = devm_regulator_register(bdi->dev, &bq24190_vbus_desc, &cfg);\n+\tif (IS_ERR(reg)) {\n+\t\tret = PTR_ERR(reg);\n+\t\tdev_err(bdi->dev, \"Can't register regulator: %d\\n\", ret);\n+\t}\n+\n+\treturn ret;\n+}\n+#else\n+static int bq24190_register_vbus_regulator(struct bq24190_dev_info *bdi)\n+{\n+\treturn 0;\n+}\n+#endif\n+\n static int bq24190_set_config(struct bq24190_dev_info *bdi)\n {\n \tint ret;\n@@ -1740,6 +1848,10 @@ static int bq24190_probe(struct i2c_client *client,\n \t\tgoto out_sysfs;\n \t}\n \n+\tret = bq24190_register_vbus_regulator(bdi);\n+\tif (ret < 0)\n+\t\tgoto out_sysfs;\n+\n \tif (bdi->extcon) {\n \t\tINIT_DELAYED_WORK(&bdi->extcon_work, bq24190_extcon_work);\n \t\tbdi->extcon_nb.notifier_call = bq24190_extcon_event;\ndiff --git a/include/linux/power/bq24190_charger.h b/include/linux/power/bq24190_charger.h\nnew file mode 100644\nindex 000000000000..45ce7f116a91\n--- /dev/null\n+++ b/include/linux/power/bq24190_charger.h\n@@ -0,0 +1,18 @@\n+/*\n+ * Platform data for the TI bq24190 battery charger driver.\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License version 2 as\n+ * published by the Free Software Foundation.\n+ */\n+\n+#ifndef _BQ24190_CHARGER_H_\n+#define _BQ24190_CHARGER_H_\n+\n+#include <linux/regulator/machine.h>\n+\n+struct bq24190_platform_data {\n+\tconst struct regulator_init_data *regulator_init_data;\n+};\n+\n+#endif\n", "prefixes": [ "v3", "08/11" ] }