diff options
author | Javier Martinez Canillas <javier@osg.samsung.com> | 2017-03-03 09:29:23 -0500 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2017-03-08 19:29:32 -0500 |
commit | eb235c561d04ea64d19a0d3e1413f9c3bc25596c (patch) | |
tree | 36a7f5e0cc3cd93019faea379aa477119801eff4 /drivers/rtc | |
parent | ffbecfbdbeeebe9749398fe9eb9eab2dd47ddff4 (diff) |
rtc: m41t80: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.
But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/rtc-m41t80.c | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index 58698d21c2c3..5b070aa711f9 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/of_device.h> | ||
23 | #include <linux/rtc.h> | 24 | #include <linux/rtc.h> |
24 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
25 | #include <linux/mutex.h> | 26 | #include <linux/mutex.h> |
@@ -86,8 +87,61 @@ static const struct i2c_device_id m41t80_id[] = { | |||
86 | }; | 87 | }; |
87 | MODULE_DEVICE_TABLE(i2c, m41t80_id); | 88 | MODULE_DEVICE_TABLE(i2c, m41t80_id); |
88 | 89 | ||
90 | static const struct of_device_id m41t80_of_match[] = { | ||
91 | { | ||
92 | .compatible = "st,m41t62", | ||
93 | .data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT) | ||
94 | }, | ||
95 | { | ||
96 | .compatible = "st,m41t65", | ||
97 | .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_WD) | ||
98 | }, | ||
99 | { | ||
100 | .compatible = "st,m41t80", | ||
101 | .data = (void *)(M41T80_FEATURE_SQ) | ||
102 | }, | ||
103 | { | ||
104 | .compatible = "st,m41t81", | ||
105 | .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_SQ) | ||
106 | }, | ||
107 | { | ||
108 | .compatible = "st,m41t81s", | ||
109 | .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ) | ||
110 | }, | ||
111 | { | ||
112 | .compatible = "st,m41t82", | ||
113 | .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ) | ||
114 | }, | ||
115 | { | ||
116 | .compatible = "st,m41t83", | ||
117 | .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ) | ||
118 | }, | ||
119 | { | ||
120 | .compatible = "st,m41t84", | ||
121 | .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ) | ||
122 | }, | ||
123 | { | ||
124 | .compatible = "st,m41t85", | ||
125 | .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ) | ||
126 | }, | ||
127 | { | ||
128 | .compatible = "st,m41t87", | ||
129 | .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ) | ||
130 | }, | ||
131 | { | ||
132 | .compatible = "st,rv4162", | ||
133 | .data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT) | ||
134 | }, | ||
135 | { | ||
136 | .compatible = "rv4162", | ||
137 | .data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT) | ||
138 | }, | ||
139 | { } | ||
140 | }; | ||
141 | MODULE_DEVICE_TABLE(of, m41t80_of_match); | ||
142 | |||
89 | struct m41t80_data { | 143 | struct m41t80_data { |
90 | u8 features; | 144 | unsigned long features; |
91 | struct rtc_device *rtc; | 145 | struct rtc_device *rtc; |
92 | }; | 146 | }; |
93 | 147 | ||
@@ -786,7 +840,11 @@ static int m41t80_probe(struct i2c_client *client, | |||
786 | if (!m41t80_data) | 840 | if (!m41t80_data) |
787 | return -ENOMEM; | 841 | return -ENOMEM; |
788 | 842 | ||
789 | m41t80_data->features = id->driver_data; | 843 | if (client->dev.of_node) |
844 | m41t80_data->features = (unsigned long) | ||
845 | of_device_get_match_data(&client->dev); | ||
846 | else | ||
847 | m41t80_data->features = id->driver_data; | ||
790 | i2c_set_clientdata(client, m41t80_data); | 848 | i2c_set_clientdata(client, m41t80_data); |
791 | 849 | ||
792 | if (client->irq > 0) { | 850 | if (client->irq > 0) { |
@@ -894,6 +952,7 @@ static int m41t80_remove(struct i2c_client *client) | |||
894 | static struct i2c_driver m41t80_driver = { | 952 | static struct i2c_driver m41t80_driver = { |
895 | .driver = { | 953 | .driver = { |
896 | .name = "rtc-m41t80", | 954 | .name = "rtc-m41t80", |
955 | .of_match_table = of_match_ptr(m41t80_of_match), | ||
897 | .pm = &m41t80_pm, | 956 | .pm = &m41t80_pm, |
898 | }, | 957 | }, |
899 | .probe = m41t80_probe, | 958 | .probe = m41t80_probe, |