Re: [PATCH 1/3] usb: USB Type-C Connector Class

From: Heikki Krogerus
Date: Thu Feb 18 2016 - 10:13:54 EST


On Thu, Feb 18, 2016 at 02:44:25PM +0100, Oliver Neukum wrote:
> On Thu, 2016-02-18 at 15:25 +0200, Heikki Krogerus wrote:
>
> Hi,
>
>
> > > We have port directories for port power switching. How is
> > > the connector directory linked to them?
> >
> > I'm sorry, I don't think I understand this point.
>
> Like this:
>
> oneukum@linux-dtbq:/sys/bus/usb/devices/3-0:1.0> ls -l
> total 0
> -rw-r--r-- 1 root root 4096 Feb 18 14:34 authorized
> -r--r--r-- 1 root root 4096 Feb 18 14:34 bAlternateSetting
> -r--r--r-- 1 root root 4096 Feb 18 14:34 bInterfaceClass
> -r--r--r-- 1 root root 4096 Feb 18 14:34 bInterfaceNumber
> -r--r--r-- 1 root root 4096 Feb 18 14:34 bInterfaceProtocol
> -r--r--r-- 1 root root 4096 Feb 18 14:34 bInterfaceSubClass
> -r--r--r-- 1 root root 4096 Feb 18 14:34 bNumEndpoints
> lrwxrwxrwx 1 root root 0 Feb 17 15:59 driver
> -> ../../../../../bus/usb/drivers/hub
> drwxr-xr-x 3 root root 0 Feb 18 09:35 ep_81
> -r--r--r-- 1 root root 4096 Feb 18 14:34 modalias
> drwxr-xr-x 2 root root 0 Feb 18 09:35 power
> lrwxrwxrwx 1 root root 0 Feb 17 15:59 subsystem
> -> ../../../../../bus/usb
> -r--r--r-- 1 root root 4096 Feb 18 14:34 supports_autosuspend
> -rw-r--r-- 1 root root 4096 Feb 18 14:34 uevent
> drwxr-xr-x 3 root root 0 Feb 18 09:35 usb3-port1
> drwxr-xr-x 3 root root 0 Feb 18 09:35 usb3-port10
> drwxr-xr-x 3 root root 0 Feb 18 09:35 usb3-port11
> drwxr-xr-x 3 root root 0 Feb 18 09:35 usb3-port12
> drwxr-xr-x 3 root root 0 Feb 18 09:35 usb3-port13
> drwxr-xr-x 3 root root 0 Feb 18 09:35 usb3-port14
> drwxr-xr-x 3 root root 0 Feb 18 09:35 usb3-port15
> drwxr-xr-x 3 root root 0 Feb 18 09:35 usb3-port2
> drwxr-xr-x 3 root root 0 Feb 18 09:35 usb3-port3
> drwxr-xr-x 3 root root 0 Feb 18 09:35 usb3-port4
> drwxr-xr-x 3 root root 0 Feb 18 09:35 usb3-port5
> drwxr-xr-x 3 root root 0 Feb 18 09:35 usb3-port6
> drwxr-xr-x 3 root root 0 Feb 18 09:35 usb3-port7
> drwxr-xr-x 3 root root 0 Feb 18 09:35 usb3-port8
> drwxr-xr-x 3 root root 0 Feb 18 09:35 usb3-port9
>
> usb*-port*
>
> They correspond to the connectors a system has.
> It seems to me that we want a link connecting them
> if the correspondance is known.

Ah, got it. In case of ACPI enumerated UCSI, we will have the actual
ACPI device object for the port as a child device object. So when we
attach the port ACPI companion to the connector device we create in
the class, it will link us directly to the correct usb*-port*.

I have not done it so far because the same port ACPI device object
will also be bound to the usb peripheral once it gets enumerated, and
I was worried if that would cause a problem. But after talking to guys
that know more about ACPI then I do, I'm sure that is not going to be
a problem.

With ACPI, the binding should happen the same way even without UCSI.
What ever device driver registers the connector device should have the
port ACPI device object as it's child. So I'm thinking about doing
this in typec_register_port() and not in UCSI driver.


Thanks,

--
heikki