Skip to contentSkip to conversation

intel_cht_int33fe: Split code to USB TypeB and TypeC variants

PATCH Superseded Yauhen Kharuzhy 4 participants 11 messages Sep 17, 2019 – Sep 18, 2019 x86 platform drivers

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover intel_cht_int33fe: Split code to USB TypeB and TypeC variants

Patch to support INT33FE ACPI pseudo-device on hardware with USB Type B connector.

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 TypeB and TypeC
variants

 drivers/platform/x86/Kconfig                  |  14 +-
 drivers/platform/x86/Makefile                 |   4 +
 .../platform/x86/intel_cht_int33fe_common.c   | 148 ++++++++++++++++++
 .../platform/x86/intel_cht_int33fe_common.h   |  44 ++++++
 .../platform/x86/intel_cht_int33fe_typeb.c    |  64 ++++++++
 ...ht_int33fe.c => intel_cht_int33fe_typec.c} |  79 +---------
 6 files changed, 278 insertions(+), 75 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_typeb.c
 rename drivers/platform/x86/{intel_cht_int33fe.c => intel_cht_int33fe_typec.c} (83%)
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/1 platform/x86/intel_cht_int33fe: Split code to USB TypeB and TypeC variants

Existing intel_cht_int33fe ACPI pseudo-device driver assumes that hardware has TypeC 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 USB B 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 type 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 source to one .ko module to make user experience easier.

---
 drivers/platform/x86/Kconfig                  |  14 +-
 drivers/platform/x86/Makefile                 |   4 +
 .../platform/x86/intel_cht_int33fe_common.c   | 148 ++++++++++++++++++
 .../platform/x86/intel_cht_int33fe_common.h   |  44 ++++++
 .../platform/x86/intel_cht_int33fe_typeb.c    |  64 ++++++++
 ...ht_int33fe.c => intel_cht_int33fe_typec.c} |  79 +---------
 6 files changed, 278 insertions(+), 75 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_typeb.c
 rename drivers/platform/x86/{intel_cht_int33fe.c => intel_cht_int33fe_typec.c} (83%)
drivers/platform/x86/Kconfig +10 -4
index 1b67bb578f9f..c7ce3f17ca70 100644
@@ -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 TypeC and TypeB connectors. This driver supports both.
+
 	  The INT33FE ACPI device has a CRS table with I2cSerialBusV2
-	  resources for 3 devices: Maxim MAX17047 Fuel Gauge Controller,
-	  FUSB302 USB Type-C Controller and PI3USB30532 USB switch.
+	  resources for Fuel Gauge Controller and (in TypeC 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 TypeB
+	  device and CONFIG_TYPEC_FUSB302=m and CONFIG_BATTERY_MAX17042=m
+	  for TypeC device.
+
 
 config INTEL_INT0002_VGPIO
 	tristate "Intel ACPI INT0002 Virtual GPIO driver"
drivers/platform/x86/Makefile +4 -0
index 415104033060..f74664515d09 100644
@@ -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_typeb.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 +148 -0

148 lines not on this page · raw message

drivers/platform/x86/intel_cht_int33fe_common.h new file +44 -0

44 lines not on this page · raw message

drivers/platform/x86/intel_cht_int33fe_typeb.c new file +64 -0

64 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 -71

144 lines not on this page · raw message

Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH v2 1/1] platform/x86/intel_cht_int33fe: Split code to USB TypeB and TypeC variants

Hi,

Quoted 9 lines · Yauhen Kharuzhy

Existing intel_cht_int33fe ACPI pseudo-device driver assumes that hardware has TypeC 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 USB B connector exists. It has INT33FE device in the DSDT table but there are only two I2C connection described: PMIC and BQ27452 battery fuel gauge.

Quoted 8 lines

Splitting existing INT33FE driver allow to maintain code for USB type 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 source to one .ko module to make user experience easier.

