From: Javier Martinez Canillas <javier@osg.samsung.com>
To: linux-kernel@vger.kernel.org
Cc: Wolfram Sang <wsa@the-dreams.de>,
Javier Martinez Canillas <javier@osg.samsung.com>,
Simon Horman <horms@verge.net.au>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Alexandre Belloni <alexandre.belloni@free-electrons.com>,
linux-i2c@vger.kernel.org
Subject: [PATCH v3 02/21] eeprom: at24: Add OF device ID table
Date: Thu, 13 Apr 2017 22:04:26 -0300 [thread overview]
Message-ID: <20170414010445.21727-3-javier@osg.samsung.com> (raw)
In-Reply-To: <20170414010445.21727-1-javier@osg.samsung.com>
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.
Suggested-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
Changes in v3:
- Fix wrong .data values for "atmel,24c02" and "atmel,24c64" entries.
Changes in v2:
- Only add a single OF device ID entry for each device type (Wolfram Sang).
drivers/misc/eeprom/at24.c | 65 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 64 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 764ff5df0dbc..6269de1457b9 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -12,6 +12,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/mutex.h>
@@ -175,6 +176,64 @@ static const struct i2c_device_id at24_ids[] = {
};
MODULE_DEVICE_TABLE(i2c, at24_ids);
+static const struct of_device_id at24_of_match[] = {
+ {
+ .compatible = "atmel,24c00",
+ .data = (void *)AT24_DEVICE_MAGIC(128 / 8, AT24_FLAG_TAKE8ADDR)
+ },
+ {
+ .compatible = "atmel,24c01",
+ .data = (void *)AT24_DEVICE_MAGIC(1024 / 8, 0)
+ },
+ {
+ .compatible = "atmel,24c02",
+ .data = (void *)AT24_DEVICE_MAGIC(2048 / 8, 0)
+ },
+ {
+ .compatible = "at24,spd",
+ .data = (void *)AT24_DEVICE_MAGIC(2048 / 8,
+ AT24_FLAG_READONLY | AT24_FLAG_IRUGO)
+ },
+ {
+ .compatible = "atmel,24c04",
+ .data = (void *)AT24_DEVICE_MAGIC(4096 / 8, 0)
+ },
+ {
+ .compatible = "atmel,24c08",
+ .data = (void *)AT24_DEVICE_MAGIC(8192 / 8, 0)
+ },
+ {
+ .compatible = "atmel,24c16",
+ .data = (void *)AT24_DEVICE_MAGIC(16384 / 8, 0)
+ },
+ {
+ .compatible = "atmel,24c32",
+ .data = (void *)AT24_DEVICE_MAGIC(32768 / 8, AT24_FLAG_ADDR16)
+ },
+ {
+ .compatible = "atmel,24c64",
+ .data = (void *)AT24_DEVICE_MAGIC(65536 / 8, AT24_FLAG_ADDR16)
+ },
+ {
+ .compatible = "atmel,24c128",
+ .data = (void *)AT24_DEVICE_MAGIC(131072 / 8, AT24_FLAG_ADDR16)
+ },
+ {
+ .compatible = "atmel,24c256",
+ .data = (void *)AT24_DEVICE_MAGIC(262144 / 8, AT24_FLAG_ADDR16)
+ },
+ {
+ .compatible = "atmel,24c512",
+ .data = (void *)AT24_DEVICE_MAGIC(524288 / 8, AT24_FLAG_ADDR16)
+ },
+ {
+ .compatible = "atmel,24c1024",
+ .data = (void *)AT24_DEVICE_MAGIC(1048576 / 8, AT24_FLAG_ADDR16)
+ },
+ { },
+};
+MODULE_DEVICE_TABLE(of, at24_of_match);
+
static const struct acpi_device_id at24_acpi_ids[] = {
{ "INT3499", AT24_DEVICE_MAGIC(8192 / 8, 0) },
{ }
@@ -598,7 +657,10 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
if (client->dev.platform_data) {
chip = *(struct at24_platform_data *)client->dev.platform_data;
} else {
- if (id) {
+ if (client->dev.of_node) {
+ magic = (kernel_ulong_t)
+ of_device_get_match_data(&client->dev);
+ } else if (id) {
magic = id->driver_data;
} else {
const struct acpi_device_id *aid;
@@ -814,6 +876,7 @@ static int at24_remove(struct i2c_client *client)
static struct i2c_driver at24_driver = {
.driver = {
.name = "at24",
+ .of_match_table = at24_of_match,
.acpi_match_table = ACPI_PTR(at24_acpi_ids),
},
.probe = at24_probe,
--
2.9.3
next prev parent reply other threads:[~2017-04-14 1:05 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20170414010445.21727-1-javier@osg.samsung.com>
2017-04-14 1:04 ` [PATCH v3 01/21] dt-bindings: i2c: eeprom: Document manufacturer used as generic fallback Javier Martinez Canillas
2017-04-19 23:27 ` Rob Herring
2017-04-19 23:35 ` Rob Herring
2017-05-15 10:48 ` Javier Martinez Canillas
2017-04-14 1:04 ` Javier Martinez Canillas [this message]
2017-04-14 1:04 ` [PATCH v3 03/21] ARM: dts: omap: Add generic compatible string for I2C EEPROM Javier Martinez Canillas
2017-04-14 14:17 ` Tony Lindgren
2017-04-19 23:56 ` Rob Herring
2017-05-15 10:55 ` Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 04/21] ARM: dts: turris-omnia: " Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 05/21] ARM: dts: at91: " Javier Martinez Canillas
2017-05-15 9:32 ` Alexandre Belloni
2017-04-14 1:04 ` [PATCH v3 06/21] ARM: dts: efm32: " Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 07/21] ARM: dts: imx: " Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 08/21] ARM: dts: keystone: " Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 09/21] ARM: dts: lpc18xx: " Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 10/21] ARM: dts: r7s72100: " Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 11/21] ARM: dts: koelsch: " Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 12/21] ARM: dts: socfpga: " Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 13/21] ARM: dts: uniphier: " Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 14/21] ARM: dts: zynq: " Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 15/21] arm64: dts: ls1043a: " Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 16/21] arm64: zynqmp: " Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 17/21] powerpc/5200: " Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 18/21] powerpc/fsl: " Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 19/21] powerpc/512x: " Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 20/21] powerpc/83xx: " Javier Martinez Canillas
2017-04-14 1:04 ` [PATCH v3 21/21] powerpc/44x: " Javier Martinez Canillas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170414010445.21727-3-javier@osg.samsung.com \
--to=javier@osg.samsung.com \
--cc=alexandre.belloni@free-electrons.com \
--cc=andy.shevchenko@gmail.com \
--cc=horms@verge.net.au \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wsa@the-dreams.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).