Re: [PATCH v4 1/2] usb: typec: Add support for UCSI interface

2017-06-21 Thread Heikki Krogerus
On Fri, Jun 16, 2017 at 03:14:37PM -0700, Guenter Roeck wrote:
> On Fri, Jun 16, 2017 at 11:21:24AM +0300, Heikki Krogerus wrote:
> > UCSI - USB Type-C Connector System Software Interface - is a
> > specification that defines set of registers and data
> > structures for controlling the USB Type-C ports. It's
> > designed for systems where an embedded controller (EC) is in
> > charge of the USB Type-C PHY or USB Power Delivery
> > controller. It is designed for systems with EC, but it is
> > not limited to them, and for example some USB Power Delivery
> > controllers will use it as their direct control interface.
> > 
> > With UCSI the EC (or USB PD controller) acts as the port
> > manager, implementing all USB Type-C and Power Delivery state
> > machines. The OS can use the interfaces for reading the
> > status of the ports and controlling basic operations like
> > role swapping.
> > 
> > The UCSI specification highlights the fact that it does not
> > define the interface method (PCI/I2C/ACPI/etc.).
> > Therefore the driver is implemented as library and every
> > supported interface method needs its own driver. Driver for
> > ACPI is provided in separate patch following this one.
> > 
> > The initial driver includes support for all required
> > features from UCSI specification version 1.0 (getting
> > connector capabilities and status, and support for power and
> > data role swapping), but none of the optional UCSI features
> > (alternate modes, power source capabilities, and cable
> > capabilities).
> > 
> > Signed-off-by: Heikki Krogerus 
> 
> I looked at this way too often, so I am sure I am missing something
> really obvious (except for the u64 data:48 field, but I just assume
> you know what you are doing there).
> 
> Reviewed-by: Guenter Roeck 

Thanks Guenter!

-- 
heikki
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 1/2] usb: typec: Add support for UCSI interface

2017-06-16 Thread Guenter Roeck
On Fri, Jun 16, 2017 at 11:21:24AM +0300, Heikki Krogerus wrote:
> UCSI - USB Type-C Connector System Software Interface - is a
> specification that defines set of registers and data
> structures for controlling the USB Type-C ports. It's
> designed for systems where an embedded controller (EC) is in
> charge of the USB Type-C PHY or USB Power Delivery
> controller. It is designed for systems with EC, but it is
> not limited to them, and for example some USB Power Delivery
> controllers will use it as their direct control interface.
> 
> With UCSI the EC (or USB PD controller) acts as the port
> manager, implementing all USB Type-C and Power Delivery state
> machines. The OS can use the interfaces for reading the
> status of the ports and controlling basic operations like
> role swapping.
> 
> The UCSI specification highlights the fact that it does not
> define the interface method (PCI/I2C/ACPI/etc.).
> Therefore the driver is implemented as library and every
> supported interface method needs its own driver. Driver for
> ACPI is provided in separate patch following this one.
> 
> The initial driver includes support for all required
> features from UCSI specification version 1.0 (getting
> connector capabilities and status, and support for power and
> data role swapping), but none of the optional UCSI features
> (alternate modes, power source capabilities, and cable
> capabilities).
> 
> Signed-off-by: Heikki Krogerus 

I looked at this way too often, so I am sure I am missing something
really obvious (except for the u64 data:48 field, but I just assume
you know what you are doing there).

Reviewed-by: Guenter Roeck 

> ---
>  drivers/usb/typec/Kconfig   |   2 +
>  drivers/usb/typec/Makefile  |   1 +
>  drivers/usb/typec/ucsi/Kconfig  |  23 ++
>  drivers/usb/typec/ucsi/Makefile |   7 +
>  drivers/usb/typec/ucsi/debug.h  |  64 
>  drivers/usb/typec/ucsi/trace.c  |   2 +
>  drivers/usb/typec/ucsi/trace.h  | 143 
>  drivers/usb/typec/ucsi/ucsi.c   | 790 
> 
>  drivers/usb/typec/ucsi/ucsi.h   | 335 +
>  9 files changed, 1367 insertions(+)
>  create mode 100644 drivers/usb/typec/ucsi/Kconfig
>  create mode 100644 drivers/usb/typec/ucsi/Makefile
>  create mode 100644 drivers/usb/typec/ucsi/debug.h
>  create mode 100644 drivers/usb/typec/ucsi/trace.c
>  create mode 100644 drivers/usb/typec/ucsi/trace.h
>  create mode 100644 drivers/usb/typec/ucsi/ucsi.c
>  create mode 100644 drivers/usb/typec/ucsi/ucsi.h
> 
> diff --git a/drivers/usb/typec/Kconfig b/drivers/usb/typec/Kconfig
> index dfcfe459b7cf..bc1b7745f1d4 100644
> --- a/drivers/usb/typec/Kconfig
> +++ b/drivers/usb/typec/Kconfig
> @@ -19,4 +19,6 @@ config TYPEC_WCOVE
> To compile this driver as module, choose M here: the module will be
> called typec_wcove
>  
> +source "drivers/usb/typec/ucsi/Kconfig"
> +
>  endmenu
> diff --git a/drivers/usb/typec/Makefile b/drivers/usb/typec/Makefile
> index b9cb862221af..bc214f15f1b5 100644
> --- a/drivers/usb/typec/Makefile
> +++ b/drivers/usb/typec/Makefile
> @@ -1,2 +1,3 @@
>  obj-$(CONFIG_TYPEC)  += typec.o
>  obj-$(CONFIG_TYPEC_WCOVE)+= typec_wcove.o
> +obj-$(CONFIG_TYPEC_UCSI) += ucsi/
> diff --git a/drivers/usb/typec/ucsi/Kconfig b/drivers/usb/typec/ucsi/Kconfig
> new file mode 100644
> index ..da4c5c3d8870
> --- /dev/null
> +++ b/drivers/usb/typec/ucsi/Kconfig
> @@ -0,0 +1,23 @@
> +config TYPEC_UCSI
> + tristate "USB Type-C Connector System Software Interface driver"
> + depends on !CPU_BIG_ENDIAN
> + select TYPEC
> + help
> +   USB Type-C Connector System Software Interface (UCSI) is a
> +   specification for an interface that allows the operating system to
> +   control the USB Type-C ports. On UCSI system the USB Type-C ports
> +   function autonomously by default, but in order to get the status of
> +   the ports and support basic operations like role swapping, the driver
> +   is required. UCSI is available on most of the new Intel based systems
> +   that are equipped with Embedded Controller and USB Type-C ports.
> +
> +   UCSI specification does not define the interface method, so depending
> +   on the platform, ACPI, PCI, I2C, etc. may be used. Therefore this
> +   driver only provides the core part, and separate drivers are needed
> +   for every supported interface method.
> +
> +   The UCSI specification can be downloaded from:
> +   
> http://www.intel.com/content/www/us/en/io/universal-serial-bus/usb-type-c-ucsi-spec.html
> +
> +   To compile the driver as a module, choose M here: the module will be
> +   called typec_ucsi.
> diff --git a/drivers/usb/typec/ucsi/Makefile b/drivers/usb/typec/ucsi/Makefile
> new file mode 100644
> index ..87dd6ee6c9f3
> --- /dev/null
> +++ b/drivers/usb/typec/ucsi/Makefile
> @@ -0,0 +1,7 @@
> +CFLAGS_trace.o   := -I$(src)
> +
> +obj-$(CONFIG_TY