Skip to contentSkip to conversation

Add device tree support to ISL12022 driver

PATCH In review Stuart Longland 3 participants 8 messages Jul 16, 2014 – Jul 21, 2014

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

Hi all,

The attached patch adds support for configuring the ISL12022 real-time clock via the Device tree framework. This is based on what I've seen in the related ISL12057 driver, it has been tested and works on a Technologic Systems TS-7670 device which uses a ISL12020 RTC device, my device tree looks like this:

	apbx@80040000 {
		i2c0: i2c@80058000 {
			pinctrl-names = "default";
			pinctrl-0 = <&i2c0_pins_a>;
			clock-frequency = <400000>;
			status = "okay";

			isl12022@0x6f {
				compatible = "isl,isl12022";
				reg = <0x6f>;
			};
		};
		... etc
	};

Regards,
Stuart Longland

#1 lore raw

PATCH 1/1 drivers/rtc/rtc-isl12022.c: Device tree support

Add some support for configuring isl12020/isl12022 devices using the Device Tree blob.

---
 drivers/rtc/rtc-isl12022.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/rtc/rtc-isl12022.c +12 -0
index 03b8911..aa55f08 100644
@@ -17,6 +17,8 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/err.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 #define DRV_VERSION "0.1"
 
@@ -271,6 +273,13 @@ static int isl12022_probe(struct i2c_client *client,
 	return PTR_ERR_OR_ZERO(isl12022->rtc);
 }
 
