From: Mike Looijmans <mike.looijmans@topic.nl>
To: Rob Herring <robh@kernel.org>
Cc: Linux USB List <linux-usb@vger.kernel.org>,
devicetree@vger.kernel.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Felipe Balbi <balbi@kernel.org>
Subject: Re: [PATCH v2] usb: dwc3: Add support for VBUS power control
Date: Fri, 19 Jun 2020 10:21:39 +0200 [thread overview]
Message-ID: <70866852-20d3-d84a-6d15-552be716ecb4@topic.nl> (raw)
In-Reply-To: <413a840f-6765-51ba-a4b4-dd6204265fb7@topic.nl>
Met vriendelijke groet / kind regards,
Mike Looijmans
System Expert
TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands
T: +31 (0) 499 33 69 69
E: mike.looijmans@topicproducts.com
W: www.topicproducts.com
Please consider the environment before printing this e-mail
On 17-06-2020 19:28, Mike Looijmans wrote:
> On 17-06-2020 18:13, Rob Herring wrote:
>> On Wed, Jun 17, 2020 at 8:38 AM Mike Looijmans
>> <mike.looijmans@topic.nl> wrote:
>>> On 10-06-2020 22:22, Rob Herring wrote:
>>>> On Wed, Jun 03, 2020 at 02:09:15PM +0200, Mike Looijmans wrote:
>>>>> Support VBUS power control using regulator framework. Enables the
>>>>> regulator
>>>>> while the port is in host mode.
>>>>>
>>>>> Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
>>>>> ---
>>>>> v2: Add missing devm_regulator_get call which got lost during rebase
>>>>>
>>>>> .../devicetree/bindings/usb/dwc3.txt | 1 +
>>>>> drivers/usb/dwc3/core.c | 34
>>>>> ++++++++++++++-----
>>>>> drivers/usb/dwc3/core.h | 4 +++
>>>>> drivers/usb/dwc3/drd.c | 6 ++--
>>>>> 4 files changed, 33 insertions(+), 12 deletions(-)
>>>>>
>>>>> diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt
>>>>> b/Documentation/devicetree/bindings/usb/dwc3.txt
>>>>> index 9946ff9ba735..56bc3f238e2d 100644
>>>>> --- a/Documentation/devicetree/bindings/usb/dwc3.txt
>>>>> +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
>>>>> @@ -37,6 +37,7 @@ Optional properties:
>>>>> - phys: from the *Generic PHY* bindings
>>>>> - phy-names: from the *Generic PHY* bindings; supported names
>>>>> are "usb2-phy"
>>>>> or "usb3-phy".
>>>>> + - vbus-supply: Regulator handle that provides the VBUS power.
>>>> Does the DWC3 block require Vbus to power itself? Doubtful. This
>>>> belongs in a usb-connector node. If the DWC3 driver wants to get the
>>>> Vbus supply, it can fetch it from that node.
>>>>
>>>> Rob
>>> Okay, I've been digging into that. But there's no actual driver that
>>> binds to a "usb-b-connector" compatible, so how do we get to the
>>> vbus-supply from there?
>>>
>>> [devm_]regulator_get only accepts a device as argument, and will not
>>> look into child nodes. The only way to get at the vbus of a child node
>>> (or a node linked through a port) would be to hand-code the equivalent
>>> of of_regulator_get(), which will not be acceptable.
>> Doesn't it look into child nodes calling of_get_child_regulator()?
> Looking at the code in regulator/core.c, yeah, it should. I'll have to
> add some debugging lines and look into why it didn't work in my test.
Ah, I had put my "connector" child in the wrong node. If I add the
following fragment to the dwc3 node, the vbus patch works:
connector {
compatible = "usb-b-connector";
label = "micro-USB-otg";
type = "micro";
vbus-supply = <®_usb0_vbus>;
};
The driver indeed picks up the vbus supply from a child node.
This would mean there's no change to the devicetree bindings, it's using
already existing bindings.
>> You're right that it wouldn't work if graph is used. The connector has
>> to be either a child of a controller for the connector or the USB
>> controller. I'd expect you'd have the former for Type-C, but for
>> "usb-b-connector" the parent is more likely just the USB controller.
> For my current case, using a direct child would be fine, there's
> nothing else connected. But I expect that we'll produce a board with
> some USB-C connector some day yeah.
>>
>> In any case, having a struct device shouldn't be a requirement and
>> most subsystems expose a get function only needing the DT node.
>>
>>> Or is it the intention that I write a usb-X-connector device driver
>>> first that handles the vbus?
>> That's a kernel implementation detail that is independent of the
>> binding, but yes we'll probably need a driver or library helper
>> functions eventually. Note that it is possible to have a struct device
>> without a driver.
>>
>> Rob
>
>
--
Mike Looijmans
prev parent reply other threads:[~2020-06-19 8:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-03 12:09 [PATCH v2] usb: dwc3: Add support for VBUS power control Mike Looijmans
[not found] ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.37aec1ae-7fee-44cb-ae24-a10a151abcb3@emailsignatures365.codetwo.com>
[not found] ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.5c7af9b2-8c7e-406c-b29a-f20ab6b96179@emailsignatures365.codetwo.com>
2020-06-10 20:22 ` Rob Herring
2020-06-11 6:09 ` Mike Looijmans
2020-06-17 14:38 ` Mike Looijmans
2020-06-17 16:13 ` Rob Herring
2020-06-17 17:28 ` Mike Looijmans
2020-06-19 8:21 ` Mike Looijmans [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=70866852-20d3-d84a-6d15-552be716ecb4@topic.nl \
--to=mike.looijmans@topic.nl \
--cc=balbi@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox