mirror of
https://xff.cz/git/u-boot/
synced 2025-09-02 09:12:08 +02:00
i2c: fsl: Add option to get clock from DT
Add an option to get the clock speed from the device tree, hence adding compatibility with DM clock drivers. Signed-off-by: Mario Six <mario.six@gdsys.cc>
This commit is contained in:
committed by
Heiko Schocher
parent
d934832de6
commit
e5c762f5a7
@@ -12,6 +12,7 @@
|
|||||||
#include <i2c.h> /* Functional interface */
|
#include <i2c.h> /* Functional interface */
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
#include <asm/fsl_i2c.h> /* HW definitions */
|
#include <asm/fsl_i2c.h> /* HW definitions */
|
||||||
|
#include <clk.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <mapmem.h>
|
#include <mapmem.h>
|
||||||
|
|
||||||
@@ -573,6 +574,7 @@ static int fsl_i2c_set_bus_speed(struct udevice *bus, uint speed)
|
|||||||
static int fsl_i2c_ofdata_to_platdata(struct udevice *bus)
|
static int fsl_i2c_ofdata_to_platdata(struct udevice *bus)
|
||||||
{
|
{
|
||||||
struct fsl_i2c_dev *dev = dev_get_priv(bus);
|
struct fsl_i2c_dev *dev = dev_get_priv(bus);
|
||||||
|
struct clk clock;
|
||||||
|
|
||||||
dev->base = map_sysmem(dev_read_addr(bus), sizeof(struct fsl_i2c_base));
|
dev->base = map_sysmem(dev_read_addr(bus), sizeof(struct fsl_i2c_base));
|
||||||
|
|
||||||
@@ -584,7 +586,11 @@ static int fsl_i2c_ofdata_to_platdata(struct udevice *bus)
|
|||||||
0x7f);
|
0x7f);
|
||||||
dev->speed = dev_read_u32_default(bus, "clock-frequency", 400000);
|
dev->speed = dev_read_u32_default(bus, "clock-frequency", 400000);
|
||||||
|
|
||||||
dev->i2c_clk = dev->index ? gd->arch.i2c2_clk : gd->arch.i2c1_clk;
|
if (!clk_get_by_index(bus, 0, &clock))
|
||||||
|
dev->i2c_clk = clk_get_rate(&clock);
|
||||||
|
else
|
||||||
|
dev->i2c_clk = dev->index ? gd->arch.i2c2_clk :
|
||||||
|
gd->arch.i2c1_clk;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user