+#ifdef CONFIG_OF
+static struct of_device_id isl12022_dt_match[] = {
+	{ .compatible = "isl,isl12022" },
+	{ },
+};
+#endif
+
 static const struct i2c_device_id isl12022_id[] = {
 	{ "isl12022", 0 },
 	{ }
@@ -280,6 +289,9 @@ MODULE_DEVICE_TABLE(i2c, isl12022_id);
 static struct i2c_driver isl12022_driver = {
 	.driver		= {
 		.name	= "rtc-isl12022",
+#ifdef CONFIG_OF
+		.of_match_table = of_match_ptr(isl12022_dt_match),
+#endif
 	},
 	.probe		= isl12022_probe,
 	.id_table	= isl12022_id,
Signature · 6 lines
1.8.5.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

Re: [PATCH] drivers/rtc/rtc-isl12022.c: Device tree support

Quoted 4 lines · Stuart Longland

Add some support for configuring isl12020/isl12022 devices using the Device Tree blob.

Please document this as with isl,isl12057, in Documentation/devicetree/bindings/i2c/trivial-devices.txt

The string itself looks fine.

Quoted 32 lines
---
 drivers/rtc/rtc-isl12022.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/rtc/rtc-isl12022.c +9 -0
index 03b8911..aa55f08 100644
@@ -17,6 +17,8 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/err.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 #define DRV_VERSION "0.1"
 
@@ -271,6 +273,13 @@ static int isl12022_probe(struct i2c_client *client,
 	return PTR_ERR_OR_ZERO(isl12022->rtc);
 }
 
+#ifdef CONFIG_OF
+static struct of_device_id isl12022_dt_match[] = {
+	{ .compatible = "isl,isl12022" },
+	{ },
+};
+#endif
+
 static const struct i2c_device_id isl12022_id[] = {
 	{ "isl12022", 0 },
 	{ }

drivers/rtc/rtc-isl12022.c MODULE_DEVICE_TABLE(i2c, isl12022_id); · line 294

Quoted 6 lines
drivers/rtc/rtc-isl12022.c +3 -0
@@ -280,6 +289,9 @@ MODULE_DEVICE_TABLE(i2c, isl12022_id);
 static struct i2c_driver isl12022_driver = {
 	.driver		= {
 		.name	= "rtc-isl12022",
+#ifdef CONFIG_OF
+		.of_match_table = of_match_ptr(isl12022_dt_match),
+#endif

You can drop the ifdef here, of_match_ptr(x) is NULL if !CONFIG_OF.

Thanks,
Mark.

#3 lore raw

Re: [PATCH] drivers/rtc/rtc-isl12022.c: Device tree support

Hi Mark,

Quoted 10 lines · Mark Rutland
Quoted 4 lines · Stuart Longland

Add some support for configuring isl12020/isl12022 devices using the Device Tree blob.

Please document this as with isl,isl12057, in Documentation/devicetree/bindings/i2c/trivial-devices.txt

The string itself looks fine.

No problems. I'll do this shortly.

Quoted 5 lines

drivers/rtc/rtc-isl12022.c MODULE_DEVICE_TABLE(i2c, isl12022_id); · line 294

Quoted 3 lines
drivers/rtc/rtc-isl12022.c +3 -0
+#ifdef CONFIG_OF
+		.of_match_table = of_match_ptr(isl12022_dt_match),
+#endif

You can drop the ifdef here, of_match_ptr(x) is NULL if !CONFIG_OF.

Ahh okay, I wasn't sure how of_match_ptr worked, so I thought I'd play it safe. A revised patch is coming right up.

Regards,

Signature · 12 lines
Stuart Longland
Systems Engineer
     _ ___
\  /|_) |                           T: +61 7 3535 9619
 \/ | \ |     38b Douglas Street    F: +61 7 3535 9699
   SYSTEMS    Milton QLD 4064       http://www.vrt.com.au


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

PATCH 1/2 drivers/rtc/rtc-isl12022.c: Device tree support

Add some support for configuring isl12020/isl12022 devices using the Device Tree blob.

---
 drivers/rtc/rtc-isl12022.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/rtc/rtc-isl12022.c +10 -0
index 03b8911..59b0ea2 100644
@@ -17,6 +17,8 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/err.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 #define DRV_VERSION "0.1"
 
@@ -271,6 +273,13 @@ static int isl12022_probe(struct i2c_client *client,
 	return PTR_ERR_OR_ZERO(isl12022->rtc);
 }
 
+#ifdef CONFIG_OF
+static struct of_device_id isl12022_dt_match[] = {
+	{ .compatible = "isl,isl12022" },
+	{ },
+};
+#endif
+
 static const struct i2c_device_id isl12022_id[] = {
 	{ "isl12022", 0 },
 	{ }
@@ -280,6 +289,7 @@ MODULE_DEVICE_TABLE(i2c, isl12022_id);
 static struct i2c_driver isl12022_driver = {
 	.driver		= {
 		.name	= "rtc-isl12022",
+		.of_match_table = of_match_ptr(isl12022_dt_match),
 	},
 	.probe		= isl12022_probe,
 	.id_table	= isl12022_id,
Signature · 1 line
1.8.5.5
#6 lore raw

PATCH 2/2 devicetree: Document binding for isl12022 driver

In reply to Stuart Longland
---
 Documentation/devicetree/bindings/i2c/trivial-devices.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/i2c/trivial-devices.txt +1 -0
index bef86e5..17e24e5 100644
@@ -55,6 +55,7 @@ fsl,sgtl5000		SGTL5000: Ultra Low-Power Audio Codec
 gmt,g751		G751: Digital Temperature Sensor and Thermal Watchdog with Two-Wire Interface
 infineon,slb9635tt	Infineon SLB9635 (Soft-) I2C TPM (old protocol, max 100khz)
 infineon,slb9645tt	Infineon SLB9645 I2C TPM (new protocol, max 400khz)
+isl,isl12022		Intersil ISL12020/ISL12022 I2C RTC Chip
 isl,isl12057		Intersil ISL12057 I2C RTC Chip
 maxim,ds1050		5 Bit Programmable, Pulse-Width Modulator
 maxim,max1237		Low-Power, 4-/12-Channel, 2-Wire Serial, 12-Bit ADCs
Signature · 1 line
1.8.5.5
#7 lore raw

Re: [PATCH] drivers/rtc/rtc-isl12022.c: Device tree support

In reply to Stuart Longland
Quoted 2 lines · On Wed, 16 Jul 2014 12:28:25 +1000 Stuart Longland…

Add some support for configuring isl12020/isl12022 devices using the Device Tree blob.

checkpatch said

WARNING: DT compatible string "isl,isl12022" appears un-documented -- check ./Documentation/devicetree/bindings/ #50: FILE: drivers/rtc/rtc-isl12022.c:278:
+ { .compatible = "isl,isl12022" },
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html