Skip to contentSkip to conversation

i2c: designware: platdrv: Set class based on DMI

PATCH Applied Ricardo Ribalda 3 participants 3 messages Jul 2, 2020 – Jul 4, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 i2c: designware: platdrv: Set class based on DMI

Current AMD's zen-based APUs use this core for some of its i2c-buses.

With this patch we re-enable autodetection of hwmon-alike devices, so lm-sensors will be able to work automatically.

It does not affect the boot-time of embedded devices, as the class is set based on the DMI information.

DMI is probed only on Qtechnology QT5222 Industrial Camera Platform.

DocLink: https://qtec.com/camera-technology-camera-platforms/

Fixes 3eddad96c439 ("i2c: designware: reverts "i2c: designware: Add support for AMD I2C controller"")

---
v6: Removed extra line, sorry for the invalid v5

 drivers/i2c/busses/i2c-designware-platdrv.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-platdrv.c +14 -1
index c2efaaaac252..a71bc58fc03c 100644
@@ -12,6 +12,7 @@
 #include <linux/clk-provider.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/dmi.h>
 #include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/i2c.h>
@@ -191,6 +192,17 @@ static int dw_i2c_plat_request_regs(struct dw_i2c_dev *dev)
 	return ret;
 }
 
+static const struct dmi_system_id dw_i2c_hwmon_class_dmi[] = {
+	{
+		.ident = "Qtechnology QT5222",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Qtechnology"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "QT5222"),
+		},
+	},
+	{ } /* terminate list */
+};
+
 static int dw_i2c_plat_probe(struct platform_device *pdev)
 {
 	struct dw_i2c_platform_data *pdata = dev_get_platdata(&pdev->dev);
@@ -267,7 +279,8 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
 
 	adap = &dev->adapter;
 	adap->owner = THIS_MODULE;
-	adap->class = I2C_CLASS_DEPRECATED;
+	adap->class = dmi_check_system(dw_i2c_hwmon_class_dmi) ?
+					I2C_CLASS_HWMON : I2C_CLASS_DEPRECATED;
 	ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev));
 	adap->dev.of_node = pdev->dev.of_node;
 	adap->nr = -1;
Signature · 1 line
2.27.0
Acked-by on v6 1/1
#1 lore raw
Quoted 10 lines · Ricardo Ribalda

Current AMD's zen-based APUs use this core for some of its i2c-buses.

With this patch we re-enable autodetection of hwmon-alike devices, so lm-sensors will be able to work automatically.

It does not affect the boot-time of embedded devices, as the class is set based on the DMI information.

DMI is probed only on Qtechnology QT5222 Industrial Camera Platform.

Quoted 9 lines

DocLink: https://qtec.com/camera-technology-camera-platforms/

Fixes 3eddad96c439 ("i2c: designware: reverts "i2c: designware: Add support for AMD I2C controller"")

---
v6: Removed extra line, sorry for the invalid v5

  drivers/i2c/busses/i2c-designware-platdrv.c | 15 ++++++++++++++-
  1 file changed, 14 insertions(+), 1 deletion(-)
Applied
#2 lore raw
In reply to Ricardo Ribalda
Quoted 8 lines · Ricardo Ribalda

Current AMD's zen-based APUs use this core for some of its i2c-buses.

With this patch we re-enable autodetection of hwmon-alike devices, so lm-sensors will be able to work automatically.

It does not affect the boot-time of embedded devices, as the class is set based on the DMI information.

Quoted 6 lines

DMI is probed only on Qtechnology QT5222 Industrial Camera Platform.

DocLink: https://qtec.com/camera-technology-camera-platforms/

Fixes 3eddad96c439 ("i2c: designware: reverts "i2c: designware: Add support for AMD I2C controller"")

Applied to for-current, thanks!