Skip to contentSkip to conversation

Add Intel LJCA device driver

PATCH In review Wentong Wu 7 participants 24 messages Oct 9, 2023 – Oct 17, 2023

Subsystems (5)
lore
Share & tools
lore

Wentong Wu

author
#0 lore raw

v20 cover Add Intel LJCA device driver

Add driver for Intel La Jolla Cove Adapter (LJCA) device. This IO-expander adds additional functions to the host system with host USB interface, such as GPIO, I2C and SPI. This patch set adds four drivers to support this device: a USB device driver, a GPIO chip driver, a I2C controller driver and a SPI controller driver.

---
v20:
- add __counted_by attributes for all of [] arrays
- use proper kernel doc for ljca_adapter structure
- re-structure ljca_recv function to make it more clear
- remove all of scoped_guard
- check return value of usb_autopm_get_interface()
- re-structure ljca_enumerate_clients() to handle error correctly
- add comment for 'uid = "0";' in ljca_match_device_ids()
- change the parameters' type of ljca_send() to u8

v17 - v19:
- rebase patch set on top of Linus' master branch (57d88e8a5974644039fbc47806bac7bb12025636)
- change valid_pins type to __le32 and access valid_pins with get_unaligned_le32
- remove COMPILE_TEST for USB_LJCA Kconfig

v16:
- drop all void * and use real types in the exported apis and internal ljca_send()
- remove #ifdef in usb-ljca.c file
- add documentation in ljca.h for the public structures
- add error message in ljca_handle_cmd_ack() if error happens and remove blank line
- use the functionality in cleanup.h for spinlock to make function much simpler
- change the type of ex_buf in struct ljca_adapter to u8 *

v14 - v15:
- enhance disconnect() of usb-ljca driver
- change memchr to strchr in ljca_match_device_ids() of usb-ljca driver
- fix build error: implicit declaration of function 'acpi_dev_clear_dependencies'

v13:
- make ljca-usb more robust with the help of Hans de Goede
- call acpi_dev_clear_dependencies() to mark _DEP ACPI dependencies on the I2C controller as satisfied
- avoid err printing because of calling usb_kill_urb when attempts to resubmit the rx urb

v10 - v12:
- switch dev_err to dev_dbg for i2c-ljca driver
- remove message length check because of defined quirk structure
- remove I2C_FUNC_SMBUS_EMUL support
- remove ljca_i2c_format_slave_addr
- remove memset before write write w_packet for i2c driver
- make ljca_i2c_stop void and print err message in case failure
- use dev_err_probe in ljca_i2c_probe function

v9:
- overhaul usb-ljca driver to make it more structured and easy understand
- fix memory leak issue for usb-ljca driver
- add spinlock to protect tx_buf and ex_buf
- change exported APIs for usb-ljca driver
- unify prefix for structures and functions for i2c-ljca driver
- unify prefix for structures and functions for spi-ljca driver
- unify prefix for structures and functions for gpio-ljca driver
- update gpio-ljca, i2c-ljca and spi-ljca drivers according to usb-ljca's changes

Wentong Wu (4):
usb: Add support for Intel LJCA device
i2c: Add support for Intel LJCA USB I2C driver
spi: Add support for Intel LJCA USB SPI driver
gpio: update Intel LJCA USB GPIO driver

 drivers/gpio/Kconfig          |   4 +-
 drivers/gpio/gpio-ljca.c      | 246 +++++++-----
 drivers/i2c/busses/Kconfig    |  11 +
 drivers/i2c/busses/Makefile   |   1 +
 drivers/i2c/busses/i2c-ljca.c | 343 ++++++++++++++++
 drivers/spi/Kconfig           |  11 +
 drivers/spi/Makefile          |   1 +
 drivers/spi/spi-ljca.c        | 297 ++++++++++++++
 drivers/usb/misc/Kconfig      |  13 +
 drivers/usb/misc/Makefile     |   1 +
 drivers/usb/misc/usb-ljca.c   | 902 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/ljca.h      | 145 +++++++
 12 files changed, 1870 insertions(+), 105 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-ljca.c
 create mode 100644 drivers/spi/spi-ljca.c
 create mode 100644 drivers/usb/misc/usb-ljca.c
 create mode 100644 include/linux/usb/ljca.h
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v20 1/4 usb: Add support for Intel LJCA device

Implements the USB part of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA).

The communication between the various LJCA module drivers and the hardware will be muxed/demuxed by this driver. Three modules ( I2C, GPIO, and SPI) are supported currently.

Each sub-module of LJCA device is identified by type field within the LJCA message header.

The sub-modules of LJCA can use ljca_transfer() to issue a transfer between host and hardware. And ljca_register_event_cb is exported to LJCA sub-module drivers for hardware event subscription.

The minimum code in ASL that covers this board is
Scope (\_SB.PCI0.DWC3.RHUB.HS01)

    {
        Device (GPIO)
        {
            Name (_ADR, Zero)
            Name (_STA, 0x0F)
        }

        Device (I2C)
        {
            Name (_ADR, One)
            Name (_STA, 0x0F)
        }

        Device (SPI)
        {
            Name (_ADR, 0x02)
            Name (_STA, 0x0F)
        }
    }
---
 drivers/usb/misc/Kconfig    |  13 +
 drivers/usb/misc/Makefile   |   1 +
 drivers/usb/misc/usb-ljca.c | 902 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/ljca.h    | 145 +++++++
 4 files changed, 1061 insertions(+)
 create mode 100644 drivers/usb/misc/usb-ljca.c
 create mode 100644 include/linux/usb/ljca.h
drivers/usb/misc/Kconfig +13 -0
index 99b15b7..c510af7 100644
@@ -165,6 +165,19 @@ config APPLE_MFI_FASTCHARGE
 
 	  It is safe to say M here.
 
+config USB_LJCA
+	tristate "Intel La Jolla Cove Adapter support"
+	select AUXILIARY_BUS
+	depends on USB && ACPI
+	help
+	  This adds support for Intel La Jolla Cove USB-I2C/SPI/GPIO
+	  Master Adapter (LJCA). Additional drivers such as I2C_LJCA,
+	  GPIO_LJCA and SPI_LJCA must be enabled in order to use the
+	  functionality of the device.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called usb-ljca.
+
 source "drivers/usb/misc/sisusbvga/Kconfig"
 
 config USB_LD
drivers/usb/misc/Makefile +1 -0
index 1992cc2..0bc732bc 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_USB_EMI26)			+= emi26.o
 obj-$(CONFIG_USB_EMI62)			+= emi62.o
 obj-$(CONFIG_USB_EZUSB_FX2)		+= ezusb.o
 obj-$(CONFIG_APPLE_MFI_FASTCHARGE)	+= apple-mfi-fastcharge.o
+obj-$(CONFIG_USB_LJCA)			+= usb-ljca.o
 obj-$(CONFIG_USB_IDMOUSE)		+= idmouse.o
 obj-$(CONFIG_USB_IOWARRIOR)		+= iowarrior.o
 obj-$(CONFIG_USB_ISIGHTFW)		+= isight_firmware.o
drivers/usb/misc/usb-ljca.c new file +902 -0

902 lines not on this page · raw message

include/linux/usb/ljca.h new file +145 -0

145 lines not on this page · raw message

Signature · 1 line
2.7.4
Reviewed-by on v20 1/4
#2 lore raw

Re: [PATCH v20 1/4] usb: Add support for Intel LJCA device

Quoted 36 lines · Wentong Wu

Implements the USB part of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA).

The communication between the various LJCA module drivers and the hardware will be muxed/demuxed by this driver. Three modules ( I2C, GPIO, and SPI) are supported currently.

Each sub-module of LJCA device is identified by type field within the LJCA message header.

The sub-modules of LJCA can use ljca_transfer() to issue a transfer between host and hardware. And ljca_register_event_cb is exported to LJCA sub-module drivers for hardware event subscription.

The minimum code in ASL that covers this board is
Scope (\_SB.PCI0.DWC3.RHUB.HS01)

     {
         Device (GPIO)
         {
             Name (_ADR, Zero)
             Name (_STA, 0x0F)
         }

         Device (I2C)
         {
             Name (_ADR, One)
             Name (_STA, 0x0F)
         }

         Device (SPI)
         {
             Name (_ADR, 0x02)
             Name (_STA, 0x0F)
         }
     }
Quoted 4 lines
#3 lore raw

