linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] iio: adc128s052: add matching options
@ 2018-04-23 21:38 Javier Arteaga
  2018-04-23 21:38 ` [PATCH v2 1/3] iio: adc128s052: Add pin-compatible IDs Javier Arteaga
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Javier Arteaga @ 2018-04-23 21:38 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Javier Arteaga, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dan O'Donovan, linux-iio,
	linux-kernel

Hi all,

On some SKUs of AAEON's UP Squared board, there is an ADC124S101
enumerated via ACPI. This is a pin-compatible variant of ADC124S021,
which is already supported by the adc128s052 driver.

This patchset adds missing DT compatible strings for ADC124S021 (and
ADC122S021) variants, adds AAEON's allocated ACPI HID, and allows ACPI
_DSD based matching.

v1 was posted at:
https://lkml.kernel.org/r/20180419132036.27493-1-javier@emutex.com

Changes from v1:
* Improved patch descriptions and series title
* Added an initial commit introducing new compatible strings
  (as per Jonathan's suggestion)
* Moved of_match_ptr removal last as this patch is less important to us

Dan O'Donovan (1):
  iio: adc128s052: reuse "compatible" for ACPI _DSD

Javier Arteaga (1):
  iio: adc128s052: Add pin-compatible IDs

Nicola Lunghi (1):
  iio: adc128s052: add ACPI _HID AANT1280

 drivers/iio/adc/ti-adc128s052.c | 43 ++++++++++++++++++++++++++++-----
 1 file changed, 37 insertions(+), 6 deletions(-)

-- 
2.17.0

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

* [PATCH v2 1/3] iio: adc128s052: Add pin-compatible IDs
  2018-04-23 21:38 [PATCH v2 0/3] iio: adc128s052: add matching options Javier Arteaga
@ 2018-04-23 21:38 ` Javier Arteaga
  2018-04-23 21:38 ` [PATCH v2 2/3] iio: adc128s052: add ACPI _HID AANT1280 Javier Arteaga
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 20+ messages in thread
From: Javier Arteaga @ 2018-04-23 21:38 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Javier Arteaga, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dan O'Donovan, linux-iio,
	linux-kernel

The datasheets for ADC122S021 and ADC124S021 list two more
pin-compatible alternatives for each device.

Add their IDs as compatible strings.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Javier Arteaga <javier@emutex.com>
---
 drivers/iio/adc/ti-adc128s052.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
index 7cf39b3e2416..e6716c326c5e 100644
--- a/drivers/iio/adc/ti-adc128s052.c
+++ b/drivers/iio/adc/ti-adc128s052.c
@@ -186,15 +186,23 @@ static int adc128_remove(struct spi_device *spi)
 static const struct of_device_id adc128_of_match[] = {
 	{ .compatible = "ti,adc128s052", },
 	{ .compatible = "ti,adc122s021", },
+	{ .compatible = "ti,adc122s051", },
+	{ .compatible = "ti,adc122s101", },
 	{ .compatible = "ti,adc124s021", },
-	{ /* sentinel */ },
+	{ .compatible = "ti,adc124s051", },
+	{ .compatible = "ti,adc124s101", },
+	{ }
 };
 MODULE_DEVICE_TABLE(of, adc128_of_match);
 
 static const struct spi_device_id adc128_id[] = {
-	{ "adc128s052", 0},	/* index into adc128_config */
-	{ "adc122s021",	1},
-	{ "adc124s021", 2},
+	{ "adc128s052", 0 },	/* index into adc128_config */
+	{ "adc122s021",	1 },
+	{ "adc122s051",	1 },
+	{ "adc122s101",	1 },
+	{ "adc124s021", 2 },
+	{ "adc124s051", 2 },
+	{ "adc124s101", 2 },
 	{ }
 };
 MODULE_DEVICE_TABLE(spi, adc128_id);
-- 
2.17.0

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

* [PATCH v2 2/3] iio: adc128s052: add ACPI _HID AANT1280
  2018-04-23 21:38 [PATCH v2 0/3] iio: adc128s052: add matching options Javier Arteaga
  2018-04-23 21:38 ` [PATCH v2 1/3] iio: adc128s052: Add pin-compatible IDs Javier Arteaga
@ 2018-04-23 21:38 ` Javier Arteaga
  2018-04-23 22:08   ` Andy Shevchenko
  2018-04-23 21:38 ` [PATCH v2 3/3] iio: adc128s052: reuse "compatible" for ACPI _DSD Javier Arteaga
  2018-10-25 15:35 ` [PATCH v3 0/3] iio: adc128s052: add matching options Dan O'Donovan
  3 siblings, 1 reply; 20+ messages in thread
From: Javier Arteaga @ 2018-04-23 21:38 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Javier Arteaga, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dan O'Donovan, linux-iio,
	linux-kernel, Nicola Lunghi

From: Nicola Lunghi <nicola.lunghi@emutex.com>

ACPI _HID AANT1280 matches an ADC124S101 present on E3940 SKUs of the UP
Squared board.

Add it to the driver.

Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
[javier@emutex.com: fix up commit message and one checkpatch warning]
Signed-off-by: Javier Arteaga <javier@emutex.com>
---
 drivers/iio/adc/ti-adc128s052.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
index e6716c326c5e..bc5096e98900 100644
--- a/drivers/iio/adc/ti-adc128s052.c
+++ b/drivers/iio/adc/ti-adc128s052.c
@@ -12,6 +12,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/acpi.h>
 #include <linux/err.h>
 #include <linux/spi/spi.h>
 #include <linux/module.h>
@@ -136,9 +137,22 @@ static int adc128_probe(struct spi_device *spi)
 {
 	struct iio_dev *indio_dev;
 	struct adc128 *adc;
-	int config = spi_get_device_id(spi)->driver_data;
+	int config;
 	int ret;
 
+	if (ACPI_COMPANION(&spi->dev)) {
+		const struct acpi_device_id *ad_id;
+
+		ad_id = acpi_match_device(spi->dev.driver->acpi_match_table,
+					  &spi->dev);
+		if (!ad_id)
+			return -ENODEV;
+
+		config = ad_id->driver_data;
+	} else {
+		config = spi_get_device_id(spi)->driver_data;
+	}
+
 	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc));
 	if (!indio_dev)
 		return -ENOMEM;
