devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Vaussard <florian.vaussard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Hartmut Knaack <knaack.h-Mmb7MZpHnFY@public.gmane.org>,
	Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>,
	Peter Meerwald-Stadler
	<pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org>
Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Ian Campbell
	<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
	Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	Martin Kepplinger
	<martink-1KBjaw7Xf1+zQB+pC5nmwQ@public.gmane.org>,
	linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Florian Vaussard
	<florian.vaussard-EWQkb/GNqlFyDzI6CaY1VQ@public.gmane.org>
Subject: [PATCH 3/3] iio: adc: max1363: Add device tree binding
Date: Tue, 21 Jun 2016 09:09:29 +0200	[thread overview]
Message-ID: <1466492969-2185-4-git-send-email-florian.vaussard@heig-vd.ch> (raw)
In-Reply-To: <1466492969-2185-1-git-send-email-florian.vaussard-EWQkb/GNqlFyDzI6CaY1VQ@public.gmane.org>

This patch adds the necessary device tree binding to allow DT probing of
currently supported parts.

Signed-off-by: Florian Vaussard <florian.vaussard-EWQkb/GNqlFyDzI6CaY1VQ@public.gmane.org>
---
 drivers/iio/adc/max1363.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c
index b5d28c0..5403ec2 100644
--- a/drivers/iio/adc/max1363.c
+++ b/drivers/iio/adc/max1363.c
@@ -25,6 +25,8 @@
 #include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -1516,6 +1518,50 @@ done:
 	return IRQ_HANDLED;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id max1363_of_match[] = {
+	{ .compatible = "maxim,max1361", .data = (void *)max1361 },
+	{ .compatible = "maxim,max1362", .data = (void *)max1362 },
+	{ .compatible = "maxim,max1363", .data = (void *)max1363 },
+	{ .compatible = "maxim,max1364", .data = (void *)max1364 },
+	{ .compatible = "maxim,max1036", .data = (void *)max1036 },
+	{ .compatible = "maxim,max1037", .data = (void *)max1037 },
+	{ .compatible = "maxim,max1038", .data = (void *)max1038 },
+	{ .compatible = "maxim,max1039", .data = (void *)max1039 },
+	{ .compatible = "maxim,max1136", .data = (void *)max1136 },
+	{ .compatible = "maxim,max1137", .data = (void *)max1137 },
+	{ .compatible = "maxim,max1138", .data = (void *)max1138 },
+	{ .compatible = "maxim,max1139", .data = (void *)max1139 },
+	{ .compatible = "maxim,max1236", .data = (void *)max1236 },
+	{ .compatible = "maxim,max1237", .data = (void *)max1237 },
+	{ .compatible = "maxim,max1238", .data = (void *)max1238 },
+	{ .compatible = "maxim,max1239", .data = (void *)max1239 },
+	{ .compatible = "maxim,max11600", .data = (void *)max11600 },
+	{ .compatible = "maxim,max11601", .data = (void *)max11601 },
+	{ .compatible = "maxim,max11602", .data = (void *)max11602 },
+	{ .compatible = "maxim,max11603", .data = (void *)max11603 },
+	{ .compatible = "maxim,max11604", .data = (void *)max11604 },
+	{ .compatible = "maxim,max11605", .data = (void *)max11605 },
+	{ .compatible = "maxim,max11606", .data = (void *)max11606 },
+	{ .compatible = "maxim,max11607", .data = (void *)max11607 },
+	{ .compatible = "maxim,max11608", .data = (void *)max11608 },
+	{ .compatible = "maxim,max11609", .data = (void *)max11609 },
+	{ .compatible = "maxim,max11610", .data = (void *)max11610 },
+	{ .compatible = "maxim,max11611", .data = (void *)max11611 },
+	{ .compatible = "maxim,max11612", .data = (void *)max11612 },
+	{ .compatible = "maxim,max11613", .data = (void *)max11613 },
+	{ .compatible = "maxim,max11614", .data = (void *)max11614 },
+	{ .compatible = "maxim,max11615", .data = (void *)max11615 },
+	{ .compatible = "maxim,max11616", .data = (void *)max11616 },
+	{ .compatible = "maxim,max11617", .data = (void *)max11617 },
+	{ .compatible = "maxim,max11644", .data = (void *)max11644 },
+	{ .compatible = "maxim,max11645", .data = (void *)max11645 },
+	{ .compatible = "maxim,max11646", .data = (void *)max11646 },
+	{ .compatible = "maxim,max11647", .data = (void *)max11647 },
+	{ /* sentinel */ }
+};
+#endif
+
 static int max1363_probe(struct i2c_client *client,
 			 const struct i2c_device_id *id)
 {
@@ -1523,6 +1569,15 @@ static int max1363_probe(struct i2c_client *client,
 	struct max1363_state *st;
 	struct iio_dev *indio_dev;
 	struct regulator *vref;
+	unsigned long devid;
+	const struct of_device_id *match;
+
+	match = of_match_device(of_match_ptr(max1363_of_match),
+				&client->dev);
+	if (match)
+		devid = (int)of_device_get_match_data(&client->dev);
+	else
+		devid = id->driver_data;
 
 	indio_dev = devm_iio_device_alloc(&client->dev,
 					  sizeof(struct max1363_state));
@@ -1549,7 +1604,7 @@ static int max1363_probe(struct i2c_client *client,
 	/* this is only used for device removal purposes */
 	i2c_set_clientdata(client, indio_dev);
 
-	st->chip_info = &max1363_chip_info_tbl[id->driver_data];
+	st->chip_info = &max1363_chip_info_tbl[devid];
 	st->client = client;
 
 	st->vref_uv = st->chip_info->int_vref_mv * 1000;
@@ -1692,6 +1747,7 @@ MODULE_DEVICE_TABLE(i2c, max1363_id);
 static struct i2c_driver max1363_driver = {
 	.driver = {
 		.name = "max1363",
+		.of_match_table = of_match_ptr(max1363_of_match),
 	},
 	.probe = max1363_probe,
 	.remove = max1363_remove,
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-06-21  7:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-21  7:09 [PATCH 0/3] iio: adc: max1363: Fix missing parts and add device tree Florian Vaussard
     [not found] ` <1466492969-2185-1-git-send-email-florian.vaussard-EWQkb/GNqlFyDzI6CaY1VQ@public.gmane.org>
2016-06-21  7:09   ` [PATCH 1/3] iio: adc: max1363: Fix missing i2c_device_id for MAX1164x parts Florian Vaussard
     [not found]     ` <1466492969-2185-2-git-send-email-florian.vaussard-EWQkb/GNqlFyDzI6CaY1VQ@public.gmane.org>
2016-06-26 17:02       ` Jonathan Cameron
2016-06-21  7:09   ` [PATCH 2/3] iio: adc: max1363: Add device tree binding documentation Florian Vaussard
     [not found]     ` <1466492969-2185-3-git-send-email-florian.vaussard-EWQkb/GNqlFyDzI6CaY1VQ@public.gmane.org>
2016-06-21 21:49       ` Rob Herring
2016-06-22  6:18         ` Florian Vaussard
     [not found]           ` <b48960b5-1965-b2cc-037b-eba4e7bbb7cb-EWQkb/GNqlFyDzI6CaY1VQ@public.gmane.org>
2016-06-26 17:02             ` Jonathan Cameron
2016-06-21  7:09   ` Florian Vaussard [this message]
2016-06-21 11:44     ` [PATCH 3/3] iio: adc: max1363: Add device tree binding kbuild test robot
     [not found]       ` <201606211912.JCmJ2q9D%fengguang.wu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-06-26 17:01         ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1466492969-2185-4-git-send-email-florian.vaussard@heig-vd.ch \
    --to=florian.vaussard-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=florian.vaussard-EWQkb/GNqlFyDzI6CaY1VQ@public.gmane.org \
    --cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
    --cc=jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=knaack.h-Mmb7MZpHnFY@public.gmane.org \
    --cc=lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org \
    --cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=martink-1KBjaw7Xf1+zQB+pC5nmwQ@public.gmane.org \
    --cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
    --cc=pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).