Re: [PATCH v20 1/4] usb: Add support for Intel LJCA device

In reply to Wentong Wu
Quoted 27 lines · Wentong Wu

Implements the USB part of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA).

The communication between the various LJCA module drivers and the hardware will be muxed/demuxed by this driver. Three modules ( I2C, GPIO, and SPI) are supported currently.

Each sub-module of LJCA device is identified by type field within the LJCA message header.

The sub-modules of LJCA can use ljca_transfer() to issue a transfer between host and hardware. And ljca_register_event_cb is exported to LJCA sub-module drivers for hardware event subscription.

The minimum code in ASL that covers this board is
Scope (\_SB.PCI0.DWC3.RHUB.HS01)

    {
        Device (GPIO)
        {
            Name (_ADR, Zero)
            Name (_STA, 0x0F)
        }

        Device (I2C)
        {
            Name (_ADR, One)
            Name (_STA, 0x0F)
Quoted 8 lines
        }

        Device (SPI)
        {
            Name (_ADR, 0x02)
            Name (_STA, 0x0F)
        }
    }

This commit message is not true anymore, or misleading at bare minimum. The ACPI specification is crystal clear about usage _ADR and _HID, i.e. they must NOT be used together for the same device node. So, can you clarify how the DSDT is organized and update the commit message and it may require (quite likely) to redesign the architecture of this driver. Sorry I missed this from previous rounds as I was busy by something else.

Greg, please do not promote this to the next before above will be clarified.

P.S> Using _ADR and _HID together is an immediate NAK from me.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw

Re: [PATCH v20 1/4] usb: Add support for Intel LJCA device

Hi,

Quoted 37 lines · Andy Shevchenko
Quoted 27 lines · Wentong Wu

Implements the USB part of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA).

The communication between the various LJCA module drivers and the hardware will be muxed/demuxed by this driver. Three modules ( I2C, GPIO, and SPI) are supported currently.

Each sub-module of LJCA device is identified by type field within the LJCA message header.

The sub-modules of LJCA can use ljca_transfer() to issue a transfer between host and hardware. And ljca_register_event_cb is exported to LJCA sub-module drivers for hardware event subscription.

The minimum code in ASL that covers this board is
Scope (\_SB.PCI0.DWC3.RHUB.HS01)

    {
        Device (GPIO)
        {
            Name (_ADR, Zero)
            Name (_STA, 0x0F)
        }

        Device (I2C)
        {
            Name (_ADR, One)
            Name (_STA, 0x0F)
Quoted 8 lines
        }

        Device (SPI)
        {
            Name (_ADR, 0x02)
            Name (_STA, 0x0F)
        }
    }
Quoted 7 lines

This commit message is not true anymore, or misleading at bare minimum. The ACPI specification is crystal clear about usage _ADR and _HID, i.e. they must NOT be used together for the same device node. So, can you clarify how the DSDT is organized and update the commit message and it may require (quite likely) to redesign the architecture of this driver. Sorry I missed this from previous rounds as I was busy by something else.

This part of the commit message unfortunately is not accurate. _ADR is not used in either DSDTs of shipping hw; nor in the code.

The code in question parsing the relevant part of the DSDT looks like this:

static int ljca_match_device_ids(struct acpi_device *adev, void *data)

{
        struct ljca_match_ids_walk_data *wd = data;
        const char *uid = acpi_device_uid(adev);

        if (acpi_match_device_ids(adev, wd->ids))
                return 0;

        if (!wd->uid)
                goto match;

        if (!uid)
                /*
                 * Some DSDTs have only one ACPI companion for the two I2C
                 * controllers and they don't set a UID at all (e.g. Dell
                 * Latitude 9420). On these platforms only the first I2C
                 * controller is used, so if a HID match has no UID we use
                 * "0" as the UID and assign ACPI companion to the first
                 * I2C controller.
                 */
                uid = "0";
        else
                uid = strchr(uid, wd->uid[0]);

        if (!uid || strcmp(uid, wd->uid))
                return 0;

match:

        wd->adev = adev;

        return 1;
}

Notice that it check _UID (for some child devices, only those of which there may be more then 1 have a UID set in the DSDT) and that in case of requested but missing UID it assumes UID = "0" for compatibility with older DSDTs which lack the UID.

And relevant DSDT bits from early hw (TigerLake Dell Latitude 9420) Note no UID for the I2C node even though the LJCA USB IO expander has 2 I2C controllers :

    Scope (_SB.PC00.XHCI.RHUB.HS06)
    {
            Device (VGPO)
            {
                Name (_HID, "INTC1074")  // _HID: Hardware ID
                Name (_DDN, "Intel UsbGpio Device")  // _DDN: DOS Device Name
            }

            Device (VI2C)
            {
                Name (_HID, "INTC1075")  // _HID: Hardware ID
                Name (_DDN, "Intel UsbI2C Device")  // _DDN: DOS Device Name
            }
    }

And for newer hw (Lenovo Thinkpad X1 yoga gen7, alder lake):

        Scope (_SB.PC00.XHCI.RHUB.HS08)
        {
            Device (VGPO)
            {
                Name (_HID, "INTC1096")  // _HID: Hardware ID
                Name (_DDN, "Intel UsbGpio Device")  // _DDN: DOS Device Name
            }

            Device (VIC0)
            {
                Name (_HID, "INTC1097")  // _HID: Hardware ID
                Name (_DDN, "Intel UsbI2C Device")  // _DDN: DOS Device Name
                Name (_UID, Zero)  // _UID: Unique ID
            }

            Device (VIC1)
            {
                Name (_HID, "INTC1097")  // _HID: Hardware ID
                Name (_DDN, "Intel UsbI2C Device")  // _DDN: DOS Device Name
                Name (_UID, One)  // _UID: Unique ID
            }

            Device (VSPI)
            {
                Name (_HID, "INTC1098")  // _HID: Hardware ID
                Name (_DDN, "Intel UsbSPI Device")  // _DDN: DOS Device Name
            }
        }

Note UIDs are used for the I2C controllers but not for the singleton SPI and GPIO controllers.

TL;DR: there is nothing to worry about here, but the commit message should be updated to reflect reality.

Regards,

Hans

#5 lore raw

Re: [PATCH v20 1/4] usb: Add support for Intel LJCA device

Quoted 2 lines · Hans de Goede
Quoted 1 line · Andy Shevchenko

On Mon, Oct 09, 2023 at 02:33:22PM +0800, Wentong Wu wrote:

...

Quoted 2 lines

TL;DR: there is nothing to worry about here, but the commit message should be updated to reflect reality.

I have just sent the similar worry, but thanks that you have checked the code and we don't need to worry too much.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw

RE: [PATCH v20 1/4] usb: Add support for Intel LJCA device

In reply to Hans de Goede
Quoted 50 lines

From: Hans de Goede <hdegoede>

Hi,

Quoted 37 lines · Andy Shevchenko
Quoted 27 lines · Wentong Wu

Implements the USB part of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA).

The communication between the various LJCA module drivers and the hardware will be muxed/demuxed by this driver. Three modules ( I2C, GPIO, and SPI) are supported currently.

Each sub-module of LJCA device is identified by type field within the LJCA message header.

The sub-modules of LJCA can use ljca_transfer() to issue a transfer between host and hardware. And ljca_register_event_cb is exported to LJCA sub-module drivers for hardware event subscription.

The minimum code in ASL that covers this board is Scope (\_SB.PCI0.DWC3.RHUB.HS01)

    {
        Device (GPIO)
        {
            Name (_ADR, Zero)
            Name (_STA, 0x0F)
        }

        Device (I2C)
        {
            Name (_ADR, One)
            Name (_STA, 0x0F)
Quoted 8 lines
        }

        Device (SPI)
        {
            Name (_ADR, 0x02)
            Name (_STA, 0x0F)
        }
    }
Quoted 7 lines

This commit message is not true anymore, or misleading at bare minimum. The ACPI specification is crystal clear about usage _ADR and _HID, i.e. they must NOT be used together for the same device node. So, can you clarify how the DSDT is organized and update the commit message and it may require (quite likely) to redesign the architecture of this driver. Sorry I missed this from previous rounds as I was busy by something else.

Quoted 2 lines

This part of the commit message unfortunately is not accurate. _ADR is not used in either DSDTs of shipping hw; nor in the code.

