]> Git Repo - u-boot.git/blobdiff - drivers/i2c/i2c-cdns.c
dtoc: Tidy up more Python style in dtb_platdata
[u-boot.git] / drivers / i2c / i2c-cdns.c
index 2c0301ad083a0dbc4b7146f9e3a3c640f314960b..7144d39984ec99428cd4b4cae390ec2630e5b92c 100644 (file)
@@ -9,6 +9,9 @@
 
 #include <common.h>
 #include <dm.h>
+#include <log.h>
+#include <linux/bitops.h>
+#include <linux/delay.h>
 #include <linux/types.h>
 #include <linux/io.h>
 #include <linux/errno.h>
@@ -213,7 +216,7 @@ static int cdns_i2c_set_bus_speed(struct udevice *dev, unsigned int speed)
        unsigned long speed_p = speed;
        int ret = 0;
 
-       if (speed > 400000) {
+       if (speed > I2C_SPEED_FAST_RATE) {
                debug("%s, failed to set clock speed to %u\n", __func__,
                      speed);
                return -EINVAL;
@@ -265,7 +268,7 @@ static int cdns_i2c_write_data(struct i2c_cdns_bus *i2c_bus, u32 addr, u8 *data,
 
        while (len-- && !is_arbitration_lost(regs)) {
                writel(*(cur_data++), &regs->data);
-               if (readl(&regs->transfer_size) == CDNS_I2C_FIFO_DEPTH) {
+               if (len && readl(&regs->transfer_size) == CDNS_I2C_FIFO_DEPTH) {
                        ret = cdns_i2c_wait(regs, CDNS_I2C_INTERRUPT_COMP |
                                            CDNS_I2C_INTERRUPT_ARBLOST);
                        if (ret & CDNS_I2C_INTERRUPT_ARBLOST)
@@ -497,7 +500,7 @@ static const struct udevice_id cdns_i2c_of_match[] = {
 };
 
 U_BOOT_DRIVER(cdns_i2c) = {
-       .name = "i2c-cdns",
+       .name = "i2c_cdns",
        .id = UCLASS_I2C,
        .of_match = cdns_i2c_of_match,
        .ofdata_to_platdata = cdns_i2c_ofdata_to_platdata,
This page took 0.026332 seconds and 4 git commands to generate.