Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.

From: Hans de Goede
Date: Wed Oct 16 2019 - 05:10:42 EST


On 10/15/19 7:39 AM, John Stultz wrote:
On Thu, Oct 3, 2019 at 1:51 PM Hans de Goede <hdegoede@xxxxxxxxxx> wrote:
On 03-10-2019 22:37, John Stultz wrote:
Fair point. I'm sort of taking a larger patchset and trying to break
it up into more easily reviewable chunks, but I guess here I mis-cut.

The user is the hikey960 gpio hub driver here:

Hmm, that seems to tie the TypeC data-role to the power-role, which
is not going to work with role swapping.

Thanks again for the feedback here. Sorry for the slow response. Been
reworking some of the easier changes but am starting to look at how to
address your feedback here.

What is controlling the usb-role-switch, and thus ultimately
causing the notifier you are suggesting to get called ?

The tcpm_mux_set() call via tcpm_state_machine_work()

really beg to be modeled as a regulator and then the
Type-C controller (using e.g. the drivers/usb/typec/tcpm/tcpm.c
framework) can use that regulator to control things.
in case of the tcpm.c framework it can then use that
regulator to implement the set_vbus callback.

So I'm looking at the bindings and I'm not sure exactly how to tie a
regulator style driver into the tcpm for this?
Looking at the driver I just see this commented out bit:

Do you happen to have a pointer to something closer to what you are describing?

Look at the tcpm_set_vbus implementation in drivers/usb/typec/tcpm/fusb302.c
you need to do something similar in your Type-C controller driver and
export the GPIO as as a gpio-controlled regulator and tie the regulator to
the connector.