We have covered the _ADR in the code like below, it first try to find the child device based on _ADR, if not found, it will check the _HID, and there is clear comment in the function.

/* bind auxiliary device to acpi device */
static void ljca_auxdev_acpi_bind(struct ljca_adapter *adap,

				   struct auxiliary_device *auxdev,
				   u64 adr, u8 id)
{
	struct ljca_match_ids_walk_data wd = { 0 };
	struct acpi_device *parent, *adev;
	struct device *dev = adap->dev;
	char uid[4];

	parent = ACPI_COMPANION(dev);
	if (!parent)
		return;

	/*
	 * get auxdev ACPI handle from the ACPI device directly
	 * under the parent that matches _ADR.
	 */
	adev = acpi_find_child_device(parent, adr, false);
	if (adev) {
		ACPI_COMPANION_SET(&auxdev->dev, adev);
		return;
	}

	/*
	 * _ADR is a grey area in the ACPI specification, some
	 * platforms use _HID to distinguish children devices.
	 */
	switch (adr) {
	case LJCA_GPIO_ACPI_ADR:
		wd.ids = ljca_gpio_hids;
		break;
	case LJCA_I2C1_ACPI_ADR:
	case LJCA_I2C2_ACPI_ADR:
		snprintf(uid, sizeof(uid), "%d", id);
		wd.uid = uid;
		wd.ids = ljca_i2c_hids;
		break;
	case LJCA_SPI1_ACPI_ADR:
	case LJCA_SPI2_ACPI_ADR:
		wd.ids = ljca_spi_hids;
		break;
	default:
		dev_warn(dev, "unsupported _ADR\n");
		return;
	}

	acpi_dev_for_each_child(parent, ljca_match_device_ids, &wd);
Quoted 98 lines

The code in question parsing the relevant part of the DSDT looks like this:

static int ljca_match_device_ids(struct acpi_device *adev, void *data) {
        struct ljca_match_ids_walk_data *wd = data;
        const char *uid = acpi_device_uid(adev);

        if (acpi_match_device_ids(adev, wd->ids))
                return 0;

        if (!wd->uid)
                goto match;

        if (!uid)
                /*
                 * Some DSDTs have only one ACPI companion for the two I2C
                 * controllers and they don't set a UID at all (e.g. Dell
                 * Latitude 9420). On these platforms only the first I2C
                 * controller is used, so if a HID match has no UID we use
                 * "0" as the UID and assign ACPI companion to the first
                 * I2C controller.
                 */
                uid = "0";
        else
                uid = strchr(uid, wd->uid[0]);

        if (!uid || strcmp(uid, wd->uid))
                return 0;

match:

        wd->adev = adev;

        return 1;
}

Notice that it check _UID (for some child devices, only those of which there may be more then 1 have a UID set in the DSDT) and that in case of requested but missing UID it assumes UID = "0"
for compatibility with older DSDTs which lack the UID.

And relevant DSDT bits from early hw (TigerLake Dell Latitude 9420) Note no UID for the I2C node even though the LJCA USB IO expander has 2 I2C controllers :

    Scope (_SB.PC00.XHCI.RHUB.HS06)
    {
            Device (VGPO)
            {
                Name (_HID, "INTC1074")  // _HID: Hardware ID
                Name (_DDN, "Intel UsbGpio Device")  // _DDN: DOS Device Name
            }

            Device (VI2C)
            {
                Name (_HID, "INTC1075")  // _HID: Hardware ID
                Name (_DDN, "Intel UsbI2C Device")  // _DDN: DOS Device Name
            }
    }

And for newer hw (Lenovo Thinkpad X1 yoga gen7, alder lake):

        Scope (_SB.PC00.XHCI.RHUB.HS08)
        {
            Device (VGPO)
            {
                Name (_HID, "INTC1096")  // _HID: Hardware ID
                Name (_DDN, "Intel UsbGpio Device")  // _DDN: DOS Device Name
            }

            Device (VIC0)
            {
                Name (_HID, "INTC1097")  // _HID: Hardware ID
                Name (_DDN, "Intel UsbI2C Device")  // _DDN: DOS Device Name
                Name (_UID, Zero)  // _UID: Unique ID
            }

            Device (VIC1)
            {
                Name (_HID, "INTC1097")  // _HID: Hardware ID
                Name (_DDN, "Intel UsbI2C Device")  // _DDN: DOS Device Name
                Name (_UID, One)  // _UID: Unique ID
            }

            Device (VSPI)
            {
                Name (_HID, "INTC1098")  // _HID: Hardware ID
                Name (_DDN, "Intel UsbSPI Device")  // _DDN: DOS Device Name
            }
        }

Note UIDs are used for the I2C controllers but not for the singleton SPI and GPIO controllers.

TL;DR: there is nothing to worry about here, but the commit message should be updated to reflect reality.

Regards,

Hans

#7 lore raw

Re: [PATCH v20 1/4] usb: Add support for Intel LJCA device

Hi,

Quoted 97 lines · Wentong
Quoted 50 lines

From: Hans de Goede <hdegoede>

Hi,

Quoted 37 lines · Andy Shevchenko
Quoted 27 lines · Wentong Wu

Implements the USB part of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA).

The communication between the various LJCA module drivers and the hardware will be muxed/demuxed by this driver. Three modules ( I2C, GPIO, and SPI) are supported currently.

Each sub-module of LJCA device is identified by type field within the LJCA message header.

The sub-modules of LJCA can use ljca_transfer() to issue a transfer between host and hardware. And ljca_register_event_cb is exported to LJCA sub-module drivers for hardware event subscription.

The minimum code in ASL that covers this board is Scope (\_SB.PCI0.DWC3.RHUB.HS01)

    {
        Device (GPIO)
        {
            Name (_ADR, Zero)
            Name (_STA, 0x0F)
        }

        Device (I2C)
        {
            Name (_ADR, One)
            Name (_STA, 0x0F)
Quoted 8 lines
        }

        Device (SPI)
        {
            Name (_ADR, 0x02)
            Name (_STA, 0x0F)
        }
    }
Quoted 7 lines

This commit message is not true anymore, or misleading at bare minimum. The ACPI specification is crystal clear about usage _ADR and _HID, i.e. they must NOT be used together for the same device node. So, can you clarify how the DSDT is organized and update the commit message and it may require (quite likely) to redesign the architecture of this driver. Sorry I missed this from previous rounds as I was busy by something else.

Quoted 2 lines

This part of the commit message unfortunately is not accurate. _ADR is not used in either DSDTs of shipping hw; nor in the code.

We have covered the _ADR in the code like below, it first try to find the child device based on _ADR, if not found, it will check the _HID, and there is clear comment in the function.

/* bind auxiliary device to acpi device */
static void ljca_auxdev_acpi_bind(struct ljca_adapter *adap,

				   struct auxiliary_device *auxdev,
				   u64 adr, u8 id)
{
	struct ljca_match_ids_walk_data wd = { 0 };
	struct acpi_device *parent, *adev;
	struct device *dev = adap->dev;
	char uid[4];

	parent = ACPI_COMPANION(dev);
	if (!parent)
		return;

	/*
	 * get auxdev ACPI handle from the ACPI device directly
	 * under the parent that matches _ADR.
	 */
	adev = acpi_find_child_device(parent, adr, false);
	if (adev) {
		ACPI_COMPANION_SET(&auxdev->dev, adev);
		return;
	}

	/*
	 * _ADR is a grey area in the ACPI specification, some
	 * platforms use _HID to distinguish children devices.
	 */
	switch (adr) {
	case LJCA_GPIO_ACPI_ADR:
		wd.ids = ljca_gpio_hids;
		break;
	case LJCA_I2C1_ACPI_ADR:
	case LJCA_I2C2_ACPI_ADR:
		snprintf(uid, sizeof(uid), "%d", id);
		wd.uid = uid;
		wd.ids = ljca_i2c_hids;
		break;
	case LJCA_SPI1_ACPI_ADR:
	case LJCA_SPI2_ACPI_ADR:
Quoted 8 lines
		wd.ids = ljca_spi_hids;
		break;
	default:
		dev_warn(dev, "unsupported _ADR\n");
		return;
	}

	acpi_dev_for_each_child(parent, ljca_match_device_ids, &wd);

Ah ok, I see. So the code:

1. First tries to find the matching child acpi_device for the auxdev by ADR

2. If 1. fails then falls back to HID + UID matching

And there are DSDTs which use either:

1. Only use _ADR to identify which child device is which, like the example DSDT snippet from the commit msg.

2. Only use _HID + _UID like the 2 example DSDT snippets from me email

But there never is a case where both _ADR and _HID are used at the same time (which would be an ACPI spec violation as Andy said).

So AFAICT there is no issue here since _ADR and _HID are never user at the same time and the commit message correctly describes scenario 1. from above, so the commit message is fine too.

So I believe that we can continue with this patch series in its current v20 form, which has already been staged for going into -next by Greg.

Andy can you confirm that moving ahead with the current version is ok ?

Regards,

Hans

#8 lore raw

Re: [PATCH v20 1/4] usb: Add support for Intel LJCA device

Quoted 123 lines · Hans de Goede
Quoted 93 lines · Wentong
Quoted 46 lines · Andy Shevchenko
Quoted 37 lines · Wentong Wu
Quoted 27 lines

Implements the USB part of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA).

