Skip to contentSkip to conversation

usb: typec: Generalize mux mode names

RFC New Heikki Krogerus 1 participant 1 message May 21, 2018 USB

lore
Share & tools
lore
#0 lore raw

RFC 1/7 usb: typec: Generalize mux mode names

Quoted 157 lines · Mats Karrman
Quoted 127 lines · Heikki Krogerus
Quoted 122 lines · Mats Karrman
Quoted 115 lines · Heikki Krogerus
Quoted 109 lines · Mats Karrman

Hi Heikki,

Quoted 99 lines · Heikki Krogerus

Hi Mats,

Quoted 87 lines · Mats Karrman
Quoted 85 lines · Heikki Krogerus
Quoted 84 lines · Mats Karrman
Quoted 58 lines · Heikki Krogerus
Quoted 50 lines · Mats Karrman

Hi,

Quoted 33 lines · Heikki Krogerus
Quoted 25 lines · Mats Karrman

Hi,

On 05/08/2018 04:25 PM, Heikki Krogerus wrote:

Hi,

On Mon, May 07, 2018 at 11:19:40PM +0200, Mats Karrman wrote:
Even so, when the mux driver "set" function is called, it will just get the
mode argument but since the mode (TYPEC_STATE_...) is overlapping for different
AMs if I understand your proposal correctly, the mux also needs to know what AM
is active.
Does this imply that the mux set function signature need to change?
My plan was actually to propose we get rid of the current mux handling
(just leave the orientation switch) in favour of the notifications I'm
introducing with the type-c bus for the alternate modes. The current
mux handling is definitely not enough, and does not work in every
scenario, like also you pointed out.
So, the mux need to subscribe to each svid:mode pair it is interested in using
typec_altmode_register_notifier() and then use those callbacks to switch the correct
signals to the connector. And a driver for an off-the-shelf mux device could have
the translation between svid:mode pairs and mux device specific control specified by
of/acpi properties. Right?
Yes. That is the plan. Would it work for you?
I think so. I'll give it a go. When about do you think you'll post the next version
of your RFC? Or do you have an updated series available somewhere public?

I'll try to put together and post the next version tomorrow.

My original plan was actually to use just the notifications with the muxes, but one thing to consider with the notifications is that in practice we have to increment the ref count for the alt mode devices when ever something registers a notifier.

Quoted 8 lines

To me that does not feel ideal. The dependency should go the other way around in case of the muxes. That is why I liked the separate API and handling for the muxes felt better, as it will do just that. The mux is then a "service" that the port driver can as for, and if it gets a handle to a mux, the mux will have its ref count incremented.

So I think fixing the mux API would perhaps be better after all. Thoughts?

So, we're back to a mux API similar to the current one, where:
- the port driver and the mux driver are connected through "graph"
- alt mode driver finds its port mux using the typec class mux api
- the mux mode setting function arguments now include both svid and mode

Quoted 7 lines

I like that.

One thought that popped up again is if we, somewhere down the line, will see some super device that support many different alternate modes on the same port and therefore will need to have multiple mux devices? However I think the mux api could be extended (later on) to support some aggregate mux device that manages multiple physical devices.

Quoted 7 lines

If we simply had always a mux for every alternate mode, that would not be a problem. So the port would have its own mux, and every supported alternate mode also had its own. I think that removes the need to deal with the svid:mode when using the muxes, as they are already tied to a specific alternate modes, right? With a single mux device, for example pi3usb30532, the driver just needs to register a mux for the port and separate mux for DP, but I don't think that's a huge problem.

Hmm... As an hypothetical example I have written a driver for another mux from TI and according to its data sheet:

"""
The HD3SS460 is a generic analog differential passive switch that can work for any high speed interface applications as long as it is biased at a common mode voltage range of 0-2V and has differential signaling with differential amplitude up to 1800mVpp....
"""

What I am thinking is that it e.g. would be possible to use this/a mux with USBSS + 2ch DP + 2ch something else (HDMI?, ThunderBolt?, ???). The problem here is that it is a general mux device so the driver writer does not know what types of muxes to register. I guess it could also be configured using properties but that would be very complicated.

Quoted 5 lines
Quoted 2 lines

Why? All the mux driver needs to get from device properties is the SVID and the mode.

Sigh... Again, if the same mux handles signals for more than one alternate mode the driver won't know what alternate mode is intended if it only receives the connector state which use overlapping numbers for different alternate modes.

You are missing the point. We are now registering separate struct typec_mux for every alt mode. The ->set callback will need to be implemented separately for every alt mode.

Quoted 6 lines

So in case of TI HD3SS460, we need to initially register a struct typec_mux for DP and implement a function for the ->set callback for DP only. If we later need to support another alt mode with that mux (HDMI perhaps), we need to register second struct typec_mux and implement separate function for that alt mode alone and point the ->set callback of the second struct typec_mux to that.

Quoted 5 lines

No, I'm not missing the point... At least not that one :) But I think you are missing my point that a driver for a general purpose mux device will end up having to register a struct typec_mux and implement a ->set function for every possible alternate mode that eventually will exist (and can be used with that mux).

Quoted 5 lines

OK, we are on the same page. So back to my question. I'll rephrase:
How would separate ->set functions differ from delivering the SVID:mode on top of the SVID specific connector state to the mux? You still need to handle every alternate mode separately in the mux driver.

Quoted 4 lines

My idea, as I tried to explain before, is to use properties for mapping mux device specific states to svid:mode:state. The mux driver would not need to know anything about alternate modes, the responsibility would be with the system architect to get the mapping right in firmware.

Quoted 5 lines

OK, I understand. I'm a little bit scared about that kind of mappings. At least the connector state value we are dealing with here is Linux kernel specific index number, so I don't know if it's OK to get that from a device property. I wonder if string identifiers would be more acceptable for hardware descriptions?

Yes, something in the line of:

?????? mappings {
?????? ?????? map {
?????? ?????? ?????? svid = "displayport";
?????? ?????? ?????? state = "pin-assy-c";
?????? ?????? ?????? setting = "somethingsomething";?????? // device driver specific ?????? ?????? };
?????? ?????? map {
?????? ?????? ?????? ...etc...
?????? };

Then the svid and state strings could be mapped to numbers by typec/class API and setting strings by the mux driver internally and the mux driver will act on svid:state info from the partner driver(s) tied to the mux.

Quoted 3 lines

Strings or numbers, I guess we would need to document somewhere to which alternate mode connector state a number/string is mapped to. I don't know if OF bindings is enough?

That's what I had in mind.

Quoted 7 lines
Quoted 3 lines

Btw. I'm not convinced we would ever get this information from ACPI tables on devices targeted for windows, but let's not worry about that now.

Ah, I admit I did not consider this case. Being used to embeddeed/devicetree systems I just imagined the hardware description as something you are always in control of. I'm afraid I have no idea about this.

It should not prevent us from using the solution. We just can't assume that the HW description can always supply this information, and implement the solution with that in mind as usual.

Thanks,