@@ -207,10 +221,19 @@ static const struct spi_device_id adc128_id[] = {
 };
 MODULE_DEVICE_TABLE(spi, adc128_id);
 
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id adc128_acpi_match[] = {
+	{ "AANT1280", 2 }, /* ADC124S021 compatible ACPI ID */
+	{ }
+};
+MODULE_DEVICE_TABLE(acpi, adc128_acpi_match);
+#endif
+
 static struct spi_driver adc128_driver = {
 	.driver = {
 		.name = "adc128s052",
 		.of_match_table = of_match_ptr(adc128_of_match),
+		.acpi_match_table = ACPI_PTR(adc128_acpi_match),
 	},
 	.probe = adc128_probe,
 	.remove = adc128_remove,
-- 
2.17.0

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

* [PATCH v2 3/3] iio: adc128s052: reuse "compatible" for ACPI _DSD
  2018-04-23 21:38 [PATCH v2 0/3] iio: adc128s052: add matching options Javier Arteaga
  2018-04-23 21:38 ` [PATCH v2 1/3] iio: adc128s052: Add pin-compatible IDs Javier Arteaga
  2018-04-23 21:38 ` [PATCH v2 2/3] iio: adc128s052: add ACPI _HID AANT1280 Javier Arteaga
@ 2018-04-23 21:38 ` Javier Arteaga
  2018-10-25 15:35 ` [PATCH v3 0/3] iio: adc128s052: add matching options Dan O'Donovan
  3 siblings, 0 replies; 20+ messages in thread
From: Javier Arteaga @ 2018-04-23 21:38 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Javier Arteaga, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dan O'Donovan, linux-iio,
	linux-kernel

From: Dan O'Donovan <dan@emutex.com>

Allow this driver to be ACPI matched by DT compatible string (through
_DSD properties) when CONFIG_OF is disabled.

Signed-off-by: Dan O'Donovan <dan@emutex.com>
[javier@emutex.com: edited the patch title and description]
Signed-off-by: Javier Arteaga <javier@emutex.com>
---
 drivers/iio/adc/ti-adc128s052.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
index bc5096e98900..c823929db784 100644
--- a/drivers/iio/adc/ti-adc128s052.c
+++ b/drivers/iio/adc/ti-adc128s052.c
@@ -232,7 +232,7 @@ MODULE_DEVICE_TABLE(acpi, adc128_acpi_match);
 static struct spi_driver adc128_driver = {
 	.driver = {
 		.name = "adc128s052",
-		.of_match_table = of_match_ptr(adc128_of_match),
+		.of_match_table = adc128_of_match,
 		.acpi_match_table = ACPI_PTR(adc128_acpi_match),
 	},
 	.probe = adc128_probe,
-- 
2.17.0

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

* Re: [PATCH v2 2/3] iio: adc128s052: add ACPI _HID AANT1280
  2018-04-23 21:38 ` [PATCH v2 2/3] iio: adc128s052: add ACPI _HID AANT1280 Javier Arteaga
@ 2018-04-23 22:08   ` Andy Shevchenko
  2018-04-24 10:51     ` Javier Arteaga
  0 siblings, 1 reply; 20+ messages in thread
From: Andy Shevchenko @ 2018-04-23 22:08 UTC (permalink / raw)
  To: Javier Arteaga
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dan O'Donovan, linux-iio,
	Linux Kernel Mailing List, Nicola Lunghi

On Tue, Apr 24, 2018 at 12:38 AM, Javier Arteaga <javier@emutex.com> wrote:
> From: Nicola Lunghi <nicola.lunghi@emutex.com>
>
> ACPI _HID AANT1280 matches an ADC124S101 present on E3940 SKUs of the UP
> Squared board.
>
> Add it to the driver.

> +       if (ACPI_COMPANION(&spi->dev)) {

> +               const struct acpi_device_id *ad_id;
> +
> +               ad_id = acpi_match_device(spi->dev.driver->acpi_match_table,
> +                                         &spi->dev);
> +               if (!ad_id)
> +                       return -ENODEV;
> +
> +               config = ad_id->driver_data;

There is a new API to get it by one call.
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git/commit/?id=b283f157611f129f5bbbf7d06f5af860d76797fd

> +       } else {
> +               config = spi_get_device_id(spi)->driver_data;
> +       }

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH v2 2/3] iio: adc128s052: add ACPI _HID AANT1280
  2018-04-23 22:08   ` Andy Shevchenko
@ 2018-04-24 10:51     ` Javier Arteaga
  0 siblings, 0 replies; 20+ messages in thread
From: Javier Arteaga @ 2018-04-24 10:51 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dan O'Donovan, linux-iio,
	Linux Kernel Mailing List, Nicola Lunghi

Hi Andy,

On Tue, Apr 24, 2018 at 01:08:31AM +0300, Andy Shevchenko wrote:
> > +       if (ACPI_COMPANION(&spi->dev)) {
> 
> > +               const struct acpi_device_id *ad_id;
> > +
> > +               ad_id = acpi_match_device(spi->dev.driver->acpi_match_table,
> > +                                         &spi->dev);
> > +               if (!ad_id)
> > +                       return -ENODEV;
> > +
> > +               config = ad_id->driver_data;
> 
> There is a new API to get it by one call.
> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git/commit/?id=b283f157611f129f5bbbf7d06f5af860d76797fd

That looks much cleaner. Will do for a v3.

Thank you!

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

* [PATCH v3 0/3] iio: adc128s052: add matching options
  2018-04-23 21:38 [PATCH v2 0/3] iio: adc128s052: add matching options Javier Arteaga
                   ` (2 preceding siblings ...)
  2018-04-23 21:38 ` [PATCH v2 3/3] iio: adc128s052: reuse "compatible" for ACPI _DSD Javier Arteaga
@ 2018-10-25 15:35 ` Dan O'Donovan
  2018-10-25 15:35   ` [PATCH v3 1/3] iio: adc128s052: Add pin-compatible IDs Dan O'Donovan
                     ` (3 more replies)
  3 siblings, 4 replies; 20+ messages in thread
From: Dan O'Donovan @ 2018-10-25 15:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andy Shevchenko, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
	Rob Herring, Mark Rutland, devicetree, Carlos Iglesias,
	Dan O'Donovan

Hi all,

On some SKUs of AAEON's UP Squared board, there is an ADC124S101
enumerated via ACPI. This is a pin-compatible variant of ADC124S021,
which is already supported by the adc128s052 driver.

This patchset adds missing DT compatible strings for ADC124S021 (and
ADC122S021) variants, adds AAEON's allocated ACPI HID, and adds the
SPDX GPL identifier to the driver.

v2 was posted at:
https://lore.kernel.org/lkml/20180423213805.12591-1-javier@emutex.com/

Changes from v2:
* Added device-tree bindings documentation for new chip variants
* Simplified code to get ACPI match data
* Dropped redundant patch to facilitate OF matching via ACPI _DSD
* Added patch to replace GPL license text with SPDX identifier

Changes from v1:
* Improved patch descriptions and series title
* Added an initial commit introducing new compatible strings
  (as per Jonathan's suggestion)
* Moved of_match_ptr removal last as this patch is less important to us

Dan O'Donovan (1):
  iio: adc128s052: use SPDX-License-Identifier

Javier Arteaga (1):
  iio: adc128s052: Add pin-compatible IDs

Nicola Lunghi (1):
  iio: adc128s052: add ACPI _HID AANT1280

 .../devicetree/bindings/iio/adc/ti-adc128s052.txt  |  9 ++++-
 drivers/iio/adc/ti-adc128s052.c                    | 39 +++++++++++++++++-----
 2 files changed, 38 insertions(+), 10 deletions(-)

-- 
2.7.4


------
This email has been scanned for spam and malware by The Email Laundry.


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

* [PATCH v3 1/3] iio: adc128s052: Add pin-compatible IDs
  2018-10-25 15:35 ` [PATCH v3 0/3] iio: adc128s052: add matching options Dan O'Donovan
@ 2018-10-25 15:35   ` Dan O'Donovan
  2018-10-28 15:35     ` Jonathan Cameron
  2018-10-30 19:37     ` Rob Herring
  2018-10-25 15:35   ` [PATCH v3 2/3] iio: adc128s052: add ACPI _HID AANT1280 Dan O'Donovan
                     ` (2 subsequent siblings)
  3 siblings, 2 replies; 20+ messages in thread
From: Dan O'Donovan @ 2018-10-25 15:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andy Shevchenko, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
	Rob Herring, Mark Rutland, devicetree, Carlos Iglesias,
	Javier Arteaga, Dan O'Donovan

From: Javier Arteaga <javier@emutex.com>

The datasheets for ADC122S021 and ADC124S021 list two more
pin-compatible alternatives for each device.

Add their IDs as compatible strings.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Javier Arteaga <javier@emutex.com>
Signed-off-by: Dan O'Donovan <dan@emutex.com>
---
 .../devicetree/bindings/iio/adc/ti-adc128s052.txt        |  9 ++++++++-
 drivers/iio/adc/ti-adc128s052.c                          | 16 ++++++++++++----
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt b/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt
index daa2b2c..c07ce1a 100644
--- a/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt
+++ b/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt
@@ -1,7 +1,14 @@
 * Texas Instruments' ADC128S052, ADC122S021 and ADC124S021 ADC chip
 
 Required properties:
- - compatible: Should be "ti,adc128s052", "ti,adc122s021" or "ti,adc124s021"
+ - compatible: Should be one of:
+   - "ti,adc128s052"
+   - "ti,adc122s021"
+   - "ti,adc122s051"
+   - "ti,adc122s101"
+   - "ti,adc124s021"
+   - "ti,adc124s051"
+   - "ti,adc124s101"
  - reg: spi chip select number for the device
  - vref-supply: The regulator supply for ADC reference voltage
 
diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
index 7cf39b3..e6716c3 100644
--- a/drivers/iio/adc/ti-adc128s052.c
+++ b/drivers/iio/adc/ti-adc128s052.c
@@ -186,15 +186,23 @@ static int adc128_remove(struct spi_device *spi)
 static const struct of_device_id adc128_of_match[] = {
 	{ .compatible = "ti,adc128s052", },
 	{ .compatible = "ti,adc122s021", },
+	{ .compatible = "ti,adc122s051", },
+	{ .compatible = "ti,adc122s101", },
 	{ .compatible = "ti,adc124s021", },
-	{ /* sentinel */ },
+	{ .compatible = "ti,adc124s051", },
+	{ .compatible = "ti,adc124s101", },
+	{ }
 };
 MODULE_DEVICE_TABLE(of, adc128_of_match);
 
 static const struct spi_device_id adc128_id[] = {
-	{ "adc128s052", 0},	/* index into adc128_config */
-	{ "adc122s021",	1},
-	{ "adc124s021", 2},
+	{ "adc128s052", 0 },	/* index into adc128_config */
+	{ "adc122s021",	1 },
+	{ "adc122s051",	1 },
+	{ "adc122s101",	1 },
+	{ "adc124s021", 2 },
+	{ "adc124s051", 2 },
+	{ "adc124s101", 2 },
 	{ }
 };
 MODULE_DEVICE_TABLE(spi, adc128_id);
-- 
2.7.4


------
This email has been scanned for spam and malware by The Email Laundry.


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

* [PATCH v3 2/3] iio: adc128s052: add ACPI _HID AANT1280
  2018-10-25 15:35 ` [PATCH v3 0/3] iio: adc128s052: add matching options Dan O'Donovan
  2018-10-25 15:35   ` [PATCH v3 1/3] iio: adc128s052: Add pin-compatible IDs Dan O'Donovan
@ 2018-10-25 15:35   ` Dan O'Donovan
  2018-10-25 17:46     ` Andy Shevchenko
                       ` (2 more replies)
  2018-10-25 15:35   ` [PATCH v3 3/3] iio: adc128s052: use SPDX-License-Identifier Dan O'Donovan
  2018-10-25 17:49   ` [PATCH v3 0/3] iio: adc128s052: add matching options Andy Shevchenko
  3 siblings, 3 replies; 20+ messages in thread
From: Dan O'Donovan @ 2018-10-25 15:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andy Shevchenko, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
	Rob Herring, Mark Rutland, devicetree, Carlos Iglesias,
	Nicola Lunghi, Javier Arteaga, Dan O'Donovan

From: Nicola Lunghi <nicola.lunghi@emutex.com>

ACPI _HID AANT1280 matches an ADC124S101 present on E3940 SKUs of the UP
Squared board.

Add it to the driver.

Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
[javier@emutex.com: fix up commit message and one checkpatch warning]
Signed-off-by: Javier Arteaga <javier@emutex.com>
Signed-off-by: Dan O'Donovan <dan@emutex.com>
---
 drivers/iio/adc/ti-adc128s052.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
index e6716c3..c2d1453 100644
--- a/drivers/iio/adc/ti-adc128s052.c
+++ b/drivers/iio/adc/ti-adc128s052.c
@@ -12,10 +12,12 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/acpi.h>
 #include <linux/err.h>
 #include <linux/spi/spi.h>
 #include <linux/module.h>
 #include <linux/iio/iio.h>
+#include <linux/property.h>
 #include <linux/regulator/consumer.h>
 
 struct adc128_configuration {
@@ -135,10 +137,15 @@ static const struct iio_info adc128_info = {
 static int adc128_probe(struct spi_device *spi)
 {
 	struct iio_dev *indio_dev;
+	unsigned int config;
 	struct adc128 *adc;
-	int config = spi_get_device_id(spi)->driver_data;
 	int ret;
 
+	if (dev_fwnode(&spi->dev))
+		config = (unsigned long) device_get_match_data(&spi->dev);
+	else
+		config = spi_get_device_id(spi)->driver_data;
+
 	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc));
 	if (!indio_dev)
 		return -ENOMEM;
@@ -207,10 +214,19 @@ static const struct spi_device_id adc128_id[] = {
 };
 MODULE_DEVICE_TABLE(spi, adc128_id);
 
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id adc128_acpi_match[] = {
+	{ "AANT1280", 2 }, /* ADC124S021 compatible ACPI ID */
+	{ }
+};
+MODULE_DEVICE_TABLE(acpi, adc128_acpi_match);
+#endif
+
 static struct spi_driver adc128_driver = {
 	.driver = {
 		.name = "adc128s052",
 		.of_match_table = of_match_ptr(adc128_of_match),
+		.acpi_match_table = ACPI_PTR(adc128_acpi_match),
 	},
 	.probe = adc128_probe,
 	.remove = adc128_remove,
-- 
2.7.4


------
This email has been scanned for spam and malware by The Email Laundry.


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

* [PATCH v3 3/3] iio: adc128s052: use SPDX-License-Identifier
  2018-10-25 15:35 ` [PATCH v3 0/3] iio: adc128s052: add matching options Dan O'Donovan
  2018-10-25 15:35   ` [PATCH v3 1/3] iio: adc128s052: Add pin-compatible IDs Dan O'Donovan
  2018-10-25 15:35   ` [PATCH v3 2/3] iio: adc128s052: add ACPI _HID AANT1280 Dan O'Donovan
@ 2018-10-25 15:35   ` Dan O'Donovan
  2018-10-28 11:58     ` Jonathan Cameron
  2018-10-25 17:49   ` [PATCH v3 0/3] iio: adc128s052: add matching options Andy Shevchenko
  3 siblings, 1 reply; 20+ messages in thread
From: Dan O'Donovan @ 2018-10-25 15:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andy Shevchenko, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
	Rob Herring, Mark Rutland, devicetree, Carlos Iglesias,
	Dan O'Donovan

This updates the ti-adc128s052.c file to use SPDX-License-Identifier
instead of more verbose license text.

Signed-off-by: Dan O'Donovan <dan@emutex.com>
---
 drivers/iio/adc/ti-adc128s052.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
index c2d1453..7d2861f 100644
--- a/drivers/iio/adc/ti-adc128s052.c
+++ b/drivers/iio/adc/ti-adc128s052.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (C) 2014 Angelo Compagnucci <angelo.compagnucci@gmail.com>
  *
@@ -6,10 +7,6 @@
  * http://www.ti.com/lit/ds/symlink/adc128s052.pdf
  * http://www.ti.com/lit/ds/symlink/adc122s021.pdf
  * http://www.ti.com/lit/ds/symlink/adc124s021.pdf
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
  */
 
 #include <linux/acpi.h>
-- 
2.7.4


------
This email has been scanned for spam and malware by The Email Laundry.


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

* Re: [PATCH v3 2/3] iio: adc128s052: add ACPI _HID AANT1280
  2018-10-25 15:35   ` [PATCH v3 2/3] iio: adc128s052: add ACPI _HID AANT1280 Dan O'Donovan
@ 2018-10-25 17:46     ` Andy Shevchenko
  2018-10-26 10:13       ` Dan O'Donovan
  2018-10-27 17:14     ` Himanshu Jha
  2018-10-28 11:56     ` Jonathan Cameron
  2 siblings, 1 reply; 20+ messages in thread
From: Andy Shevchenko @ 2018-10-25 17:46 UTC (permalink / raw)
  To: Dan O'Donovan
  Cc: linux-kernel, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
	Rob Herring, Mark Rutland, devicetree, Carlos Iglesias,
	Nicola Lunghi, Javier Arteaga

On Thu, Oct 25, 2018 at 04:35:41PM +0100, Dan O'Donovan wrote:
> From: Nicola Lunghi <nicola.lunghi@emutex.com>
> 
> ACPI _HID AANT1280 matches an ADC124S101 present on E3940 SKUs of the UP
> Squared board.
> 
> Add it to the driver.
> 
> Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
> [javier@emutex.com: fix up commit message and one checkpatch warning]
> Signed-off-by: Javier Arteaga <javier@emutex.com>
> Signed-off-by: Dan O'Donovan <dan@emutex.com>
> ---
>  drivers/iio/adc/ti-adc128s052.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
> index e6716c3..c2d1453 100644
> --- a/drivers/iio/adc/ti-adc128s052.c
> +++ b/drivers/iio/adc/ti-adc128s052.c
> @@ -12,10 +12,12 @@
>   * published by the Free Software Foundation.
>   */
>  
> +#include <linux/acpi.h>
>  #include <linux/err.h>
>  #include <linux/spi/spi.h>
>  #include <linux/module.h>
>  #include <linux/iio/iio.h>
> +#include <linux/property.h>
>  #include <linux/regulator/consumer.h>
>  
>  struct adc128_configuration {
> @@ -135,10 +137,15 @@ static const struct iio_info adc128_info = {
>  static int adc128_probe(struct spi_device *spi)
>  {
>  	struct iio_dev *indio_dev;
> +	unsigned int config;
>  	struct adc128 *adc;
> -	int config = spi_get_device_id(spi)->driver_data;
>  	int ret;
>  
> +	if (dev_fwnode(&spi->dev))
> +		config = (unsigned long) device_get_match_data(&spi->dev);
> +	else
> +		config = spi_get_device_id(spi)->driver_data;
> +
>  	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc));
>  	if (!indio_dev)
>  		return -ENOMEM;
> @@ -207,10 +214,19 @@ static const struct spi_device_id adc128_id[] = {
>  };
>  MODULE_DEVICE_TABLE(spi, adc128_id);
>  
> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id adc128_acpi_match[] = {

> +	{ "AANT1280", 2 }, /* ADC124S021 compatible ACPI ID */

Looking how driver is organized and what ACPI can provide I would highly
recommend to look forward to PTYP field for utilization of the type of the HW.

Maybe it would not work with published BIOSes, but would be good for the future
(in that case anybody can utilize that _HID + PTYP pair on their platforms).

> +	{ }
> +};
> +MODULE_DEVICE_TABLE(acpi, adc128_acpi_match);
> +#endif
> +
>  static struct spi_driver adc128_driver = {
>  	.driver = {
>  		.name = "adc128s052",

>  		.of_match_table = of_match_ptr(adc128_of_match),
> +		.acpi_match_table = ACPI_PTR(adc128_acpi_match),
>  	},
>  	.probe = adc128_probe,
>  	.remove = adc128_remove,
> -- 
> 2.7.4
> 
> 
> ------
> This email has been scanned for spam and malware by The Email Laundry.
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 0/3] iio: adc128s052: add matching options
  2018-10-25 15:35 ` [PATCH v3 0/3] iio: adc128s052: add matching options Dan O'Donovan
                     ` (2 preceding siblings ...)
  2018-10-25 15:35   ` [PATCH v3 3/3] iio: adc128s052: use SPDX-License-Identifier Dan O'Donovan
@ 2018-10-25 17:49   ` Andy Shevchenko
  3 siblings, 0 replies; 20+ messages in thread
From: Andy Shevchenko @ 2018-10-25 17:49 UTC (permalink / raw)
  To: Dan O'Donovan
  Cc: linux-kernel, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
	Rob Herring, Mark Rutland, devicetree, Carlos Iglesias

On Thu, Oct 25, 2018 at 04:35:39PM +0100, Dan O'Donovan wrote:
> Hi all,
> 
> On some SKUs of AAEON's UP Squared board, there is an ADC124S101
> enumerated via ACPI. This is a pin-compatible variant of ADC124S021,
> which is already supported by the adc128s052 driver.
> 
> This patchset adds missing DT compatible strings for ADC124S021 (and
> ADC122S021) variants, adds AAEON's allocated ACPI HID, and adds the
> SPDX GPL identifier to the driver.
> 
> v2 was posted at:
> https://lore.kernel.org/lkml/20180423213805.12591-1-javier@emutex.com/

Overall LGTM
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> 
> Changes from v2:
> * Added device-tree bindings documentation for new chip variants
> * Simplified code to get ACPI match data
> * Dropped redundant patch to facilitate OF matching via ACPI _DSD
> * Added patch to replace GPL license text with SPDX identifier
> 
> Changes from v1:
> * Improved patch descriptions and series title
> * Added an initial commit introducing new compatible strings
>   (as per Jonathan's suggestion)
> * Moved of_match_ptr removal last as this patch is less important to us
> 
> Dan O'Donovan (1):
>   iio: adc128s052: use SPDX-License-Identifier
> 
> Javier Arteaga (1):
>   iio: adc128s052: Add pin-compatible IDs
> 
> Nicola Lunghi (1):
>   iio: adc128s052: add ACPI _HID AANT1280
> 
>  .../devicetree/bindings/iio/adc/ti-adc128s052.txt  |  9 ++++-
>  drivers/iio/adc/ti-adc128s052.c                    | 39 +++++++++++++++++-----
>  2 files changed, 38 insertions(+), 10 deletions(-)
> 
> -- 
> 2.7.4
> 
> 
> ------
> This email has been scanned for spam and malware by The Email Laundry.
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 2/3] iio: adc128s052: add ACPI _HID AANT1280
  2018-10-25 17:46     ` Andy Shevchenko
@ 2018-10-26 10:13       ` Dan O'Donovan
  2018-10-26 12:12         ` Andy Shevchenko
  0 siblings, 1 reply; 20+ messages in thread
From: Dan O'Donovan @ 2018-10-26 10:13 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-kernel, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
	Rob Herring, Mark Rutland, devicetree, Carlos Iglesias,
	Nicola Lunghi, Javier Arteaga



On 10/25/2018 06:46 PM, Andy Shevchenko wrote:
> On Thu, Oct 25, 2018 at 04:35:41PM +0100, Dan O'Donovan wrote:
>> From: Nicola Lunghi <nicola.lunghi@emutex.com>
>>
>> ACPI _HID AANT1280 matches an ADC124S101 present on E3940 SKUs of the UP
>> Squared board.
>>
>> Add it to the driver.
>>
>> Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
>> [javier@emutex.com: fix up commit message and one checkpatch warning]
>> Signed-off-by: Javier Arteaga <javier@emutex.com>
>> Signed-off-by: Dan O'Donovan <dan@emutex.com>
>> ---
>>  drivers/iio/adc/ti-adc128s052.c | 18 +++++++++++++++++-
>>  1 file changed, 17 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
>> index e6716c3..c2d1453 100644
>> --- a/drivers/iio/adc/ti-adc128s052.c
>> +++ b/drivers/iio/adc/ti-adc128s052.c
>> @@ -12,10 +12,12 @@
>>   * published by the Free Software Foundation.
>>   */
>>  
>> +#include <linux/acpi.h>
>>  #include <linux/err.h>
>>  #include <linux/spi/spi.h>
>>  #include <linux/module.h>
>>  #include <linux/iio/iio.h>
>> +#include <linux/property.h>
>>  #include <linux/regulator/consumer.h>
>>  
>>  struct adc128_configuration {
>> @@ -135,10 +137,15 @@ static const struct iio_info adc128_info = {
>>  static int adc128_probe(struct spi_device *spi)
>>  {
>>  	struct iio_dev *indio_dev;
>> +	unsigned int config;
>>  	struct adc128 *adc;
>> -	int config = spi_get_device_id(spi)->driver_data;
>>  	int ret;
>>  
>> +	if (dev_fwnode(&spi->dev))
>> +		config = (unsigned long) device_get_match_data(&spi->dev);
>> +	else
>> +		config = spi_get_device_id(spi)->driver_data;
>> +
>>  	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc));
>>  	if (!indio_dev)
>>  		return -ENOMEM;
>> @@ -207,10 +214,19 @@ static const struct spi_device_id adc128_id[] = {
>>  };
>>  MODULE_DEVICE_TABLE(spi, adc128_id);
>>  
>> +#ifdef CONFIG_ACPI
>> +static const struct acpi_device_id adc128_acpi_match[] = {
> 
>> +	{ "AANT1280", 2 }, /* ADC124S021 compatible ACPI ID */
> 
> Looking how driver is organized and what ACPI can provide I would highly
> recommend to look forward to PTYP field for utilization of the type of the HW.
> 
> Maybe it would not work with published BIOSes, but would be good for the future
> (in that case anybody can utilize that _HID + PTYP pair on their platforms).
> 
Thanks Andy for your review and feedback.  Your _HID + PTYP suggestion sounds
interesting, but I couldn't find any information in the ACPI spec or elsewhere
about how/when/where to use it.  It isn't used in the UP Squared ACPI tables.
Do you have any links or other information you could share about it? Thanks!

>> +	{ }
>> +};
>> +MODULE_DEVICE_TABLE(acpi, adc128_acpi_match);
>> +#endif
>> +
>>  static struct spi_driver adc128_driver = {
>>  	.driver = {
>>  		.name = "adc128s052",
> 
>>  		.of_match_table = of_match_ptr(adc128_of_match),
>> +		.acpi_match_table = ACPI_PTR(adc128_acpi_match),
>>  	},
>>  	.probe = adc128_probe,
>>  	.remove = adc128_remove,
>> -- 
>> 2.7.4
>>
>>
>> ------
>> This email has been scanned for spam and malware by The Email Laundry.
>>
> 

------
This email has been scanned for spam and malware by The Email Laundry.


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

* Re: [PATCH v3 2/3] iio: adc128s052: add ACPI _HID AANT1280
  2018-10-26 10:13       ` Dan O'Donovan
@ 2018-10-26 12:12         ` Andy Shevchenko
  0 siblings, 0 replies; 20+ messages in thread
From: Andy Shevchenko @ 2018-10-26 12:12 UTC (permalink / raw)
  To: Dan O'Donovan
  Cc: linux-kernel, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
	Rob Herring, Mark Rutland, devicetree, Carlos Iglesias,
	Nicola Lunghi, Javier Arteaga

On Fri, Oct 26, 2018 at 11:13:01AM +0100, Dan O'Donovan wrote:
> On 10/25/2018 06:46 PM, Andy Shevchenko wrote:
> > On Thu, Oct 25, 2018 at 04:35:41PM +0100, Dan O'Donovan wrote:

> >> +	{ "AANT1280", 2 }, /* ADC124S021 compatible ACPI ID */

> > Looking how driver is organized and what ACPI can provide I would highly
> > recommend to look forward to PTYP field for utilization of the type of the HW.

> > Maybe it would not work with published BIOSes, but would be good for the future
> > (in that case anybody can utilize that _HID + PTYP pair on their platforms).

> Thanks Andy for your review and feedback.  Your _HID + PTYP suggestion sounds
> interesting, but I couldn't find any information in the ACPI spec or elsewhere
> about how/when/where to use it.  

I stand corrected, it's not in the spec, rather de facto use of it in some
cases, see below.

> It isn't used in the UP Squared ACPI tables.
> Do you have any links or other information you could share about it? Thanks!

As far as I can find the following code in the kernel and thus real ACPI tables
in the wild that utilize it.

drivers/acpi/dptf/dptf_power.c:84:      status = acpi_evaluate_integer(acpi_dev->handle, "PTYP", NULL, &ptype);
drivers/platform/x86/intel_cht_int33fe.c:101:   status = acpi_evaluate_integer(ACPI_HANDLE(dev), "PTYP", NULL, &ptyp);
drivers/thermal/int340x_thermal/int3403_thermal.c:237:  status = acpi_evaluate_integer(priv->adev->handle, "PTYP",


-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 2/3] iio: adc128s052: add ACPI _HID AANT1280
  2018-10-25 15:35   ` [PATCH v3 2/3] iio: adc128s052: add ACPI _HID AANT1280 Dan O'Donovan
  2018-10-25 17:46     ` Andy Shevchenko
@ 2018-10-27 17:14     ` Himanshu Jha
  2018-10-28 11:42       ` Jonathan Cameron
  2018-10-28 11:56     ` Jonathan Cameron
  2 siblings, 1 reply; 20+ messages in thread
From: Himanshu Jha @ 2018-10-27 17:14 UTC (permalink / raw)
  To: Dan O'Donovan
  Cc: linux-kernel, Andy Shevchenko, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
	Rob Herring, Mark Rutland, devicetree, Carlos Iglesias,
	Nicola Lunghi, Javier Arteaga, srinivas.pandruvada

Hi Dan,

On Thu, Oct 25, 2018 at 04:35:41PM +0100, Dan O'Donovan wrote:
> From: Nicola Lunghi <nicola.lunghi@emutex.com>
> 
> ACPI _HID AANT1280 matches an ADC124S101 present on E3940 SKUs of the UP
> Squared board.
> 
> Add it to the driver.
> 
> Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
> [javier@emutex.com: fix up commit message and one checkpatch warning]
> Signed-off-by: Javier Arteaga <javier@emutex.com>
> Signed-off-by: Dan O'Donovan <dan@emutex.com>
> ---
>  drivers/iio/adc/ti-adc128s052.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)

[]

> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id adc128_acpi_match[] = {
> +	{ "AANT1280", 2 }, /* ADC124S021 compatible ACPI ID */
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(acpi, adc128_acpi_match);
> +#endif

I'm curious about the naming conventions used for selecting 
an ACPI ID.

AFAIK, ACPI or PNP ID consists of *Vendor* ID + Product ID.

PNP ID: PNP Vendor IDs consist of 3 characters, each character being
an uppercase letter (A-Z).

ACPI ID: ACPI Vendor IDs consist of 4 characters, each character being
either an uppercase letter (A-Z) or a numeral (0-9).

In your case,

Vendor ID -> AANT (AAEON TECHNOLOGY INC. registered ACPI ID prefix)
http://www.uefi.org/ACPI_ID_List?search=AANT

Product ID -> 1280

How did you come up with 1280 ? And why AANT ? why not TXNW which is
registered ACPI prefix for TEXAS INSTRUMENTS ?
http://www.uefi.org/ACPI_ID_List?search=Texas+

Latest ACPI manuals says:

6.1.5 _HID (Hardware ID)
------------------------

This object is used to supply OSPM with the device’s Plug and Play
hardware ID.[1]

[1] "A Plug and Play ID or ACPI ID can be obtained by sending e-mail to
pnpid@microsoft.com."

A _HID object evaluates to either a numeric 32-bit compressed EISA type ID or a string. If a
string, the format must be an alphanumeric PNP or ACPI ID with no asterisk or other leading
characters.

A valid PNP ID must be of the form "AAA####" where A is an uppercase letter and # is a hex
digit. A valid ACPI ID must be of the form "NNNN####" where N is an uppercase letter or a
digit ('0'-'9') and # is a hex digit. This specification reserves the string "ACPI" for use only
with devices defined herein. It further reserves all strings representing 4 HEX digits for
exclusive use with PCI-assigned Vendor IDs.


Next question:

There are a lot drivers in iio/ using ACPI for device enumeration using
these IDs. For now, let's take an example of Bosch Sensors:

drivers/iio/accel/bmc150-accel-i2c.c:static const struct acpi_device_id bmc150_accel_acpi_match[] = {
drivers/iio/accel/bmc150-accel-i2c.c-   {"BSBA0150",    bmc150},
drivers/iio/accel/bmc150-accel-i2c.c-   {"BMC150A",     bmc150},
drivers/iio/accel/bmc150-accel-i2c.c-   {"BMI055A",     bmi055},
drivers/iio/accel/bmc150-accel-i2c.c-   {"BMA0255",     bma255},

drivers/iio/gyro/bmg160_i2c.c:static const struct acpi_device_id bmg160_acpi_match[] = {
drivers/iio/gyro/bmg160_i2c.c-  {"BMG0160", 0},
drivers/iio/gyro/bmg160_i2c.c-  {"BMI055B", 0},
drivers/iio/gyro/bmg160_i2c.c-  {},
drivers/iio/gyro/bmg160_i2c.c-};

drivers/iio/imu/bmi160/bmi160_i2c.c:static const struct acpi_device_id bmi160_acpi_match[] = {
drivers/iio/imu/bmi160/bmi160_i2c.c-    {"BMI0160", 0},
drivers/iio/imu/bmi160/bmi160_i2c.c-    { },
drivers/iio/imu/bmi160/bmi160_i2c.c-};
drivers/iio/imu/bmi160/bmi160_i2c.c-MODULE_DEVICE_TABLE(acpi, bmi160_acpi_match);

Bosch registered ACPI ID: BOSC
http://www.uefi.org/ACPI_ID_List?search=Bosch

Bosch registered PNP ID: BSG
http://www.uefi.org/PNP_ID_List?search=Bosch

So, how could we use PNP ID "BMI" which is registered prefix for
BENSON MEDICAL INSTRUMENTS COMPANY ?
http://www.uefi.org/PNP_ID_List?search=BMI

Product ID -> "160" is fine for bmi160 which uniquely identifies the
sensor device.

But shouldn't the prefix be "BSG0160" instead of "BMI0160" ?

When I wrote the driver for Bosch BME680, I followed the same guideline
as done everywhere else in the Bosch family:

drivers/iio/pressure/bmp280-i2c.c-      {"BMP0280", BMP280_CHIP_ID },
drivers/iio/pressure/bmp280-i2c.c-      {"BMP0180", BMP180_CHIP_ID },
drivers/iio/pressure/bmp280-i2c.c-      {"BMP0085", BMP180_CHIP_ID },
drivers/iio/pressure/bmp280-i2c.c-      {"BME0280", BME280_CHIP_ID },

Therefore, I used BME0680 for bosch bme680 sensor!

In OF matching, we use vendor prefixes and that looks more legimate:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/Documentation/devicetree/bindings/vendor-prefixes.txt

Dan,

These questions are not just for you but to rest of the community
members as well.

If there is something I misunderstood, then please let me know :)


Thanks
-- 
Himanshu Jha
Undergraduate Student
Department of Electronics & Communication
Guru Tegh Bahadur Institute of Technology

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

* Re: [PATCH v3 2/3] iio: adc128s052: add ACPI _HID AANT1280
  2018-10-27 17:14     ` Himanshu Jha
@ 2018-10-28 11:42       ` Jonathan Cameron
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2018-10-28 11:42 UTC (permalink / raw)
  To: Himanshu Jha
  Cc: Dan O'Donovan, linux-kernel, Andy Shevchenko, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
	Rob Herring, Mark Rutland, devicetree, Carlos Iglesias,
	Nicola Lunghi, Javier Arteaga, srinivas.pandruvada

On Sat, 27 Oct 2018 22:44:28 +0530
Himanshu Jha <himanshujha199640@gmail.com> wrote:

> Hi Dan,
> 
> On Thu, Oct 25, 2018 at 04:35:41PM +0100, Dan O'Donovan wrote:
> > From: Nicola Lunghi <nicola.lunghi@emutex.com>
> > 
> > ACPI _HID AANT1280 matches an ADC124S101 present on E3940 SKUs of the UP
> > Squared board.
> > 
> > Add it to the driver.
> > 
> > Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
> > [javier@emutex.com: fix up commit message and one checkpatch warning]
> > Signed-off-by: Javier Arteaga <javier@emutex.com>
> > Signed-off-by: Dan O'Donovan <dan@emutex.com>
> > ---
> >  drivers/iio/adc/ti-adc128s052.c | 18 +++++++++++++++++-
> >  1 file changed, 17 insertions(+), 1 deletion(-)  
> 
> []
> 
> > +#ifdef CONFIG_ACPI
> > +static const struct acpi_device_id adc128_acpi_match[] = {
> > +	{ "AANT1280", 2 }, /* ADC124S021 compatible ACPI ID */
> > +	{ }
> > +};
> > +MODULE_DEVICE_TABLE(acpi, adc128_acpi_match);
> > +#endif  
> 
> I'm curious about the naming conventions used for selecting 
> an ACPI ID.
> 
> AFAIK, ACPI or PNP ID consists of *Vendor* ID + Product ID.
> 
> PNP ID: PNP Vendor IDs consist of 3 characters, each character being
> an uppercase letter (A-Z).
> 
> ACPI ID: ACPI Vendor IDs consist of 4 characters, each character being
> either an uppercase letter (A-Z) or a numeral (0-9).
> 
> In your case,
> 
> Vendor ID -> AANT (AAEON TECHNOLOGY INC. registered ACPI ID prefix)
> http://www.uefi.org/ACPI_ID_List?search=AANT
> 
> Product ID -> 1280
> 
> How did you come up with 1280 ? And why AANT ? why not TXNW which is
> registered ACPI prefix for TEXAS INSTRUMENTS ?
> http://www.uefi.org/ACPI_ID_List?search=Texas+
Simple answer to that:

TI don't (as far as I know) publish defined ID spaces so no one can
use their ID without risking stepping on an ID in use by someone else.
I would assume there is an AAEON module on this board (pretty common
for embedded boards) so they have assigned an ID from their namespace
as they can know it doesn't clash with anyone else.

> 
> Latest ACPI manuals says:
> 
> 6.1.5 _HID (Hardware ID)
> ------------------------
> 
> This object is used to supply OSPM with the device’s Plug and Play
> hardware ID.[1]
> 
> [1] "A Plug and Play ID or ACPI ID can be obtained by sending e-mail to
> pnpid@microsoft.com."
> 
> A _HID object evaluates to either a numeric 32-bit compressed EISA type ID or a string. If a
> string, the format must be an alphanumeric PNP or ACPI ID with no asterisk or other leading
> characters.
> 
> A valid PNP ID must be of the form "AAA####" where A is an uppercase letter and # is a hex
> digit. A valid ACPI ID must be of the form "NNNN####" where N is an uppercase letter or a
> digit ('0'-'9') and # is a hex digit. This specification reserves the string "ACPI" for use only
> with devices defined herein. It further reserves all strings representing 4 HEX digits for
> exclusive use with PCI-assigned Vendor IDs.
> 
> 
> Next question:
> 
> There are a lot drivers in iio/ using ACPI for device enumeration using
> these IDs. For now, let's take an example of Bosch Sensors:
> 
> drivers/iio/accel/bmc150-accel-i2c.c:static const struct acpi_device_id bmc150_accel_acpi_match[] = {
> drivers/iio/accel/bmc150-accel-i2c.c-   {"BSBA0150",    bmc150},
> drivers/iio/accel/bmc150-accel-i2c.c-   {"BMC150A",     bmc150},
> drivers/iio/accel/bmc150-accel-i2c.c-   {"BMI055A",     bmi055},
> drivers/iio/accel/bmc150-accel-i2c.c-   {"BMA0255",     bma255},
> 
> drivers/iio/gyro/bmg160_i2c.c:static const struct acpi_device_id bmg160_acpi_match[] = {
> drivers/iio/gyro/bmg160_i2c.c-  {"BMG0160", 0},
> drivers/iio/gyro/bmg160_i2c.c-  {"BMI055B", 0},
> drivers/iio/gyro/bmg160_i2c.c-  {},
> drivers/iio/gyro/bmg160_i2c.c-};
> 
> drivers/iio/imu/bmi160/bmi160_i2c.c:static const struct acpi_device_id bmi160_acpi_match[] = {
> drivers/iio/imu/bmi160/bmi160_i2c.c-    {"BMI0160", 0},
> drivers/iio/imu/bmi160/bmi160_i2c.c-    { },
> drivers/iio/imu/bmi160/bmi160_i2c.c-};
> drivers/iio/imu/bmi160/bmi160_i2c.c-MODULE_DEVICE_TABLE(acpi, bmi160_acpi_match);
> 
> Bosch registered ACPI ID: BOSC
> http://www.uefi.org/ACPI_ID_List?search=Bosch
> 
> Bosch registered PNP ID: BSG
> http://www.uefi.org/PNP_ID_List?search=Bosch
> 
> So, how could we use PNP ID "BMI" which is registered prefix for
> BENSON MEDICAL INSTRUMENTS COMPANY ?
> http://www.uefi.org/PNP_ID_List?search=BMI
> 
> Product ID -> "160" is fine for bmi160 which uniquely identifies the
> sensor device.
> 
> But shouldn't the prefix be "BSG0160" instead of "BMI0160" ?
> 
> When I wrote the driver for Bosch BME680, I followed the same guideline
> as done everywhere else in the Bosch family:
> 
> drivers/iio/pressure/bmp280-i2c.c-      {"BMP0280", BMP280_CHIP_ID },
> drivers/iio/pressure/bmp280-i2c.c-      {"BMP0180", BMP180_CHIP_ID },
> drivers/iio/pressure/bmp280-i2c.c-      {"BMP0085", BMP180_CHIP_ID },
> drivers/iio/pressure/bmp280-i2c.c-      {"BME0280", BME280_CHIP_ID },
> 
> Therefore, I used BME0680 for bosch bme680 sensor!
> 
> In OF matching, we use vendor prefixes and that looks more legimate:
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/Documentation/devicetree/bindings/vendor-prefixes.txt
> 
> Dan,
> 
> These questions are not just for you but to rest of the community
> members as well.
> 
> If there is something I misunderstood, then please let me know :)
The sad truth is that for ACPI things aren't really governed by the
spec, but rather by what people put in bios tables.

Now, I know is some cases the ID has been assigned pretty much to provide
an easy way to test the device as there are no known IDs in use for
the part.  In those cases we should be a little careful and it would be
nice to keep to the spec.  If companies actually published a
canonical list of their ID usage it would certainly make this nicer.
I have access to the Hisilicon list for example, but it's not (as far
as I know) public.

Some of the more random IDs are real ones found in the wild (such as
the one in this case).  Reality of a lot of these parts is that we will
never get them to fix the Bios.

I can rock up at an ACPI WG meeting and rant about it (mostly I don't as
they are in the middle of the night UK time) but in reality the smaller
companies don't have anyone attending so it wouldn't help much.

One thing we could do perhaps is start recording as comments, boards
on which a particular ID is found, or when we know it is the suggested
value from the manufacturer of a device.

Jonathan

P.S Technically I'm a member of the ASWG part of UEFI who is responsible
for that standard (on behalf of Huawei, though I never actually attend as
the call are in the middle of the night), but there are only so many things
one can try to solve + to be honest inconsistent namespaces don't
really hurt anyone other than requiring additional IDs to be added when
a new one shows up in the wild.

> 
> 
> Thanks


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

* Re: [PATCH v3 2/3] iio: adc128s052: add ACPI _HID AANT1280
  2018-10-25 15:35   ` [PATCH v3 2/3] iio: adc128s052: add ACPI _HID AANT1280 Dan O'Donovan
  2018-10-25 17:46     ` Andy Shevchenko
  2018-10-27 17:14     ` Himanshu Jha
@ 2018-10-28 11:56     ` Jonathan Cameron
  2 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2018-10-28 11:56 UTC (permalink / raw)
  To: Dan O'Donovan
  Cc: linux-kernel, Andy Shevchenko, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
	Rob Herring, Mark Rutland, devicetree, Carlos Iglesias,
	Nicola Lunghi, Javier Arteaga

On Thu, 25 Oct 2018 16:35:41 +0100
Dan O'Donovan <dan@emutex.com> wrote:

> From: Nicola Lunghi <nicola.lunghi@emutex.com>
> 
> ACPI _HID AANT1280 matches an ADC124S101 present on E3940 SKUs of the UP
> Squared board.
> 
> Add it to the driver.
> 
> Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
> [javier@emutex.com: fix up commit message and one checkpatch warning]
> Signed-off-by: Javier Arteaga <javier@emutex.com>
> Signed-off-by: Dan O'Donovan <dan@emutex.com>
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/ti-adc128s052.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
> index e6716c3..c2d1453 100644
> --- a/drivers/iio/adc/ti-adc128s052.c
> +++ b/drivers/iio/adc/ti-adc128s052.c
> @@ -12,10 +12,12 @@
>   * published by the Free Software Foundation.
>   */
>  
> +#include <linux/acpi.h>
>  #include <linux/err.h>
>  #include <linux/spi/spi.h>
>  #include <linux/module.h>
>  #include <linux/iio/iio.h>
> +#include <linux/property.h>
>  #include <linux/regulator/consumer.h>
>  
>  struct adc128_configuration {
> @@ -135,10 +137,15 @@ static const struct iio_info adc128_info = {
>  static int adc128_probe(struct spi_device *spi)
>  {
>  	struct iio_dev *indio_dev;
> +	unsigned int config;
>  	struct adc128 *adc;
> -	int config = spi_get_device_id(spi)->driver_data;
>  	int ret;
>  
> +	if (dev_fwnode(&spi->dev))
> +		config = (unsigned long) device_get_match_data(&spi->dev);
> +	else
> +		config = spi_get_device_id(spi)->driver_data;
> +
>  	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc));
>  	if (!indio_dev)
>  		return -ENOMEM;
> @@ -207,10 +214,19 @@ static const struct spi_device_id adc128_id[] = {
>  };
>  MODULE_DEVICE_TABLE(spi, adc128_id);
>  
> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id adc128_acpi_match[] = {
> +	{ "AANT1280", 2 }, /* ADC124S021 compatible ACPI ID */
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(acpi, adc128_acpi_match);
> +#endif
> +
>  static struct spi_driver adc128_driver = {
>  	.driver = {
>  		.name = "adc128s052",
>  		.of_match_table = of_match_ptr(adc128_of_match),
> +		.acpi_match_table = ACPI_PTR(adc128_acpi_match),
>  	},
>  	.probe = adc128_probe,
>  	.remove = adc128_remove,


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

* Re: [PATCH v3 3/3] iio: adc128s052: use SPDX-License-Identifier
  2018-10-25 15:35   ` [PATCH v3 3/3] iio: adc128s052: use SPDX-License-Identifier Dan O'Donovan
@ 2018-10-28 11:58     ` Jonathan Cameron
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2018-10-28 11:58 UTC (permalink / raw)
  To: Dan O'Donovan
  Cc: linux-kernel, Andy Shevchenko, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
	Rob Herring, Mark Rutland, devicetree, Carlos Iglesias

On Thu, 25 Oct 2018 16:35:42 +0100
Dan O'Donovan <dan@emutex.com> wrote:

> This updates the ti-adc128s052.c file to use SPDX-License-Identifier
> instead of more verbose license text.
> 
> Signed-off-by: Dan O'Donovan <dan@emutex.com>
Applied, 

Thanks,

Jonathan

> ---
>  drivers/iio/adc/ti-adc128s052.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
> index c2d1453..7d2861f 100644
> --- a/drivers/iio/adc/ti-adc128s052.c
> +++ b/drivers/iio/adc/ti-adc128s052.c
> @@ -1,3 +1,4 @@
> +// SPDX-License-Identifier: GPL-2.0
>  /*
>   * Copyright (C) 2014 Angelo Compagnucci <angelo.compagnucci@gmail.com>
>   *
> @@ -6,10 +7,6 @@
>   * http://www.ti.com/lit/ds/symlink/adc128s052.pdf
>   * http://www.ti.com/lit/ds/symlink/adc122s021.pdf
>   * http://www.ti.com/lit/ds/symlink/adc124s021.pdf
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 as
> - * published by the Free Software Foundation.
>   */
>  
>  #include <linux/acpi.h>


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

* Re: [PATCH v3 1/3] iio: adc128s052: Add pin-compatible IDs
  2018-10-25 15:35   ` [PATCH v3 1/3] iio: adc128s052: Add pin-compatible IDs Dan O'Donovan
@ 2018-10-28 15:35     ` Jonathan Cameron
  2018-10-30 19:37     ` Rob Herring
  1 sibling, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2018-10-28 15:35 UTC (permalink / raw)
  To: Dan O'Donovan
  Cc: linux-kernel, Andy Shevchenko, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
	Rob Herring, Mark Rutland, devicetree, Carlos Iglesias,
	Javier Arteaga

On Thu, 25 Oct 2018 16:35:40 +0100
Dan O'Donovan <dan@emutex.com> wrote:

> From: Javier Arteaga <javier@emutex.com>
> 
> The datasheets for ADC122S021 and ADC124S021 list two more
> pin-compatible alternatives for each device.
> 
> Add their IDs as compatible strings.
> 
> Suggested-by: Jonathan Cameron <jic23@kernel.org>
> Signed-off-by: Javier Arteaga <javier@emutex.com>
> Signed-off-by: Dan O'Donovan <dan@emutex.com>
> ---
>  .../devicetree/bindings/iio/adc/ti-adc128s052.txt        |  9 ++++++++-
>  drivers/iio/adc/ti-adc128s052.c                          | 16 ++++++++++++----
>  2 files changed, 20 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt b/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt
> index daa2b2c..c07ce1a 100644
> --- a/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt
> +++ b/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt
> @@ -1,7 +1,14 @@
>  * Texas Instruments' ADC128S052, ADC122S021 and ADC124S021 ADC chip
>  
>  Required properties:
> - - compatible: Should be "ti,adc128s052", "ti,adc122s021" or "ti,adc124s021"
> + - compatible: Should be one of:
> +   - "ti,adc128s052"
Hmm.  Ideally I think these should be in 'alphabetical' order. However
I can see a certain logic to having the part whose name we are using for
the driver listed first..

Not important enough to change.

> +   - "ti,adc122s021"
> +   - "ti,adc122s051"
> +   - "ti,adc122s101"
> +   - "ti,adc124s021"
> +   - "ti,adc124s051"
> +   - "ti,adc124s101"
>   - reg: spi chip select number for the device
>   - vref-supply: The regulator supply for ADC reference voltage
>  
> diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
> index 7cf39b3..e6716c3 100644
> --- a/drivers/iio/adc/ti-adc128s052.c
> +++ b/drivers/iio/adc/ti-adc128s052.c
> @@ -186,15 +186,23 @@ static int adc128_remove(struct spi_device *spi)
>  static const struct of_device_id adc128_of_match[] = {
>  	{ .compatible = "ti,adc128s052", },
>  	{ .compatible = "ti,adc122s021", },
> +	{ .compatible = "ti,adc122s051", },
> +	{ .compatible = "ti,adc122s101", },
>  	{ .compatible = "ti,adc124s021", },
> -	{ /* sentinel */ },
> +	{ .compatible = "ti,adc124s051", },
> +	{ .compatible = "ti,adc124s101", },
> +	{ }
Dropping then sentinel shouldn't have occurred in this patch.
I don't really care if it is there or not personally but we shouldn't be
making changes without clear benefit.  I'll put it back.
>  };
>  MODULE_DEVICE_TABLE(of, adc128_of_match);
>  
>  static const struct spi_device_id adc128_id[] = {
> -	{ "adc128s052", 0},	/* index into adc128_config */
> -	{ "adc122s021",	1},
> -	{ "adc124s021", 2},
> +	{ "adc128s052", 0 },	/* index into adc128_config */
> +	{ "adc122s021",	1 },
> +	{ "adc122s051",	1 },
> +	{ "adc122s101",	1 },
> +	{ "adc124s021", 2 },
> +	{ "adc124s051", 2 },
> +	{ "adc124s101", 2 },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(spi, adc128_id);


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

* Re: [PATCH v3 1/3] iio: adc128s052: Add pin-compatible IDs
  2018-10-25 15:35   ` [PATCH v3 1/3] iio: adc128s052: Add pin-compatible IDs Dan O'Donovan
  2018-10-28 15:35     ` Jonathan Cameron
@ 2018-10-30 19:37     ` Rob Herring
  1 sibling, 0 replies; 20+ messages in thread
From: Rob Herring @ 2018-10-30 19:37 UTC (permalink / raw)
  To: Dan O'Donovan
  Cc: linux-kernel, Andy Shevchenko, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
	Mark Rutland, devicetree, Carlos Iglesias, Javier Arteaga,
	Dan O'Donovan

On Thu, 25 Oct 2018 16:35:40 +0100, Dan O'Donovan wrote:
> From: Javier Arteaga <javier@emutex.com>
> 
> The datasheets for ADC122S021 and ADC124S021 list two more
> pin-compatible alternatives for each device.
> 
> Add their IDs as compatible strings.
> 
> Suggested-by: Jonathan Cameron <jic23@kernel.org>
> Signed-off-by: Javier Arteaga <javier@emutex.com>
> Signed-off-by: Dan O'Donovan <dan@emutex.com>
> ---
>  .../devicetree/bindings/iio/adc/ti-adc128s052.txt        |  9 ++++++++-
>  drivers/iio/adc/ti-adc128s052.c                          | 16 ++++++++++++----
>  2 files changed, 20 insertions(+), 5 deletions(-)
> 

Reviewed-by: Rob Herring <robh@kernel.org>

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

end of thread, other threads:[~2018-10-30 19:37 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-23 21:38 [PATCH v2 0/3] iio: adc128s052: add matching options Javier Arteaga
2018-04-23 21:38 ` [PATCH v2 1/3] iio: adc128s052: Add pin-compatible IDs Javier Arteaga
2018-04-23 21:38 ` [PATCH v2 2/3] iio: adc128s052: add ACPI _HID AANT1280 Javier Arteaga
2018-04-23 22:08   ` Andy Shevchenko
2018-04-24 10:51     ` Javier Arteaga
2018-04-23 21:38 ` [PATCH v2 3/3] iio: adc128s052: reuse "compatible" for ACPI _DSD Javier Arteaga
2018-10-25 15:35 ` [PATCH v3 0/3] iio: adc128s052: add matching options Dan O'Donovan
2018-10-25 15:35   ` [PATCH v3 1/3] iio: adc128s052: Add pin-compatible IDs Dan O'Donovan
2018-10-28 15:35     ` Jonathan Cameron
2018-10-30 19:37     ` Rob Herring
2018-10-25 15:35   ` [PATCH v3 2/3] iio: adc128s052: add ACPI _HID AANT1280 Dan O'Donovan
2018-10-25 17:46     ` Andy Shevchenko
2018-10-26 10:13       ` Dan O'Donovan
2018-10-26 12:12         ` Andy Shevchenko
2018-10-27 17:14     ` Himanshu Jha
2018-10-28 11:42       ` Jonathan Cameron
2018-10-28 11:56     ` Jonathan Cameron
2018-10-25 15:35   ` [PATCH v3 3/3] iio: adc128s052: use SPDX-License-Identifier Dan O'Donovan
2018-10-28 11:58     ` Jonathan Cameron
2018-10-25 17:49   ` [PATCH v3 0/3] iio: adc128s052: add matching options 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).