Add Intel LJCA device driver
Subsystems (5)
v16 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 such as GPIO, I2C and SPI with USB host interface. We add 4 drivers to support this device: a USB driver, a GPIO chip driver, a I2C controller driver and a SPI controller driver.
---
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 *
v15:
- enhance disconnect() of usb-ljca driver
- change memchr to strchr in ljca_match_device_ids() of usb-ljca driver
v14:
- 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, and patch is from Hans de Goede
v12:
- switch dev_err to dev_dbg for i2c-ljca driver
- avoid err printing because of calling usb_kill_urb when attempts to resubmit the rx urb
v11:
- 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
v10:
- remove ljca_i2c_format_slave_addr
- remove memset before write write w_packet
- 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 | 342 +++++++++++++++++ drivers/spi/Kconfig | 11 + drivers/spi/Makefile | 1 + drivers/spi/spi-ljca.c | 297 +++++++++++++++ drivers/usb/misc/Kconfig | 14 + drivers/usb/misc/Makefile | 1 + drivers/usb/misc/usb-ljca.c | 835 ++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/ljca.h | 145 ++++++++ 12 files changed, 1803 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
PATCH v16 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 | 14 + drivers/usb/misc/Makefile | 1 + drivers/usb/misc/usb-ljca.c | 835 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/ljca.h | 145 ++++++++ 4 files changed, 995 insertions(+) create mode 100644 drivers/usb/misc/usb-ljca.c create mode 100644 include/linux/usb/ljca.h
drivers/usb/misc/Kconfig +14 -0
@@ -165,6 +165,20 @@ 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 + depends on ACPI || COMPILE_TEST + 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
@@ -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 +835 -0
835 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
kernel test robot
build botRe: [PATCH v16 1/4] usb: Add support for Intel LJCA device
kernel test robot noticed the following build warnings:
Hi Wentong,
kernel test robot noticed the following build warnings:
[auto build test WARNING on wsa/i2c/for-next]
[also build test WARNING on broonie-spi/for-next linus/master v6.6-rc1 next-20230912] [cannot apply to usb/usb-testing usb/usb-next usb/usb-linus]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Wentong-Wu/usb-Add-support-for-Intel-LJCA-device/20230913-094239 base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next patch link: https://lore.kernel.org/r/1694569212-10080-2-git-send-email-wentong.wu%40intel.com patch subject: [PATCH v16 1/4] usb: Add support for Intel LJCA device config: sparc-allyesconfig (https://download.01.org/0day-ci/archive/20230913/[email protected]/config) compiler: sparc64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230913/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/usb/misc/usb-ljca.c: In function 'ljca_match_device_ids':
drivers/usb/misc/usb-ljca.c:389:27: error: implicit declaration of function 'acpi_device_uid'; did you mean 'dmi_device_id'? [-Werror=implicit-function-declaration]
389 | const char *uid = acpi_device_uid(adev);
| ^~~~~~~~~~~~~~~
| dmi_device_id
>> drivers/usb/misc/usb-ljca.c:389:27: warning: initialization of 'const char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
drivers/usb/misc/usb-ljca.c:391:13: error: implicit declaration of function 'acpi_match_device_ids'; did you mean 'ljca_match_device_ids'? [-Werror=implicit-function-declaration]
391 | if (acpi_match_device_ids(adev, wd->ids))
| ^~~~~~~~~~~~~~~~~~~~~
| ljca_match_device_ids
drivers/usb/misc/usb-ljca.c: In function 'ljca_auxdev_acpi_bind':
drivers/usb/misc/usb-ljca.c:429:16: error: implicit declaration of function 'acpi_find_child_device'; did you mean 'acpi_match_device'? [-Werror=implicit-function-declaration]
429 | adev = acpi_find_child_device(parent, adr, false);
| ^~~~~~~~~~~~~~~~~~~~~~
| acpi_match_device
>> drivers/usb/misc/usb-ljca.c:429:14: warning: assignment to 'struct acpi_device *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
429 | adev = acpi_find_child_device(parent, adr, false);
| ^
drivers/usb/misc/usb-ljca.c:458:9: error: implicit declaration of function 'acpi_dev_for_each_child'; did you mean 'device_for_each_child'? [-Werror=implicit-function-declaration]
458 | acpi_dev_for_each_child(parent, ljca_match_device_ids, &wd);
| ^~~~~~~~~~~~~~~~~~~~~~~
| device_for_each_childcc1: some warnings being treated as errors
vim +389 drivers/usb/misc/usb-ljca.c
385
386 static int ljca_match_device_ids(struct acpi_device *adev, void *data)
387 {
388 struct ljca_match_ids_walk_data *wd = data;
> 389 const char *uid = acpi_device_uid(adev);
390
391 if (acpi_match_device_ids(adev, wd->ids))
392 return 0;
393
394 if (!wd->uid)
395 goto match;
396
397 if (!uid)
398 uid = "0";
399 else
400 uid = strchr(uid, wd->uid[0]);
401
402 if (!uid || strcmp(uid, wd->uid))
403 return 0;
404
405 match:
406 wd->adev = adev;
407
408 return 1;
409 }
410
411 /* bind auxiliary device to acpi device */
412 static void ljca_auxdev_acpi_bind(struct ljca_adapter *adap,
413 struct auxiliary_device *auxdev,
414 u64 adr, u8 id)
415 {
416 struct ljca_match_ids_walk_data wd = { 0 };
417 struct acpi_device *parent, *adev;
418 struct device *dev = adap->dev;
419 char uid[4];
420
421 parent = ACPI_COMPANION(dev);
422 if (!parent)
423 return;
424
425 /*
426 * get auxdev ACPI handle from the ACPI device directly
427 * under the parent that matches _ADR.
428 */
> 429 adev = acpi_find_child_device(parent, adr, false); 430 if (adev) {
431 ACPI_COMPANION_SET(&auxdev->dev, adev);
432 return;
433 }
434
435 /*
436 * _ADR is a grey area in the ACPI specification, some
437 * platforms use _HID to distinguish children devices.
438 */
439 switch (adr) {
440 case LJCA_GPIO_ACPI_ADR:
441 wd.ids = ljca_gpio_hids;
442 break;
443 case LJCA_I2C1_ACPI_ADR:
444 case LJCA_I2C2_ACPI_ADR:
445 snprintf(uid, sizeof(uid), "%d", id);
446 wd.uid = uid;
447 wd.ids = ljca_i2c_hids;
448 break;
449 case LJCA_SPI1_ACPI_ADR:
450 case LJCA_SPI2_ACPI_ADR:
451 wd.ids = ljca_spi_hids;
452 break;
453 default:
454 dev_warn(dev, "unsupported _ADR\n");
455 return;
456 }
457
458 acpi_dev_for_each_child(parent, ljca_match_device_ids, &wd);
459 if (wd.adev) {
460 ACPI_COMPANION_SET(&auxdev->dev, wd.adev);
461 return;
462 }
463
464 parent = ACPI_COMPANION(dev->parent->parent);
465 if (!parent)
466 return;
467
468 acpi_dev_for_each_child(parent, ljca_match_device_ids, &wd);
469 if (wd.adev)
470 ACPI_COMPANION_SET(&auxdev->dev, wd.adev);
471 }
472
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v16 1/4] usb: Add support for Intel LJCA device
Hi,
Quoted 41 lines · kernel test robot
Hi Wentong,
kernel test robot noticed the following build warnings:
[auto build test WARNING on wsa/i2c/for-next]
[also build test WARNING on broonie-spi/for-next linus/master v6.6-rc1 next-20230912] [cannot apply to usb/usb-testing usb/usb-next usb/usb-linus]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Wentong-Wu/usb-Add-support-for-Intel-LJCA-device/20230913-094239 base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next patch link: https://lore.kernel.org/r/1694569212-10080-2-git-send-email-wentong.wu%40intel.com patch subject: [PATCH v16 1/4] usb: Add support for Intel LJCA device config: sparc-allyesconfig (https://download.01.org/0day-ci/archive/20230913/[email protected]/config) compiler: sparc64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230913/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All warnings (new ones prefixed by >>):
drivers/usb/misc/usb-ljca.c: In function 'ljca_match_device_ids':drivers/usb/misc/usb-ljca.c:389:27: error: implicit declaration of function 'acpi_device_uid'; did you mean 'dmi_device_id'? [-Werror=implicit-function-declaration] 389 | const char *uid = acpi_device_uid(adev); | ^~~~~~~~~~~~~~~ | dmi_device_idQuoted 1 line
Quoted 1 line
drivers/usb/misc/usb-ljca.c:389:27: warning: initialization of 'const char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
drivers/usb/misc/usb-ljca.c:391:13: error: implicit declaration of function 'acpi_match_device_ids'; did you mean 'ljca_match_device_ids'? [-Werror=implicit-function-declaration]391 | if (acpi_match_device_ids(adev, wd->ids)) | ^~~~~~~~~~~~~~~~~~~~~ | ljca_match_device_ids drivers/usb/misc/usb-ljca.c: In function 'ljca_auxdev_acpi_bind': drivers/usb/misc/usb-ljca.c:429:16: error: implicit declaration of function 'acpi_find_child_device'; did you mean 'acpi_match_device'? [-Werror=implicit-function-declaration] 429 | adev = acpi_find_child_device(parent, adr, false); | ^~~~~~~~~~~~~~~~~~~~~~ | acpi_match_device
Quoted 8 lines
Quoted 1 line
Quoted 1 line
drivers/usb/misc/usb-ljca.c:429:14: warning: assignment to 'structacpi_device*' from 'int' makes pointer from integer without a cast [-Wint-conversion]429 | adev = acpi_find_child_device(parent, adr, false); | ^ drivers/usb/misc/usb-ljca.c:458:9: error: implicit declaration of function 'acpi_dev_for_each_child'; did you mean 'device_for_each_child'? [-Werror=implicit-function-declaration] 458 | acpi_dev_for_each_child(parent, ljca_match_device_ids, &wd); | ^~~~~~~~~~~~~~~~~~~~~~~ | device_for_each_childcc1: some warnings being treated as errors
Ok, so this need to have a "depends on ACPI" added to its Kconfig entry. There are other ways to fix it, but this driver will not be functional without ACPI anyways so "depends on ACPI" seems to be the best solution for this.
Regards,
Hans
Quoted 91 lines
vim +389
drivers/usb/misc/usb-ljca.c385 386 static int ljca_match_device_ids(struct acpi_device *adev, void *data) 387 { 388 struct ljca_match_ids_walk_data *wd = data;Quoted 1 line
389 const char *uid =
acpi_device_uid(adev);390
391 if (acpi_match_device_ids(adev, wd->ids))392 return 0; 393 394 if (!wd->uid) 395 goto match; 396 397 if (!uid) 398 uid = "0"; 399 else 400 uid = strchr(uid, wd->uid[0]); 401 402 if (!uid || strcmp(uid, wd->uid)) 403 return 0; 404 405 match: 406 wd->adev = adev; 407 408 return 1; 409 } 410 411 /* bind auxiliary device to acpi device */ 412 static void ljca_auxdev_acpi_bind(struct ljca_adapter *adap, 413 struct auxiliary_device *auxdev, 414 u64 adr, u8 id) 415 { 416 struct ljca_match_ids_walk_data wd = { 0 }; 417 struct acpi_device *parent, *adev; 418 struct device *dev = adap->dev; 419 char uid[4]; 420 421 parent = ACPI_COMPANION(dev); 422 if (!parent) 423 return; 424 425 /* 426 * get auxdev ACPI handle from the ACPI device directly 427 * under the parent that matches _ADR. 428 */Quoted 1 line
429 adev =
acpi_find_child_device(parent, adr, false);430 if (adev) { 431 ACPI_COMPANION_SET(&auxdev->dev, adev); 432 return; 433 } 434 435 /* 436 * _ADR is a grey area in the ACPI specification, some 437 * platforms use _HID to distinguish children devices. 438 */ 439 switch (adr) { 440 case LJCA_GPIO_ACPI_ADR: 441 wd.ids = ljca_gpio_hids; 442 break; 443 case LJCA_I2C1_ACPI_ADR: 444 case LJCA_I2C2_ACPI_ADR: 445 snprintf(uid, sizeof(uid), "%d", id); 446 wd.uid = uid; 447 wd.ids = ljca_i2c_hids; 448 break; 449 case LJCA_SPI1_ACPI_ADR: 450 case LJCA_SPI2_ACPI_ADR: 451 wd.ids = ljca_spi_hids; 452 break; 453 default: 454 dev_warn(dev, "unsupported _ADR\n"); 455 return; 456 } 457 458 acpi_dev_for_each_child(parent, ljca_match_device_ids, &wd); 459 if (wd.adev) { 460 ACPI_COMPANION_SET(&auxdev->dev, wd.adev); 461 return; 462 } 463 464 parent = ACPI_COMPANION(dev->parent->parent); 465 if (!parent) 466 return; 467 468 acpi_dev_for_each_child(parent, ljca_match_device_ids, &wd); 469 if (wd.adev) 470 ACPI_COMPANION_SET(&auxdev->dev, wd.adev); 471 } 472
RE: [PATCH v16 1/4] usb: Add support for Intel LJCA device
Quoted 73 lines
From: Hans de Goede
Hi,
Quoted 4 lines · kernel test robot
Hi Wentong,
kernel test robot noticed the following build warnings:
Quoted 8 lines
[auto build test WARNING on wsa/i2c/for-next] [also build test WARNING on broonie-spi/for-next linus/master v6.6-rc1 next-20230912] [cannot apply to usb/usb-testing usb/usb-next usb/usb-linus] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Wentong-Wu/usb-Add-
support-for-Intel-LJCA-device/20230913-094239
Quoted 1 line
base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-
next
Quoted 1 line
patch link: https://lore.kernel.org/r/1694569212-10080-2-git-send-email-
wentong.wu%40intel.com
Quoted 3 lines
patch subject: [PATCH v16 1/4] usb: Add support for Intel LJCA device
config: sparc-allyesconfig
(https://download.01.org/0day-ci/archive/20230913/202309131427.AUBwVNB
Quoted 4 lines
[email protected]/config)
compiler: sparc64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build):
(https://download.01.org/0day-ci/archive/20230913/202309131427.AUBwVNB
Quoted 9 lines
[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Closes: | https://lore.kernel.org/oe-kbuild-all/202309131427.AUBwVNBm-lkp@inte | l.com/Quoted 4 lines
All warnings (new ones prefixed by >>):
drivers/usb/misc/usb-ljca.c: In function 'ljca_match_device_ids':
drivers/usb/misc/usb-ljca.c:389:27: error: implicit declaration of function'
acpi_device_uid'; did you mean 'dmi_device_id'? [-Werror=implicit-function- declaration]Quoted 7 lines
389 | const char *uid = acpi_device_uid(adev); | ^~~~~~~~~~~~~~~ | dmi_device_idQuoted 3 lines
Quoted 3 lines
drivers/usb/misc/usb-ljca.c:389:27: warning: initialization of 'const char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
drivers/usb/misc/usb-ljca.c:391:13: error: implicit declaration of function'
acpi_match_device_ids'; did you mean 'ljca_match_device_ids'? [- Werror=implicit-function-declaration]Quoted 5 lines
391 | if (acpi_match_device_ids(adev, wd->ids)) | ^~~~~~~~~~~~~~~~~~~~~ | ljca_match_device_ids
drivers/usb/misc/usb-ljca.c: In function 'ljca_auxdev_acpi_bind':
drivers/usb/misc/usb-ljca.c:429:16: error: implicit declaration of function'
acpi_find_child_device'; did you mean 'acpi_match_device'? [-Werror=implicit- function-declaration]Quoted 9 lines
429 | adev = acpi_find_child_device(parent, adr, false); | ^~~~~~~~~~~~~~~~~~~~~~ | acpi_match_deviceQuoted 3 lines
Quoted 3 lines
drivers/usb/misc/usb-ljca.c:429:14: warning: assignment to 'structacpi_device*' from 'int' makes pointer from integer without a cast [-Wint-conversion]429 | adev = acpi_find_child_device(parent, adr, false); | ^
drivers/usb/misc/usb-ljca.c:458:9: error: implicit declaration of function'
acpi_dev_for_each_child'; did you mean 'device_for_each_child'? [- Werror=implicit-function-declaration]
Quoted 8 lines
Quoted 4 lines
458 | acpi_dev_for_each_child(parent, ljca_match_device_ids, &wd); | ^~~~~~~~~~~~~~~~~~~~~~~ | device_for_each_childcc1: some warnings being treated as errors
Ok, so this need to have a "depends on ACPI" added to its
Kconfigentry. There are other ways to fix it, but this driver will not be functional without ACPI anyways so "depends on ACPI" seems to be the best solution for this.
Yes, "depends on ACPI" is already there, but I have to remove "depends on COMPILE_TEST"
Thanks
Wentong
Quoted 4 lines
Regards,
Hans
Re: [PATCH v16 1/4] usb: Add support for Intel LJCA device
In reply to Wentong Wudrivers/usb/misc/usb-ljca.c line 96
Quoted 6 lines · Wentong Wu
drivers/usb/misc/usb-ljca.c new file +6
-0+struct ljca_bank_descriptor { +u8 bank_id; +u8 pin_num; + +/* 1 bit for each gpio, 1 means valid */ +u32 valid_pins;
No endianness?
Quoted 1 line
+}
__packed;
Regards
Oliver
RE: [PATCH v16 1/4] usb: Add support for Intel LJCA device
Quoted 4 lines
From: Oliver Neukum <[email protected]>
On 13.09.23 03:40, Wentong Wu wrote:
Quoted 8 lines
drivers/usb/misc/usb-ljca.c line 96
Quoted 6 lines
drivers/usb/misc/usb-ljca.c new file +6
-0+struct ljca_bank_descriptor { +u8 bank_id; +u8 pin_num; + +/* 1 bit for each gpio, 1 means valid */ +u32 valid_pins;No endianness?
On both sides, the endianness is same.
BTW, the code has been tested on several real productions.
BR,
Wentong
Quoted 5 lines
Quoted 2 lines
+}
__packed;Regards
Oliver
Re: [PATCH v16 1/4] usb: Add support for Intel LJCA device
Hi,
Quoted 13 lines · Wentong
Quoted 4 lines
From: Oliver Neukum <[email protected]>
On 13.09.23 03:40, Wentong Wu wrote:
Quoted 8 lines
drivers/usb/misc/usb-ljca.c line 96
Quoted 6 lines
drivers/usb/misc/usb-ljca.c new file +6
-0+struct ljca_bank_descriptor { +u8 bank_id; +u8 pin_num; + +/* 1 bit for each gpio, 1 means valid */ +u32 valid_pins;No endianness?
Quoted 1 line
On both sides, the endianness is same.
Right, but normally USB drivers are also written so that they can work on big-endian CPUs.
I realize that this driver will likely never be used with a big-endian CPU but still it is good practice to make the driver work on big-endian CPUs too. Even if it is just to set a good example when other drivers copy the code.
So this should be:
struct ljca_bank_descriptor {
u8 bank_id;
u8 pin_num;
/* 1 bit for each gpio, 1 means valid */
__le32 valid_pins;
} __packed;And then when reading valid_pins you should use:
u32 valid_pins = get_unaligned_le32(&ljca_bank_descriptor.valid_pins);
On x86_64 the compiler should optimize all of this away to just a regular read.
Regards,
Hans
RE: [PATCH v16 1/4] usb: Add support for Intel LJCA device
Quoted 18 lines
From: Hans de Goede <[email protected]>
Hi,
Quoted 13 lines · Wentong
Quoted 12 lines
From: Oliver Neukum <[email protected]>
drivers/usb/misc/usb-ljca.c line 96
Quoted 6 lines · Wentong Wu
drivers/usb/misc/usb-ljca.c new file +6
-0+struct ljca_bank_descriptor { +u8 bank_id; +u8 pin_num; + +/* 1 bit for each gpio, 1 means valid */ +u32 valid_pins;No endianness?
Quoted 8 lines
Quoted 1 line
On both sides, the endianness is same.
Right, but normally USB drivers are also written so that they can work on big- endian CPUs.
I realize that this driver will likely never be used with a big-endian CPU but still it is good practice to make the driver work on big-endian CPUs too. Even if it is just to set a good example when other drivers copy the code.
Thanks, I agree the point here.
And I will update the driver after the test, thanks again.
BR,
Wentong
Quoted 21 lines
So this should be:
struct ljca_bank_descriptor { u8 bank_id; u8 pin_num; /* 1 bit for each gpio, 1 means valid */ __le32 valid_pins; } __packed;And then when reading
valid_pinsyou should use:u32 valid_pins = get_unaligned_le32(&ljca_bank_descriptor.valid_pins);On
x86_64the compiler should optimize all of this away to just a regular read.Regards,
Hans
PATCH v16 2/4 i2c: Add support for Intel LJCA USB I2C driver
In reply to Wentong WuImplements 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 | 342 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 354 insertions(+) create mode 100644 drivers/i2c/busses/i2c-ljca.c
drivers/i2c/busses/Kconfig +11 -0
@@ -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
@@ -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 +342 -0
342 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v16 3/4 spi: Add support for Intel LJCA USB SPI driver
In reply to Wentong WuImplements 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
@@ -583,6 +583,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
@@ -70,6 +70,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_LP8841_RTC) += spi-lp8841-rtc.o obj-$(CONFIG_SPI_MESON_SPICC) += spi-meson-spicc.o
drivers/spi/spi-ljca.c new file +297 -0
297 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v16 4/4 gpio: update Intel LJCA USB GPIO driver
In reply to Wentong WuThis 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
@@ -1294,9 +1294,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