{"id":809275,"url":"http://patchwork.ozlabs.org/api/1.0/patches/809275/?format=json","project":{"id":35,"url":"http://patchwork.ozlabs.org/api/1.0/projects/35/?format=json","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":""},"msgid":"<20170903124156.7440-3-hdegoede@redhat.com>","date":"2017-09-03T12:41:55","name":"[v4,2/3] i2c-cht-wc: Add device-properties for fusb302 integration","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"7e18031582d935a3b3f4c5abac96f4b0e16e6c61","submitter":{"id":1893,"url":"http://patchwork.ozlabs.org/api/1.0/people/1893/?format=json","name":"Hans de Goede","email":"hdegoede@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20170903124156.7440-3-hdegoede@redhat.com/mbox/","series":[{"id":1226,"url":"http://patchwork.ozlabs.org/api/1.0/series/1226/?format=json","date":"2017-09-03T12:41:53","name":"i2c: Hookup typec power-negotation to the PMIC and charger","version":4,"mbox":"http://patchwork.ozlabs.org/series/1226/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/809275/checks/","tags":{},"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-mx03.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx03.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 3xlXgX2qQTz9s2G\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun,  3 Sep 2017 22:42:32 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752968AbdICMmO (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tSun, 3 Sep 2017 08:42:14 -0400","from mx1.redhat.com ([209.132.183.28]:38812 \"EHLO mx1.redhat.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1752878AbdICMmG (ORCPT <rfc822;linux-i2c@vger.kernel.org>);\n\tSun, 3 Sep 2017 08:42:06 -0400","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\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 C4B8883F42;\n\tSun,  3 Sep 2017 12:42:05 +0000 (UTC)","from shalem.localdomain.com (ovpn-116-76.ams2.redhat.com\n\t[10.36.116.76])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 714036031E;\n\tSun,  3 Sep 2017 12:42:02 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com C4B8883F42","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>, Guenter 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","Subject":"[PATCH v4 2/3] i2c-cht-wc: Add device-properties for fusb302\n\tintegration","Date":"Sun,  3 Sep 2017 14:41:55 +0200","Message-Id":"<20170903124156.7440-3-hdegoede@redhat.com>","In-Reply-To":"<20170903124156.7440-1-hdegoede@redhat.com>","References":"<20170903124156.7440-1-hdegoede@redhat.com>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.11","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.27]);\n\tSun, 03 Sep 2017 12:42:05 +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":"Add device-properties to make the bq24292i charger connected to\nthe bus get its input-current-limit from the fusb302 Type-C port\ncontroller which is used on boards with the cht-wc PMIC,\nas well as regulator_init_data for the 5V boost converter on\nthe bq24292i.\n\nSince this means we now hook-up the bq24292i to the fusb302 Type-C port\ncontroller add a check for the ACPI device which instantiates the fusb302.\n\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\n---\nChanges in v2:\n-Set board_info.dev_name\n-Define and pass regulator_init_data for the bq24292i\n-Add a check for the ACPI device which instantiates the fusb302\nChanges in v4:\n-Drop the ti,input-current-limit-from-supplier property on the bq24292i\n this is the default now\n---\n drivers/i2c/busses/Kconfig      |  5 ++++\n drivers/i2c/busses/i2c-cht-wc.c | 51 +++++++++++++++++++++++++++++++++++------\n 2 files changed, 49 insertions(+), 7 deletions(-)","diff":"diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig\nindex 79c33817e412..272ef10fb629 100644\n--- a/drivers/i2c/busses/Kconfig\n+++ b/drivers/i2c/busses/Kconfig\n@@ -197,6 +197,11 @@ config I2C_CHT_WC\n \t  SMBus controller found in the Intel Cherry Trail Whiskey Cove PMIC\n \t  found on some Intel Cherry Trail systems.\n \n+\t  Note this controller is hooked up to a TI bq24292i charger-IC,\n+\t  combined with a FUSB302 Type-C port-controller as such it is advised\n+\t  to also select CONFIG_CHARGER_BQ24190=m and CONFIG_TYPEC_FUSB302=m\n+\t  (the fusb302 driver currently is in drivers/staging).\n+\n config I2C_NFORCE2\n \ttristate \"Nvidia nForce2, nForce3 and nForce4\"\n \tdepends on PCI\ndiff --git a/drivers/i2c/busses/i2c-cht-wc.c b/drivers/i2c/busses/i2c-cht-wc.c\nindex 21312eed09e4..82e331db8d98 100644\n--- a/drivers/i2c/busses/i2c-cht-wc.c\n+++ b/drivers/i2c/busses/i2c-cht-wc.c\n@@ -16,6 +16,7 @@\n  * GNU General Public License for more details.\n  */\n \n+#include <linux/acpi.h>\n #include <linux/completion.h>\n #include <linux/delay.h>\n #include <linux/i2c.h>\n@@ -25,6 +26,7 @@\n #include <linux/mfd/intel_soc_pmic.h>\n #include <linux/module.h>\n #include <linux/platform_device.h>\n+#include <linux/power/bq24190_charger.h>\n #include <linux/slab.h>\n \n #define CHT_WC_I2C_CTRL\t\t\t0x5e24\n@@ -232,13 +234,35 @@ static const struct irq_chip cht_wc_i2c_irq_chip = {\n \t.name\t\t\t= \"cht_wc_ext_chrg_irq_chip\",\n };\n \n+static const char * const bq24190_suppliers[] = { \"fusb302-typec-source\" };\n+\n static const struct property_entry bq24190_props[] = {\n-\tPROPERTY_ENTRY_STRING(\"extcon-name\", \"cht_wcove_pwrsrc\"),\n+\tPROPERTY_ENTRY_STRING_ARRAY(\"supplied-from\", bq24190_suppliers),\n \tPROPERTY_ENTRY_BOOL(\"omit-battery-class\"),\n \tPROPERTY_ENTRY_BOOL(\"disable-reset\"),\n \t{ }\n };\n \n+static struct regulator_consumer_supply fusb302_consumer = {\n+\t.supply = \"vbus\",\n+\t/* Must match fusb302 dev_name in intel_cht_int33fe.c */\n+\t.dev_name = \"i2c-fusb302\",\n+};\n+\n+static const struct regulator_init_data bq24190_vbus_init_data = {\n+\t.constraints = {\n+\t\t/* The name is used in intel_cht_int33fe.c do not change. */\n+\t\t.name = \"cht_wc_usb_typec_vbus\",\n+\t\t.valid_ops_mask = REGULATOR_CHANGE_STATUS,\n+\t},\n+\t.consumer_supplies = &fusb302_consumer,\n+\t.num_consumer_supplies = 1,\n+};\n+\n+static struct bq24190_platform_data bq24190_pdata = {\n+\t.regulator_init_data = &bq24190_vbus_init_data,\n+};\n+\n static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev)\n {\n \tstruct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent);\n@@ -246,7 +270,9 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev)\n \tstruct i2c_board_info board_info = {\n \t\t.type = \"bq24190\",\n \t\t.addr = 0x6b,\n+\t\t.dev_name = \"bq24190\",\n \t\t.properties = bq24190_props,\n+\t\t.platform_data = &bq24190_pdata,\n \t};\n \tint ret, reg, irq;\n \n@@ -314,11 +340,21 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev)\n \tif (ret)\n \t\tgoto remove_irq_domain;\n \n-\tboard_info.irq = adap->client_irq;\n-\tadap->client = i2c_new_device(&adap->adapter, &board_info);\n-\tif (!adap->client) {\n-\t\tret = -ENOMEM;\n-\t\tgoto del_adapter;\n+\t/*\n+\t * Normally the Whiskey Cove PMIC is paired with a TI bq24292i charger,\n+\t * connected to this i2c bus, and a max17047 fuel-gauge and a fusb302\n+\t * USB Type-C controller connected to another i2c bus. In this setup\n+\t * the max17047 and fusb302 devices are enumerated through an INT33FE\n+\t * ACPI device. If this device is present register an i2c-client for\n+\t * the TI bq24292i charger.\n+\t */\n+\tif (acpi_dev_present(\"INT33FE\", NULL, -1)) {\n+\t\tboard_info.irq = adap->client_irq;\n+\t\tadap->client = i2c_new_device(&adap->adapter, &board_info);\n+\t\tif (!adap->client) {\n+\t\t\tret = -ENOMEM;\n+\t\t\tgoto del_adapter;\n+\t\t}\n \t}\n \n \tplatform_set_drvdata(pdev, adap);\n@@ -335,7 +371,8 @@ static int cht_wc_i2c_adap_i2c_remove(struct platform_device *pdev)\n {\n \tstruct cht_wc_i2c_adap *adap = platform_get_drvdata(pdev);\n \n-\ti2c_unregister_device(adap->client);\n+\tif (adap->client)\n+\t\ti2c_unregister_device(adap->client);\n \ti2c_del_adapter(&adap->adapter);\n \tirq_domain_remove(adap->irq_domain);\n \n","prefixes":["v4","2/3"]}