Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/807549/?format=api
{ "id": 807549, "url": "http://patchwork.ozlabs.org/api/patches/807549/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/patch/20170830094814.17758-7-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-7-hdegoede@redhat.com>", "list_archive_url": null, "date": "2017-08-30T09:48:09", "name": "[v3,06/11] staging: typec: fusb302: Add support for USB2 charger detection through extcon", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "9b14638b1ed9688347ade753f5c9dd925fe35350", "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-7-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/807549/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/807549/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-mx08.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com", "ext-mx08.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 3xj13h1LYjz9t2R\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 19:51:12 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751730AbdH3Jsl (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tWed, 30 Aug 2017 05:48:41 -0400", "from mx1.redhat.com ([209.132.183.28]:40182 \"EHLO mx1.redhat.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751760AbdH3Jsj (ORCPT <rfc822;linux-i2c@vger.kernel.org>);\n\tWed, 30 Aug 2017 05:48:39 -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 CA2E8C0587F5;\n\tWed, 30 Aug 2017 09:48:38 +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 0D48A87C9A;\n\tWed, 30 Aug 2017 09:48:35 +0000 (UTC)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com CA2E8C0587F5", "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, \"Yueyao (Nathan) Zhu\" <yueyao@google.com>", "Subject": "[PATCH v3 06/11] staging: typec: fusb302: Add support for USB2\n\tcharger detection through extcon", "Date": "Wed, 30 Aug 2017 11:48:09 +0200", "Message-Id": "<20170830094814.17758-7-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.32]);\n\tWed, 30 Aug 2017 09:48:39 +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": "The fusb302 port-controller relies on an external device doing USB2\ncharger-type detection.\n\nThe Intel Whiskey Cove PMIC with which the fusb302 is combined on some\nX86/ACPI platforms already has a charger-type detection driver which\nuses extcon to communicate the detected charger-type.\n\nRather then inventing a new API for USB2 charger-type detection\nspecifically for use with the tcpm code, this commit simply re-uses the\nexisting extcon API and uses that do USB2 charger detection.\n\nNote that the \"fcs,extcon-name\" property name is only for kernel internal\nuse by X86/ACPI platform code and as such is NOT documented in\nthe fusb302 devicetree bindings.\n\nCc: \"Yueyao (Nathan) Zhu\" <yueyao@google.com>\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\n---\nChanges in v2:\n-Put extcon code directly in fusb302.c rather then introducing helpers\n which are only used by fusb302.c\n\nChanges in v3:\n-Improve commit message\n---\n drivers/staging/typec/fusb302/fusb302.c | 49 +++++++++++++++++++++++++++++++++\n 1 file changed, 49 insertions(+)", "diff": "diff --git a/drivers/staging/typec/fusb302/fusb302.c b/drivers/staging/typec/fusb302/fusb302.c\nindex 675161cf4f3a..6f007f66d597 100644\n--- a/drivers/staging/typec/fusb302/fusb302.c\n+++ b/drivers/staging/typec/fusb302/fusb302.c\n@@ -17,6 +17,7 @@\n #include <linux/debugfs.h>\n #include <linux/delay.h>\n #include <linux/errno.h>\n+#include <linux/extcon.h>\n #include <linux/gpio.h>\n #include <linux/i2c.h>\n #include <linux/interrupt.h>\n@@ -96,6 +97,7 @@ struct fusb302_chip {\n \n \tint gpio_int_n;\n \tint gpio_int_n_irq;\n+\tstruct extcon_dev *extcon;\n \n \tstruct workqueue_struct *wq;\n \tstruct delayed_work bc_lvl_handler;\n@@ -516,6 +518,38 @@ static int tcpm_get_vbus(struct tcpc_dev *dev)\n \treturn ret;\n }\n \n+static int tcpm_get_current_limit(struct tcpc_dev *dev)\n+{\n+\tstruct fusb302_chip *chip = container_of(dev, struct fusb302_chip,\n+\t\t\t\t\t\t tcpc_dev);\n+\tint current_limit = 0;\n+\tunsigned long timeout;\n+\n+\tif (!chip->extcon)\n+\t\treturn 0;\n+\n+\t/*\n+\t * USB2 Charger detection may still be in progress when we get here,\n+\t * this can take upto 600ms, wait 800ms max.\n+\t */\n+\ttimeout = jiffies + msecs_to_jiffies(800);\n+\tdo {\n+\t\tif (extcon_get_state(chip->extcon, EXTCON_CHG_USB_SDP) == 1)\n+\t\t\tcurrent_limit = 500;\n+\n+\t\tif (extcon_get_state(chip->extcon, EXTCON_CHG_USB_CDP) == 1 ||\n+\t\t extcon_get_state(chip->extcon, EXTCON_CHG_USB_ACA) == 1)\n+\t\t\tcurrent_limit = 1500;\n+\n+\t\tif (extcon_get_state(chip->extcon, EXTCON_CHG_USB_DCP) == 1)\n+\t\t\tcurrent_limit = 2000;\n+\n+\t\tmsleep(50);\n+\t} while (current_limit == 0 && time_before(jiffies, timeout));\n+\n+\treturn current_limit;\n+}\n+\n static int fusb302_set_cc_pull(struct fusb302_chip *chip,\n \t\t\t bool pull_up, bool pull_down)\n {\n@@ -1201,6 +1235,7 @@ static void init_tcpc_dev(struct tcpc_dev *fusb302_tcpc_dev)\n {\n \tfusb302_tcpc_dev->init = tcpm_init;\n \tfusb302_tcpc_dev->get_vbus = tcpm_get_vbus;\n+\tfusb302_tcpc_dev->get_current_limit = tcpm_get_current_limit;\n \tfusb302_tcpc_dev->set_cc = tcpm_set_cc;\n \tfusb302_tcpc_dev->get_cc = tcpm_get_cc;\n \tfusb302_tcpc_dev->set_polarity = tcpm_set_polarity;\n@@ -1685,6 +1720,7 @@ static int fusb302_probe(struct i2c_client *client,\n \tstruct fusb302_chip *chip;\n \tstruct i2c_adapter *adapter;\n \tstruct device *dev = &client->dev;\n+\tconst char *name;\n \tint ret = 0;\n \tu32 v;\n \n@@ -1717,6 +1753,19 @@ static int fusb302_probe(struct i2c_client *client,\n \tif (!device_property_read_u32(dev, \"fcs,operating-sink-microwatt\", &v))\n \t\tchip->tcpc_config.operating_snk_mw = v / 1000;\n \n+\t/*\n+\t * Devicetree platforms should get extcon via phandle (not yet\n+\t * supported). On ACPI platforms, we get the name from a device prop.\n+\t * This device prop is for kernel internal use only and is expected\n+\t * to be set by the platform code which also registers the i2c client\n+\t * for the fusb302.\n+\t */\n+\tif (device_property_read_string(dev, \"fcs,extcon-name\", &name) == 0) {\n+\t\tchip->extcon = extcon_get_extcon_dev(name);\n+\t\tif (!chip->extcon)\n+\t\t\treturn -EPROBE_DEFER;\n+\t}\n+\n \tret = fusb302_debugfs_init(chip);\n \tif (ret < 0)\n \t\treturn ret;\n", "prefixes": [ "v3", "06/11" ] }