From patchwork Sun Aug 6 12:35:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9883739 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4BEC76031B for ; Sun, 6 Aug 2017 12:38:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E64E283B0 for ; Sun, 6 Aug 2017 12:38:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3231228514; Sun, 6 Aug 2017 12:38:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3331283B0 for ; Sun, 6 Aug 2017 12:38:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751998AbdHFMim (ORCPT ); Sun, 6 Aug 2017 08:38:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55116 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751925AbdHFMg3 (ORCPT ); Sun, 6 Aug 2017 08:36:29 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 819D2C0587E8; Sun, 6 Aug 2017 12:36:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 819D2C0587E8 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=hdegoede@redhat.com Received: from shalem.localdomain.com (ovpn-116-85.ams2.redhat.com [10.36.116.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4FEF6FE46; Sun, 6 Aug 2017 12:36:25 +0000 (UTC) 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 10/18] staging: typec: fusb302: Add support for fcs, vbus-regulator-name device-property Date: Sun, 6 Aug 2017 14:35:47 +0200 Message-Id: <20170806123555.5124-11-hdegoede@redhat.com> In-Reply-To: <20170806123555.5124-1-hdegoede@redhat.com> References: <20170806123555.5124-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 (mx1.redhat.com [10.5.110.32]); Sun, 06 Aug 2017 12:36:29 +0000 (UTC) Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On devicetree platforms the fusb302 dt-node will have a vbus regulator property with a phandle to the regulator. On ACPI platforms, there are no phandles and we need to get the vbus by a system wide unique name. Add support for a new "fcs,vbus-regulator-name" device-property which ACPI platform code can set to pass the name. Signed-off-by: Hans de Goede --- drivers/staging/typec/fusb302/fusb302.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/staging/typec/fusb302/fusb302.c b/drivers/staging/typec/fusb302/fusb302.c index e1e08f57af99..c3bcc5484ade 100644 --- a/drivers/staging/typec/fusb302/fusb302.c +++ b/drivers/staging/typec/fusb302/fusb302.c @@ -1722,6 +1722,28 @@ static int fusb302_probe(struct i2c_client *client, return -EPROBE_DEFER; } + /* + * Devicetree platforms should get vbus from their dt-node. + * On ACPI platforms, we need to get the vbus by a system wide unique + * name, which is set in a device prop by the platform code. + */ + if (device_property_read_string(dev, "fcs,vbus-regulator-name", + &name) == 0) { + /* + * Use regulator_get_optional so that we can detect if we need + * to defer the probe rather then getting the dummy-regulator. + */ + chip->vbus = devm_regulator_get_optional(dev, name); + if (IS_ERR(chip->vbus)) { + ret = PTR_ERR(chip->vbus); + return (ret == -ENODEV) ? -EPROBE_DEFER : ret; + } + } else { + chip->vbus = devm_regulator_get(dev, "vbus"); + if (IS_ERR(chip->vbus)) + return PTR_ERR(chip->vbus); + } + ret = tcpm_register_psy(chip->dev, &chip->tcpc_dev, "fusb302-typec-source"); if (ret < 0) @@ -1739,12 +1761,6 @@ static int fusb302_probe(struct i2c_client *client, INIT_DELAYED_WORK(&chip->bc_lvl_handler, fusb302_bc_lvl_handler_work); init_tcpc_dev(&chip->tcpc_dev); - chip->vbus = devm_regulator_get(chip->dev, "vbus"); - if (IS_ERR(chip->vbus)) { - ret = PTR_ERR(chip->vbus); - goto destroy_workqueue; - } - if (client->irq) { chip->gpio_int_n_irq = client->irq; } else {