intel_cht_int33fe: Split code to USB Micro-B and Type-C variants
v3 cover intel_cht_int33fe: Split code to USB Micro-B and Type-C variants
Patch to support INT33FE ACPI pseudo-device on hardware with USB Micro-B connector.
v4:
- Micro-B variant: Don't print error to the kernel log if i2c_acpi_new_device() has returned -EPROBE_DEFER.
v3:
- Rename TypeB variant to Micro-B (we have only one such device for now and it has Micro-B connector)
- Rebase on current linus/master
- Remove empty lines and replace "TypeC" by "Type-C"
v2:
Instead of defining two separated modules with two separated config options, compile {common,typeb,typec} sources into one .ko module. Call needed variant-specific probe function based after of hardware type detection in common code.
Yauhen Kharuzhy (1):
platform/x86/intel_cht_int33fe: Split code to USB Micro-B and Type-C
variants
drivers/platform/x86/Kconfig | 12 +-
drivers/platform/x86/Makefile | 4 +
.../platform/x86/intel_cht_int33fe_common.c | 147 ++++++++++++++++++
.../platform/x86/intel_cht_int33fe_common.h | 41 +++++
.../platform/x86/intel_cht_int33fe_microb.c | 67 ++++++++
...ht_int33fe.c => intel_cht_int33fe_typec.c} | 78 +---------
6 files changed, 276 insertions(+), 73 deletions(-)
create mode 100644 drivers/platform/x86/intel_cht_int33fe_common.c
create mode 100644 drivers/platform/x86/intel_cht_int33fe_common.h
create mode 100644 drivers/platform/x86/intel_cht_int33fe_microb.c
rename drivers/platform/x86/{intel_cht_int33fe.c => intel_cht_int33fe_typec.c} (82%)Signature · 1 line
2.23.0.rc1
PATCH v4 1/1 platform/x86/intel_cht_int33fe: Split code to USB Micro-B and Type-C variants
Existing intel_cht_int33fe ACPI pseudo-device driver assumes that hardware has Type-C connector and register related devices described as I2C connections in the _CRS resource.
There is at least one hardware (Lenovo Yoga Book YB1-91L/F) with Micro-B USB connector exists. It has INT33FE device in the DSDT table but there are only two I2C connection described: PMIC and BQ27452 battery fuel gauge.
Splitting existing INT33FE driver allow to maintain code for USB Micro-B (AB) connector variant separately and make it simpler.
Split driver to intel_cht_int33fe_common.c and intel_cht_int33fe_{typeb,typec}.c. Compile all this sources to one .ko module to make user experience easier.
---
drivers/platform/x86/Kconfig | 12 +-
drivers/platform/x86/Makefile | 4 +
.../platform/x86/intel_cht_int33fe_common.c | 147 ++++++++++++++++++
.../platform/x86/intel_cht_int33fe_common.h | 41 +++++
.../platform/x86/intel_cht_int33fe_microb.c | 67 ++++++++
...ht_int33fe.c => intel_cht_int33fe_typec.c} | 78 +---------
6 files changed, 276 insertions(+), 73 deletions(-)
create mode 100644 drivers/platform/x86/intel_cht_int33fe_common.c
create mode 100644 drivers/platform/x86/intel_cht_int33fe_common.h
create mode 100644 drivers/platform/x86/intel_cht_int33fe_microb.c
rename drivers/platform/x86/{intel_cht_int33fe.c => intel_cht_int33fe_typec.c} (82%)drivers/platform/x86/Kconfig +9 -3
@@ -926,18 +926,24 @@ config INTEL_CHT_INT33FE depends on CHARGER_BQ24190=y || (CHARGER_BQ24190=m && m) depends on USB_ROLES_INTEL_XHCI=y || (USB_ROLES_INTEL_XHCI=m && m) depends on TYPEC_MUX_PI3USB30532=y || (TYPEC_MUX_PI3USB30532=m && m) - ---help--- + help This driver add support for the INT33FE ACPI device found on some Intel Cherry Trail devices. + There are two kinds of INT33FE ACPI device possible: for hardware + with USB Type-C and Micro-B connectors. This driver supports both. + The INT33FE ACPI device has a CRS table with I2cSerialBusV2 - resources for 3 devices: Maxim MAX17047 Fuel Gauge Controller, + resources for Fuel Gauge Controller and (in the Type-C variant) FUSB302 USB Type-C Controller and PI3USB30532 USB switch. This driver instantiates i2c-clients for these, so that standard i2c drivers for these chips can bind to the them. If you enable this driver it is advised to also select - CONFIG_TYPEC_FUSB302=m and CONFIG_BATTERY_MAX17042=m. + CONFIG_BATTERY_BQ27XXX=m and CONFIG_BATTERY_BQ27XXX_I2C=m for Micro-B + device and CONFIG_TYPEC_FUSB302=m and CONFIG_BATTERY_MAX17042=m + for Type-C device. + config INTEL_INT0002_VGPIO tristate "Intel ACPI INT0002 Virtual GPIO driver"
drivers/platform/x86/Makefile +4 -0
@@ -61,6 +61,10 @@ obj-$(CONFIG_TOSHIBA_BT_RFKILL) += toshiba_bluetooth.o obj-$(CONFIG_TOSHIBA_HAPS) += toshiba_haps.o obj-$(CONFIG_TOSHIBA_WMI) += toshiba-wmi.o obj-$(CONFIG_INTEL_CHT_INT33FE) += intel_cht_int33fe.o +intel_cht_int33fe-objs := intel_cht_int33fe_common.o \ + intel_cht_int33fe_typec.o \ + intel_cht_int33fe_microb.o + obj-$(CONFIG_INTEL_INT0002_VGPIO) += intel_int0002_vgpio.o obj-$(CONFIG_INTEL_HID_EVENT) += intel-hid.o obj-$(CONFIG_INTEL_VBTN) += intel-vbtn.o
drivers/platform/x86/intel_cht_int33fe_common.c new file +147 -0
147 lines not on this page · raw message
drivers/platform/x86/intel_cht_int33fe_common.h new file +41 -0
41 lines not on this page · raw message
drivers/platform/x86/intel_cht_int33fe_microb.c new file +67 -0
67 lines not on this page · raw message
drivers/platform/x86/intel_cht_int33fe_typec.c renamed from drivers/platform/x86/intel_cht_int33fe.c +8 -70
143 lines not on this page · raw message
Signature · 1 line
2.23.0.rc1
Re: [PATCH v4 1/1] platform/x86/intel_cht_int33fe: Split code to USB Micro-B and Type-C variants
Quoted 1 line · Yauhen Kharuzhy
You so fast with new versions that I had no chance to comment on. Finally here mine.
Quoted 11 lines
Existing
intel_cht_int33feACPI pseudo-device driver assumes that hardware has Type-C connector and register related devices described as I2C connections in the_CRSresource.There is at least one hardware (Lenovo Yoga Book YB1-91L/F) with Micro-B USB connector exists. It has INT33FE device in the DSDT table but there are only two I2C connection described: PMIC and BQ27452 battery fuel gauge.
Splitting existing INT33FE driver allow to maintain code for USB Micro-B (AB) connector variant separately and make it simpler.
I didn't get what (AB) means in this context?
Did you mean "(or AB)"?
Quoted 3 lines
Split driver to
intel_cht_int33fe_common.cand intel_cht_int33fe_{typeb,typec}.c. Compile all this sources to one .ko module to make user experience easier.
You forgot to replace typeb here.
drivers/platform/x86/Kconfig config INTEL_CHT_INT33FE · line 929
Quoted 2 lines
drivers/platform/x86/Kconfig +1
-1- ---help--- + help
This is unneeded churn
drivers/platform/x86/Kconfig config INTEL_CHT_INT33FE · line 944
Quoted 2 lines
drivers/platform/x86/Kconfig +2
-0+ CONFIG_BATTERY_BQ27XXX=m and CONFIG_BATTERY_BQ27XXX_I2C=m for Micro-B + device and CONFIG_TYPEC_FUSB302=m and CONFIG_BATTERY_MAX17042=m
First s/and/or/.
Quoted 3 lines
+ for Type-C device.
+ * 1. The Whiskey Cove pmic, which is also described by the INT34D3 ACPI device
pmic -> PMIC
drivers/platform/x86/intel_cht_int33fe_microb.c line 59
Quoted 11 lines
drivers/platform/x86/intel_cht_int33fe_microb.c new file +11
-0+if (IS_ERR (data->battery_fg)) { +int err =PTR_ERR (data->battery_fg); + +if (err != -EPROBE_DEFER ) +dev_err (dev, +"Failed to register battery fuel gauge: %d\n" , + err); +return err; + } + +return 0 ;
I would rather replace this altogether by return PTR_ERR_OR_ZERO() like it's done in the other function in the original driver.
Signature · 2 lines
With Best Regards, Andy Shevchenko