The communication between the various LJCA module drivers and the hardware will be muxed/demuxed by this driver. Three modules ( I2C, GPIO, and SPI) are supported currently.

Each sub-module of LJCA device is identified by type field within the LJCA message header.

The sub-modules of LJCA can use ljca_transfer() to issue a transfer between host and hardware. And ljca_register_event_cb is exported to LJCA sub-module drivers for hardware event subscription.

The minimum code in ASL that covers this board is Scope (\_SB.PCI0.DWC3.RHUB.HS01)

    {
        Device (GPIO)
        {
            Name (_ADR, Zero)
            Name (_STA, 0x0F)
        }

        Device (I2C)
        {
            Name (_ADR, One)
            Name (_STA, 0x0F)
Quoted 8 lines
        }

        Device (SPI)
        {
            Name (_ADR, 0x02)
            Name (_STA, 0x0F)
        }
    }
Quoted 7 lines

This commit message is not true anymore, or misleading at bare minimum. The ACPI specification is crystal clear about usage _ADR and _HID, i.e. they must NOT be used together for the same device node. So, can you clarify how the DSDT is organized and update the commit message and it may require (quite likely) to redesign the architecture of this driver. Sorry I missed this from previous rounds as I was busy by something else.

Quoted 2 lines

This part of the commit message unfortunately is not accurate. _ADR is not used in either DSDTs of shipping hw; nor in the code.

We have covered the _ADR in the code like below, it first try to find the child device based on _ADR, if not found, it will check the _HID, and there is clear comment in the function.

