* [PATCH] misc: ad525x_dpot_spi: Add device tree support
@ 2017-05-26 18:17 Roshni Shah
2017-05-26 19:16 ` kbuild test robot
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Roshni Shah @ 2017-05-26 18:17 UTC (permalink / raw)
To: robh+dt, mark.rutland; +Cc: arnd, gregkh, devicetree, linux-kernel, Roshni Shah
This patch adds Device Tree support to the Analog Devices
digital potentiometers (SPI bus) AD525x driver.
Signed-off-by: Roshni Shah <roshni.shah@timesys.com>
---
.../devicetree/bindings/misc/ad525x_dpot-spi.txt | 44 ++++++
drivers/misc/ad525x_dpot-spi.c | 161 ++++++++++++++++++++-
2 files changed, 204 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/misc/ad525x_dpot-spi.txt
diff --git a/Documentation/devicetree/bindings/misc/ad525x_dpot-spi.txt b/Documentation/devicetree/bindings/misc/ad525x_dpot-spi.txt
new file mode 100644
index 000000000000..d383aa58b2de
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/ad525x_dpot-spi.txt
@@ -0,0 +1,44 @@
+Digital Potentiometers (SPI) compatible with Analog Devices family
+
+Required properties:
+- compatible: Should be one of
+ * "ad,ad5160"
+ * "ad,ad5161"
+ * "ad,ad5162"
+ * "ad,ad5165"
+ * "ad,ad5200"
+ * "ad,ad5201"
+ * "ad,ad5203"
+ * "ad,ad5204"
+ * "ad,ad5206"
+ * "ad,ad5207"
+ * "ad,ad5231"
+ * "ad,ad5232"
+ * "ad,ad5233"
+ * "ad,ad5235"
+ * "ad,ad5260"
+ * "ad,ad5262"
+ * "ad,ad5263"
+ * "ad,ad5290"
+ * "ad,ad5291"
+ * "ad,ad5292"
+ * "ad,ad5293"
+ * "ad,ad7376"
+ * "ad,ad8400"
+ * "ad,ad8402"
+ * "ad,ad8403"
+ * "ad,adn2850"
+ * "ad,ad5270"
+ * "ad,ad5271"
+- reg : spi chip select number for the device
+- spi-max-frequency : max spi frequency to use
+see: Documentation/misc-devices/ad525x_dpot.txt
+
+Example:
+ ad5204@1 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "ad,ad5204";
+ spi-max-frequency = <5000000>;
+ reg = <1>;
+ };
diff --git a/drivers/misc/ad525x_dpot-spi.c b/drivers/misc/ad525x_dpot-spi.c
index 39a7f517ee7e..d649cf2b6631 100644
--- a/drivers/misc/ad525x_dpot-spi.c
+++ b/drivers/misc/ad525x_dpot-spi.c
@@ -8,6 +8,7 @@
#include <linux/spi/spi.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include "ad525x_dpot.h"
@@ -81,14 +82,26 @@ static const struct ad_dpot_bus_ops bops = {
};
static int ad_dpot_spi_probe(struct spi_device *spi)
{
+ int ret;
+ const struct of_device_id *of_id = of_match_device(ad_dpot_spi_of_match,
+ &spi->dev);
+
struct ad_dpot_bus_data bdata = {
.client = spi,
.bops = &bops,
};
- return ad_dpot_probe(&spi->dev, &bdata,
+ if (of_id) {
+ ret = ad_dpot_probe(&spi->dev, &bdata,
+ of_id->data,
+ of_id->name);
+ } else {
+ ret = ad_dpot_probe(&spi->dev, &bdata,
spi_get_device_id(spi)->driver_data,
spi_get_device_id(spi)->name);
+ }
+
+ return ret;
}
static int ad_dpot_spi_remove(struct spi_device *spi)
@@ -129,9 +142,155 @@ static const struct spi_device_id ad_dpot_spi_id[] = {
};
MODULE_DEVICE_TABLE(spi, ad_dpot_spi_id);
+static const struct of_device_id ad_dpot_spi_of_match[] = {
+ {
+ .compatible = "ad,ad5160",
+ .name = "ad5160",
+ .data = (void *)AD5160_ID,
+ },
+ {
+ .compatible = "ad,ad5161",
+ .name = "ad5161",
+ .data = (void *)AD5161_ID,
+ },
+ {
+ .compatible = "ad,ad5162",
+ .name = "ad5162",
+ .data = (void *)AD5162_ID,
+ },
+ {
+ .compatible = "ad,ad5165",
+ .name = "ad5165",
+ .data = (void *)AD5165_ID,
+ },
+ {
+ .compatible = "ad,ad5200",
+ .name = "ad5200",
+ .data = (void *)AD5200_ID,
+ },
+ {
+ .compatible = "ad,ad5201",
+ .name = "ad5201",
+ .data = (void *)AD5201_ID,
+ },
+ {
+ .compatible = "ad,ad5203",
+ .name = "ad5203",
+ .data = (void *)AD5203_ID,
+ },
+ {
+ .compatible = "ad,ad5204",
+ .name = "ad5204",
+ .data = (void *)AD5204_ID,
+ },
+ {
+ .compatible = "ad,ad5206",
+ .name = "ad5206",
+ .data = (void *)AD5206_ID,
+ },
+ {
+ .compatible = "ad,ad5207",
+ .name = "ad5207",
+ .data = (void *)AD5207_ID,
+ },
+ {
+ .compatible = "ad,ad5231",
+ .name = "ad5231",
+ .data = (void *)AD5231_ID,
+ },
+ {
+ .compatible = "ad,ad5232",
+ .name = "ad5232",
+ .data = (void *)AD5232_ID,
+ },
+ {
+ .compatible = "ad,ad5233",
+ .name = "ad5233",
+ .data = (void *)AD5233_ID,
+ },
+ {
+ .compatible = "ad,ad5235",
+ .name = "ad5235",
+ .data = (void *)AD5235_ID,
+ },
+ {
+ .compatible = "ad,ad5260",
+ .name = "ad5260",
+ .data = (void *)AD5260_ID,
+ },
+ {
+ .compatible = "ad,ad5262",
+ .name = "ad5262",
+ .data = (void *)AD5262_ID,
+ },
+ {
+ .compatible = "ad,ad5263",
+ .name = "ad5263",
+ .data = (void *)AD5263_ID,
+ },
+ {
+ .compatible = "ad,ad5290",
+ .name = "ad5290",
+ .data = (void *)AD5290_ID,
+ },
+ {
+ .compatible = "ad,ad5291",
+ .name = "ad5291",
+ .data = (void *)AD5291_ID,
+ },
+ {
+ .compatible = "ad,ad5292",
+ .name = "ad5292",
+ .data = (void *)AD5292_ID,
+ },
+ {
+ .compatible = "ad,ad5293",
+ .name = "ad5293",
+ .data = (void *)AD5293_ID,
+ },
+ {
+ .compatible = "ad,ad7376",
+ .name = "ad7376",
+ .data = (void *)AD7376_ID,
+ },
+ {
+ .compatible = "ad,ad8400",
+ .name = "ad8400",
+ .data = (void *)AD8400_ID,
+ },
+ {
+ .compatible = "ad,ad8402",
+ .name = "ad8402",
+ .data = (void *)AD8402_ID,
+ },
+ {
+ .compatible = "ad,ad8403",
+ .name = "ad8403",
+ .data = (void *)AD8403_ID,
+ },
+ {
+ .compatible = "ad,adn2850",
+ .name = "adn2850",
+ .data = (void *)ADN2850_ID,
+ },
+ {
+ .compatible = "ad,ad5270",
+ .name = "ad5270",
+ .data = (void *)AD5270_ID,
+ },
+ {
+ .compatible = "ad,ad5271",
+ .name = "ad5271",
+ .data = (void *)AD5271_ID,
+ },
+ { }
+};
+MODULE_DEVICE_TABLE(of, ad_dpot_spi_of_match);
+
static struct spi_driver ad_dpot_spi_driver = {
.driver = {
.name = "ad_dpot",
+ .of_match_table = ad_dpot_spi_of_match,
},
.probe = ad_dpot_spi_probe,
.remove = ad_dpot_spi_remove,
--
2.13.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] misc: ad525x_dpot_spi: Add device tree support
2017-05-26 18:17 [PATCH] misc: ad525x_dpot_spi: Add device tree support Roshni Shah
@ 2017-05-26 19:16 ` kbuild test robot
2017-05-26 20:18 ` Arnd Bergmann
2017-05-27 11:08 ` Lars-Peter Clausen
2 siblings, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2017-05-26 19:16 UTC (permalink / raw)
To: Roshni Shah
Cc: kbuild-all, robh+dt, mark.rutland, arnd, gregkh, devicetree,
linux-kernel, Roshni Shah
[-- Attachment #1: Type: text/plain, Size: 2052 bytes --]
Hi Roshni,
[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on v4.12-rc2 next-20170526]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Roshni-Shah/misc-ad525x_dpot_spi-Add-device-tree-support/20170527-023127
config: x86_64-randconfig-x010-201721 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All warnings (new ones prefixed by >>):
drivers/misc/ad525x_dpot-spi.c: In function 'ad_dpot_spi_probe':
>> drivers/misc/ad525x_dpot-spi.c:96:9: warning: passing argument 3 of 'ad_dpot_probe' makes integer from pointer without a cast [-Wint-conversion]
of_id->data,
^~~~~
In file included from drivers/misc/ad525x_dpot-spi.c:13:0:
drivers/misc/ad525x_dpot.h:211:5: note: expected 'long unsigned int' but argument is of type 'const void * const'
int ad_dpot_probe(struct device *dev, struct ad_dpot_bus_data *bdata,
^~~~~~~~~~~~~
vim +/ad_dpot_probe +96 drivers/misc/ad525x_dpot-spi.c
80 .write_r8d8 = write16,
81 .write_r8d16 = write24,
82 };
83 static int ad_dpot_spi_probe(struct spi_device *spi)
84 {
85 int ret;
86 const struct of_device_id *of_id = of_match_device(ad_dpot_spi_of_match,
87 &spi->dev);
88
89 struct ad_dpot_bus_data bdata = {
90 .client = spi,
91 .bops = &bops,
92 };
93
94 if (of_id) {
95 ret = ad_dpot_probe(&spi->dev, &bdata,
> 96 of_id->data,
97 of_id->name);
98 } else {
99 ret = ad_dpot_probe(&spi->dev, &bdata,
100 spi_get_device_id(spi)->driver_data,
101 spi_get_device_id(spi)->name);
102 }
103
104 return ret;
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33810 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] misc: ad525x_dpot_spi: Add device tree support
2017-05-26 18:17 [PATCH] misc: ad525x_dpot_spi: Add device tree support Roshni Shah
2017-05-26 19:16 ` kbuild test robot
@ 2017-05-26 20:18 ` Arnd Bergmann
2017-05-27 11:08 ` Lars-Peter Clausen
2 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2017-05-26 20:18 UTC (permalink / raw)
To: Roshni Shah
Cc: Rob Herring, Mark Rutland, gregkh, devicetree, Linux Kernel Mailing List
On Fri, May 26, 2017 at 8:17 PM, Roshni Shah <roshni.shah@timesys.com> wrote:
> @@ -81,14 +82,26 @@ static const struct ad_dpot_bus_ops bops = {
> +static const struct of_device_id ad_dpot_spi_of_match[] = {
> + {
> + .compatible = "ad,ad5160",
> + .name = "ad5160",
> + .data = (void *)AD5160_ID,
> + },
> + {
> + .compatible = "ad,ad5161",
> + .name = "ad5161",
> + .data = (void *)AD5161_ID,
> + },
You should only match on 'compatible', not on 'name'. By convention,
the name just describes what the device does.
Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] misc: ad525x_dpot_spi: Add device tree support
2017-05-26 18:17 [PATCH] misc: ad525x_dpot_spi: Add device tree support Roshni Shah
2017-05-26 19:16 ` kbuild test robot
2017-05-26 20:18 ` Arnd Bergmann
@ 2017-05-27 11:08 ` Lars-Peter Clausen
2 siblings, 0 replies; 4+ messages in thread
From: Lars-Peter Clausen @ 2017-05-27 11:08 UTC (permalink / raw)
To: Roshni Shah, robh+dt, mark.rutland; +Cc: arnd, gregkh, devicetree, linux-kernel
Hi,
Thanks for the patch.
On 05/26/2017 08:17 PM, Roshni Shah wrote:
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/misc/ad525x_dpot-spi.txt
> @@ -0,0 +1,44 @@
> +Digital Potentiometers (SPI) compatible with Analog Devices family
> +
> +Required properties:
> +- compatible: Should be one of
> + * "ad,ad5160"
The Analog Devices vendor prefix is adi.
- Lars
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-27 11:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-26 18:17 [PATCH] misc: ad525x_dpot_spi: Add device tree support Roshni Shah
2017-05-26 19:16 ` kbuild test robot
2017-05-26 20:18 ` Arnd Bergmann
2017-05-27 11:08 ` Lars-Peter Clausen
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).