Message ID | 5F1D4949966C4C509360407B0F948EFE@HIGHGuY (mailing list archive) |
---|---|
State | Not Applicable |
Delegated to: | Grant Likely |
Headers | show |
Hi, > As far as I could tell, using compatible = <24c64>; didn't load the right > module (module name is at24) and using at24 caused a device id mismatch > because at24 is not a known device ID. I could be wrong here and if so, I'd > very much like a source code hint as to why... Have you tried "<vendor>, 24c64"? All I can say is that it works for me. Plain at24 worked for years with pcm030.dts and pcm032.dts, so I don't know which issue you are facing. This patch is just about extending the support. > My patch worked by changing drivers/of/of_i2c.c to allow a generic > kind = " " statement that was filled in as i2c_board_info.type, to allow > the module name and the device id to be different. > This makes the at24 driver no longer rely on probing (which it claims > is buggy anyway) and also benefits other drivers that support multiple > devices, but where probing is difficult (e.g. lm90 driver). > > I'm in the process of getting employer approval to get these patches > upstream. I hope you will get it approved, it is a lot easier to talk about code :) Best regards, Wolfram
On Sat, Nov 20, 2010 at 1:42 PM, Wolfram Sang <w.sang@pengutronix.de> wrote: > Hi, > >> As far as I could tell, using compatible = <24c64>; didn't load the right >> module (module name is at24) and using at24 caused a device id mismatch >> because at24 is not a known device ID. I could be wrong here and if so, I'd >> very much like a source code hint as to why... > > Have you tried "<vendor>, 24c64"? All I can say is that it works for me. Plain > at24 worked for years with pcm030.dts and pcm032.dts, so I don't know which > issue you are facing. This patch is just about extending the support. According to of_modalias_node, the prefix is stripped anyway, so that wouldn't help. The code probably worked using the buggy probing... > >> My patch worked by changing drivers/of/of_i2c.c to allow a generic >> kind = " " statement that was filled in as i2c_board_info.type, to allow >> the module name and the device id to be different. >> This makes the at24 driver no longer rely on probing (which it claims >> is buggy anyway) and also benefits other drivers that support multiple >> devices, but where probing is difficult (e.g. lm90 driver). >> >> I'm in the process of getting employer approval to get these patches >> upstream. > It'll get approved ;) It's the first time I'm taking these steps, but the procedures are there, so at most it'll take some extra time. > I hope you will get it approved, it is a lot easier to talk about code :) > > Best regards, > > Wolfram > > -- > Pengutronix e.K. | Wolfram Sang | > Industrial Linux Solutions | http://www.pengutronix.de/ | > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEARECAAYFAkznwjIACgkQD27XaX1/VRssnwCgg55UCwZFLcMI8kJI3mhCJQxL > N7kAoJHpLn5BJpNjET+ngaQFrGxUBQm1 > =tyTb > -----END PGP SIGNATURE----- > >
Hi Wolfram, I seem to be mistaken. I retried "compatible=<linux,24c64>" and it did all the right things. I was mistaken that request_module() only takes the driver name, at24 in this case, and not all device names in the table_ids. This pretty much makes my patch redundant. Thanks for helping me clear things out. Regards, Stijn On Sat, Nov 20, 2010 at 1:42 PM, Wolfram Sang <w.sang@pengutronix.de> wrote: > Hi, > >> As far as I could tell, using compatible = <24c64>; didn't load the right >> module (module name is at24) and using at24 caused a device id mismatch >> because at24 is not a known device ID. I could be wrong here and if so, I'd >> very much like a source code hint as to why... > > Have you tried "<vendor>, 24c64"? All I can say is that it works for me. Plain > at24 worked for years with pcm030.dts and pcm032.dts, so I don't know which > issue you are facing. This patch is just about extending the support. > >> My patch worked by changing drivers/of/of_i2c.c to allow a generic >> kind = " " statement that was filled in as i2c_board_info.type, to allow >> the module name and the device id to be different. >> This makes the at24 driver no longer rely on probing (which it claims >> is buggy anyway) and also benefits other drivers that support multiple >> devices, but where probing is difficult (e.g. lm90 driver). >> >> I'm in the process of getting employer approval to get these patches >> upstream. > > I hope you will get it approved, it is a lot easier to talk about code :) > > Best regards, > > Wolfram > > -- > Pengutronix e.K. | Wolfram Sang | > Industrial Linux Solutions | http://www.pengutronix.de/ | > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEARECAAYFAkznwjIACgkQD27XaX1/VRssnwCgg55UCwZFLcMI8kJI3mhCJQxL > N7kAoJHpLn5BJpNjET+ngaQFrGxUBQm1 > =tyTb > -----END PGP SIGNATURE----- > >
diff --git a/Documentation/powerpc/dts-bindings/eeprom.txt b/Documentation/powerpc/dts-bindings/eeprom.txt new file mode 100644 index 0000000..4342c10 --- /dev/null +++ b/Documentation/powerpc/dts-bindings/eeprom.txt @@ -0,0 +1,28 @@ +EEPROMs (I2C) + +Required properties: + + - compatible : should be "<manufacturer>,<type>" + If there is no specific driver for <manufacturer>, a generic + driver based on <type> is selected. Possible types are: + 24c00, 24c01, 24c02, 24c04, 24c08, 24c16, 24c32, 24c64, + 24c128, 24c256, 24c512, 24c1024, spd + + - reg : the I2C address of the EEPROM + +Optional properties: + + - pagesize : the length of the pagesize for writing. Please consult the + manual of your device, that value varies a lot. A wrong value + may result in data loss! If not specified, a safety value of + '1' is used which will be very slow. + + - read-only: this parameterless property disables writes to the eeprom + +Example: + +eeprom@52 { + compatible = "atmel,24c32"; + reg = <0x52>; + pagesize = <32>; +}; diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 559b0b3..3a53efc 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -20,6 +20,7 @@ #include <linux/log2.h> #include <linux/bitops.h> #include <linux/jiffies.h> +#include <linux/of.h> #include <linux/i2c.h> #include <linux/i2c/at24.h> @@ -457,6 +458,27 @@ static ssize_t at24_macc_write(struct memory_accessor *macc, const char *buf, /*-------------------------------------------------------------------------*/ +#ifdef CONFIG_OF +static void at24_get_ofdata(struct i2c_client *client, + struct at24_platform_data *chip) +{ + const __be32 *val; + struct device_node *node = client->dev.of_node; + + if (node) { + if (of_get_property(node, "read-only", NULL)) + chip->flags |= AT24_FLAG_READONLY; + val = of_get_property(node, "pagesize", NULL); + if (val) + chip->page_size = be32_to_cpup(val); + } +} +#else +static void at24_get_ofdata(struct i2c_client *client, + struct at24_platform_data *chip) +{ } +#endif /* CONFIG_OF */ + static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)