summaryrefslogtreecommitdiff
path: root/drivers/i2c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/Kconfig4
-rw-r--r--drivers/i2c/acpi_i2c.c1
-rw-r--r--drivers/i2c/ast2600_i2c.c1
-rw-r--r--drivers/i2c/ast_i2c.c1
-rw-r--r--drivers/i2c/at91_i2c.c1
-rw-r--r--drivers/i2c/cros_ec_ldo.c1
-rw-r--r--drivers/i2c/cros_ec_tunnel.c1
-rw-r--r--drivers/i2c/davinci_i2c.c2
-rw-r--r--drivers/i2c/designware_i2c.c1
-rw-r--r--drivers/i2c/designware_i2c_pci.c1
-rw-r--r--drivers/i2c/exynos_hs_i2c.c27
-rw-r--r--drivers/i2c/fsl_i2c.c2
-rw-r--r--drivers/i2c/i2c-cdns.c1
-rw-r--r--drivers/i2c/i2c-cortina.c2
-rw-r--r--drivers/i2c/i2c-emul-uclass.c1
-rw-r--r--drivers/i2c/i2c-gpio.c1
-rw-r--r--drivers/i2c/i2c-microchip.c1
-rw-r--r--drivers/i2c/i2c-uclass.c1
-rw-r--r--drivers/i2c/i2c-uniphier.c1
-rw-r--r--drivers/i2c/i2c-versatile.c1
-rw-r--r--drivers/i2c/i2c_core.c143
-rw-r--r--drivers/i2c/ihs_i2c.c1
-rw-r--r--drivers/i2c/imx_lpi2c.c89
-rw-r--r--drivers/i2c/intel_i2c.c2
-rw-r--r--drivers/i2c/iproc_i2c.c1
-rw-r--r--drivers/i2c/lpc32xx_i2c.c2
-rw-r--r--drivers/i2c/meson_i2c.c1
-rw-r--r--drivers/i2c/mtk_i2c.c30
-rw-r--r--drivers/i2c/muxes/i2c-arb-gpio-challenge.c13
-rw-r--r--drivers/i2c/muxes/i2c-mux-gpio.c2
-rw-r--r--drivers/i2c/muxes/i2c-mux-uclass.c1
-rw-r--r--drivers/i2c/muxes/pca954x.c4
-rw-r--r--drivers/i2c/mv_i2c.c1
-rw-r--r--drivers/i2c/mvtwsi.c2
-rw-r--r--drivers/i2c/mxc_i2c.c4
-rw-r--r--drivers/i2c/nx_i2c.c2
-rw-r--r--drivers/i2c/ocores_i2c.c1
-rw-r--r--drivers/i2c/omap24xx_i2c.c1
-rw-r--r--drivers/i2c/qup_i2c.c1
-rw-r--r--drivers/i2c/rcar_i2c.c2
-rw-r--r--drivers/i2c/rcar_iic.c1
-rw-r--r--drivers/i2c/rk_i2c.c1
-rw-r--r--drivers/i2c/s3c24x0_i2c.c34
-rw-r--r--drivers/i2c/s3c24x0_i2c.h2
-rw-r--r--drivers/i2c/sandbox_i2c.c1
-rw-r--r--drivers/i2c/sh_i2c.c1
-rw-r--r--drivers/i2c/soft_i2c.c14
-rw-r--r--drivers/i2c/stm32f7_i2c.c1
-rw-r--r--drivers/i2c/sun6i_p2wi.c1
-rw-r--r--drivers/i2c/sun8i_rsb.c1
-rw-r--r--drivers/i2c/tegra186_bpmp_i2c.c1
-rw-r--r--drivers/i2c/tegra_i2c.c1
-rw-r--r--drivers/i2c/xilinx_xiic.c1
53 files changed, 152 insertions, 263 deletions
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 34b02114dc6..52067fa7c1f 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -650,7 +650,7 @@ config SYS_I2C_GENI
config SYS_I2C_S3C24X0
bool "Samsung I2C driver"
- depends on (ARCH_EXYNOS4 || ARCH_EXYNOS5) && DM_I2C
+ depends on DM_I2C
help
Support for Samsung I2C controller as Samsung SoCs.
@@ -771,7 +771,7 @@ config SYS_I2C_BUS_MAX
int "Max I2C busses"
depends on ARCH_OMAP2PLUS || ARCH_SOCFPGA
default 3 if OMAP34XX || AM33XX || AM43XX
- default 4 if ARCH_SOCFPGA || OMAP44XX
+ default 4 if ARCH_SOCFPGA
default 5 if OMAP54XX
help
Define the maximum number of available I2C buses.
diff --git a/drivers/i2c/acpi_i2c.c b/drivers/i2c/acpi_i2c.c
index 142f41178c1..82cb5db5cc8 100644
--- a/drivers/i2c/acpi_i2c.c
+++ b/drivers/i2c/acpi_i2c.c
@@ -3,7 +3,6 @@
* Copyright 2019 Google LLC
*/
-#include <common.h>
#include <dm.h>
#include <i2c.h>
#include <log.h>
diff --git a/drivers/i2c/ast2600_i2c.c b/drivers/i2c/ast2600_i2c.c
index e566b01feac..9d1d70670b9 100644
--- a/drivers/i2c/ast2600_i2c.c
+++ b/drivers/i2c/ast2600_i2c.c
@@ -2,7 +2,6 @@
/*
* Copyright ASPEED Technology Inc.
*/
-#include <common.h>
#include <clk.h>
#include <dm.h>
#include <errno.h>
diff --git a/drivers/i2c/ast_i2c.c b/drivers/i2c/ast_i2c.c
index 1c1d5566dad..02ee406bbd7 100644
--- a/drivers/i2c/ast_i2c.c
+++ b/drivers/i2c/ast_i2c.c
@@ -5,7 +5,6 @@
* Copyright 2017 Google, Inc.
*/
-#include <common.h>
#include <clk.h>
#include <dm.h>
#include <errno.h>
diff --git a/drivers/i2c/at91_i2c.c b/drivers/i2c/at91_i2c.c
index b7a25885e66..cfae36c74d1 100644
--- a/drivers/i2c/at91_i2c.c
+++ b/drivers/i2c/at91_i2c.c
@@ -8,7 +8,6 @@
#include <malloc.h>
#include <asm/global_data.h>
#include <asm/io.h>
-#include <common.h>
#include <clk.h>
#include <dm.h>
#include <errno.h>
diff --git a/drivers/i2c/cros_ec_ldo.c b/drivers/i2c/cros_ec_ldo.c
index c593540ac13..dfe823c142c 100644
--- a/drivers/i2c/cros_ec_ldo.c
+++ b/drivers/i2c/cros_ec_ldo.c
@@ -4,7 +4,6 @@
* Written by Simon Glass <sjg@chromium.org>
*/
-#include <common.h>
#include <dm.h>
#include <cros_ec.h>
#include <errno.h>
diff --git a/drivers/i2c/cros_ec_tunnel.c b/drivers/i2c/cros_ec_tunnel.c
index 75828b6e7c2..2d610e0a2aa 100644
--- a/drivers/i2c/cros_ec_tunnel.c
+++ b/drivers/i2c/cros_ec_tunnel.c
@@ -4,7 +4,6 @@
* Written by Simon Glass <sjg@chromium.org>
*/
-#include <common.h>
#include <dm.h>
#include <cros_ec.h>
#include <errno.h>
diff --git a/drivers/i2c/davinci_i2c.c b/drivers/i2c/davinci_i2c.c
index 25ef937dc0b..39132747208 100644
--- a/drivers/i2c/davinci_i2c.c
+++ b/drivers/i2c/davinci_i2c.c
@@ -11,7 +11,7 @@
* Please see doc/driver-model/i2c-howto.rst for instructions.
*/
-#include <common.h>
+#include <config.h>
#include <i2c.h>
#include <dm.h>
#include <log.h>
diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c
index 29cf63375c7..e8c1623d41f 100644
--- a/drivers/i2c/designware_i2c.c
+++ b/drivers/i2c/designware_i2c.c
@@ -4,7 +4,6 @@
* Vipin Kumar, STMicroelectronics, vipin.kumar@st.com.
*/
-#include <common.h>
#include <clk.h>
#include <dm.h>
#include <i2c.h>
diff --git a/drivers/i2c/designware_i2c_pci.c b/drivers/i2c/designware_i2c_pci.c
index 28495a3f428..11c98672265 100644
--- a/drivers/i2c/designware_i2c_pci.c
+++ b/drivers/i2c/designware_i2c_pci.c
@@ -5,7 +5,6 @@
* Copyright 2019 Google Inc
*/
-#include <common.h>
#include <dm.h>
#include <log.h>
#include <spl.h>
diff --git a/drivers/i2c/exynos_hs_i2c.c b/drivers/i2c/exynos_hs_i2c.c
index a7349e06cfd..fa0d1c8f64a 100644
--- a/drivers/i2c/exynos_hs_i2c.c
+++ b/drivers/i2c/exynos_hs_i2c.c
@@ -6,15 +6,18 @@
* David Mueller, ELSOFT AG, d.mueller@elsoft.ch
*/
-#include <common.h>
#include <dm.h>
#include <i2c.h>
#include <log.h>
+#if IS_ENABLED(CONFIG_ARCH_EXYNOS4) || IS_ENABLED(CONFIG_ARCH_EXYNOS5)
#include <asm/arch/clk.h>
#include <asm/arch/cpu.h>
#include <asm/arch/pinmux.h>
+#endif
#include <asm/global_data.h>
+#include <asm/io.h>
#include <linux/delay.h>
+#include <clk.h>
#include "s3c24x0_i2c.h"
DECLARE_GLOBAL_DATA_PTR;
@@ -77,7 +80,6 @@ DECLARE_GLOBAL_DATA_PTR;
HSI2C_TRANS_ABORT)
#define HSI2C_TRANS_FINISHED_MASK (HSI2C_TRANS_ERROR_MASK | HSI2C_TRANS_SUCCESS)
-
/* I2C_FIFO_STAT Register bits */
#define HSI2C_RX_FIFO_EMPTY (1u << 24)
#define HSI2C_RX_FIFO_FULL (1u << 23)
@@ -139,18 +141,25 @@ static int hsi2c_wait_for_trx(struct exynos5_hsi2c *i2c)
return I2C_NOK_TOUT;
}
-static int hsi2c_get_clk_details(struct s3c24x0_i2c_bus *i2c_bus)
+static int hsi2c_get_clk_details(struct udevice *dev)
{
+ struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev);
struct exynos5_hsi2c *hsregs = i2c_bus->hsregs;
ulong clkin;
unsigned int op_clk = i2c_bus->clock_frequency;
unsigned int i = 0, utemp0 = 0, utemp1 = 0;
unsigned int t_ftl_cycle;
-#if defined(CONFIG_ARCH_EXYNOS4) || defined(CONFIG_ARCH_EXYNOS5)
+#if IS_ENABLED(CONFIG_ARCH_EXYNOS4) || IS_ENABLED(CONFIG_ARCH_EXYNOS5)
clkin = get_i2c_clk();
#else
- clkin = get_PCLK();
+ struct clk clk;
+ int ret;
+
+ ret = clk_get_by_name(dev, "hsi2c", &clk);
+ if (ret < 0)
+ return ret;
+ clkin = clk_get_rate(&clk);
#endif
/* FPCLK / FI2C =
* (CLK_DIV + 1) * (TSCLK_L + TSCLK_H + 2) + 8 + 2 * FLT_CYCLE
@@ -493,7 +502,7 @@ static int s3c24x0_i2c_set_bus_speed(struct udevice *dev, unsigned int speed)
i2c_bus->clock_frequency = speed;
- if (hsi2c_get_clk_details(i2c_bus))
+ if (hsi2c_get_clk_details(dev))
return -EFAULT;
hsi2c_ch_init(i2c_bus);
@@ -520,7 +529,9 @@ static int s3c24x0_i2c_probe(struct udevice *dev, uint chip, uint chip_flags)
static int s3c_i2c_of_to_plat(struct udevice *dev)
{
+#if IS_ENABLED(CONFIG_ARCH_EXYNOS4) || IS_ENABLED(CONFIG_ARCH_EXYNOS5)
const void *blob = gd->fdt_blob;
+#endif
struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev);
int node;
@@ -528,7 +539,9 @@ static int s3c_i2c_of_to_plat(struct udevice *dev)
i2c_bus->hsregs = dev_read_addr_ptr(dev);
+#if IS_ENABLED(CONFIG_ARCH_EXYNOS4) || IS_ENABLED(CONFIG_ARCH_EXYNOS5)
i2c_bus->id = pinmux_decode_periph_id(blob, node);
+#endif
i2c_bus->clock_frequency =
dev_read_u32_default(dev, "clock-frequency",
@@ -536,7 +549,9 @@ static int s3c_i2c_of_to_plat(struct udevice *dev)
i2c_bus->node = node;
i2c_bus->bus_num = dev_seq(dev);
+#if IS_ENABLED(CONFIG_ARCH_EXYNOS4) || IS_ENABLED(CONFIG_ARCH_EXYNOS5)
exynos_pinmux_config(i2c_bus->id, PINMUX_FLAG_HS_MODE);
+#endif
i2c_bus->active = true;
diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c
index d9d8ee81d2e..bac14fb2f42 100644
--- a/drivers/i2c/fsl_i2c.c
+++ b/drivers/i2c/fsl_i2c.c
@@ -6,7 +6,7 @@
* Changes for multibus/multiadapter I2C support.
*/
-#include <common.h>
+#include <config.h>
#include <command.h>
#include <i2c.h> /* Functional interface */
#include <log.h>
diff --git a/drivers/i2c/i2c-cdns.c b/drivers/i2c/i2c-cdns.c
index 935b2ac6377..3f7cf8533ec 100644
--- a/drivers/i2c/i2c-cdns.c
+++ b/drivers/i2c/i2c-cdns.c
@@ -7,7 +7,6 @@
* with added driver-model support and code cleanup.
*/
-#include <common.h>
#include <dm.h>
#include <log.h>
#include <linux/bitops.h>
diff --git a/drivers/i2c/i2c-cortina.c b/drivers/i2c/i2c-cortina.c
index 960ae8c700f..96f957164c1 100644
--- a/drivers/i2c/i2c-cortina.c
+++ b/drivers/i2c/i2c-cortina.c
@@ -4,12 +4,12 @@
* Arthur Li, Cortina Access, arthur.li@cortina-access.com.
*/
-#include <common.h>
#include <i2c.h>
#include <log.h>
#include <asm/io.h>
#include <dm.h>
#include <mapmem.h>
+#include <time.h>
#include "i2c-cortina.h"
static void set_speed(struct i2c_regs *regs, int i2c_spd)
diff --git a/drivers/i2c/i2c-emul-uclass.c b/drivers/i2c/i2c-emul-uclass.c
index d421ddfcbe2..0954d53847e 100644
--- a/drivers/i2c/i2c-emul-uclass.c
+++ b/drivers/i2c/i2c-emul-uclass.c
@@ -5,7 +5,6 @@
#define LOG_CATEGORY UCLASS_I2C_EMUL
-#include <common.h>
#include <dm.h>
#include <i2c.h>
#include <log.h>
diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c
index 5fc3cfe42ef..e0a575fb4a4 100644
--- a/drivers/i2c/i2c-gpio.c
+++ b/drivers/i2c/i2c-gpio.c
@@ -5,7 +5,6 @@
* This file is based on: drivers/i2c/soft-i2c.c,
* with added driver-model support and code cleanup.
*/
-#include <common.h>
#include <errno.h>
#include <dm.h>
#include <i2c.h>
diff --git a/drivers/i2c/i2c-microchip.c b/drivers/i2c/i2c-microchip.c
index d453e243d6f..788747879a2 100644
--- a/drivers/i2c/i2c-microchip.c
+++ b/drivers/i2c/i2c-microchip.c
@@ -6,7 +6,6 @@
* Padmarao Begari <padmarao.begari@microchip.com>
* Conor Dooley <conor.dooley@microchip.com>
*/
-#include <common.h>
#include <clk.h>
#include <dm.h>
#include <i2c.h>
diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
index 98f95859f3b..380a9f8f3ad 100644
--- a/drivers/i2c/i2c-uclass.c
+++ b/drivers/i2c/i2c-uclass.c
@@ -5,7 +5,6 @@
#define LOG_CATEGORY UCLASS_I2C
-#include <common.h>
#include <dm.h>
#include <errno.h>
#include <i2c.h>
diff --git a/drivers/i2c/i2c-uniphier.c b/drivers/i2c/i2c-uniphier.c
index 6eafbeeef4e..cc22c075ab1 100644
--- a/drivers/i2c/i2c-uniphier.c
+++ b/drivers/i2c/i2c-uniphier.c
@@ -198,7 +198,6 @@ static int uniphier_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
return 0;
}
-
static const struct dm_i2c_ops uniphier_i2c_ops = {
.xfer = uniphier_i2c_xfer,
.set_bus_speed = uniphier_i2c_set_bus_speed,
diff --git a/drivers/i2c/i2c-versatile.c b/drivers/i2c/i2c-versatile.c
index 0a1a85dfc28..a8f0a170f79 100644
--- a/drivers/i2c/i2c-versatile.c
+++ b/drivers/i2c/i2c-versatile.c
@@ -5,7 +5,6 @@
*
*/
-#include <common.h>
#include <dm.h>
#include <errno.h>
#include <i2c.h>
diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c
index fe0cd75d94a..cccd45027db 100644
--- a/drivers/i2c/i2c_core.c
+++ b/drivers/i2c/i2c_core.c
@@ -7,7 +7,7 @@
*
* Multibus/multiadapter I2C core functions (wrappers)
*/
-#include <common.h>
+#include <config.h>
#include <i2c.h>
#include <linker_lists.h>
#include <asm/global_data.h>
@@ -33,137 +33,8 @@ struct i2c_adapter *i2c_get_adapter(int index)
return i2c_adap_p;
}
-#if !defined(CFG_SYS_I2C_DIRECT_BUS)
-struct i2c_bus_hose i2c_bus[CFG_SYS_NUM_I2C_BUSES] =
- CFG_SYS_I2C_BUSES;
-#endif
-
DECLARE_GLOBAL_DATA_PTR;
-#ifndef CFG_SYS_I2C_DIRECT_BUS
-/*
- * i2c_mux_set()
- * -------------
- *
- * This turns on the given channel on I2C multiplexer chip connected to
- * a given I2C adapter directly or via other multiplexers. In the latter
- * case the entire multiplexer chain must be initialized first starting
- * with the one connected directly to the adapter. When disabling a chain
- * muxes must be programmed in reverse order, starting with the one
- * farthest from the adapter.
- *
- * mux_id is the multiplexer chip type from defined in i2c.h. So far only
- * NXP (Philips) PCA954x multiplexers are supported. Switches are NOT
- * supported (anybody uses them?)
- */
-
-static int i2c_mux_set(struct i2c_adapter *adap, int mux_id, int chip,
- int channel)
-{
- uint8_t buf;
- int ret;
-
- /* channel < 0 - turn off the mux */
- if (channel < 0) {
- buf = 0;
- ret = adap->write(adap, chip, 0, 0, &buf, 1);
- if (ret)
- printf("%s: Could not turn off the mux.\n", __func__);
- return ret;
- }
-
- switch (mux_id) {
- case I2C_MUX_PCA9540_ID:
- case I2C_MUX_PCA9542_ID:
- if (channel > 1)
- return -1;
- buf = (uint8_t)((channel & 0x01) | (1 << 2));
- break;
- case I2C_MUX_PCA9544_ID:
- if (channel > 3)
- return -1;
- buf = (uint8_t)((channel & 0x03) | (1 << 2));
- break;
- case I2C_MUX_PCA9547_ID:
- if (channel > 7)
- return -1;
- buf = (uint8_t)((channel & 0x07) | (1 << 3));
- break;
- case I2C_MUX_PCA9548_ID:
- if (channel > 7)
- return -1;
- buf = (uint8_t)(0x01 << channel);
- break;
- default:
- printf("%s: wrong mux id: %d\n", __func__, mux_id);
- return -1;
- }
-
- ret = adap->write(adap, chip, 0, 0, &buf, 1);
- if (ret)
- printf("%s: could not set mux: id: %d chip: %x channel: %d\n",
- __func__, mux_id, chip, channel);
- return ret;
-}
-
-static int i2c_mux_set_all(void)
-{
- struct i2c_bus_hose *i2c_bus_tmp = &i2c_bus[I2C_BUS];
- int i;
-
- /* Connect requested bus if behind muxes */
- if (i2c_bus_tmp->next_hop[0].chip != 0) {
- /* Set all muxes along the path to that bus */
- for (i = 0; i < CFG_SYS_I2C_MAX_HOPS; i++) {
- int ret;
-
- if (i2c_bus_tmp->next_hop[i].chip == 0)
- break;
-
- ret = i2c_mux_set(I2C_ADAP,
- i2c_bus_tmp->next_hop[i].mux.id,
- i2c_bus_tmp->next_hop[i].chip,
- i2c_bus_tmp->next_hop[i].channel);
- if (ret != 0)
- return ret;
- }
- }
- return 0;
-}
-
-static int i2c_mux_disconnect_all(void)
-{
- struct i2c_bus_hose *i2c_bus_tmp = &i2c_bus[I2C_BUS];
- int i;
- uint8_t buf = 0;
-
- if (I2C_ADAP->init_done == 0)
- return 0;
-
- /* Disconnect current bus (turn off muxes if any) */
- if ((i2c_bus_tmp->next_hop[0].chip != 0) &&
- (I2C_ADAP->init_done != 0)) {
- i = CFG_SYS_I2C_MAX_HOPS;
- do {
- uint8_t chip;
- int ret;
-
- chip = i2c_bus_tmp->next_hop[--i].chip;
- if (chip == 0)
- continue;
-
- ret = I2C_ADAP->write(I2C_ADAP, chip, 0, 0, &buf, 1);
- if (ret != 0) {
- printf("i2c: mux disconnect error\n");
- return ret;
- }
- } while (i > 0);
- }
-
- return 0;
-}
-#endif
-
/*
* i2c_init_bus():
* ---------------
@@ -237,11 +108,6 @@ int i2c_set_bus_num(unsigned int bus)
if ((bus == I2C_BUS) && (I2C_ADAP->init_done > 0))
return 0;
-#ifndef CFG_SYS_I2C_DIRECT_BUS
- if (bus >= CFG_SYS_NUM_I2C_BUSES)
- return -1;
-#endif
-
max = ll_entry_count(struct i2c_adapter, i2c);
if (I2C_ADAPTER(bus) >= max) {
printf("Error, wrong i2c adapter %d max %d possible\n",
@@ -249,17 +115,10 @@ int i2c_set_bus_num(unsigned int bus)
return -2;
}
-#ifndef CFG_SYS_I2C_DIRECT_BUS
- i2c_mux_disconnect_all();
-#endif
-
gd->cur_i2c_bus = bus;
if (I2C_ADAP->init_done == 0)
i2c_init_bus(bus, I2C_ADAP->speed, I2C_ADAP->slaveaddr);
-#ifndef CFG_SYS_I2C_DIRECT_BUS
- i2c_mux_set_all();
-#endif
return 0;
}
diff --git a/drivers/i2c/ihs_i2c.c b/drivers/i2c/ihs_i2c.c
index d715714638f..dc88cd19167 100644
--- a/drivers/i2c/ihs_i2c.c
+++ b/drivers/i2c/ihs_i2c.c
@@ -4,7 +4,6 @@
* Dirk Eibach, Guntermann & Drunck GmbH, dirk.eibach@gdsys.cc
*/
-#include <common.h>
#include <i2c.h>
#include <dm.h>
#include <regmap.h>
diff --git a/drivers/i2c/imx_lpi2c.c b/drivers/i2c/imx_lpi2c.c
index ad9293c92e1..4636da9f301 100644
--- a/drivers/i2c/imx_lpi2c.c
+++ b/drivers/i2c/imx_lpi2c.c
@@ -3,7 +3,6 @@
* Copyright 2016 Freescale Semiconductors, Inc.
*/
-#include <common.h>
#include <errno.h>
#include <log.h>
#include <asm/io.h>
@@ -20,7 +19,10 @@
#define LPI2C_NACK_TOUT_MS 1
#define LPI2C_TIMEOUT_MS 100
-static int bus_i2c_init(struct udevice *bus, int speed);
+#define LPI2C_CHUNK_DATA 256U
+#define LPI2C_CHUNK_LEN_MIN 1U
+
+static int bus_i2c_init(struct udevice *bus);
/* Weak linked function for overridden by some SoC power function */
int __weak init_i2c_power(unsigned i2c_num)
@@ -119,8 +121,10 @@ static int bus_i2c_send(struct udevice *bus, u8 *txbuf, int len)
static int bus_i2c_receive(struct udevice *bus, u8 *rxbuf, int len)
{
+ struct dm_i2c_bus *i2c = dev_get_uclass_priv(bus);
struct imx_lpi2c_bus *i2c_bus = dev_get_priv(bus);
struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)(i2c_bus->base);
+ unsigned int chunk_len, rx_remain, timeout;
lpi2c_status_t result = LPI2C_SUCESS;
u32 val;
ulong start_time = get_timer(0);
@@ -129,33 +133,50 @@ static int bus_i2c_receive(struct udevice *bus, u8 *rxbuf, int len)
if (!len)
return result;
- result = bus_i2c_wait_for_tx_ready(regs);
- if (result) {
- debug("i2c: receive wait fot tx ready: %d\n", result);
- return result;
- }
+ /*
+ * Extend the timeout for a bulk read if needed.
+ * The calculated timeout is the result of multiplying the
+ * transfer length with 8 bit + ACK + one clock of extra time,
+ * considering the I2C bus frequency.
+ */
+ timeout = max(len * 10 * 1000 / i2c->speed_hz, LPI2C_TIMEOUT_MS);
- /* clear all status flags */
- writel(0x7f00, &regs->msr);
- /* send receive command */
- val = LPI2C_MTDR_CMD(0x1) | LPI2C_MTDR_DATA(len - 1);
- writel(val, &regs->mtdr);
+ rx_remain = len;
+ while (rx_remain > 0) {
+ chunk_len = clamp(rx_remain, LPI2C_CHUNK_LEN_MIN, LPI2C_CHUNK_DATA) - 1;
- while (len--) {
- do {
- result = imx_lpci2c_check_clear_error(regs);
- if (result) {
- debug("i2c: receive check clear error: %d\n",
- result);
- return result;
- }
- if (get_timer(start_time) > LPI2C_TIMEOUT_MS) {
- debug("i2c: receive mrdr: timeout\n");
- return -1;
- }
- val = readl(&regs->mrdr);
- } while (val & LPI2C_MRDR_RXEMPTY_MASK);
- *rxbuf++ = LPI2C_MRDR_DATA(val);
+ result = bus_i2c_wait_for_tx_ready(regs);
+ if (result) {
+ debug("i2c: receive wait for tx ready: %d\n", result);
+ return result;
+ }
+
+ /* clear all status flags */
+ writel(0x7f00, &regs->msr);
+ /* send receive command */
+ writel(LPI2C_MTDR_CMD(0x1) | LPI2C_MTDR_DATA(chunk_len), &regs->mtdr);
+ rx_remain = rx_remain - (chunk_len & 0xff) - 1;
+
+ while (len--) {
+ do {
+ result = imx_lpci2c_check_clear_error(regs);
+ if (result) {
+ debug("i2c: receive check clear error: %d\n",
+ result);
+ return result;
+ }
+ if (get_timer(start_time) > timeout) {
+ debug("i2c: receive mrdr: timeout\n");
+ return -1;
+ }
+ val = readl(&regs->mrdr);
+ } while (val & LPI2C_MRDR_RXEMPTY_MASK);
+ *rxbuf++ = LPI2C_MRDR_DATA(val);
+
+ /* send next receive command before controller NACKs last byte */
+ if ((len - rx_remain) < 2 && rx_remain > 0)
+ break;
+ }
}
return result;
@@ -173,7 +194,7 @@ static int bus_i2c_start(struct udevice *bus, u8 addr, u8 dir)
debug("i2c: start check busy bus: 0x%x\n", result);
/* Try to init the lpi2c then check the bus busy again */
- bus_i2c_init(bus, I2C_SPEED_STANDARD_RATE);
+ bus_i2c_init(bus);
result = imx_lpci2c_check_busy_bus(regs);
if (result) {
printf("i2c: Error check busy bus: 0x%x\n", result);
@@ -264,7 +285,6 @@ static int bus_i2c_write(struct udevice *bus, u32 chip, u8 *buf, int len)
return result;
}
-
u32 __weak imx_get_i2cclk(u32 i2c_num)
{
return 0;
@@ -346,11 +366,14 @@ static int bus_i2c_set_bus_speed(struct udevice *bus, int speed)
return 0;
}
-static int bus_i2c_init(struct udevice *bus, int speed)
+static int bus_i2c_init(struct udevice *bus)
{
u32 val;
int ret;
+ struct dm_i2c_bus *i2c = dev_get_uclass_priv(bus);
+ int speed = i2c->speed_hz;
+
struct imx_lpi2c_bus *i2c_bus = dev_get_priv(bus);
struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)(i2c_bus->base);
/* reset peripheral */
@@ -390,13 +413,13 @@ static int imx_lpi2c_probe_chip(struct udevice *bus, u32 chip,
result = bus_i2c_start(bus, chip, 0);
if (result) {
bus_i2c_stop(bus);
- bus_i2c_init(bus, I2C_SPEED_STANDARD_RATE);
+ bus_i2c_init(bus);
return result;
}
result = bus_i2c_stop(bus);
if (result)
- bus_i2c_init(bus, I2C_SPEED_STANDARD_RATE);
+ bus_i2c_init(bus);
return result;
}
@@ -491,7 +514,7 @@ static int imx_lpi2c_probe(struct udevice *bus)
return ret;
}
- ret = bus_i2c_init(bus, I2C_SPEED_STANDARD_RATE);
+ ret = bus_i2c_init(bus);
if (ret < 0)
return ret;
diff --git a/drivers/i2c/intel_i2c.c b/drivers/i2c/intel_i2c.c
index 4fc6f1a11a7..d8ceea10cda 100644
--- a/drivers/i2c/intel_i2c.c
+++ b/drivers/i2c/intel_i2c.c
@@ -7,11 +7,11 @@
* Copyright (C) 2016 Stefan Roese <sr@denx.de>
*/
-#include <common.h>
#include <dm.h>
#include <i2c.h>
#include <log.h>
#include <pci.h>
+#include <time.h>
#include <asm/io.h>
/* PCI Configuration Space (D31:F3): SMBus */
diff --git a/drivers/i2c/iproc_i2c.c b/drivers/i2c/iproc_i2c.c
index 39af49c4ec5..6570f64fe77 100644
--- a/drivers/i2c/iproc_i2c.c
+++ b/drivers/i2c/iproc_i2c.c
@@ -6,7 +6,6 @@
#include <asm/global_data.h>
#include <asm/io.h>
-#include <common.h>
#include <config.h>
#include <dm.h>
#include <linux/printk.h>
diff --git a/drivers/i2c/lpc32xx_i2c.c b/drivers/i2c/lpc32xx_i2c.c
index 496f4feec56..a4e42e64a9b 100644
--- a/drivers/i2c/lpc32xx_i2c.c
+++ b/drivers/i2c/lpc32xx_i2c.c
@@ -6,7 +6,7 @@
* Written-by: Albert ARIBAUD - 3ADEV <albert.aribaud@3adev.fr>
*/
-#include <common.h>
+#include <config.h>
#include <log.h>
#include <asm/io.h>
#include <i2c.h>
diff --git a/drivers/i2c/meson_i2c.c b/drivers/i2c/meson_i2c.c
index 434e3461b1d..19f1b6b0819 100644
--- a/drivers/i2c/meson_i2c.c
+++ b/drivers/i2c/meson_i2c.c
@@ -2,7 +2,6 @@
/*
* (C) Copyright 2017 - Beniamino Galvani <b.galvani@gmail.com>
*/
-#include <common.h>
#include <log.h>
#include <asm/io.h>
#include <clk.h>
diff --git a/drivers/i2c/mtk_i2c.c b/drivers/i2c/mtk_i2c.c
index 5592fe91817..3450177741a 100644
--- a/drivers/i2c/mtk_i2c.c
+++ b/drivers/i2c/mtk_i2c.c
@@ -221,6 +221,8 @@ struct mtk_i2c_priv {
void __iomem *pdmabase; /* dma base address*/
struct clk clk_main; /* main clock for i2c bus */
struct clk clk_dma; /* DMA clock for i2c via DMA */
+ struct clk clk_arb; /* DMA clock for i2c ARB */
+ struct clk clk_pmic; /* DMA clock for i2c PMIC */
const struct mtk_i2c_soc_data *soc_data; /* Compatible data for different IC */
int op; /* operation mode */
bool zero_len; /* Only transfer slave address, no data */
@@ -255,6 +257,18 @@ static int mtk_i2c_clk_enable(struct mtk_i2c_priv *priv)
if (ret)
return log_msg_ret("enable clk_dma", ret);
+ if (priv->clk_arb.dev) {
+ ret = clk_enable(&priv->clk_arb);
+ if (ret)
+ return log_msg_ret("enable clk_arb", ret);
+ }
+
+ if (priv->clk_pmic.dev) {
+ ret = clk_enable(&priv->clk_pmic);
+ if (ret)
+ return log_msg_ret("enable clk_pmic", ret);
+ }
+
return 0;
}
@@ -262,6 +276,18 @@ static int mtk_i2c_clk_disable(struct mtk_i2c_priv *priv)
{
int ret;
+ if (priv->clk_pmic.dev) {
+ ret = clk_disable(&priv->clk_pmic);
+ if (ret)
+ return log_msg_ret("disable clk_pmic", ret);
+ }
+
+ if (priv->clk_arb.dev) {
+ ret = clk_disable(&priv->clk_arb);
+ if (ret)
+ return log_msg_ret("disable clk_arb", ret);
+ }
+
ret = clk_disable(&priv->clk_dma);
if (ret)
return log_msg_ret("disable clk_dma", ret);
@@ -748,6 +774,10 @@ static int mtk_i2c_of_to_plat(struct udevice *dev)
ret = clk_get_by_index(dev, 1, &priv->clk_dma);
+ /* optional i2c clock */
+ clk_get_by_name(dev, "arb", &priv->clk_arb);
+ clk_get_by_name(dev, "pmic", &priv->clk_pmic);
+
return ret;
}
diff --git a/drivers/i2c/muxes/i2c-arb-gpio-challenge.c b/drivers/i2c/muxes/i2c-arb-gpio-challenge.c
index ad730e0e79f..3d2ce0ca705 100644
--- a/drivers/i2c/muxes/i2c-arb-gpio-challenge.c
+++ b/drivers/i2c/muxes/i2c-arb-gpio-challenge.c
@@ -4,12 +4,12 @@
* Written by Simon Glass <sjg@chromium.org>
*/
-#include <common.h>
#include <dm.h>
#include <errno.h>
#include <i2c.h>
#include <log.h>
#include <malloc.h>
+#include <time.h>
#include <asm/global_data.h>
#include <asm/gpio.h>
#include <linux/delay.h>
@@ -54,7 +54,7 @@ int i2c_arbitrator_select(struct udevice *mux, struct udevice *bus,
/* Indicate that we want to claim the bus */
ret = dm_gpio_set_value(&priv->ap_claim, 1);
if (ret)
- goto err;
+ return ret;
udelay(priv->slew_delay_us);
/* Wait for the EC to release it */
@@ -62,7 +62,7 @@ int i2c_arbitrator_select(struct udevice *mux, struct udevice *bus,
while (get_timer(start_retry) < priv->wait_retry_ms) {
ret = dm_gpio_get_value(&priv->ec_claim);
if (ret < 0) {
- goto err;
+ return ret;
} else if (!ret) {
/* We got it, so return */
return 0;
@@ -75,17 +75,14 @@ int i2c_arbitrator_select(struct udevice *mux, struct udevice *bus,
/* It didn't release, so give up, wait, and try again */
ret = dm_gpio_set_value(&priv->ap_claim, 0);
if (ret)
- goto err;
+ return ret;
mdelay(priv->wait_retry_ms);
} while (get_timer(start) < priv->wait_free_ms);
/* Give up, release our claim */
printf("I2C: Could not claim bus, timeout %lu\n", get_timer(start));
- ret = -ETIMEDOUT;
- ret = 0;
-err:
- return ret;
+ return -ETIMEDOUT;
}
static int i2c_arbitrator_probe(struct udevice *dev)
diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
index 4ca206115f8..0a2800ebd7a 100644
--- a/drivers/i2c/muxes/i2c-mux-gpio.c
+++ b/drivers/i2c/muxes/i2c-mux-gpio.c
@@ -10,7 +10,6 @@
#include <asm/global_data.h>
#include <asm/io.h>
#include <asm-generic/gpio.h>
-#include <common.h>
#include <dm.h>
#include <dm/device_compat.h>
#include <dm/devres.h>
@@ -39,7 +38,6 @@ struct i2c_mux_gpio_priv {
u32 idle;
};
-
static int i2c_mux_gpio_select(struct udevice *dev, struct udevice *bus,
uint channel)
{
diff --git a/drivers/i2c/muxes/i2c-mux-uclass.c b/drivers/i2c/muxes/i2c-mux-uclass.c
index a5d1bb0576d..d1999d21feb 100644
--- a/drivers/i2c/muxes/i2c-mux-uclass.c
+++ b/drivers/i2c/muxes/i2c-mux-uclass.c
@@ -6,7 +6,6 @@
#define LOG_CATEGORY UCLASS_I2C_MUX
-#include <common.h>
#include <dm.h>
#include <errno.h>
#include <i2c.h>
diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c
index 0034dfbf6da..795288fe2e9 100644
--- a/drivers/i2c/muxes/pca954x.c
+++ b/drivers/i2c/muxes/pca954x.c
@@ -5,18 +5,14 @@
* Written by Michal Simek
*/
-#include <common.h>
#include <dm.h>
#include <errno.h>
#include <i2c.h>
#include <log.h>
#include <malloc.h>
-#include <asm/global_data.h>
#include <asm-generic/gpio.h>
-DECLARE_GLOBAL_DATA_PTR;
-
enum pca_type {
PCA9543,
PCA9544,
diff --git a/drivers/i2c/mv_i2c.c b/drivers/i2c/mv_i2c.c
index 5bc9cd7b295..949cc45d308 100644
--- a/drivers/i2c/mv_i2c.c
+++ b/drivers/i2c/mv_i2c.c
@@ -16,7 +16,6 @@
* Murray.Jensen@cmst.csiro.au, 27-Jan-01.
*/
-#include <common.h>
#include <dm.h>
#include <i2c.h>
#include <log.h>
diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index c38330f758a..44e8e191b03 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -7,7 +7,7 @@
* Copyright (c) 2010 Albert Aribaud.
*/
-#include <common.h>
+#include <config.h>
#include <i2c.h>
#include <log.h>
#include <asm/global_data.h>
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
index d501133a0c8..2f3cb5908c9 100644
--- a/drivers/i2c/mxc_i2c.c
+++ b/drivers/i2c/mxc_i2c.c
@@ -14,7 +14,7 @@
*
*/
-#include <common.h>
+#include <config.h>
#include <log.h>
#include <asm/arch/clock.h>
#include <asm/arch/imx-regs.h>
@@ -512,7 +512,6 @@ static int i2c_init_transfer(struct mxc_i2c_bus *i2c_bus, u8 chip,
return ret;
}
-
static int i2c_write_data(struct mxc_i2c_bus *i2c_bus, u8 chip, const u8 *buf,
int len)
{
@@ -621,6 +620,7 @@ int enable_i2c_clk(unsigned char enable, unsigned int i2c_num)
__attribute__((weak, alias("__enable_i2c_clk")));
#if !CONFIG_IS_ENABLED(DM_I2C)
+
/*
* Read data from I2C device
*
diff --git a/drivers/i2c/nx_i2c.c b/drivers/i2c/nx_i2c.c
index 07cda0fa679..8562dd82bd6 100644
--- a/drivers/i2c/nx_i2c.c
+++ b/drivers/i2c/nx_i2c.c
@@ -1,8 +1,8 @@
-#include <common.h>
#include <errno.h>
#include <dm.h>
#include <i2c.h>
#include <log.h>
+#include <time.h>
#include <asm/arch/nexell.h>
#include <asm/arch/reset.h>
#include <asm/arch/clk.h>
diff --git a/drivers/i2c/ocores_i2c.c b/drivers/i2c/ocores_i2c.c
index fff85118d0d..cf714d22ee4 100644
--- a/drivers/i2c/ocores_i2c.c
+++ b/drivers/i2c/ocores_i2c.c
@@ -12,7 +12,6 @@
* Andreas Larsson <andreas@gaisler.com>
*/
-#include <common.h>
#include <asm/global_data.h>
#include <asm/io.h>
#include <clk.h>
diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c
index 6fc9d1eba9d..ebe472e20cd 100644
--- a/drivers/i2c/omap24xx_i2c.c
+++ b/drivers/i2c/omap24xx_i2c.c
@@ -38,7 +38,6 @@
*
*/
-#include <common.h>
#include <dm.h>
#include <i2c.h>
#include <log.h>
diff --git a/drivers/i2c/qup_i2c.c b/drivers/i2c/qup_i2c.c
index 5ae3cccd4ac..26707d63980 100644
--- a/drivers/i2c/qup_i2c.c
+++ b/drivers/i2c/qup_i2c.c
@@ -9,7 +9,6 @@
#include <init.h>
#include <env.h>
-#include <common.h>
#include <log.h>
#include <dm/device_compat.h>
#include <linux/delay.h>
diff --git a/drivers/i2c/rcar_i2c.c b/drivers/i2c/rcar_i2c.c
index ff9a2d80dda..3bd5108fd23 100644
--- a/drivers/i2c/rcar_i2c.c
+++ b/drivers/i2c/rcar_i2c.c
@@ -11,7 +11,6 @@
* Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
*/
-#include <common.h>
#include <clk.h>
#include <dm.h>
#include <i2c.h>
@@ -55,7 +54,6 @@
#define RCAR_I2C_ICFBSCR 0x38
#define RCAR_I2C_ICFBSCR_TCYC17 0x0f /* 17*Tcyc */
-
enum rcar_i2c_type {
RCAR_I2C_TYPE_GEN2,
RCAR_I2C_TYPE_GEN3,
diff --git a/drivers/i2c/rcar_iic.c b/drivers/i2c/rcar_iic.c
index f0e50914c68..2aa0f5fbfae 100644
--- a/drivers/i2c/rcar_iic.c
+++ b/drivers/i2c/rcar_iic.c
@@ -9,7 +9,6 @@
* Copyright (C) 2011, 2013 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
*/
-#include <common.h>
#include <clk.h>
#include <dm.h>
#include <i2c.h>
diff --git a/drivers/i2c/rk_i2c.c b/drivers/i2c/rk_i2c.c
index 9927af94a80..fa167268ae7 100644
--- a/drivers/i2c/rk_i2c.c
+++ b/drivers/i2c/rk_i2c.c
@@ -6,7 +6,6 @@
* Peter, Software Engineering, <superpeter.cai@gmail.com>.
*/
-#include <common.h>
#include <clk.h>
#include <dm.h>
#include <errno.h>
diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c
index 505e20bc61c..ade1ad6cef7 100644
--- a/drivers/i2c/s3c24x0_i2c.c
+++ b/drivers/i2c/s3c24x0_i2c.c
@@ -4,21 +4,20 @@
* David Mueller, ELSOFT AG, d.mueller@elsoft.ch
*/
-#include <common.h>
#include <errno.h>
#include <dm.h>
#include <fdtdec.h>
-#if defined(CONFIG_ARCH_EXYNOS4) || defined(CONFIG_ARCH_EXYNOS5)
+#include <time.h>
#include <log.h>
+#if IS_ENABLED(CONFIG_ARCH_EXYNOS4) || IS_ENABLED(CONFIG_ARCH_EXYNOS5)
#include <asm/arch/clk.h>
#include <asm/arch/cpu.h>
#include <asm/arch/pinmux.h>
-#else
-#include <asm/arch/s3c24x0_cpu.h>
#endif
#include <asm/global_data.h>
#include <asm/io.h>
#include <i2c.h>
+#include <clk.h>
#include "s3c24x0_i2c.h"
DECLARE_GLOBAL_DATA_PTR;
@@ -50,13 +49,22 @@ static void read_write_byte(struct s3c24x0_i2c *i2c)
clrbits_le32(&i2c->iiccon, I2CCON_IRPND);
}
-static void i2c_ch_init(struct s3c24x0_i2c *i2c, int speed, int slaveadd)
+static int i2c_ch_init(struct udevice *dev, int speed, int slaveadd)
{
+ struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev);
+ struct s3c24x0_i2c *i2c = i2c_bus->regs;
ulong freq, pres = 16, div;
-#if defined(CONFIG_ARCH_EXYNOS4) || defined(CONFIG_ARCH_EXYNOS5)
+
+#if IS_ENABLED(CONFIG_ARCH_EXYNOS4) || defined(CONFIG_ARCH_EXYNOS5)
freq = get_i2c_clk();
#else
- freq = get_PCLK();
+ struct clk clk;
+ int ret;
+
+ ret = clk_get_by_name(dev, "i2c", &clk);
+ if (ret < 0)
+ return ret;
+ freq = clk_get_rate(&clk);
#endif
/* calculate prescaler and divisor values */
if ((freq / pres / (16 + 1)) > speed)
@@ -75,6 +83,7 @@ static void i2c_ch_init(struct s3c24x0_i2c *i2c, int speed, int slaveadd)
writel(slaveadd, &i2c->iicadd);
/* program Master Transmit (and implicit STOP) */
writel(I2C_MODE_MT | I2C_TXRX_ENA, &i2c->iicstat);
+ return 0;
}
#define SYS_I2C_S3C24X0_SLAVE_ADDR 0
@@ -85,8 +94,9 @@ static int s3c24x0_i2c_set_bus_speed(struct udevice *dev, unsigned int speed)
i2c_bus->clock_frequency = speed;
- i2c_ch_init(i2c_bus->regs, i2c_bus->clock_frequency,
- SYS_I2C_S3C24X0_SLAVE_ADDR);
+ if (i2c_ch_init(dev, i2c_bus->clock_frequency,
+ SYS_I2C_S3C24X0_SLAVE_ADDR))
+ return -EFAULT;
return 0;
}
@@ -301,7 +311,9 @@ static int s3c24x0_i2c_xfer(struct udevice *dev, struct i2c_msg *msg,
static int s3c_i2c_of_to_plat(struct udevice *dev)
{
+#if IS_ENABLED(CONFIG_ARCH_EXYNOS4) || IS_ENABLED(CONFIG_ARCH_EXYNOS5)
const void *blob = gd->fdt_blob;
+#endif
struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev);
int node;
@@ -309,7 +321,9 @@ static int s3c_i2c_of_to_plat(struct udevice *dev)
i2c_bus->regs = dev_read_addr_ptr(dev);
+#if IS_ENABLED(CONFIG_ARCH_EXYNOS4) || IS_ENABLED(CONFIG_ARCH_EXYNOS5)
i2c_bus->id = pinmux_decode_periph_id(blob, node);
+#endif
i2c_bus->clock_frequency =
dev_read_u32_default(dev, "clock-frequency",
@@ -317,7 +331,9 @@ static int s3c_i2c_of_to_plat(struct udevice *dev)
i2c_bus->node = node;
i2c_bus->bus_num = dev_seq(dev);
+#if IS_ENABLED(CONFIG_ARCH_EXYNOS4) || IS_ENABLED(CONFIG_ARCH_EXYNOS5)
exynos_pinmux_config(i2c_bus->id, 0);
+#endif
i2c_bus->active = true;
diff --git a/drivers/i2c/s3c24x0_i2c.h b/drivers/i2c/s3c24x0_i2c.h
index ec8f1acaef5..12249d5c141 100644
--- a/drivers/i2c/s3c24x0_i2c.h
+++ b/drivers/i2c/s3c24x0_i2c.h
@@ -54,7 +54,9 @@ struct s3c24x0_i2c_bus {
struct exynos5_hsi2c *hsregs;
int is_highspeed; /* High speed type, rather than I2C */
unsigned clock_frequency;
+#if IS_ENABLED(CONFIG_ARCH_EXYNOS4) || IS_ENABLED(CONFIG_ARCH_EXYNOS5)
int id;
+#endif
unsigned clk_cycle;
unsigned clk_div;
};
diff --git a/drivers/i2c/sandbox_i2c.c b/drivers/i2c/sandbox_i2c.c
index c99e6de9332..74bb5e93397 100644
--- a/drivers/i2c/sandbox_i2c.c
+++ b/drivers/i2c/sandbox_i2c.c
@@ -5,7 +5,6 @@
* Copyright (c) 2014 Google, Inc
*/
-#include <common.h>
#include <dm.h>
#include <errno.h>
#include <i2c.h>
diff --git a/drivers/i2c/sh_i2c.c b/drivers/i2c/sh_i2c.c
index 3335d9482a2..ab816101dea 100644
--- a/drivers/i2c/sh_i2c.c
+++ b/drivers/i2c/sh_i2c.c
@@ -7,7 +7,6 @@
* Please see doc/driver-model/i2c-howto.rst for instructions.
*/
-#include <common.h>
#include <i2c.h>
#include <log.h>
#include <asm/global_data.h>
diff --git a/drivers/i2c/soft_i2c.c b/drivers/i2c/soft_i2c.c
index ed8ba47de45..79f7a320502 100644
--- a/drivers/i2c/soft_i2c.c
+++ b/drivers/i2c/soft_i2c.c
@@ -15,7 +15,7 @@
* Please see doc/driver-model/i2c-howto.rst for instructions.
*/
-#include <common.h>
+#include <config.h>
#if defined(CONFIG_AT91FAMILY)
#include <asm/io.h>
#include <asm/arch/hardware.h>
@@ -96,7 +96,6 @@ DECLARE_GLOBAL_DATA_PTR;
#define I2C_ACK 0 /* PD_SDA level to ack a byte */
#define I2C_NOACK 1 /* PD_SDA level to noack a byte */
-
#ifdef DEBUG_I2C
#define PRINTD(fmt,args...) do { \
printf (fmt ,##args); \
@@ -108,16 +107,13 @@ DECLARE_GLOBAL_DATA_PTR;
/*-----------------------------------------------------------------------
* Local functions
*/
-#if !defined(CONFIG_SYS_I2C_INIT_BOARD)
static void send_reset (void);
-#endif
static void send_start (void);
static void send_stop (void);
static void send_ack (int);
static int write_byte (uchar byte);
static uchar read_byte (int);
-#if !defined(CONFIG_SYS_I2C_INIT_BOARD)
/*-----------------------------------------------------------------------
* Send a reset sequence consisting of 9 clocks with the data signal high
* to clock any confused device back into an idle state. Also send a
@@ -145,7 +141,6 @@ static void send_reset(void)
send_stop();
I2C_TRISTATE;
}
-#endif
/*-----------------------------------------------------------------------
* START: High -> Low on SDA while SCL is High
@@ -278,12 +273,6 @@ static uchar read_byte(int ack)
*/
static void soft_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
{
-#if defined(CONFIG_SYS_I2C_INIT_BOARD)
- /* call board specific i2c bus reset routine before accessing the */
- /* environment, which might be in a chip on that bus. For details */
- /* about this problem see doc/I2C_Edge_Conditions. */
- i2c_init_board();
-#else
/*
* WARNING: Do NOT save speed in a static variable: if the
* I2C routines are called before RAM is initialized (to read
@@ -291,7 +280,6 @@ static void soft_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
* system will crash.
*/
send_reset ();
-#endif
}
/*-----------------------------------------------------------------------
diff --git a/drivers/i2c/stm32f7_i2c.c b/drivers/i2c/stm32f7_i2c.c
index f42e08a6418..3f51b1dd1db 100644
--- a/drivers/i2c/stm32f7_i2c.c
+++ b/drivers/i2c/stm32f7_i2c.c
@@ -5,7 +5,6 @@
#define LOG_CATEGORY UCLASS_I2C
-#include <common.h>
#include <clk.h>
#include <dm.h>
#include <i2c.h>
diff --git a/drivers/i2c/sun6i_p2wi.c b/drivers/i2c/sun6i_p2wi.c
index b8e07a533ca..c927c0edf25 100644
--- a/drivers/i2c/sun6i_p2wi.c
+++ b/drivers/i2c/sun6i_p2wi.c
@@ -15,7 +15,6 @@
#include <axp_pmic.h>
#include <clk.h>
-#include <common.h>
#include <dm.h>
#include <errno.h>
#include <i2c.h>
diff --git a/drivers/i2c/sun8i_rsb.c b/drivers/i2c/sun8i_rsb.c
index f36f2c7afac..2197f180566 100644
--- a/drivers/i2c/sun8i_rsb.c
+++ b/drivers/i2c/sun8i_rsb.c
@@ -10,7 +10,6 @@
#include <axp_pmic.h>
#include <clk.h>
-#include <common.h>
#include <dm.h>
#include <errno.h>
#include <i2c.h>
diff --git a/drivers/i2c/tegra186_bpmp_i2c.c b/drivers/i2c/tegra186_bpmp_i2c.c
index 588f6bdcc4b..d30eb523122 100644
--- a/drivers/i2c/tegra186_bpmp_i2c.c
+++ b/drivers/i2c/tegra186_bpmp_i2c.c
@@ -3,7 +3,6 @@
* Copyright (c) 2016, NVIDIA CORPORATION.
*/
-#include <common.h>
#include <dm.h>
#include <i2c.h>
#include <log.h>
diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index 57d77d56ea5..3c324bd2663 100644
--- a/drivers/i2c/tegra_i2c.c
+++ b/drivers/i2c/tegra_i2c.c
@@ -5,7 +5,6 @@
* NVIDIA Corporation <www.nvidia.com>
*/
-#include <common.h>
#include <dm.h>
#include <errno.h>
#include <i2c.h>
diff --git a/drivers/i2c/xilinx_xiic.c b/drivers/i2c/xilinx_xiic.c
index 72199a62b2d..056024e350f 100644
--- a/drivers/i2c/xilinx_xiic.c
+++ b/drivers/i2c/xilinx_xiic.c
@@ -9,7 +9,6 @@
* Copyright (c) 2009-2010 Intel Corporation
*/
-#include <common.h>
#include <clk.h>
#include <dm.h>
#include <i2c.h>