Thank you for doing this, this version looks much better IMHO.

Note that this does not apply to Linus' current master, please rebase. Specifically this conflicts with this patch:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=78cd4bf53635d3aeb73435bc89eb6eb39450f315

Which just got merged. Instead of rebasing on Linus' master (which is always a bit adventurous to use during the merge window) you can also cherry-pick that single commit on top of v5.3 and use that as a base.

Note that that patch makes changes to struct cht_int33fe_data specifically it drops the:

	struct fwnode_handle *mux;

Member, so when rebasing you should drop that in the new version of the struct on common.h .

Besides that this need a rebase, overall this looks good, I have some small remarks inline:

<snip>

Quoted 101 lines
drivers/platform/x86/intel_cht_int33fe_common.c new file +95 -0
new file mode 100644
index 000000000000..4a3d7ebd37dd
@@ -0,0 +1,148 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Common code for Intel Cherry Trail ACPI INT33FE pseudo device drivers
+ * (USB TypeB and TypeC connector variants).
+ *
+ * Copyright (c) 2019 Yauhen Kharuzhy <[email protected]>
+ */
+
+#include <linux/acpi.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#include "intel_cht_int33fe_common.h"
+
+#define EXPECTED_PTYPE		4
+
+static int cht_int33fe_i2c_res_filter(struct acpi_resource *ares, void *data)
+{
+	struct acpi_resource_i2c_serialbus *sb;
+	int *count = data;
+
+	if (i2c_acpi_get_i2c_resource(ares, &sb))
+		(*count)++;
+
+	return 1;
+}
+
+static int cht_int33fe_count_i2c_clients(struct device *dev)
+{
+	struct acpi_device *adev;
+	LIST_HEAD(resource_list);
+	int count = 0;
+
+	adev = ACPI_COMPANION(dev);
+	if (!adev)
+		return -EINVAL;
+
+	acpi_dev_get_resources(adev, &resource_list,
+			       cht_int33fe_i2c_res_filter, &count);
+
+	acpi_dev_free_resource_list(&resource_list);
+
+	return count;
+}
+
+static int cht_int33fe_check_hw_type(struct device *dev)
+{
+	unsigned long long ptyp;
+	acpi_status status;
+	int ret;
+
+	status = acpi_evaluate_integer(ACPI_HANDLE(dev), "PTYP", NULL, &ptyp);
+	if (ACPI_FAILURE(status)) {
+		dev_err(dev, "Error getting PTYPE\n");
+		return -ENODEV;
+	}
+
+	/*
+	 * The same ACPI HID is used for different configurations check PTYP
+	 * to ensure that we are dealing with the expected config.
+	 */
+	if (ptyp != EXPECTED_PTYPE)
+		return -ENODEV;
+
+	/* Check presence of INT34D3 (hardware-rev 3) expected for ptype == 4 */
+	if (!acpi_dev_present("INT34D3", "1", 3)) {
+		dev_err(dev, "Error PTYPE == %d, but no INT34D3 device\n",
+			EXPECTED_PTYPE);
+		return -ENODEV;
+	}
+
+	ret = cht_int33fe_count_i2c_clients(dev);
+	if (ret < 0)
+		return ret;
+
+	switch (ret) {
+	case 2:
+		return INT33FE_HW_TYPEB;
+	case 4:
+		return INT33FE_HW_TYPEC;
+	default:
+		return -ENODEV;
+	}
+}
+
+static int cht_int33fe_probe(struct platform_device *pdev)
+{
+	struct cht_int33fe_data *data;
+	struct device *dev = &pdev->dev;
+	int ret;
+
+	ret = cht_int33fe_check_hw_type(dev);
+	if (ret < 0)

drivers/platform/x86/intel_cht_int33fe_common.c line 105

Quoted 10 lines
drivers/platform/x86/intel_cht_int33fe_common.c new file +10 -0
+		return ret;
+
+	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->hw_type = ret;
+	data->dev = dev;
+
+	switch (data->hw_type) {

I suggested adding hw_type to data so that it could be used to select the right remove function in cht_int33fe_remove(), since you are using a remove function pointer in data for this (which is fine), there is no reason to store hw_type in cht_int33fe_data anymore, please drop this and change the

	switch (data->hw_type) {

to:

	switch (ret) {
Quoted 22 lines
drivers/platform/x86/intel_cht_int33fe_common.c new file +22 -0
+	case INT33FE_HW_TYPEB:
+		data->probe = cht_int33fe_typeb_probe;
+		data->remove = cht_int33fe_typeb_remove;
+		break;
+
+	case INT33FE_HW_TYPEC:
+		data->probe = cht_int33fe_typec_probe;
+		data->remove = cht_int33fe_typec_remove;
+		break;
+	}
+
+	platform_set_drvdata(pdev, data);
+
+	return data->probe(data);
+}
+
+static int cht_int33fe_remove(struct platform_device *pdev)
+{
+	struct cht_int33fe_data *data = platform_get_drvdata(pdev);
+
+	return data->remove(data);
+}

<snip>

Quoted 6 lines
drivers/platform/x86/intel_cht_int33fe_common.h new file +0 -0
new file mode 100644
index 000000000000..cb0cc4552017
@@ -0,0 +1,44 @@

<snip>

drivers/platform/x86/intel_cht_int33fe_common.h line 44

Quoted 4 lines
drivers/platform/x86/intel_cht_int33fe_common.h new file +4 -0
+int cht_int33fe_typec_remove(struct cht_int33fe_data *data);
+
+#endif /* _INTEL_CHT_INT33FE_COMMON_H */
+

Please drop the empty line at the end of intel_cht_int33fe_common.h .

Quoted 6 lines
drivers/platform/x86/intel_cht_int33fe_typeb.c new file +0 -0
new file mode 100644
index 000000000000..905c29f2f714
@@ -0,0 +1,64 @@

<snip>

drivers/platform/x86/intel_cht_int33fe_typec.c

Quoted 8 lines
drivers/platform/x86/intel_cht_int33fe_typeb.c new file +7 -0
+int cht_int33fe_typeb_remove(struct cht_int33fe_data *data)
+{
+	i2c_unregister_device(data->battery_fg);
+
+	return 0;
+}
+
drivers/platform/x86/intel_cht_int33fe_typec.c renamed from drivers/platform/x86/intel_cht_int33fe.c +0 -0

Please drop the empty line at the end of intel_cht_int33fe_typeb.c .

Regards,

Hans

p.s.

I've done the rebase myself and I'm building a kernel with my re-based version of this patch to test it on a typec device. I will get back to you with the results (I expect things will just work, just making sure).

#3 lore raw

Re: [PATCH v2 1/1] platform/x86/intel_cht_int33fe: Split code to USB TypeB and TypeC variants

Quoted 36 lines · Hans de Goede

Hi,

Quoted 9 lines · Yauhen Kharuzhy

Existing intel_cht_int33fe ACPI pseudo-device driver assumes that hardware has TypeC 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 USB B connector exists. It has INT33FE device in the DSDT table but there are only two I2C connection described: PMIC and BQ27452 battery fuel gauge.

Quoted 8 lines

Splitting existing INT33FE driver allow to maintain code for USB type 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 source to one .ko module to make user experience easier.

Thank you for doing this, this version looks much better IMHO.

Note that this does not apply to Linus' current master, please rebase. Specifically this conflicts with this patch:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=78cd4bf53635d3aeb73435bc89eb6eb39450f315

Which just got merged. Instead of rebasing on Linus' master (which is always a bit adventurous to use during the merge window) you can also cherry-pick that single commit on top of v5.3 and use that as a base.

Note that that patch makes changes to struct cht_int33fe_data specifically it drops the:

Quoted 7 lines
	struct fwnode_handle *mux;

Member, so when rebasing you should drop that in the new version of the struct on common.h .

Besides that this need a rebase, overall this looks good, I have some small remarks inline:

Arghh.. OK, I have rebased the patch but at current torvalds kernel i2c_acpi_new_device() fails with -EPROBE_DEFER at my hw, so I cannot check if it is fully working. But I will resend patch anyway soon, this error should not be related to the patch content.

Quoted 11 lines

drivers/platform/x86/intel_cht_int33fe_common.c line 105

Quoted 4 lines
drivers/platform/x86/intel_cht_int33fe_common.c new file +4 -0
+	data->hw_type = ret;
+	data->dev = dev;
+
+	switch (data->hw_type) {

I suggested adding hw_type to data so that it could be used to select the right remove function in cht_int33fe_remove(), since you are using a remove function pointer in data for this (which is fine), there is no reason to store hw_type in cht_int33fe_data anymore, please drop this and change the

Quoted 5 lines
	switch (data->hw_type) {

to:

	switch (ret) {

OK, sure

Quoted 7 lines

p.s.

I've done the rebase myself and I'm building a kernel with my re-based version of this patch to test it on a typec device. I will get back to you with the results (I expect things will just work, just making sure).

Signature · 1 line
Yauhen Kharuzhy
#4 lore raw

Re: [PATCH v2 1/1] platform/x86/intel_cht_int33fe: Split code to USB TypeB and TypeC variants

Hi,

Quoted 42 lines · Yauhen Kharuzhy
Quoted 41 lines · Hans de Goede

Hi,

Quoted 9 lines · Yauhen Kharuzhy

Existing intel_cht_int33fe ACPI pseudo-device driver assumes that hardware has TypeC 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 USB B connector exists. It has INT33FE device in the DSDT table but there are only two I2C connection described: PMIC and BQ27452 battery fuel gauge.

Quoted 8 lines

Splitting existing INT33FE driver allow to maintain code for USB type 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 source to one .ko module to make user experience easier.

Thank you for doing this, this version looks much better IMHO.

Note that this does not apply to Linus' current master, please rebase. Specifically this conflicts with this patch:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=78cd4bf53635d3aeb73435bc89eb6eb39450f315

Which just got merged. Instead of rebasing on Linus' master (which is always a bit adventurous to use during the merge window) you can also cherry-pick that single commit on top of v5.3 and use that as a base.

Note that that patch makes changes to struct cht_int33fe_data specifically it drops the:

	struct fwnode_handle *mux;

Member, so when rebasing you should drop that in the new version of the struct on common.h .

Quoted 7 lines
Quoted 2 lines

Besides that this need a rebase, overall this looks good, I have some small remarks inline:

Arghh.. OK, I have rebased the patch but at current torvalds kernel i2c_acpi_new_device() fails with -EPROBE_DEFER at my hw, so I cannot check if it is fully working. But I will resend patch anyway soon, this error should not be related to the patch content.

Are you sure it is not working? -EPROBE_DEFER is normal(ish) it just means that the i2c-controller driver for the bus has not initialized yet.

If you are building the i2c_designware or acpi_lpss drivers as module, or if you are building the intel_cht_int33fe code into the kernel, then this is more or less expected to happen.

You can do "ls /sys/bus/i2c/devices" to check if it did succeed on later re-probe attempts (the fuel-gauge device should be there if things succeeded).

And you should probably do one more version, suppressing the dev_err on -EPROBE_DEFER like e.g. this snippet from the typec code:

        if (fusb302_irq < 0) {
                if (fusb302_irq != -EPROBE_DEFER)
                        dev_err(dev, "Error getting FUSB302 irq\n");
                return fusb302_irq;
        }

Regards,

Hans

Quoted 28 lines
Quoted 12 lines

drivers/platform/x86/intel_cht_int33fe_common.c line 105

Quoted 5 lines
drivers/platform/x86/intel_cht_int33fe_common.c new file +4 -0
+	data->hw_type = ret;
+	data->dev = dev;
+
+	switch (data->hw_type) {

I suggested adding hw_type to data so that it could be used to select the right remove function in cht_int33fe_remove(), since you are using a remove function pointer in data for this (which is fine), there is no reason to store hw_type in cht_int33fe_data anymore, please drop this and change the

Quoted 5 lines
	switch (data->hw_type) {

to:

	switch (ret) {

OK, sure

Quoted 7 lines

p.s.

I've done the rebase myself and I'm building a kernel with my re-based version of this patch to test it on a typec device. I will get back to you with the results (I expect things will just work, just making sure).

#5 lore raw

Re: [PATCH v2 1/1] platform/x86/intel_cht_int33fe: Split code to USB TypeB and TypeC variants

Quoted 53 lines · Hans de Goede

Hi,

Quoted 42 lines · Yauhen Kharuzhy
Quoted 41 lines · Hans de Goede

Hi,

Quoted 9 lines · Yauhen Kharuzhy

Existing intel_cht_int33fe ACPI pseudo-device driver assumes that hardware has TypeC 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 USB B connector exists. It has INT33FE device in the DSDT table but there are only two I2C connection described: PMIC and BQ27452 battery fuel gauge.

Quoted 8 lines

Splitting existing INT33FE driver allow to maintain code for USB type 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 source to one .ko module to make user experience easier.

Thank you for doing this, this version looks much better IMHO.

Note that this does not apply to Linus' current master, please rebase. Specifically this conflicts with this patch:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=78cd4bf53635d3aeb73435bc89eb6eb39450f315

Which just got merged. Instead of rebasing on Linus' master (which is always a bit adventurous to use during the merge window) you can also cherry-pick that single commit on top of v5.3 and use that as a base.

Note that that patch makes changes to struct cht_int33fe_data specifically it drops the:

	struct fwnode_handle *mux;

Member, so when rebasing you should drop that in the new version of the struct on common.h .

Quoted 7 lines
Quoted 2 lines

Besides that this need a rebase, overall this looks good, I have some small remarks inline:

Arghh.. OK, I have rebased the patch but at current torvalds kernel i2c_acpi_new_device() fails with -EPROBE_DEFER at my hw, so I cannot check if it is fully working. But I will resend patch anyway soon, this error should not be related to the patch content.

Quoted 6 lines

Are you sure it is not working? -EPROBE_DEFER is normal(ish) it just means that the i2c-controller driver for the bus has not initialized yet.

If you are building the i2c_designware or acpi_lpss drivers as module, or if you are building the intel_cht_int33fe code into the kernel, then this is more or less expected to happen.

I would agree but i2cdetect/i2cget works for this bus as expected. I
remember that I met this bug at one of previous iterations, hm... As I remember
it was caused by this commit:
00500147cbd3fc51353d0d003eaa9d31c72c0d50 drivers: Introduce device lookup variants by ACPI_COMPANION device.

This needs to be investigated.

Quoted 6 lines

You can do "ls /sys/bus/i2c/devices" to check if it did succeed on later re-probe attempts (the fuel-gauge device should be there if things succeeded).

And you should probably do one more version, suppressing the dev_err on -EPROBE_DEFER like e.g. this snippet from the typec code:

OK, -EPROBE_DEFER was unexpected here for me...

Signature · 1 line
Yauhen Kharuzhy
#6 lore raw

Re: [PATCH v2 1/1] platform/x86/intel_cht_int33fe: Split code to USB TypeB and TypeC variants

Quoted 61 lines · Yauhen Kharuzhy
Quoted 53 lines · Hans de Goede

Hi,

Quoted 42 lines · Yauhen Kharuzhy
Quoted 41 lines · Hans de Goede

Hi,

Quoted 9 lines · Yauhen Kharuzhy

Existing intel_cht_int33fe ACPI pseudo-device driver assumes that hardware has TypeC 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 USB B connector exists. It has INT33FE device in the DSDT table but there are only two I2C connection described: PMIC and BQ27452 battery fuel gauge.

Quoted 8 lines

Splitting existing INT33FE driver allow to maintain code for USB type 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 source to one .ko module to make user experience easier.

Thank you for doing this, this version looks much better IMHO.

Note that this does not apply to Linus' current master, please rebase. Specifically this conflicts with this patch:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=78cd4bf53635d3aeb73435bc89eb6eb39450f315

Which just got merged. Instead of rebasing on Linus' master (which is always a bit adventurous to use during the merge window) you can also cherry-pick that single commit on top of v5.3 and use that as a base.

Note that that patch makes changes to struct cht_int33fe_data specifically it drops the:

	struct fwnode_handle *mux;

Member, so when rebasing you should drop that in the new version of the struct on common.h .

Quoted 7 lines
Quoted 2 lines

Besides that this need a rebase, overall this looks good, I have some small remarks inline:

Arghh.. OK, I have rebased the patch but at current torvalds kernel i2c_acpi_new_device() fails with -EPROBE_DEFER at my hw, so I cannot check if it is fully working. But I will resend patch anyway soon, this error should not be related to the patch content.

Quoted 6 lines

Are you sure it is not working? -EPROBE_DEFER is normal(ish) it just means that the i2c-controller driver for the bus has not initialized yet.

If you are building the i2c_designware or acpi_lpss drivers as module, or if you are building the intel_cht_int33fe code into the kernel, then this is more or less expected to happen.

Quoted 6 lines

I would agree but i2cdetect/i2cget works for this bus as expected. I
remember that I met this bug at one of previous iterations, hm... As I remember
it was caused by this commit:
00500147cbd3fc51353d0d003eaa9d31c72c0d50 drivers: Introduce device lookup variants by ACPI_COMPANION device.

This needs to be investigated.

It was reverted by commit merged today, so it is not an issue anymore:

commit 644bf60088955421051e716ab9c8fe7fb7997fd7

Author: Suzuki K Poulose <[email protected]>
Date:   Thu Aug 1 11:20:24 2019 +0100

i2c: Revert incorrect conversion to use generic helper

Quoted 13 lines
Quoted 6 lines

You can do "ls /sys/bus/i2c/devices" to check if it did succeed on later re-probe attempts (the fuel-gauge device should be there if things succeeded).

And you should probably do one more version, suppressing the dev_err on -EPROBE_DEFER like e.g. this snippet from the typec code:

OK, -EPROBE_DEFER was unexpected here for me...

Signature · 1 line
Yauhen Kharuzhy
Signature · 1 line
Yauhen Kharuzhy
#7 lore raw

Re: [PATCH v2 1/1] platform/x86/intel_cht_int33fe: Split code to USB TypeB and TypeC variants

In reply to Yauhen Kharuzhy
Quoted 11 lines · Yauhen Kharuzhy

Existing intel_cht_int33fe ACPI pseudo-device driver assumes that hardware has TypeC 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 USB B 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 type B (AB) connector variant separately and make it simpler.

Sorry, but "Type B" is even more confusing here. Type B refers to the Standard-B USB connector, so _not_ the micro connector family. You can check the connector definitions from the latest USB 3.2 specification. The standard-b definition goes something like this:

"The standard _Type-B_ connector defined by the USB x specification."

Note that all the five supported connectors are listed in ch5 "Mechanical":

Standard-A
Standard-B
Micro-B
Micro-AB
Type-C

So what was the problem with names that refer to the micro connector family, for example "micro-ab" or "micro-b"?

thanks,

Signature · 1 line
heikki
#8 lore raw

Re: [PATCH v2 1/1] platform/x86/intel_cht_int33fe: Split code to USB TypeB and TypeC variants

Quoted 23 lines · Heikki Krogerus
Quoted 11 lines · Yauhen Kharuzhy

Existing intel_cht_int33fe ACPI pseudo-device driver assumes that hardware has TypeC 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 USB B 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 type B (AB) connector variant separately and make it simpler.

Sorry, but "Type B" is even more confusing here. Type B refers to the Standard-B USB connector, so _not_ the micro connector family. You can check the connector definitions from the latest USB 3.2 specification. The standard-b definition goes something like this:

"The standard _Type-B_ connector defined by the USB x specification."

Note that all the five supported connectors are listed in ch5 "Mechanical":

Quoted 8 lines

Standard-A
Standard-B
Micro-B
Micro-AB
Type-C

So what was the problem with names that refer to the micro connector family, for example "micro-ab" or "micro-b"?

Only one problem: there is no difference between micro B, micro AB, mini B or Standard-B types of connectors from this driver point of view – all of them can be used for device charging. Now we have only two kind of hardware with INT33FE pseudo-device: with Micro-B and Type-C connectors but other kind may exist. TypeB is not standartized but it seemed to me a good generalization of "USB connectors to charger connection but not Type-C". No problem to change it to other suitable name, 'simple', 'dumb', 'non-TypeC' or 'micro-B'. All this names are not ideal.

Signature · 1 line
Yauhen Kharuzhy
#9 lore raw

Re: [PATCH v2 1/1] platform/x86/intel_cht_int33fe: Split code to USB TypeB and TypeC variants

Hi,

Quoted 33 lines · Yauhen Kharuzhy
Quoted 23 lines · Heikki Krogerus
Quoted 11 lines · Yauhen Kharuzhy

Existing intel_cht_int33fe ACPI pseudo-device driver assumes that hardware has TypeC 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 USB B 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 type B (AB) connector variant separately and make it simpler.

Sorry, but "Type B" is even more confusing here. Type B refers to the Standard-B USB connector, so _not_ the micro connector family. You can check the connector definitions from the latest USB 3.2 specification. The standard-b definition goes something like this:

"The standard _Type-B_ connector defined by the USB x specification."

Note that all the five supported connectors are listed in ch5 "Mechanical":

Quoted 8 lines

Standard-A
Standard-B
Micro-B
Micro-AB
Type-C

So what was the problem with names that refer to the micro connector family, for example "micro-ab" or "micro-b"?

Quoted 8 lines

Only one problem: there is no difference between micro B, micro AB, mini B or Standard-B types of connectors from this driver point of view – all of them can be used for device charging. Now we have only two kind of hardware with INT33FE pseudo-device: with Micro-B and Type-C connectors but other kind may exist. TypeB is not standartized but it seemed to me a good generalization of "USB connectors to charger connection but not Type-C". No problem to change it to other suitable name, 'simple', 'dumb', 'non-TypeC' or 'micro-B'. All this names are not ideal.

Since the one non Type-C connector device we has has a micro-B I would just call the file drivers/platform/x86/intel_cht_int33fe_microb.c and be done with it.

Regards,

Hans

#10 lore raw

Re: [PATCH v2 1/1] platform/x86/intel_cht_int33fe: Split code to USB TypeB and TypeC variants

In reply to Yauhen Kharuzhy
Quoted 10 lines · Yauhen Kharuzhy

Existing intel_cht_int33fe ACPI pseudo-device driver assumes that hardware has TypeC 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 USB B connector exists. It has INT33FE device in the DSDT table but there are only two I2C connection described: PMIC and BQ27452 battery fuel gauge.

Quoted 6 lines

Splitting existing INT33FE driver allow to maintain code for USB type 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 source to one .ko module to make user experience easier.

Before sending new version also check that you spell correctly "Type-C" everywhere (except variable / function names).

Signature · 2 lines
With Best Regards,
Andy Shevchenko