Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5657812imm; Wed, 12 Sep 2018 09:09:34 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbcCkjwF9Oa45DdeWIvbliUBGVXn0uqN6CMdsG+R9+MV0tOBRJ+3CtZ7k01fmNXz2RNXORL X-Received: by 2002:a63:e4b:: with SMTP id 11-v6mr3137793pgo.320.1536768574063; Wed, 12 Sep 2018 09:09:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536768574; cv=none; d=google.com; s=arc-20160816; b=hbXNvk/yt7Sg9BVonXemMXbmMSWsbVXHFJdavVIFL3f7WIhEYu7t1ZXA/MmFQAL1i5 ESM5YrGzII/adouQ5wtY4oGhxoAJJtlVC0mr9+yOHOWn0vsyeA9Z9g/Mda61TO9S/KLB oOqiscOvHv4Rnlt/phgc0+24Dx7r70KpdVyclMXeBzcZsxDzZeuXt8q4P0K3dbyiJxHm LdTS+39thk1hGouxkhpVeKoe0fu0cCPwFp3BqB1QxTcqRDOY3eYn4zSUjzaSAqHR7oZl E8ox5zAXJLIE7GRnhS2Jf+oH2KahGhejqmBgJtwCqqFIUwudHXxpAgBUh/EV3CyjoJrg Dg3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:cc:from:date:content-transfer-encoding:mime-version :subject:to:dkim-signature; bh=8QNGzoeneFaV0BTMFvfMB4hbUbzPaLIYeFwJBr+k5RE=; b=ApgoYNyti2zyesdYjUtjDEu4ZMZgWiFkwaggy1mMLvrbZypXjvyMn41J15ja85TXWu 49oV0tHPQrqG4Wo0x1EF62Vz9qsKQYtr4A0rFOKC1HGVobYA4+va1In/mb1ZfVJImRRV p8h/1852uVx4kkmc20egUmUE+cFX4+1aas/9QeSVYtydOnYsZjnEf2BOxewiFTrE4k3Z qbdqK5lymmaOmsH+027C16GYp9iTyq5Pkj/kzbgWI1rs0i0zb8s0316UqsrOCuw1pN8c 8337QZKts16jBChny0JPm5NngORd/1IJIdNswQCQXAVESOJmhfR+ELy6kR38vxKW/AxF +Jfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@akkea.ca header.s=mail header.b="j80v/MO+"; 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 v5-v6si1274095plo.380.2018.09.12.09.09.08; Wed, 12 Sep 2018 09:09:34 -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="j80v/MO+"; 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 S1727992AbeILVOK (ORCPT + 99 others); Wed, 12 Sep 2018 17:14:10 -0400 Received: from node.akkea.ca ([192.155.83.177]:55442 "EHLO node.akkea.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726640AbeILVOK (ORCPT ); Wed, 12 Sep 2018 17:14:10 -0400 Received: by node.akkea.ca (Postfix, from userid 33) id 128F65420DB; Wed, 12 Sep 2018 16:08:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1536768538; bh=8QNGzoeneFaV0BTMFvfMB4hbUbzPaLIYeFwJBr+k5RE=; h=To:Subject:Date:From:Cc:In-Reply-To:References; b=j80v/MO+PKM5UGYSGohNwde9S5I7aiyuGbp+ChH4eN1VOfCVOdsfBnAsv8iqR3c6c FsIk+pcNfYbEWnkN29CcQQrqYJwNeGg/TvDZqXLP+8nhpTc6Kt3eeMNkrZQfhVMoJe RzVl+5r76kg3a/FJH1fJgz+S5aZDqTnhiw0WxmIE= To: linux@roeck-us.net Subject: Re: [PATCH v3] usb: typec: get the vbus source and charge values from the devicetree X-PHP-Originating-Script: 1000:rcube.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Wed, 12 Sep 2018 10:08:58 -0600 From: Angus Ainslie Cc: Heikki Krogerus , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <8A418EC6-62A4-4354-8928-7693696409D1@gmail.com> References: <20180906192644.24587-1-angus@akkea.ca> <20180911145931.32441-1-angus@akkea.ca> <8A418EC6-62A4-4354-8928-7693696409D1@gmail.com> Message-ID: <9d7431e51aa069f288dd4bf39e9db9f1@www.akkea.ca> X-Sender: angus@akkea.ca User-Agent: Roundcube Webmail/1.1.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-09-11 09:33, Guenter Roeck wrote: > I cant put my finger on it but this seems wrong. As i said both src > and sink should never be true at the same time. I also din’t > understand why turning off src should power off your board. Ultimately > my concern is that we may be just painting over the real problem, and > that would be really bad to do with dt properties. > I agree that this doesn't seem like the correct way of solving the problem. On this HW (Emcraft iMX8M BSB) I think the PTN5110 chip has been connected correctly so I'm assuming that it is some quirk of the PTN5110. I didn't design the HW or the chip. This is a workaround for "quirky" hardware and there may be others that don't behave exactly as expected. > Note that sending to groeck7@ makes it hard for me to see your emails > and to reply. Using linux@roeck-us.net would be much better. > Ok, I think that email was grabbed from the driver source. > Guenter > > Sent from my iPhone > >> On Sep 11, 2018, at 7:59 AM, Angus Ainslie (Purism) >> wrote: >> >> 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 >>