aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorWolfram Sang <w.sang@pengutronix.de>2010-11-17 07:00:48 -0500
committerGrant Likely <grant.likely@secretlab.ca>2010-12-24 04:13:36 -0500
commit9ed030d728f3bd03b6e869357da02725afda19a7 (patch)
tree2dfe452c10e5562a817197d686e7bed61d946fe4 /drivers
parent194588604765ac803f98fb9d19a36f6b835f4620 (diff)
misc/at24: parse device tree data
Information about the pagesize and read-only-status may also come from the devicetree. Parse this data, too, and act accordingly. While we are here, change the initialization printout a bit. write_max is useful to know to detect performance bottlenecks, the rest is superfluous. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/misc/eeprom/at24.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 559b0b3c16c3..3a53efc28821 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -20,6 +20,7 @@
20#include <linux/log2.h> 20#include <linux/log2.h>
21#include <linux/bitops.h> 21#include <linux/bitops.h>
22#include <linux/jiffies.h> 22#include <linux/jiffies.h>
23#include <linux/of.h>
23#include <linux/i2c.h> 24#include <linux/i2c.h>
24#include <linux/i2c/at24.h> 25#include <linux/i2c/at24.h>
25 26
@@ -457,6 +458,27 @@ static ssize_t at24_macc_write(struct memory_accessor *macc, const char *buf,
457 458
458/*-------------------------------------------------------------------------*/ 459/*-------------------------------------------------------------------------*/
459 460
461#ifdef CONFIG_OF
462static void at24_get_ofdata(struct i2c_client *client,
463 struct at24_platform_data *chip)
464{
465 const __be32 *val;
466 struct device_node *node = client->dev.of_node;
467
468 if (node) {
469 if (of_get_property(node, "read-only", NULL))
470 chip->flags |= AT24_FLAG_READONLY;
471 val = of_get_property(node, "pagesize", NULL);
472 if (val)
473 chip->page_size = be32_to_cpup(val);
474 }
475}
476#else
477static void at24_get_ofdata(struct i2c_client *client,
478 struct at24_platform_data *chip)
479{ }
480#endif /* CONFIG_OF */
481
460static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) 482static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
461{ 483{
462 struct at24_platform_data chip; 484 struct at24_platform_data chip;
@@ -485,6 +507,9 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
485 */ 507 */
486 chip.page_size = 1; 508 chip.page_size = 1;
487 509
510 /* update chipdata if OF is present */
511 at24_get_ofdata(client, &chip);
512
488 chip.setup = NULL; 513 chip.setup = NULL;
489 chip.context = NULL; 514 chip.context = NULL;
490 } 515 }
@@ -597,19 +622,15 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
597 622
598 i2c_set_clientdata(client, at24); 623 i2c_set_clientdata(client, at24);
599 624
600 dev_info(&client->dev, "%zu byte %s EEPROM %s\n", 625 dev_info(&client->dev, "%zu byte %s EEPROM, %s, %u bytes/write\n",
601 at24->bin.size, client->name, 626 at24->bin.size, client->name,
602 writable ? "(writable)" : "(read-only)"); 627 writable ? "writable" : "read-only", at24->write_max);
603 if (use_smbus == I2C_SMBUS_WORD_DATA || 628 if (use_smbus == I2C_SMBUS_WORD_DATA ||
604 use_smbus == I2C_SMBUS_BYTE_DATA) { 629 use_smbus == I2C_SMBUS_BYTE_DATA) {
605 dev_notice(&client->dev, "Falling back to %s reads, " 630 dev_notice(&client->dev, "Falling back to %s reads, "
606 "performance will suffer\n", use_smbus == 631 "performance will suffer\n", use_smbus ==
607 I2C_SMBUS_WORD_DATA ? "word" : "byte"); 632 I2C_SMBUS_WORD_DATA ? "word" : "byte");
608 } 633 }
609 dev_dbg(&client->dev,
610 "page_size %d, num_addresses %d, write_max %d, use_smbus %d\n",
611 chip.page_size, num_addresses,
612 at24->write_max, use_smbus);
613 634
614 /* export data to kernel code */ 635 /* export data to kernel code */
615 if (chip.setup) 636 if (chip.setup)