Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1895595imm; Sun, 9 Sep 2018 11:08:40 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbVZDrFeYRs+HDgK7HhzDbsVqRZLxXCTI2gZBjzgAjng7KbnhBgzwShoYso58i0/XZL8g/Y X-Received: by 2002:a62:c98e:: with SMTP id l14-v6mr19397104pfk.10.1536516520197; Sun, 09 Sep 2018 11:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536516520; cv=none; d=google.com; s=arc-20160816; b=fM785SvvMkRt4vyI/usMgWEdelK3Hl1HCuw/5BiU7nSoQ+4bkJqCyWOF3mYz/2RiYg 11q2EUtAa8VzKouBx+U9RIukeF/mAEOZcBzCAjrHch7jPy42Fqeay5t5Ie2MywOH384G v+Z+5BWDlZCQBpFcsQBYZ2sr1YXA+CAWz/ITdErQgmDoM1I5tfUSuDelwJv4iZBJKdpO 36PMhnnshLXZW4oW+yIfbW+rj2s9uxSP5RmzGXZmxQQMYi4pRQSruIOi1Ky03QnZ8p0l iq269tW61gQiLuMztKHdmDHn3XNjCsycL3M5qWZswEtsXlHHTfDkW8nAlpHFClYH+M6S wyLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-signature; bh=wekhRXdFbphLFc0yBKbSQzPg1Qv8tK/sgqcd5cX5TZU=; b=mURknXhQRd2hnQxxKof52dx1kjr6O1dvfm05ixMIG3llx5W50O0oqOp+nBqCBMTRg4 VohCrUk2DLApxhaF+yVPosunQbXhRPs+SJ2fEDPFEw1BxO0M3GJUCj+fCOwe8ff51a8Q nXTd9GqDT8ATw7/w8LiH8jzzYp5m4OavEHUjIobwKTrZMi2Fr9eF0t9w8K7wfK7ZXHM9 vsh53jlw6aJ1H2hQAlYIbJ1oeQaa9Zn3kNJ+fbEun8GdN4eWCbLklZ/XK7XpcqWISC/p /K08XbYQiLlSFAwTjsglyc3qv/nHLi82XDKTtV3uWIswlh+AI4/HpgeXBOfRMt6F6i5T zKOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@akkea.ca header.s=mail header.b=UkHIAU5J; dkim=pass header.i=@akkea.ca header.s=mail header.b=UkHIAU5J; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i12-v6si15804224pfj.190.2018.09.09.11.08.24; Sun, 09 Sep 2018 11:08:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@akkea.ca header.s=mail header.b=UkHIAU5J; dkim=pass header.i=@akkea.ca header.s=mail header.b=UkHIAU5J; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727650AbeIIW4K (ORCPT + 99 others); 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.17.1