summaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/i2c-uclass.c2
-rw-r--r--drivers/i2c/i2c-uniphier-f.c7
-rw-r--r--drivers/i2c/i2c-uniphier.c7
-rw-r--r--drivers/i2c/mv_i2c.c2
-rw-r--r--drivers/i2c/mvtwsi.c17
5 files changed, 20 insertions, 15 deletions
diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
index a6991bf875..b890806a44 100644
--- a/drivers/i2c/i2c-uclass.c
+++ b/drivers/i2c/i2c-uclass.c
@@ -230,6 +230,8 @@ static int i2c_bind_driver(struct udevice *bus, uint chip_addr, uint offset_len,
snprintf(name, sizeof(name), "generic_%x", chip_addr);
str = strdup(name);
+ if (!str)
+ return -ENOMEM;
ret = device_bind_driver(bus, "i2c_generic_chip_drv", str, &dev);
debug("%s: device_bind_driver: ret=%d\n", __func__, ret);
if (ret)
diff --git a/drivers/i2c/i2c-uniphier-f.c b/drivers/i2c/i2c-uniphier-f.c
index 6707edd9ef..fd28c17399 100644
--- a/drivers/i2c/i2c-uniphier-f.c
+++ b/drivers/i2c/i2c-uniphier-f.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2014 Panasonic Corporation
- * Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ * Copyright (C) 2015 Socionext Inc.
+ * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
*
* SPDX-License-Identifier: GPL-2.0+
*/
@@ -352,8 +353,8 @@ static const struct dm_i2c_ops uniphier_fi2c_ops = {
};
static const struct udevice_id uniphier_fi2c_of_match[] = {
- { .compatible = "panasonic,uniphier-fi2c" },
- {},
+ { .compatible = "socionext,uniphier-fi2c" },
+ { /* sentinel */ }
};
U_BOOT_DRIVER(uniphier_fi2c) = {
diff --git a/drivers/i2c/i2c-uniphier.c b/drivers/i2c/i2c-uniphier.c
index 64a9ed81d2..666272dd0d 100644
--- a/drivers/i2c/i2c-uniphier.c
+++ b/drivers/i2c/i2c-uniphier.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2014 Panasonic Corporation
- * Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ * Copyright (C) 2015 Socionext Inc.
+ * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
*
* SPDX-License-Identifier: GPL-2.0+
*/
@@ -212,8 +213,8 @@ static const struct dm_i2c_ops uniphier_i2c_ops = {
};
static const struct udevice_id uniphier_i2c_of_match[] = {
- { .compatible = "panasonic,uniphier-i2c" },
- {},
+ { .compatible = "socionext,uniphier-i2c" },
+ { /* sentinel */ }
};
U_BOOT_DRIVER(uniphier_i2c) = {
diff --git a/drivers/i2c/mv_i2c.c b/drivers/i2c/mv_i2c.c
index e65cce0d8e..fc02e65504 100644
--- a/drivers/i2c/mv_i2c.c
+++ b/drivers/i2c/mv_i2c.c
@@ -73,7 +73,7 @@ static void i2c_board_init(struct mv_i2c *base)
}
#ifdef CONFIG_I2C_MULTI_BUS
-static u32 i2c_regs[CONFIG_MV_I2C_NUM] = CONFIG_MV_I2C_REG;
+static unsigned long i2c_regs[CONFIG_MV_I2C_NUM] = CONFIG_MV_I2C_REG;
static unsigned int bus_initialized[CONFIG_MV_I2C_NUM];
static unsigned int current_bus;
diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index 9b2ca1e81b..6f6edd5e51 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -228,13 +228,14 @@ static int twsi_stop(int status)
return status;
}
-/*
- * Ugly formula to convert m and n values to a frequency comes from
- * TWSI specifications
- */
-
-#define TWSI_FREQUENCY(m, n) \
- (CONFIG_SYS_TCLK / (10 * (m + 1) * (1 << n)))
+static unsigned int twsi_calc_freq(const int n, const int m)
+{
+#ifdef CONFIG_SUNXI
+ return CONFIG_SYS_TCLK / (10 * (m + 1) * (1 << n));
+#else
+ return CONFIG_SYS_TCLK / (10 * (m + 1) * (2 << n));
+#endif
+}
/*
* Reset controller.
@@ -266,7 +267,7 @@ static unsigned int twsi_i2c_set_bus_speed(struct i2c_adapter *adap,
/* compute m, n setting for highest speed not above requested speed */
for (n = 0; n < 8; n++) {
for (m = 0; m < 16; m++) {
- tmp_speed = TWSI_FREQUENCY(m, n);
+ tmp_speed = twsi_calc_freq(n, m);
if ((tmp_speed <= requested_speed)
&& (tmp_speed > highest_speed)) {
highest_speed = tmp_speed;
OpenPOWER on IntegriCloud