linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] i2c: designware: platdrv: Set class based on dmi
@ 2020-07-02  9:38 Ricardo Ribalda
  2020-07-02  9:48 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Ricardo Ribalda @ 2020-07-02  9:38 UTC (permalink / raw)
  To: Jarkko Nikula, Andy Shevchenko, Mika Westerberg, linux-i2c,
	linux-kernel, Wolfram Sang
  Cc: 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
https://qtec.com/camera-technology-camera-platforms/

Fixes: 3eddad96c439 ("i2c: designware: reverts "i2c: designware: Add support for AMD I2C controller"")
Signed-off-by: Ricardo Ribalda <ribalda@kernel.org>
---

v3: Comment by Andy Shevchenko <andriy.shevchenko@linux.intel.com>
  - Add Fixes tag
  - Do not user strstr for dmidecode
  Comment by Jarkko Nikula <jarkko.nikula@linux.intel.com>
  - Use dmi_check_system()
 drivers/i2c/busses/i2c-designware-platdrv.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index c2efaaaac252..a9f2d416b7d1 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -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,18 @@ static int dw_i2c_plat_request_regs(struct dw_i2c_dev *dev)
 	return ret;
 }
 
+static const struct dmi_system_id allow_probe[] = {
+	{
+		.ident = "Qtechnology QT5222",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Qtechnology"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "QT5222")
+		}
+	},
+
+	{ }
+};
+
 static int dw_i2c_plat_probe(struct platform_device *pdev)
 {
 	struct dw_i2c_platform_data *pdata = dev_get_platdata(&pdev->dev);
@@ -267,7 +280,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(allow_probe) ?
+					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;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] i2c: designware: platdrv: Set class based on dmi
  2020-07-02  9:38 [PATCH v3] i2c: designware: platdrv: Set class based on dmi Ricardo Ribalda
@ 2020-07-02  9:48 ` Andy Shevchenko
  2020-07-02  9:49   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2020-07-02  9:48 UTC (permalink / raw)
  To: Ricardo Ribalda
  Cc: Jarkko Nikula, Mika Westerberg, linux-i2c, linux-kernel, Wolfram Sang

On Thu, Jul 02, 2020 at 11:38:32AM +0200, Ricardo Ribalda wrote:
> 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 -> DMI

> Dmi is probed only on Qtechnology QT5222 Industrial Camera Platform

Dmi -> DMI

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

Use DocLink: tag.

...

> +static const struct dmi_system_id allow_probe[] = {

allow_probe -> dw_i2c_hwmon_class_dmi

> +	{
> +		.ident = "Qtechnology QT5222",
> +		.matches = {
> +			DMI_MATCH(DMI_SYS_VENDOR, "Qtechnology"),

> +			DMI_MATCH(DMI_PRODUCT_NAME, "QT5222")

Comma is missed.

> +		}
> +	},

> +

Redundant.

> +	{ }
> +};

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] i2c: designware: platdrv: Set class based on dmi
  2020-07-02  9:48 ` Andy Shevchenko
@ 2020-07-02  9:49   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2020-07-02  9:49 UTC (permalink / raw)
  To: Ricardo Ribalda
  Cc: Jarkko Nikula, Mika Westerberg, linux-i2c, linux-kernel, Wolfram Sang

On Thu, Jul 02, 2020 at 12:48:08PM +0300, Andy Shevchenko wrote:
> On Thu, Jul 02, 2020 at 11:38:32AM +0200, Ricardo Ribalda wrote:
> > 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 -> DMI

...and in the Subject.

> > Dmi is probed only on Qtechnology QT5222 Industrial Camera Platform
> 
> Dmi -> DMI

...and period at the end of sentence.

> > https://qtec.com/camera-technology-camera-platforms/
> 
> Use DocLink: tag.
> 
> ...
> 
> > +static const struct dmi_system_id allow_probe[] = {
> 
> allow_probe -> dw_i2c_hwmon_class_dmi
> 
> > +	{
> > +		.ident = "Qtechnology QT5222",
> > +		.matches = {
> > +			DMI_MATCH(DMI_SYS_VENDOR, "Qtechnology"),
> 
> > +			DMI_MATCH(DMI_PRODUCT_NAME, "QT5222")
> 
> Comma is missed.
> 
> > +		}
> > +	},
> 
> > +
> 
> Redundant.
> 
> > +	{ }
> > +};
> 
> -- 
> With Best Regards,
> Andy Shevchenko
> 
> 

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-02  9:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-02  9:38 [PATCH v3] i2c: designware: platdrv: Set class based on dmi Ricardo Ribalda
2020-07-02  9:48 ` Andy Shevchenko
2020-07-02  9:49   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).