/* bind auxiliary device to acpi device */
static void ljca_auxdev_acpi_bind(struct ljca_adapter *adap,

				   struct auxiliary_device *auxdev,
				   u64 adr, u8 id)
{
	struct ljca_match_ids_walk_data wd = { 0 };
	struct acpi_device *parent, *adev;
	struct device *dev = adap->dev;
	char uid[4];

	parent = ACPI_COMPANION(dev);
	if (!parent)
		return;

	/*
	 * get auxdev ACPI handle from the ACPI device directly
	 * under the parent that matches _ADR.
	 */
	adev = acpi_find_child_device(parent, adr, false);
	if (adev) {
		ACPI_COMPANION_SET(&auxdev->dev, adev);
		return;
	}

	/*
	 * _ADR is a grey area in the ACPI specification, some
	 * platforms use _HID to distinguish children devices.
	 */
	switch (adr) {
	case LJCA_GPIO_ACPI_ADR:
		wd.ids = ljca_gpio_hids;
		break;
	case LJCA_I2C1_ACPI_ADR:
	case LJCA_I2C2_ACPI_ADR:
		snprintf(uid, sizeof(uid), "%d", id);
		wd.uid = uid;
		wd.ids = ljca_i2c_hids;
		break;
	case LJCA_SPI1_ACPI_ADR:
	case LJCA_SPI2_ACPI_ADR:
Quoted 8 lines
		wd.ids = ljca_spi_hids;
		break;
	default:
		dev_warn(dev, "unsupported _ADR\n");
		return;
	}

	acpi_dev_for_each_child(parent, ljca_match_device_ids, &wd);

Ah ok, I see. So the code:

1. First tries to find the matching child acpi_device for the auxdev by ADR

2. If 1. fails then falls back to HID + UID matching

And there are DSDTs which use either:

1. Only use _ADR to identify which child device is which, like the example DSDT snippet from the commit msg.

2. Only use _HID + _UID like the 2 example DSDT snippets from me email

But there never is a case where both _ADR and _HID are used at the same time (which would be an ACPI spec violation as Andy said).

So AFAICT there is no issue here since _ADR and _HID are never user at the same time and the commit message correctly describes scenario 1. from above, so the commit message is fine too.

Quoted 6 lines

So I believe that we can continue with this patch series in its current v20 form, which has already been staged for going into -next by Greg.

Andy can you confirm that moving ahead with the current version is ok ?

Yes as we have a few weeks to fix corner cases.

What I'm worrying is that opening door for _ADR that seems never used is kinda an overkill here (resolving non-existing problem). Looking at the design of the driver I'm not sure why ACPI HIDs are collected somewhere else than in the respective drivers. And looking at the ID lists themselves I am not sure why the firmware of the respective hardware platforms are not using _CID.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw

Re: [PATCH v20 1/4] usb: Add support for Intel LJCA device

Hi Andy,

Quoted 1 line · Andriy

On Thu, Oct 12, 2023 at 01:14:23PM +0200, Hans de Goede wrote:

<snip>

Quoted 24 lines
Quoted 24 lines

Ah ok, I see. So the code:

1. First tries to find the matching child acpi_device for the auxdev by ADR

2. If 1. fails then falls back to HID + UID matching

And there are DSDTs which use either:

1. Only use _ADR to identify which child device is which, like the example DSDT snippet from the commit msg.

2. Only use _HID + _UID like the 2 example DSDT snippets from me email

But there never is a case where both _ADR and _HID are used at the same time (which would be an ACPI spec violation as Andy said).

So AFAICT there is no issue here since _ADR and _HID are never user at the same time and the commit message correctly describes scenario 1. from above, so the commit message is fine too.

So I believe that we can continue with this patch series in its current v20 form, which has already been staged for going into -next by Greg.

Quoted 7 lines
Quoted 2 lines

Andy can you confirm that moving ahead with the current version is ok ?

Yes as we have a few weeks to fix corner cases.

What I'm worrying is that opening door for _ADR that seems never used is kinda an overkill here (resolving non-existing problem).

I assume that there actually some DSDTs using the _ADR approach and that this support is not there just for fun.

Wentong, can you confirm that the _ADR using codepaths are actually used on some hardware / with some DSDTs out there ?

Quoted 4 lines

Looking at the design of the
driver I'm not sure why ACPI HIDs are collected somewhere else than in the respective drivers. And looking at the ID lists themselves I am not sure why the firmware of the respective hardware platforms are not using _CID.

This is a USB device which has 4 functions:

1. GPIO controller
2. I2C controller 1
3. I2C controller 2
4. SPI controller

The driver for the main USB interface uses the new auxbus to create 4 child devices. The _ADR or if that fails _HID + _UID matching is done to find the correct acpi_device child of the acpi_device which is the ACPI-companion of the main USB device.

After looking up the correct acpi_device child this is then set as the fwnode / ACPI-companion
of the auxbus device created for that function.

Having the correct fwnode is important because other parts of the DSDT reference this fwnode to specify GPIO / I2C / SPI resources and if the fwnode of the aux-device is not set correctly then the resources for other devices referencing it (typically a camera sensor) can not be found.

As for why the driver for the auxbus devices / children do not use HID matching, AFAIK the auxbus has no support for using ACPI (or DT) matching for aux-devices and these drivers need to be auxiliary_driver's and bind to the auxbus device and not to a platform_device instantiated for the acpi_device since they need the auxbus device to access the USB device.

Regards,

Hans

#10 lore raw

RE: [PATCH v20 1/4] usb: Add support for Intel LJCA device

Quoted 38 lines

From: Hans de Goede <hdegoede>

Hi Andy,

Quoted 1 line · Andriy

On Thu, Oct 12, 2023 at 01:14:23PM +0200, Hans de Goede wrote:

<snip>

Quoted 29 lines
Quoted 28 lines

Ah ok, I see. So the code:

1. First tries to find the matching child acpi_device for the auxdev by ADR

2. If 1. fails then falls back to HID + UID matching

And there are DSDTs which use either:

1. Only use _ADR to identify which child device is which, like the example DSDT snippet from the commit msg.

2. Only use _HID + _UID like the 2 example DSDT snippets from me email

But there never is a case where both _ADR and _HID are used at the same time (which would be an ACPI spec violation as Andy said).

So AFAICT there is no issue here since _ADR and _HID are never user at the same time and the commit message correctly describes scenario
1. from above, so the commit message is fine too.

So I believe that we can continue with this patch series in its current v20 form, which has already been staged for going into -next by Greg.

Andy can you confirm that moving ahead with the current version is ok ?

Quoted 7 lines
Quoted 4 lines

Yes as we have a few weeks to fix corner cases.

What I'm worrying is that opening door for _ADR that seems never used is kinda an overkill here (resolving non-existing problem).

I assume that there actually some DSDTs using the _ADR approach and that this support is not there just for fun.

right, it's not for fun, we use _ADR here is to reduce the maintain effort because currently it defines _HID for every new platform and the drivers have to be updated accordingly, while _ADR doesn't have that problem.

Quoted 2 lines

Wentong, can you confirm that the _ADR using codepaths are actually used on some hardware / with some DSDTs out there ?

what I can share is that we will see.

Quoted 3 lines
Quoted 3 lines

Looking at the design of the
driver I'm not sure why ACPI HIDs are collected somewhere else than in the respective drivers.

AFAIK, auxiliary bus doesn't support parsing fwnodes currently. Probably we can support it for auxiliary bus in another patch.

Quoted 3 lines
Quoted 2 lines

And looking at the ID lists themselves I am
not sure why the firmware of the respective hardware platforms are not using

_CID.

I think firmware can select _CID as well, but the shipped hw doesn't use _CID, the driver has to make sure the shipped hw working as well. And switching to _CID for the shipped hw is not easy, and it has to change windows driver as well.

Quoted 22 lines

This is a USB device which has 4 functions:

1. GPIO controller
2. I2C controller 1
3. I2C controller 2
4. SPI controller

The driver for the main USB interface uses the new auxbus to create 4 child devices. The _ADR or if that fails _HID + _UID matching is done to find the correct acpi_device child of the acpi_device which is the ACPI-companion of the main USB device.

After looking up the correct acpi_device child this is then set as the fwnode / ACPI-companion of the auxbus device created for that function.

Having the correct fwnode is important because other parts of the DSDT reference this fwnode to specify GPIO / I2C / SPI resources and if the fwnode of the aux-device is not set correctly then the resources for other devices referencing it (typically a camera
sensor) can not be found.

Quoted 5 lines

As for why the driver for the auxbus devices / children do not use HID matching, AFAIK the auxbus has no support for using ACPI (or DT) matching for aux-devices and these drivers need to be auxiliary_driver's and bind to the auxbus device and not to a platform_device instantiated for the acpi_device since they need the auxbus device to access the USB device.

Yes, total agree. Thanks

Thanks
Wentong

Quoted 5 lines

Regards,

Hans

#11 lore raw

Re: [PATCH v20 1/4] usb: Add support for Intel LJCA device

Hi,

Quoted 43 lines · Wentong
Quoted 43 lines

From: Hans de Goede <hdegoede>

Hi Andy,

Quoted 1 line · Andriy

On Thu, Oct 12, 2023 at 01:14:23PM +0200, Hans de Goede wrote:

<snip>

Quoted 33 lines
Quoted 22 lines

Ah ok, I see. So the code:

1. First tries to find the matching child acpi_device for the auxdev by ADR

2. If 1. fails then falls back to HID + UID matching

And there are DSDTs which use either:

1. Only use _ADR to identify which child device is which, like the example DSDT snippet from the commit msg.

2. Only use _HID + _UID like the 2 example DSDT snippets from me email

But there never is a case where both _ADR and _HID are used at the same time (which would be an ACPI spec violation as Andy said).

So AFAICT there is no issue here since _ADR and _HID are never user at the same time and the commit message correctly describes scenario
1. from above, so the commit message is fine too.

Quoted 6 lines

So I believe that we can continue with this patch series in its current v20 form, which has already been staged for going into -next by Greg.

Andy can you confirm that moving ahead with the current version is ok ?

Yes as we have a few weeks to fix corner cases.

What I'm worrying is that opening door for _ADR that seems never used is kinda an overkill here (resolving non-existing problem).

Quoted 6 lines
Quoted 2 lines

I assume that there actually some DSDTs using the _ADR approach and that this support is not there just for fun.

right, it's not for fun, we use _ADR here is to reduce the maintain effort because currently it defines _HID for every new platform and the drivers have to be updated accordingly, while _ADR doesn't have that problem.

Hmm, this sounds to me like _ADR is currently not actually being used in any shipping DSDTs ?

Adding support for it to the driver seems a bit premature then IMHO ?

Also HIDs can perfectly be re-used for compatible hardware in a newer generation so that is really not a good argument to use _ADR instead.

Regards,

Hans

#12 lore raw

Re: [PATCH v20 1/4] usb: Add support for Intel LJCA device

In reply to Wu, Wentong
Quoted 2 lines · Wentong
Quoted 2 lines · Andriy
Quoted 1 line · Hans de Goede

<snip>

Quoted 34 lines
Quoted 34 lines
Quoted 33 lines
Quoted 22 lines

Ah ok, I see. So the code:

1. First tries to find the matching child acpi_device for the auxdev by ADR

2. If 1. fails then falls back to HID + UID matching

And there are DSDTs which use either:

1. Only use _ADR to identify which child device is which, like the example DSDT snippet from the commit msg.

2. Only use _HID + _UID like the 2 example DSDT snippets from me email

But there never is a case where both _ADR and _HID are used at the same time (which would be an ACPI spec violation as Andy said).

So AFAICT there is no issue here since _ADR and _HID are never user at the same time and the commit message correctly describes scenario
1. from above, so the commit message is fine too.

Quoted 6 lines

So I believe that we can continue with this patch series in its current v20 form, which has already been staged for going into -next by Greg.

Andy can you confirm that moving ahead with the current version is ok ?

Yes as we have a few weeks to fix corner cases.

What I'm worrying is that opening door for _ADR that seems never used is kinda an overkill here (resolving non-existing problem).

Quoted 6 lines
Quoted 2 lines

I assume that there actually some DSDTs using the _ADR approach and that this support is not there just for fun.

right, it's not for fun, we use _ADR here is to reduce the maintain effort because currently it defines _HID for every new platform and the drivers have to be updated accordingly, while _ADR doesn't have that problem.

But this does not confirm if you have such devices. Moreover, My question about _CID per function stays the same. Why firmware is not using it? In that case you need only one ID per function in the driver (it might require some IDs in the _HID, I don't remember that part of the spec by heart, i.e. if _CID can be only provided with existing _HID or not).

Quoted 11 lines
Quoted 2 lines

Wentong, can you confirm that the _ADR using codepaths are actually used on some hardware / with some DSDTs out there ?

what I can share is that we will see.

Quoted 3 lines
Quoted 3 lines

Looking at the design of the
driver I'm not sure why ACPI HIDs are collected somewhere else than in the respective drivers.

AFAIK, auxiliary bus doesn't support parsing fwnodes currently. Probably we can support it for auxiliary bus in another patch.

This is good idea!

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

And looking at the ID lists themselves I am
not sure why the firmware of the respective hardware platforms are not using

_CID.

I think firmware can select _CID as well, but the shipped hw doesn't use _CID, the driver has to make sure the shipped hw working as well. And switching to _CID for the shipped hw is not easy, and it has to change windows driver as well.

I understand, but at least you may stop growing list in the driver. And actually using separate IDs for multifunctional device seems not ideal solution to me.

Quoted 1 line
Quoted 1 line

This is a USB device which has 4 functions:

Yes, I understand this part, but thank you for elaboration about auxbus, which seems lack of needed support. And I would really like to see someone adds it there.

Quoted 26 lines
Quoted 19 lines

1. GPIO controller
2. I2C controller 1
3. I2C controller 2
4. SPI controller

The driver for the main USB interface uses the new auxbus to create 4 child devices. The _ADR or if that fails _HID + _UID matching is done to find the correct acpi_device child of the acpi_device which is the ACPI-companion of the main USB device.

After looking up the correct acpi_device child this is then set as the fwnode / ACPI-companion of the auxbus device created for that function.

Having the correct fwnode is important because other parts of the DSDT reference this fwnode to specify GPIO / I2C / SPI resources and if the fwnode of the aux-device is not set correctly then the resources for other devices referencing it (typically a camera
sensor) can not be found.

Quoted 5 lines

As for why the driver for the auxbus devices / children do not use HID matching, AFAIK the auxbus has no support for using ACPI (or DT) matching for aux-devices and these drivers need to be auxiliary_driver's and bind to the auxbus device and not to a platform_device instantiated for the acpi_device since they need the auxbus device to access the USB device.

Yes, total agree. Thanks

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#13 lore raw

RE: [PATCH v20 1/4] usb: Add support for Intel LJCA device

Quoted 44 lines

From: Shevchenko, Andriy

Quoted 2 lines · Wentong
Quoted 2 lines · Andriy
Quoted 1 line · Hans de Goede

<snip>

Quoted 37 lines
Quoted 36 lines
Quoted 26 lines
Quoted 26 lines

Ah ok, I see. So the code:

1. First tries to find the matching child acpi_device for the auxdev by ADR

2. If 1. fails then falls back to HID + UID matching

And there are DSDTs which use either:

1. Only use _ADR to identify which child device is which, like the example DSDT snippet from the commit msg.

2. Only use _HID + _UID like the 2 example DSDT snippets from me email

But there never is a case where both _ADR and _HID are used at the same time (which would be an ACPI spec violation as Andy said).

So AFAICT there is no issue here since _ADR and _HID are never user at the same time and the commit message correctly describes scenario 1. from above, so the commit message is fine too.

So I believe that we can continue with this patch series in its current v20 form, which has already been staged for going into -next by Greg.

Quoted 7 lines
Quoted 2 lines

Andy can you confirm that moving ahead with the current version is ok ?

Yes as we have a few weeks to fix corner cases.

What I'm worrying is that opening door for _ADR that seems never used is kinda an overkill here (resolving non-existing problem).

I assume that there actually some DSDTs using the _ADR approach and that this support is not there just for fun.

Quoted 7 lines
Quoted 3 lines

right, it's not for fun, we use _ADR here is to reduce the maintain effort because currently it defines _HID for every new platform and the drivers have to be updated accordingly, while _ADR doesn't have that

problem.

But this does not confirm if you have such devices. Moreover, My question about _CID per function stays the same. Why firmware is not using it?

Yes, both _ADR and _CID can stop growing list in the driver. And for _ADR, it also only require one ID per function. I don't know why BIOS team doesn't select _CID, but I have suggested use _ADR internally, and , to make things moving forward, the driver adds support for _ADR here first.

But you're right, _CID is another solution as well, we will discuss it with firmware team more.

Quoted 21 lines

In that case you need only one ID per function in the driver (it might require some IDs in the _HID, I don't remember that part of the spec by heart, i.e. if _CID can be only provided with existing _HID or not).

Quoted 11 lines
Quoted 2 lines

Wentong, can you confirm that the _ADR using codepaths are actually used on some hardware / with some DSDTs out there ?

what I can share is that we will see.

Quoted 3 lines
Quoted 3 lines

Looking at the design of the
driver I'm not sure why ACPI HIDs are collected somewhere else than in the respective drivers.

AFAIK, auxiliary bus doesn't support parsing fwnodes currently. Probably we can support it for auxiliary bus in another patch.

This is good idea!

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

And looking at the ID lists themselves I am not sure why the firmware of the respective hardware platforms are not using

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

_CID.

I think firmware can select _CID as well, but the shipped hw doesn't use _CID, the driver has to make sure the shipped hw working as well. And switching to _CID for the shipped hw is not easy, and it has to change

windows driver as well.

I understand, but at least you may stop growing list in the driver.

Yes,

Quoted 2 lines

And actually using separate IDs for multifunctional device seems not ideal solution to me.

Agree, I will consider _CID more, but currently to avoid this and also support shipped hardware, _ADR is at least a choice.

BR,
Wentong

Quoted 38 lines
Quoted 1 line
Quoted 1 line

This is a USB device which has 4 functions:

Yes, I understand this part, but thank you for elaboration about auxbus, which seems lack of needed support. And I would really like to see someone adds it there.

Quoted 19 lines
Quoted 19 lines

1. GPIO controller
2. I2C controller 1
3. I2C controller 2
4. SPI controller

The driver for the main USB interface uses the new auxbus to create 4 child devices. The _ADR or if that fails _HID + _UID matching is done to find the correct acpi_device child of the acpi_device which is the ACPI-companion of the main USB device.

After looking up the correct acpi_device child this is then set as the fwnode / ACPI-companion of the auxbus device created for that function.

Having the correct fwnode is important because other parts of the DSDT reference this fwnode to specify GPIO / I2C / SPI resources and if the fwnode of the aux-device is not set correctly then the resources for other devices referencing it (typically a camera sensor) can not be found.

Quoted 5 lines
Quoted 5 lines

As for why the driver for the auxbus devices / children do not use HID matching, AFAIK the auxbus has no support for using ACPI (or DT) matching for aux-devices and these drivers need to be auxiliary_driver's and bind to the auxbus device and not to a platform_device instantiated for the acpi_device since they need the auxbus

device to access the USB device.

Quoted 2 lines

Yes, total agree. Thanks

--
With Best Regards,
Andy Shevchenko

#14 lore raw

Re: [PATCH v20 1/4] usb: Add support for Intel LJCA device

Quoted 52 lines · Wentong
Quoted 44 lines

From: Shevchenko, Andriy

Quoted 2 lines · Wentong
Quoted 2 lines · Andriy
Quoted 1 line · Hans de Goede

<snip>

Quoted 37 lines
Quoted 36 lines
Quoted 26 lines
Quoted 26 lines

Ah ok, I see. So the code:

1. First tries to find the matching child acpi_device for the auxdev by ADR

2. If 1. fails then falls back to HID + UID matching

And there are DSDTs which use either:

1. Only use _ADR to identify which child device is which, like the example DSDT snippet from the commit msg.

2. Only use _HID + _UID like the 2 example DSDT snippets from me email

But there never is a case where both _ADR and _HID are used at the same time (which would be an ACPI spec violation as Andy said).

So AFAICT there is no issue here since _ADR and _HID are never user at the same time and the commit message correctly describes scenario 1. from above, so the commit message is fine too.

So I believe that we can continue with this patch series in its current v20 form, which has already been staged for going into -next by Greg.

Quoted 7 lines
Quoted 2 lines

Andy can you confirm that moving ahead with the current version is ok ?

Yes as we have a few weeks to fix corner cases.

What I'm worrying is that opening door for _ADR that seems never used is kinda an overkill here (resolving non-existing problem).

I assume that there actually some DSDTs using the _ADR approach and that this support is not there just for fun.

Quoted 7 lines
Quoted 3 lines

right, it's not for fun, we use _ADR here is to reduce the maintain effort because currently it defines _HID for every new platform and the drivers have to be updated accordingly, while _ADR doesn't have that

problem.

But this does not confirm if you have such devices. Moreover, My question about _CID per function stays the same. Why firmware is not using it?

Quoted 7 lines

Yes, both _ADR and _CID can stop growing list in the driver. And for _ADR, it also only require one ID per function. I don't know why BIOS team doesn't select _CID, but I have suggested use _ADR internally, and , to make things moving forward, the driver adds support for _ADR here first.

But you're right, _CID is another solution as well, we will discuss it with firmware team more.

Should I revert this series now until this gets sorted out?

thanks,

greg k-h

#15 lore raw

RE: [PATCH v20 1/4] usb: Add support for Intel LJCA device

Quoted 61 lines

From: [email protected]

Quoted 9 lines · Wentong
Quoted 9 lines

From: Shevchenko, Andriy

Quoted 2 lines · Wentong
Quoted 2 lines · Andriy
Quoted 1 line · Hans de Goede

<snip>

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Ah ok, I see. So the code:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

1. First tries to find the matching child acpi_device for the auxdev by ADR

2. If 1. fails then falls back to HID + UID matching

And there are DSDTs which use either:

1. Only use _ADR to identify which child device is which, like the

example

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
Quoted 16 lines
Quoted 16 lines

DSDT snippet from the commit msg.

2. Only use _HID + _UID like the 2 example DSDT snippets from me email

But there never is a case where both _ADR and _HID are used at the same time (which would be an ACPI spec violation as Andy said).

So AFAICT there is no issue here since _ADR and _HID are never user at the same time and the commit message correctly describes scenario 1. from above, so the commit message is fine too.

So I believe that we can continue with this patch series in its current v20 form, which has already been staged for going into -next by Greg.

Quoted 7 lines
Quoted 2 lines

Andy can you confirm that moving ahead with the current version is ok ?

Yes as we have a few weeks to fix corner cases.

What I'm worrying is that opening door for _ADR that seems never used is kinda an overkill here (resolving non-existing problem).

I assume that there actually some DSDTs using the _ADR approach and that this support is not there just for fun.

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

right, it's not for fun, we use _ADR here is to reduce the maintain effort because currently it defines _HID for every new platform and the drivers have to be updated accordingly, while _ADR doesn't have that

problem.

But this does not confirm if you have such devices. Moreover, My question about _CID per function stays the same. Why firmware is not using

it?

Quoted 5 lines

Yes, both _ADR and _CID can stop growing list in the driver. And for _ADR, it also only require one ID per function. I don't know why BIOS team doesn't select _CID, but I have suggested use _ADR internally, and , to make things moving forward, the driver adds support for _ADR here

Quoted 6 lines

first.

Quoted 3 lines

But you're right, _CID is another solution as well, we will discuss it with firmware team more.

Should I revert this series now until this gets sorted out?

Current _ADR support is a solution, I don't think _CID is better than _ADR to both stop growing list in driver and support the shipped hardware at the same time.

Andy, what's your idea?

BR,
Wentong

Quoted 4 lines

thanks,

greg k-h

#16 lore raw

Re: [PATCH v20 1/4] usb: Add support for Intel LJCA device

Quoted 4 lines · Wentong
Quoted 4 lines

From: [email protected]

Quoted 2 lines · Wentong
Quoted 2 lines

From: Shevchenko, Andriy
On Mon, Oct 16, 2023 at 08:52:28AM +0300, Wu, Wentong wrote:

...

Quoted 13 lines
Quoted 13 lines
Quoted 2 lines
Quoted 2 lines

But this does not confirm if you have such devices. Moreover, My question about _CID per function stays the same. Why firmware is not using

it?

Quoted 5 lines

Yes, both _ADR and _CID can stop growing list in the driver. And for _ADR, it also only require one ID per function. I don't know why BIOS team doesn't select _CID, but I have suggested use _ADR internally, and , to make things moving forward, the driver adds support for _ADR here

first.

Quoted 3 lines

But you're right, _CID is another solution as well, we will discuss it with firmware team more.

Quoted 6 lines
Quoted 1 line

Should I revert this series now until this gets sorted out?

Current _ADR support is a solution, I don't think _CID is better than _ADR to both stop growing list in driver and support the shipped hardware at the same time.

Andy, what's your idea?

In my opinion if _CID can be made, it's better than _ADR. As using _ADR like you do is a bit of grey area in the ACPI specification. I.o.w. can you get a confirmation, let's say, from Microsoft, that they will go your way for other similar devices?

Btw, Microsoft has their own solution actually using _ADR for the so called "wired" USB devices. Is it your case? If so, I'm not sure why _HID has been used from day 1...

Also I suggest to wait for Hans' opinion on the topic.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#17 lore raw

Re: [PATCH v20 1/4] usb: Add support for Intel LJCA device

Hi,

Quoted 33 lines · Andriy
Quoted 4 lines · Wentong
Quoted 4 lines

From: [email protected]

Quoted 2 lines · Wentong
Quoted 2 lines

From: Shevchenko, Andriy
On Mon, Oct 16, 2023 at 08:52:28AM +0300, Wu, Wentong wrote:

...

Quoted 13 lines
Quoted 13 lines
Quoted 2 lines
Quoted 2 lines

But this does not confirm if you have such devices. Moreover, My question about _CID per function stays the same. Why firmware is not using

it?

Quoted 5 lines

Yes, both _ADR and _CID can stop growing list in the driver. And for _ADR, it also only require one ID per function. I don't know why BIOS team doesn't select _CID, but I have suggested use _ADR internally, and , to make things moving forward, the driver adds support for _ADR here

first.

Quoted 3 lines

But you're right, _CID is another solution as well, we will discuss it with firmware team more.

Quoted 6 lines
Quoted 1 line

Should I revert this series now until this gets sorted out?

Current _ADR support is a solution, I don't think _CID is better than _ADR to both stop growing list in driver and support the shipped hardware at the same time.

Andy, what's your idea?

In my opinion if _CID can be made, it's better than _ADR. As using _ADR like you do is a bit of grey area in the ACPI specification. I.o.w. can you get a confirmation, let's say, from Microsoft, that they will go your way for other similar devices?

Quoted 5 lines

Btw, Microsoft has their own solution actually using _ADR for the so called "wired" USB devices. Is it your case? If so, I'm not sure why _HID has been used from day 1...

Also I suggest to wait for Hans' opinion on the topic.

I definitely don't think we should revert the entire series since this supports actual hw which has already been shipping for years.

But if the _ADR support is only there to support future hw and it is not even certain yet that that future hw is actually going to be using _ADR support then I believe that a follow-up patch to drop _ADR support for now is in order. We can then re-introduce it (revert the follow up patch) if future hw actually starts using _ADR support.

Specifically what I'm suggesting is something like the following:

drivers/usb/misc/usb-ljca.c +2 -12
index c9decd0396d4..e1bbaf964786 100644
@@ -457,8 +457,8 @@ static void ljca_auxdev_acpi_bind(struct ljca_adapter *adap,
 				  u64 adr, u8 id)
 {
 	struct ljca_match_ids_walk_data wd = { 0 };
-	struct acpi_device *parent, *adev;
 	struct device *dev = adap->dev;
+	struct acpi_device *parent;
 	char uid[4];
 
 	parent = ACPI_COMPANION(dev);
@@ -466,17 +466,7 @@ static void ljca_auxdev_acpi_bind(struct ljca_adapter *adap,
 		return;
 
 	/*
-	 * get auxdev ACPI handle from the ACPI device directly
-	 * under the parent that matches _ADR.
-	 */
-	adev = acpi_find_child_device(parent, adr, false);
-	if (adev) {
-		ACPI_COMPANION_SET(&auxdev->dev, adev);
-		return;
-	}
-
-	/*
-	 * _ADR is a grey area in the ACPI specification, some
+	 * Currently LJCA hw does not use _ADR instead current
 	 * platforms use _HID to distinguish children devices.
 	 */
 	switch (adr) {

As a follow-up patch to the existing series.

Regards,

Hans

#18 lore raw

RE: [PATCH v20 1/4] usb: Add support for Intel LJCA device

Quoted 22 lines

From: Hans de Goede <hdegoede>

Quoted 20 lines · Andriy
Quoted 4 lines · Wentong
Quoted 4 lines

From: [email protected]

Quoted 2 lines · Wentong
Quoted 2 lines

From: Shevchenko, Andriy
On Mon, Oct 16, 2023 at 08:52:28AM +0300, Wu, Wentong wrote:

...

Quoted 12 lines
Quoted 12 lines
Quoted 3 lines
Quoted 3 lines

But this does not confirm if you have such devices. Moreover, My question about _CID per function stays the same. Why firmware is not using

it?

Quoted 6 lines

Yes, both _ADR and _CID can stop growing list in the driver. And for _ADR, it also only require one ID per function. I don't know why BIOS team doesn't select _CID, but I have suggested use _ADR internally, and , to make things moving forward, the driver adds support for _ADR here

first.

Quoted 1 line
Quoted 19 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

But you're right, _CID is another solution as well, we will discuss it with firmware team more.

Should I revert this series now until this gets sorted out?

Current _ADR support is a solution, I don't think _CID is better than _ADR to both stop growing list in driver and support the shipped hardware at

the same time.

Quoted 11 lines
Quoted 2 lines

Andy, what's your idea?

In my opinion if _CID can be made, it's better than _ADR. As using _ADR like you do is a bit of grey area in the ACPI specification. I.o.w. can you get a confirmation, let's say, from Microsoft, that they will go your way for other similar devices?

Btw, Microsoft has their own solution actually using _ADR for the so called "wired" USB devices. Is it your case? If so, I'm not sure why _HID has been used from day 1...

Thanks for your info, we will discuss more with them, but I also think we should keep this series and I will do the follow up as Hans' suggest.

Quoted 4 lines
Quoted 1 line

Also I suggest to wait for Hans' opinion on the topic.

I definitely don't think we should revert the entire series since this supports actual hw which has already been shipping for years.

Totally agree, thanks

Quoted 6 lines

But if the _ADR support is only there to support future hw and it is not even certain yet that that future hw is actually going to be using _ADR support then I believe that a follow-up patch to drop _ADR support for now is in order. We can then re-introduce it (revert the follow up patch) if future hw actually starts using _ADR support.

Yes, thanks.

Quoted 44 lines

Specifically what I'm suggesting is something like the following:

drivers/usb/misc/usb-ljca.c index renamed from drivers/usb/misc/usb-ljca.c +0 -0

c9decd0396d4..e1bbaf964786 100644

drivers/usb/misc/usb-ljca.c +1 -1
@@ -457,8 +457,8 @@ static void ljca_auxdev_acpi_bind(struct ljca_adapter
 *adap,
 				  u64 adr, u8 id)
 {
 	struct ljca_match_ids_walk_data wd = { 0 };
-	struct acpi_device *parent, *adev;
 	struct device *dev = adap->dev;
+	struct acpi_device *parent;
 	char uid[4];
 
drivers/usb/misc/usb-ljca.c +1 -11
 	parent = ACPI_COMPANION(dev);
@@ -466,17 +466,7 @@ static void ljca_auxdev_acpi_bind(struct ljca_adapter
 *adap,
 		return;
 
 	/*
-	 * get auxdev ACPI handle from the ACPI device directly
-	 * under the parent that matches _ADR.
-	 */
-	adev = acpi_find_child_device(parent, adr, false);
-	if (adev) {
-		ACPI_COMPANION_SET(&auxdev->dev, adev);
-		return;
-	}
-
-	/*
-	 * _ADR is a grey area in the ACPI specification, some
+	 * Currently LJCA hw does not use _ADR instead current
 	 * platforms use _HID to distinguish children devices.
 	 */

switch (adr) {

As a follow-up patch to the existing series.

Regards,

Hans

author
#19 lore raw

PATCH v20 2/4 i2c: Add support for Intel LJCA USB I2C driver

In reply to Wentong Wu

Implements the I2C function of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA). It communicate with LJCA I2C module with specific protocol through interfaces exported by LJCA USB driver.

---
 drivers/i2c/busses/Kconfig    |  11 ++
 drivers/i2c/busses/Makefile   |   1 +
 drivers/i2c/busses/i2c-ljca.c | 343 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 355 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-ljca.c
drivers/i2c/busses/Kconfig +11 -0
index 169607e..035b7f5 100644
@@ -1264,6 +1264,17 @@ config I2C_DLN2
 	 This driver can also be built as a module.  If so, the module
 	 will be called i2c-dln2.
 
+config I2C_LJCA
+	tristate "I2C functionality of Intel La Jolla Cove Adapter"
+	depends on USB_LJCA
+	default USB_LJCA
+	help
+	  If you say yes to this option, I2C functionality support of Intel
+	  La Jolla Cove Adapter (LJCA) will be included.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called i2c-ljca.
+
 config I2C_CP2615
 	tristate "Silicon Labs CP2615 USB sound card and I2C adapter"
 	depends on USB
drivers/i2c/busses/Makefile +1 -0
index af56fe2..3757b93 100644
@@ -133,6 +133,7 @@ obj-$(CONFIG_I2C_GXP)		+= i2c-gxp.o
 # External I2C/SMBus adapter drivers
 obj-$(CONFIG_I2C_DIOLAN_U2C)	+= i2c-diolan-u2c.o
 obj-$(CONFIG_I2C_DLN2)		+= i2c-dln2.o
+obj-$(CONFIG_I2C_LJCA)		+= i2c-ljca.o
 obj-$(CONFIG_I2C_CP2615) += i2c-cp2615.o
 obj-$(CONFIG_I2C_PARPORT)	+= i2c-parport.o
 obj-$(CONFIG_I2C_PCI1XXXX)	+= i2c-mchp-pci1xxxx.o
drivers/i2c/busses/i2c-ljca.c new file +343 -0

343 lines not on this page · raw message

Signature · 1 line
2.7.4
Reviewed-by on v20 2/4
#20 lore raw

Re: [PATCH v20 2/4] i2c: Add support for Intel LJCA USB I2C driver

Quoted 9 lines · Wentong Wu

Implements the I2C function of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA). It communicate with LJCA I2C module with specific protocol through interfaces exported by LJCA USB driver.

I2C driver looks good. Waiting for the USB part to be applied.

author
#21 lore raw

PATCH v20 3/4 spi: Add support for Intel LJCA USB SPI driver

In reply to Wentong Wu

Implements the SPI function of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA). It communicate with LJCA SPI module with specific protocol through interfaces exported by LJCA USB driver.

---
 drivers/spi/Kconfig    |  11 ++
 drivers/spi/Makefile   |   1 +
 drivers/spi/spi-ljca.c | 297 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 309 insertions(+)
 create mode 100644 drivers/spi/spi-ljca.c
drivers/spi/Kconfig +11 -0
index 2c21d5b..32d9ea6 100644
@@ -616,6 +616,17 @@ config SPI_FSL_ESPI
 	  From MPC8536, 85xx platform uses the controller, and all P10xx,
 	  P20xx, P30xx,P40xx, P50xx uses this controller.
 
+config SPI_LJCA
+	tristate "Intel La Jolla Cove Adapter SPI support"
+	depends on USB_LJCA
+	default USB_LJCA
+	help
+	  Select this option to enable SPI driver for the Intel
+	  La Jolla Cove Adapter (LJCA) board.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called spi-ljca.
+
 config SPI_MESON_SPICC
 	tristate "Amlogic Meson SPICC controller"
 	depends on COMMON_CLK
drivers/spi/Makefile +1 -0
index 6af5484..4ff8d72 100644
@@ -71,6 +71,7 @@ obj-$(CONFIG_SPI_INTEL_PCI)		+= spi-intel-pci.o
 obj-$(CONFIG_SPI_INTEL_PLATFORM)	+= spi-intel-platform.o
 obj-$(CONFIG_SPI_LANTIQ_SSC)		+= spi-lantiq-ssc.o
 obj-$(CONFIG_SPI_JCORE)			+= spi-jcore.o
+obj-$(CONFIG_SPI_LJCA)			+= spi-ljca.o
 obj-$(CONFIG_SPI_LM70_LLP)		+= spi-lm70llp.o
 obj-$(CONFIG_SPI_LOONGSON_CORE)		+= spi-loongson-core.o
 obj-$(CONFIG_SPI_LOONGSON_PCI)		+= spi-loongson-pci.o
drivers/spi/spi-ljca.c new file +297 -0

297 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer Reviewed-by on v20 3/4
#22 lore raw

Re: [PATCH v20 3/4] spi: Add support for Intel LJCA USB SPI driver

Quoted 4 lines · Wentong Wu

Implements the SPI function of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA). It communicate with LJCA SPI module with specific protocol through interfaces exported by LJCA USB driver.

author
#23 lore raw

PATCH v20 4/4 gpio: update Intel LJCA USB GPIO driver

In reply to Wentong Wu

This driver communicate with LJCA GPIO module with specific protocol through interfaces exported by LJCA USB driver. Update the driver according to LJCA USB driver's changes.

---
 drivers/gpio/Kconfig     |   4 +-
 drivers/gpio/gpio-ljca.c | 246 +++++++++++++++++++++++++++--------------------
 2 files changed, 145 insertions(+), 105 deletions(-)
drivers/gpio/Kconfig +2 -2
index 673bafb..8d5b6c3 100644
@@ -1312,9 +1312,9 @@ config GPIO_KEMPLD
 
 config GPIO_LJCA
 	tristate "INTEL La Jolla Cove Adapter GPIO support"
-	depends on MFD_LJCA
+	depends on USB_LJCA
 	select GPIOLIB_IRQCHIP
-	default MFD_LJCA
+	default USB_LJCA
 	help
 	  Select this option to enable GPIO driver for the INTEL
 	  La Jolla Cove Adapter (LJCA) board.
drivers/gpio/gpio-ljca.c +143 -103

473 lines not on this page · raw message

Signature · 1 line
2.7.4