[i2c] Fwd: [PATCH 2/3] I2C: at24: add kernel interface for reading/writing EEPROM

Jon Smirl jonsmirl at gmail.com
Wed Aug 27 15:40:22 CEST 2008


On 8/27/08, David Brownell <david-b at pacbell.net> wrote:
> On Tuesday 26 August 2008, Trent Piepho wrote:
>  > Lots of tv cards have eeproms with configuration information.  They use an
>  > I2C driver called tveeprom that exports this:
>  >
>  > int tveeprom_read(struct i2c_client *c, unsigned char *eedata, int len)
>
>
> That presumes the driver somehow has access to that I2C client.

How about using bus_find_device? PowerPC uses it to locate the i2c
device using pointers in the device tree.

+static int of_dev_node_match(struct device *dev, void *data)
+{
+        return dev->archdata.of_node == data;
+}
+
+struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
+{
+	struct device *dev;
+	
+	dev = bus_find_device(&i2c_bus_type, NULL, node,
+					 of_dev_node_match);
+	if (!dev)
+		return NULL;
+		
+	return to_i2c_client(dev);
+}
+EXPORT_SYMBOL(of_find_i2c_device_by_node);
+




>
>  (Also, that it's an I2C EEPROM.  I keep wanting to have something
>  usable for SPI EEPROMs and NVRAM too.  But maybe nobody else cares.)
>
>
>
>  > > Last I heard, the U-Boot policy was not to touch controllers that are
>  > > not required during boot.  Despite relatively common cases like needing
>  > > to set up MAC addresses ... maybe this patch of Kevin's can make it a
>  > > bunch easier to cope with that U-Boot policy.  :)
>  >
>  > U-boot can put the MAC address into a property of the MAC's device node in
>  > the OF device tree (which u-boot passes to the kernel).
>
>
> Maybe with PowerPC it does.  Not on ARM.  ;)
>
>
>


-- 
Jon Smirl
jonsmirl at gmail.com



More information about the i2c mailing list