aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/misc/eeprom/at24.c71
1 files changed, 70 insertions, 1 deletions
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index a466e40acb2c..e0b4b36ef010 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -12,6 +12,7 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/of_device.h>
15#include <linux/slab.h> 16#include <linux/slab.h>
16#include <linux/delay.h> 17#include <linux/delay.h>
17#include <linux/mutex.h> 18#include <linux/mutex.h>
@@ -176,6 +177,64 @@ static const struct i2c_device_id at24_ids[] = {
176}; 177};
177MODULE_DEVICE_TABLE(i2c, at24_ids); 178MODULE_DEVICE_TABLE(i2c, at24_ids);
178 179
180static const struct of_device_id at24_of_match[] = {
181 {
182 .compatible = "atmel,24c00",
183 .data = (void *)AT24_DEVICE_MAGIC(128 / 8, AT24_FLAG_TAKE8ADDR)
184 },
185 {
186 .compatible = "atmel,24c01",
187 .data = (void *)AT24_DEVICE_MAGIC(1024 / 8, 0)
188 },
189 {
190 .compatible = "atmel,24c02",
191 .data = (void *)AT24_DEVICE_MAGIC(2048 / 8, 0)
192 },
193 {
194 .compatible = "atmel,spd",
195 .data = (void *)AT24_DEVICE_MAGIC(2048 / 8,
196 AT24_FLAG_READONLY | AT24_FLAG_IRUGO)
197 },
198 {
199 .compatible = "atmel,24c04",
200 .data = (void *)AT24_DEVICE_MAGIC(4096 / 8, 0)
201 },
202 {
203 .compatible = "atmel,24c08",
204 .data = (void *)AT24_DEVICE_MAGIC(8192 / 8, 0)
205 },
206 {
207 .compatible = "atmel,24c16",
208 .data = (void *)AT24_DEVICE_MAGIC(16384 / 8, 0)
209 },
210 {
211 .compatible = "atmel,24c32",
212 .data = (void *)AT24_DEVICE_MAGIC(32768 / 8, AT24_FLAG_ADDR16)
213 },
214 {
215 .compatible = "atmel,24c64",
216 .data = (void *)AT24_DEVICE_MAGIC(65536 / 8, AT24_FLAG_ADDR16)
217 },
218 {
219 .compatible = "atmel,24c128",
220 .data = (void *)AT24_DEVICE_MAGIC(131072 / 8, AT24_FLAG_ADDR16)
221 },
222 {
223 .compatible = "atmel,24c256",
224 .data = (void *)AT24_DEVICE_MAGIC(262144 / 8, AT24_FLAG_ADDR16)
225 },
226 {
227 .compatible = "atmel,24c512",
228 .data = (void *)AT24_DEVICE_MAGIC(524288 / 8, AT24_FLAG_ADDR16)
229 },
230 {
231 .compatible = "atmel,24c1024",
232 .data = (void *)AT24_DEVICE_MAGIC(1048576 / 8, AT24_FLAG_ADDR16)
233 },
234 { },
235};
236MODULE_DEVICE_TABLE(of, at24_of_match);
237
179static const struct acpi_device_id at24_acpi_ids[] = { 238static const struct acpi_device_id at24_acpi_ids[] = {
180 { "INT3499", AT24_DEVICE_MAGIC(8192 / 8, 0) }, 239 { "INT3499", AT24_DEVICE_MAGIC(8192 / 8, 0) },
181 { } 240 { }
@@ -629,7 +688,16 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
629 if (client->dev.platform_data) { 688 if (client->dev.platform_data) {
630 chip = *(struct at24_platform_data *)client->dev.platform_data; 689 chip = *(struct at24_platform_data *)client->dev.platform_data;
631 } else { 690 } else {
632 if (id) { 691 /*
692 * The I2C core allows OF nodes compatibles to match against the
693 * I2C device ID table as a fallback, so check not only if an OF
694 * node is present but also if it matches an OF device ID entry.
695 */
696 if (client->dev.of_node &&
697 of_match_device(at24_of_match, &client->dev)) {
698 magic = (kernel_ulong_t)
699 of_device_get_match_data(&client->dev);
700 } else if (id) {
633 magic = id->driver_data; 701 magic = id->driver_data;
634 } else { 702 } else {
635 const struct acpi_device_id *aid; 703 const struct acpi_device_id *aid;
@@ -855,6 +923,7 @@ static int at24_remove(struct i2c_client *client)
855static struct i2c_driver at24_driver = { 923static struct i2c_driver at24_driver = {
856 .driver = { 924 .driver = {
857 .name = "at24", 925 .name = "at24",
926 .of_match_table = at24_of_match,
858 .acpi_match_table = ACPI_PTR(at24_acpi_ids), 927 .acpi_match_table = ACPI_PTR(at24_acpi_ids),
859 }, 928 },
860 .probe = at24_probe, 929 .probe = at24_probe,