Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4172372imm; Tue, 11 Sep 2018 08:01:53 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZVv4UyZIHZ/nDP0oAQQXiclnRneUkTxkes0basFGwiVRAg7HN6eAGvs/c5WNz/xiHb4hxU X-Received: by 2002:a63:6446:: with SMTP id y67-v6mr28997250pgb.443.1536678113166; Tue, 11 Sep 2018 08:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536678113; cv=none; d=google.com; s=arc-20160816; b=aBRPxxERz/0jR1DbkY+phvLNQ0Ie9uH/PMpco3N0bE2UYulD+yDGYKOw2l6i+bZHl2 nfyc3+Aof929JqQJ6rsJHwSEgcGNwyi4R5CTPeN0hz9bF8FzrbSh6GvjXFaHdb35GECy JuHuFFXNTn0ltSGUwyC5GvhshgIUwPNMD+7lxa+KP+KU3I69WD5nugxT8whlnyACNBgu xe3jHsmYItqsVut8trUKLwOcd/fcooOVCCkDg7ERBc/JB0CwdEb1gkbT3XOrnmXb6dog kBcyiTXWS5mHcU4L+FcC/ghyQilBOLME6bbGZS5BT+yTcgdnQlPga6TJfS815chgqqvu OT/Q== 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=m72XrVPEbnI9sQkL8cE43w0uTdLon6z2Qa/nWtjpraE=; b=KUtXd6GcoZifx2LzUQfzpbKSQH+ZsFMntkAVUsReKDwzAO/NUNRCLE6KMFeB6yWTVq 0SjCqLLI8skrNOJgH5alynB0QEiIRk0b5pH6+W22WTJKfM7tvf4kW7opH40MoWJIx/GU +OXz+6l1X4hovz/gZOZANuj8SCbU/Rv1YsCb1hu1ULW2plmcQ03HYajVlucmOrjykk6g KJJ8yJoGklEsqp7/tFvpiVPk14VFXBHyiWpZ/PJZDYlYPXkAoHuNVdJo4cbrG1nteb4o lmUFankVU0QAwSdSepiyverD+nPN2o+rtp9aFPkMHo8qHrtGL3w6B+L9Ki7s1//qxjPl S35Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@akkea.ca header.s=mail header.b=KekXPlMJ; dkim=pass header.i=@akkea.ca header.s=mail header.b=KekXPlMJ; 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 b1-v6si19081909plc.168.2018.09.11.08.01.37; Tue, 11 Sep 2018 08:01:53 -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=KekXPlMJ; dkim=pass header.i=@akkea.ca header.s=mail header.b=KekXPlMJ; 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 S1727682AbeIKT70 (ORCPT + 99 others); Tue, 11 Sep 2018 15:59:26 -0400 Received: from node.akkea.ca ([192.155.83.177]:54086 "EHLO node.akkea.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727231AbeIKT70 (ORCPT ); Tue, 11 Sep 2018 15:59:26 -0400 Received: from localhost (localhost [127.0.0.1]) by node.akkea.ca (Postfix) with ESMTP id 989DF5420EF; Tue, 11 Sep 2018 14:59:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1536677985; bh=m72XrVPEbnI9sQkL8cE43w0uTdLon6z2Qa/nWtjpraE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KekXPlMJ3svKRBmTPHQr8sdzDkHH6rZEZDQuOrJrRE7TBTGzzVN+PWXkmNje3W9Lb wVuL8/sXPZlhBqzSxVs+MMzW/5shZU1rVacpzBHDLF8PWjAF8HNNwnFEeZtCPka1Lr guADj4GLNOCE7lpVnc8XxWO2IlhF3ED/dloX1zPg= 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 dfHNCLAbGn4Z; Tue, 11 Sep 2018 14:59:45 +0000 (UTC) Received: from localhost.localdomain (S0106b04e267b9d3e.cg.shawcable.net [68.147.232.7]) by node.akkea.ca (Postfix) with ESMTPSA id BB6085420DB; Tue, 11 Sep 2018 14:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1536677985; bh=m72XrVPEbnI9sQkL8cE43w0uTdLon6z2Qa/nWtjpraE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KekXPlMJ3svKRBmTPHQr8sdzDkHH6rZEZDQuOrJrRE7TBTGzzVN+PWXkmNje3W9Lb wVuL8/sXPZlhBqzSxVs+MMzW/5shZU1rVacpzBHDLF8PWjAF8HNNwnFEeZtCPka1Lr guADj4GLNOCE7lpVnc8XxWO2IlhF3ED/dloX1zPg= 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 v3] usb: typec: get the vbus source and charge values from the devicetree Date: Tue, 11 Sep 2018 08:59:31 -0600 Message-Id: <20180911145931.32441-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 V2: Change the devicetree documentation. Change the devicetree property names. Changed since V1: use devicetree values instead of hardcoded initialization. Signed-off-by: Angus Ainslie (Purism) --- .../devicetree/bindings/usb/typec-tcpci.txt | 6 ++++++ drivers/usb/typec/tcpm.c | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/typec-tcpci.txt b/Documentation/devicetree/bindings/usb/typec-tcpci.txt index 0dd1469e7318..b07418ae6482 100644 --- a/Documentation/devicetree/bindings/usb/typec-tcpci.txt +++ b/Documentation/devicetree/bindings/usb/typec-tcpci.txt @@ -15,6 +15,12 @@ Required sub-node: of connector node are specified in Documentation/devicetree/bindings/connector/usb-connector.txt +Optional properties for usb-c-connector sub-node: +- 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-sink: set the initalization value for vbus-sink to true. + If this property is not present the initial value will be false. + Example: ptn5110@50 { diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index ca7bedb46f7f..10c14ece3858 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-sink")) + port->vbus_charge = true; + else + port->vbus_charge = false; + if (port->port_type == TYPEC_PORT_SNK) goto sink; -- 2.17.1