diff options
author | Javier Martinez Canillas <javier@osg.samsung.com> | 2017-03-03 09:29:24 -0500 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2017-03-08 19:29:34 -0500 |
commit | ff764b88e63a097a6a8383f0f1f76e7fa5a5e096 (patch) | |
tree | 6173c5ba4260ddc82142ed6c6f5807c063c8d01e /drivers/rtc | |
parent | eb235c561d04ea64d19a0d3e1413f9c3bc25596c (diff) |
rtc: rs5c372: 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-rs5c372.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c index c8c757466783..d4eff8d7131f 100644 --- a/drivers/rtc/rtc-rs5c372.c +++ b/drivers/rtc/rtc-rs5c372.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/bcd.h> | 15 | #include <linux/bcd.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/of_device.h> | ||
18 | 19 | ||
19 | /* | 20 | /* |
20 | * Ricoh has a family of I2C based RTCs, which differ only slightly from | 21 | * Ricoh has a family of I2C based RTCs, which differ only slightly from |
@@ -83,6 +84,35 @@ static const struct i2c_device_id rs5c372_id[] = { | |||
83 | }; | 84 | }; |
84 | MODULE_DEVICE_TABLE(i2c, rs5c372_id); | 85 | MODULE_DEVICE_TABLE(i2c, rs5c372_id); |
85 | 86 | ||
87 | static const struct of_device_id rs5c372_of_match[] = { | ||
88 | { | ||
89 | .compatible = "ricoh,r2025sd", | ||
90 | .data = (void *)rtc_r2025sd | ||
91 | }, | ||
92 | { | ||
93 | .compatible = "ricoh,r2221tl", | ||
94 | .data = (void *)rtc_r2221tl | ||
95 | }, | ||
96 | { | ||
97 | .compatible = "ricoh,rs5c372a", | ||
98 | .data = (void *)rtc_rs5c372a | ||
99 | }, | ||
100 | { | ||
101 | .compatible = "ricoh,rs5c372b", | ||
102 | .data = (void *)rtc_rs5c372b | ||
103 | }, | ||
104 | { | ||
105 | .compatible = "ricoh,rv5c386", | ||
106 | .data = (void *)rtc_rv5c386 | ||
107 | }, | ||
108 | { | ||
109 | .compatible = "ricoh,rv5c387a", | ||
110 | .data = (void *)rtc_rv5c387a | ||
111 | }, | ||
112 | { } | ||
113 | }; | ||
114 | MODULE_DEVICE_TABLE(of, rs5c372_of_match); | ||
115 | |||
86 | /* REVISIT: this assumes that: | 116 | /* REVISIT: this assumes that: |
87 | * - we're in the 21st century, so it's safe to ignore the century | 117 | * - we're in the 21st century, so it's safe to ignore the century |
88 | * bit for rv5c38[67] (REG_MONTH bit 7); | 118 | * bit for rv5c38[67] (REG_MONTH bit 7); |
@@ -581,7 +611,11 @@ static int rs5c372_probe(struct i2c_client *client, | |||
581 | 611 | ||
582 | rs5c372->client = client; | 612 | rs5c372->client = client; |
583 | i2c_set_clientdata(client, rs5c372); | 613 | i2c_set_clientdata(client, rs5c372); |
584 | rs5c372->type = id->driver_data; | 614 | if (client->dev.of_node) |
615 | rs5c372->type = (enum rtc_type) | ||
616 | of_device_get_match_data(&client->dev); | ||
617 | else | ||
618 | rs5c372->type = id->driver_data; | ||
585 | 619 | ||
586 | /* we read registers 0x0f then 0x00-0x0f; skip the first one */ | 620 | /* we read registers 0x0f then 0x00-0x0f; skip the first one */ |
587 | rs5c372->regs = &rs5c372->buf[1]; | 621 | rs5c372->regs = &rs5c372->buf[1]; |
@@ -673,6 +707,7 @@ static int rs5c372_remove(struct i2c_client *client) | |||
673 | static struct i2c_driver rs5c372_driver = { | 707 | static struct i2c_driver rs5c372_driver = { |
674 | .driver = { | 708 | .driver = { |
675 | .name = "rtc-rs5c372", | 709 | .name = "rtc-rs5c372", |
710 | .of_match_table = of_match_ptr(rs5c372_of_match), | ||
676 | }, | 711 | }, |
677 | .probe = rs5c372_probe, | 712 | .probe = rs5c372_probe, |
678 | .remove = rs5c372_remove, | 713 | .remove = rs5c372_remove, |