mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-19 05:31:32 +00:00
dm: i2c: Convert uclass to livetree
Update the i2c uclass to support a live device tree. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
a7d0021063
commit
1704308eb6
2 changed files with 14 additions and 17 deletions
|
@ -7,7 +7,6 @@
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fdtdec.h>
|
|
||||||
#include <i2c.h>
|
#include <i2c.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <dm/device-internal.h>
|
#include <dm/device-internal.h>
|
||||||
|
@ -467,18 +466,20 @@ int i2c_deblock(struct udevice *bus)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_IS_ENABLED(OF_CONTROL)
|
#if CONFIG_IS_ENABLED(OF_CONTROL)
|
||||||
int i2c_chip_ofdata_to_platdata(const void *blob, int node,
|
int i2c_chip_ofdata_to_platdata(struct udevice *dev, struct dm_i2c_chip *chip)
|
||||||
struct dm_i2c_chip *chip)
|
|
||||||
{
|
{
|
||||||
chip->offset_len = fdtdec_get_int(gd->fdt_blob, node,
|
int addr;
|
||||||
"u-boot,i2c-offset-len", 1);
|
|
||||||
|
chip->offset_len = dev_read_u32_default(dev, "u-boot,i2c-offset-len",
|
||||||
|
1);
|
||||||
chip->flags = 0;
|
chip->flags = 0;
|
||||||
chip->chip_addr = fdtdec_get_int(gd->fdt_blob, node, "reg", -1);
|
addr = dev_read_u32_default(dev, "reg", -1);
|
||||||
if (chip->chip_addr == -1) {
|
if (addr == -1) {
|
||||||
debug("%s: I2C Node '%s' has no 'reg' property\n", __func__,
|
debug("%s: I2C Node '%s' has no 'reg' property %s\n", __func__,
|
||||||
fdt_get_name(blob, node, NULL));
|
dev_read_name(dev), dev->name);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
chip->chip_addr = addr;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -489,8 +490,7 @@ static int i2c_post_probe(struct udevice *dev)
|
||||||
#if CONFIG_IS_ENABLED(OF_CONTROL)
|
#if CONFIG_IS_ENABLED(OF_CONTROL)
|
||||||
struct dm_i2c_bus *i2c = dev_get_uclass_priv(dev);
|
struct dm_i2c_bus *i2c = dev_get_uclass_priv(dev);
|
||||||
|
|
||||||
i2c->speed_hz = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
|
i2c->speed_hz = dev_read_u32_default(dev, "clock-frequency", 100000);
|
||||||
"clock-frequency", 100000);
|
|
||||||
|
|
||||||
return dm_i2c_set_bus_speed(dev, i2c->speed_hz);
|
return dm_i2c_set_bus_speed(dev, i2c->speed_hz);
|
||||||
#else
|
#else
|
||||||
|
@ -503,11 +503,9 @@ static int i2c_child_post_bind(struct udevice *dev)
|
||||||
#if CONFIG_IS_ENABLED(OF_CONTROL)
|
#if CONFIG_IS_ENABLED(OF_CONTROL)
|
||||||
struct dm_i2c_chip *plat = dev_get_parent_platdata(dev);
|
struct dm_i2c_chip *plat = dev_get_parent_platdata(dev);
|
||||||
|
|
||||||
if (dev_of_offset(dev) == -1)
|
if (!dev_of_valid(dev))
|
||||||
return 0;
|
return 0;
|
||||||
|
return i2c_chip_ofdata_to_platdata(dev, plat);
|
||||||
return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev_of_offset(dev),
|
|
||||||
plat);
|
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -525,8 +525,7 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len,
|
||||||
* @node: Node offset to read from
|
* @node: Node offset to read from
|
||||||
* @spi: Place to put the decoded information
|
* @spi: Place to put the decoded information
|
||||||
*/
|
*/
|
||||||
int i2c_chip_ofdata_to_platdata(const void *blob, int node,
|
int i2c_chip_ofdata_to_platdata(struct udevice *dev, struct dm_i2c_chip *chip);
|
||||||
struct dm_i2c_chip *chip);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* i2c_dump_msgs() - Dump a list of I2C messages
|
* i2c_dump_msgs() - Dump a list of I2C messages
|
||||||
|
|
Loading…
Add table
Reference in a new issue