From patchwork Sun Sep 9 18:05:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angus Ainslie X-Patchwork-Id: 10593393 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CC77D13AC for ; Sun, 9 Sep 2018 18:05:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8E6E291E1 for ; Sun, 9 Sep 2018 18:05:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9C24291EB; Sun, 9 Sep 2018 18:05:45 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 22418291E1 for ; Sun, 9 Sep 2018 18:05:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727241AbeIIW4K (ORCPT ); Sun, 9 Sep 2018 18:56:10 -0400 Received: from node.akkea.ca ([192.155.83.177]:53384 "EHLO node.akkea.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726629AbeIIW4J (ORCPT ); Sun, 9 Sep 2018 18:56:09 -0400 Received: from localhost (localhost [127.0.0.1]) by node.akkea.ca (Postfix) with ESMTP id 696F95420EF; Sun, 9 Sep 2018 18:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1536516343; bh=wekhRXdFbphLFc0yBKbSQzPg1Qv8tK/sgqcd5cX5TZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UkHIAU5JyEqvWvYv/YJvZStTMFknPQriqNiPNcMF1/v+N6QClbluCTBXJVXlNCPnF 5h1pFZw+TmhEc2ugVUKQqzMDdyGMtoldTurN6T+NwU+c/2bNhPoprGmWhdh/jzoF0V Ut0rnHLEHSB7LA9IUz8VzXke/GpkJ5tuaqYyYI4E= X-Virus-Scanned: Debian amavisd-new at mail.akkea.ca Received: from node.akkea.ca ([127.0.0.1]) by localhost (mail.akkea.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sWtfs2cLgFry; Sun, 9 Sep 2018 18:05:43 +0000 (UTC) Received: from localhost.localdomain (S010614dae980e3b8.cg.shawcable.net [68.147.236.72]) by node.akkea.ca (Postfix) with ESMTPSA id A73CF5420DB; Sun, 9 Sep 2018 18:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1536516343; bh=wekhRXdFbphLFc0yBKbSQzPg1Qv8tK/sgqcd5cX5TZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UkHIAU5JyEqvWvYv/YJvZStTMFknPQriqNiPNcMF1/v+N6QClbluCTBXJVXlNCPnF 5h1pFZw+TmhEc2ugVUKQqzMDdyGMtoldTurN6T+NwU+c/2bNhPoprGmWhdh/jzoF0V Ut0rnHLEHSB7LA9IUz8VzXke/GpkJ5tuaqYyYI4E= From: "Angus Ainslie (Purism)" To: groeck7@gmail.com Cc: Heikki Krogerus , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, "Angus Ainslie (Purism)" Subject: [PATCH v2] usb: typec: get the vbus source and charge values from the devicetree Date: Sun, 9 Sep 2018 12:05:31 -0600 Message-Id: <20180909180531.28092-1-angus@akkea.ca> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180906192644.24587-1-angus@akkea.ca> References: <20180906192644.24587-1-angus@akkea.ca> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the board is being powered by USB disabling the source and sink can remove power from the board. Allow the source and sink to be initallized based on devicetree values. Changed since V1: use devicetree values instead of hardcoded initialization. Signed-off-by: Angus Ainslie (Purism) --- .../bindings/connector/usb-connector.txt | 4 ++++ drivers/usb/typec/tcpm.c | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/connector/usb-connector.txt b/Documentation/devicetree/bindings/connector/usb-connector.txt index 8855bfcfd778..afe851a713c3 100644 --- a/Documentation/devicetree/bindings/connector/usb-connector.txt +++ b/Documentation/devicetree/bindings/connector/usb-connector.txt @@ -22,6 +22,10 @@ Optional properties for usb-c-connector: or Try.SRC, should be "sink" for Try.SNK or "source" for Try.SRC. - data-role: should be one of "host", "device", "dual"(DRD) if typec connector supports USB data. +- init-vbus-source: set the initalization value for vbus-source to true. + If this property is not present the initial value will be false. +- init-vbus-charge: set the initalization value for vbus-charge to true. + If this property is not present the initial value will be false. Required properties for usb-c-connector with power delivery support: - source-pdos: An array of u32 with each entry providing supported power diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index ca7bedb46f7f..7f5d4f209e07 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -2462,9 +2462,7 @@ static int tcpm_init_vbus(struct tcpm_port *port) { int ret; - ret = port->tcpc->set_vbus(port->tcpc, false, false); - port->vbus_source = false; - port->vbus_charge = false; + ret = port->tcpc->set_vbus(port->tcpc, port->vbus_source, port->vbus_charge); return ret; } @@ -4266,6 +4264,16 @@ static int tcpm_fw_get_caps(struct tcpm_port *port, return -EINVAL; port->port_type = port->typec_caps.type; + if (fwnode_property_present(fwnode, "init-vbus-source")) + port->vbus_source = true; + else + port->vbus_source = false; + + if (fwnode_property_present(fwnode, "init-vbus-charge")) + port->vbus_charge = true; + else + port->vbus_charge = false; + if (port->port_type == TYPEC_PORT_SNK) goto sink;