Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752224AbdHFMjL (ORCPT ); Sun, 6 Aug 2017 08:39:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55936 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751564AbdHFMgX (ORCPT ); Sun, 6 Aug 2017 08:36:23 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9352837EEF Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=hdegoede@redhat.com From: Hans de Goede To: Darren Hart , Andy Shevchenko , Wolfram Sang , Sebastian Reichel , Greg Kroah-Hartman , Guenter Roeck , Heikki Krogerus Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, Liam Breck , Tony Lindgren , linux-pm@vger.kernel.org, devel@driverdev.osuosl.org Subject: [PATCH 08/18] staging: typec: fusb302: Add support for USB2 charger detection through extcon Date: Sun, 6 Aug 2017 14:35:45 +0200 Message-Id: <20170806123555.5124-9-hdegoede@redhat.com> In-Reply-To: <20170806123555.5124-1-hdegoede@redhat.com> References: <20170806123555.5124-1-hdegoede@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sun, 06 Aug 2017 12:36:22 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2341 Lines: 60 The fusb302 port-controller relies on an external device doing USB2 charger-type detection. The Intel Whiskey Cove PMIC with which the fusb302 is combined on some X86/ACPI platforms already has a charger-type detection driver which uses extcon to communicate the detected charger-type. This commit uses the tcpm_get_usb2_current_limit_extcon helper to enable USB2 charger detection on these systems. Note that the "fcs,extcon-name" property name is only for kernel internal use by X86/ACPI platform code and as such is NOT documented in the devicetree bindings. Signed-off-by: Hans de Goede --- drivers/staging/typec/fusb302/fusb302.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/staging/typec/fusb302/fusb302.c b/drivers/staging/typec/fusb302/fusb302.c index be454b5ff6c7..1d8c9b66df2f 100644 --- a/drivers/staging/typec/fusb302/fusb302.c +++ b/drivers/staging/typec/fusb302/fusb302.c @@ -1201,6 +1201,8 @@ static void init_tcpc_dev(struct tcpc_dev *fusb302_tcpc_dev) { fusb302_tcpc_dev->init = tcpm_init; fusb302_tcpc_dev->get_vbus = tcpm_get_vbus; + fusb302_tcpc_dev->get_usb2_current_limit = + tcpm_get_usb2_current_limit_extcon; fusb302_tcpc_dev->set_cc = tcpm_set_cc; fusb302_tcpc_dev->get_cc = tcpm_get_cc; fusb302_tcpc_dev->set_polarity = tcpm_set_polarity; @@ -1685,6 +1687,7 @@ static int fusb302_probe(struct i2c_client *client, struct fusb302_chip *chip; struct i2c_adapter *adapter; struct device *dev = &client->dev; + const char *name; int ret = 0; u32 val; @@ -1717,6 +1720,19 @@ static int fusb302_probe(struct i2c_client *client, if (device_property_read_u32(dev, "fcs,operating-snk-mw", &val) == 0) chip->tcpc_config.operating_snk_mw = val; + /* + * Devicetree platforms should get extcon via phandle (not yet + * supported). On ACPI platforms, we get the name from a device prop. + * This device prop is for kernel internal use only and is expected + * to be set by the platform code which also registers the i2c client + * for the fusb302. + */ + if (device_property_read_string(dev, "fcs,extcon-name", &name) == 0) { + chip->tcpc_dev.usb2_extcon = extcon_get_extcon_dev(name); + if (!chip->tcpc_dev.usb2_extcon) + return -EPROBE_DEFER; + } + ret = fusb302_debugfs_init(chip); if (ret < 0) return ret; -- 2.13.3