diff options
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/Kconfig | 21 | ||||
-rw-r--r-- | drivers/i2c/Makefile | 4 | ||||
-rw-r--r-- | drivers/i2c/at91_i2c.c | 4 | ||||
-rw-r--r-- | drivers/i2c/davinci_i2c.c | 4 | ||||
-rw-r--r-- | drivers/i2c/designware_i2c.c | 4 | ||||
-rw-r--r-- | drivers/i2c/fsl_i2c.c | 6 | ||||
-rw-r--r-- | drivers/i2c/i2c-gpio.c | 17 | ||||
-rw-r--r-- | drivers/i2c/ihs_i2c.c | 42 | ||||
-rw-r--r-- | drivers/i2c/lpc32xx_i2c.c | 4 | ||||
-rw-r--r-- | drivers/i2c/mv_i2c.c | 2 | ||||
-rw-r--r-- | drivers/i2c/mvtwsi.c | 16 | ||||
-rw-r--r-- | drivers/i2c/mxc_i2c.c | 4 | ||||
-rw-r--r-- | drivers/i2c/omap24xx_i2c.c | 2 |
13 files changed, 79 insertions, 51 deletions
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index f79b50fcf5..1844941eb2 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig @@ -14,6 +14,17 @@ config DM_I2C device (bus child) info is kept as parent plat. The interface is defined in include/i2c.h. +config SPL_DM_I2C + bool "Enable Driver Model for I2C drivers in SPL" + depends on SPL_DM && DM_I2C + default y + help + Enable driver model for I2C. The I2C uclass interface: probe, read, + write and speed, is implemented with the bus drivers operations, + which provide methods for bus setting and data transfer. Each chip + device (bus child) info is kept as parent platdata. The interface + is defined in include/i2c.h. + config I2C_CROS_EC_TUNNEL tristate "Chrome OS EC tunnel I2C bus" depends on CROS_EC @@ -61,6 +72,16 @@ config DM_I2C_GPIO bindings are supported. Binding info: doc/device-tree-bindings/i2c/i2c-gpio.txt +config SPL_DM_I2C_GPIO + bool "Enable Driver Model for software emulated I2C bus driver in SPL" + depends on SPL_DM && DM_I2C_GPIO && SPL_DM_GPIO && SPL_GPIO_SUPPORT + default y + help + Enable the i2c bus driver emulation by using the GPIOs. The bus GPIO + configuration is given by the device tree. Kernel-style device tree + bindings are supported. + Binding info: doc/device-tree-bindings/i2c/i2c-gpio.txt + config SYS_I2C_AT91 bool "Atmel I2C driver" depends on DM_I2C && ARCH_AT91 diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile index 29aab0f9e3..acd27ac29d 100644 --- a/drivers/i2c/Makefile +++ b/drivers/i2c/Makefile @@ -2,9 +2,9 @@ # # (C) Copyright 2000-2007 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. -obj-$(CONFIG_DM_I2C) += i2c-uclass.o +obj-$(CONFIG_$(SPL_)DM_I2C) += i2c-uclass.o ifdef CONFIG_ACPIGEN -obj-$(CONFIG_DM_I2C) += acpi_i2c.o +obj-$(CONFIG_$(SPL_)DM_I2C) += acpi_i2c.o endif obj-$(CONFIG_$(SPL_)DM_I2C_GPIO) += i2c-gpio.o obj-$(CONFIG_$(SPL_)I2C_CROS_EC_TUNNEL) += cros_ec_tunnel.o diff --git a/drivers/i2c/at91_i2c.c b/drivers/i2c/at91_i2c.c index aca8de9436..6b4c0e4804 100644 --- a/drivers/i2c/at91_i2c.c +++ b/drivers/i2c/at91_i2c.c @@ -51,6 +51,10 @@ static int at91_i2c_xfer_msg(struct at91_i2c_bus *bus, struct i2c_msg *msg) u32 i; int ret = 0; + /* if there is no message to send/receive, just exit quietly */ + if (msg->len == 0) + return ret; + readl(®->sr); if (is_read) { writel(TWI_CR_START, ®->cr); diff --git a/drivers/i2c/davinci_i2c.c b/drivers/i2c/davinci_i2c.c index 7811abad80..a4abd25c39 100644 --- a/drivers/i2c/davinci_i2c.c +++ b/drivers/i2c/davinci_i2c.c @@ -21,7 +21,7 @@ #include <linux/delay.h> #include "davinci_i2c.h" -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) /* Information about i2c controller */ struct i2c_bus { int id; @@ -340,7 +340,7 @@ static int _davinci_i2c_probe_chip(struct i2c_regs *i2c_base, uint8_t chip) return rc; } -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) static struct i2c_regs *davinci_get_base(struct i2c_adapter *adap) { switch (adap->hwadapnr) { diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c index 60111b8419..072803691e 100644 --- a/drivers/i2c/designware_i2c.c +++ b/drivers/i2c/designware_i2c.c @@ -598,7 +598,7 @@ static int __dw_i2c_init(struct i2c_regs *i2c_base, int speed, int slaveaddr) writel(IC_RX_TL, &i2c_base->ic_rx_tl); writel(IC_TX_TL, &i2c_base->ic_tx_tl); writel(IC_STOP_DET, &i2c_base->ic_intr_mask); -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) _dw_i2c_set_bus_speed(NULL, i2c_base, speed, IC_CLK); writel(slaveaddr, &i2c_base->ic_sar); #endif @@ -611,7 +611,7 @@ static int __dw_i2c_init(struct i2c_regs *i2c_base, int speed, int slaveaddr) return 0; } -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) /* * The legacy I2C functions. These need to get removed once * all users of this driver are converted to DM. diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c index 5283575968..2200303ea8 100644 --- a/drivers/i2c/fsl_i2c.c +++ b/drivers/i2c/fsl_i2c.c @@ -40,7 +40,7 @@ DECLARE_GLOBAL_DATA_PTR; -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) static const struct fsl_i2c_base *i2c_base[4] = { (struct fsl_i2c_base *)(CONFIG_SYS_IMMR + CONFIG_SYS_FSL_I2C_OFFSET), #ifdef CONFIG_SYS_FSL_I2C2_OFFSET @@ -203,7 +203,7 @@ static uint set_i2c_bus_speed(const struct fsl_i2c_base *base, return speed; } -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) static uint get_i2c_clock(int bus) { if (bus) @@ -497,7 +497,7 @@ static uint __i2c_set_bus_speed(const struct fsl_i2c_base *base, return 0; } -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) static void fsl_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd) { __i2c_init(i2c_base[adap->hwadapnr], speed, slaveadd, diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c index 387f00b2cd..a301a4460b 100644 --- a/drivers/i2c/i2c-gpio.c +++ b/drivers/i2c/i2c-gpio.c @@ -50,9 +50,10 @@ static void i2c_gpio_sda_set(struct i2c_gpio_bus *bus, int bit) struct gpio_desc *sda = &bus->gpios[PIN_SDA]; if (bit) - dm_gpio_set_dir_flags(sda, GPIOD_IS_IN); + sda->flags = (sda->flags & ~GPIOD_IS_OUT) | GPIOD_IS_IN; else - dm_gpio_set_dir_flags(sda, GPIOD_IS_OUT); + sda->flags = (sda->flags & (~GPIOD_IS_IN & ~GPIOD_IS_OUT_ACTIVE)) | GPIOD_IS_OUT; + dm_gpio_set_dir(sda); } static void i2c_gpio_scl_set(struct i2c_gpio_bus *bus, int bit) @@ -61,14 +62,16 @@ static void i2c_gpio_scl_set(struct i2c_gpio_bus *bus, int bit) int count = 0; if (bit) { - dm_gpio_set_dir_flags(scl, GPIOD_IS_IN); + scl->flags = (scl->flags & ~GPIOD_IS_OUT) | GPIOD_IS_IN; + dm_gpio_set_dir(scl); while (!dm_gpio_get_value(scl) && count++ < 100000) udelay(1); if (!dm_gpio_get_value(scl)) pr_err("timeout waiting on slave to release scl\n"); } else { - dm_gpio_set_dir_flags(scl, GPIOD_IS_OUT); + scl->flags = (scl->flags & (~GPIOD_IS_IN & ~GPIOD_IS_OUT_ACTIVE)) | GPIOD_IS_OUT; + dm_gpio_set_dir(scl); } } @@ -76,11 +79,11 @@ static void i2c_gpio_scl_set(struct i2c_gpio_bus *bus, int bit) static void i2c_gpio_scl_set_output_only(struct i2c_gpio_bus *bus, int bit) { struct gpio_desc *scl = &bus->gpios[PIN_SCL]; - ulong flags = GPIOD_IS_OUT; + scl->flags = (scl->flags & (~GPIOD_IS_IN & ~GPIOD_IS_OUT_ACTIVE)) | GPIOD_IS_OUT; if (bit) - flags |= GPIOD_IS_OUT_ACTIVE; - dm_gpio_set_dir_flags(scl, flags); + scl->flags |= GPIOD_IS_OUT_ACTIVE; + dm_gpio_set_dir(scl); } static void i2c_gpio_write_bit(struct i2c_gpio_bus *bus, int delay, uchar bit) diff --git a/drivers/i2c/ihs_i2c.c b/drivers/i2c/ihs_i2c.c index ba7817478c..02f0144930 100644 --- a/drivers/i2c/ihs_i2c.c +++ b/drivers/i2c/ihs_i2c.c @@ -6,7 +6,7 @@ #include <common.h> #include <i2c.h> -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) #include <dm.h> #include <regmap.h> #else @@ -18,7 +18,7 @@ #include <linux/bitops.h> #include <linux/delay.h> -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) struct ihs_i2c_priv { uint speed; struct regmap *map; @@ -91,7 +91,7 @@ enum { I2COP_READ = 1, }; -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) static int wait_for_int(struct udevice *dev, int read) #else static int wait_for_int(bool read) @@ -99,11 +99,11 @@ static int wait_for_int(bool read) { u16 val; uint ctr = 0; -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) struct ihs_i2c_priv *priv = dev_get_priv(dev); #endif -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) ihs_i2c_get(priv->map, interrupt_status, &val); #else I2C_GET_REG(interrupt_status, &val); @@ -116,7 +116,7 @@ static int wait_for_int(bool read) debug("%s: timed out\n", __func__); return -ETIMEDOUT; } -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) ihs_i2c_get(priv->map, interrupt_status, &val); #else I2C_GET_REG(interrupt_status, &val); @@ -126,7 +126,7 @@ static int wait_for_int(bool read) return (val & I2CINT_ERROR_EV) ? -EIO : 0; } -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) static int ihs_i2c_transfer(struct udevice *dev, uchar chip, uchar *buffer, int len, int read, bool is_last) #else @@ -137,13 +137,13 @@ static int ihs_i2c_transfer(uchar chip, uchar *buffer, int len, bool read, u16 val; u16 data; int res; -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) struct ihs_i2c_priv *priv = dev_get_priv(dev); #endif /* Clear interrupt status */ data = I2CINT_ERROR_EV | I2CINT_RECEIVE_EV | I2CINT_TRANSMIT_EV; -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) ihs_i2c_set(priv->map, interrupt_status, data); ihs_i2c_get(priv->map, interrupt_status, &val); #else @@ -157,7 +157,7 @@ static int ihs_i2c_transfer(uchar chip, uchar *buffer, int len, bool read, if (len > 1) val |= buffer[1] << 8; -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) ihs_i2c_set(priv->map, write_mailbox_ext, val); #else I2C_SET_REG(write_mailbox_ext, val); @@ -170,13 +170,13 @@ static int ihs_i2c_transfer(uchar chip, uchar *buffer, int len, bool read, | ((len > 1) ? I2CMB_2BYTE : 0) | (is_last ? 0 : I2CMB_HOLD_BUS); -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) ihs_i2c_set(priv->map, write_mailbox, data); #else I2C_SET_REG(write_mailbox, data); #endif -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) res = wait_for_int(dev, read); #else res = wait_for_int(read); @@ -190,7 +190,7 @@ static int ihs_i2c_transfer(uchar chip, uchar *buffer, int len, bool read, /* If we want to read, get the bytes from the mailbox */ if (read) { -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) ihs_i2c_get(priv->map, read_mailbox_ext, &val); #else I2C_GET_REG(read_mailbox_ext, &val); @@ -203,7 +203,7 @@ static int ihs_i2c_transfer(uchar chip, uchar *buffer, int len, bool read, return 0; } -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) static int ihs_i2c_send_buffer(struct udevice *dev, uchar chip, u8 *data, int len, bool hold_bus, int read) #else static int ihs_i2c_send_buffer(uchar chip, u8 *data, int len, bool hold_bus, @@ -216,7 +216,7 @@ static int ihs_i2c_send_buffer(uchar chip, u8 *data, int len, bool hold_bus, int transfer = min(len, 2); bool is_last = len <= transfer; -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) res = ihs_i2c_transfer(dev, chip, data, transfer, read, hold_bus ? false : is_last); #else @@ -233,21 +233,21 @@ static int ihs_i2c_send_buffer(uchar chip, u8 *data, int len, bool hold_bus, return 0; } -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) static int ihs_i2c_address(struct udevice *dev, uchar chip, u8 *addr, int alen, bool hold_bus) #else static int ihs_i2c_address(uchar chip, u8 *addr, int alen, bool hold_bus) #endif { -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) return ihs_i2c_send_buffer(dev, chip, addr, alen, hold_bus, I2COP_WRITE); #else return ihs_i2c_send_buffer(chip, addr, alen, hold_bus, I2COP_WRITE); #endif } -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) static int ihs_i2c_access(struct udevice *dev, uchar chip, u8 *addr, int alen, uchar *buffer, int len, int read) #else @@ -261,7 +261,7 @@ static int ihs_i2c_access(struct i2c_adapter *adap, uchar chip, u8 *addr, if (len <= 0) return -EINVAL; -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) res = ihs_i2c_address(dev, chip, addr, alen, len); #else res = ihs_i2c_address(chip, addr, alen, len); @@ -269,14 +269,14 @@ static int ihs_i2c_access(struct i2c_adapter *adap, uchar chip, u8 *addr, if (res) return res; -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) return ihs_i2c_send_buffer(dev, chip, buffer, len, false, read); #else return ihs_i2c_send_buffer(chip, buffer, len, false, read); #endif } -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) int ihs_i2c_probe(struct udevice *bus) { diff --git a/drivers/i2c/lpc32xx_i2c.c b/drivers/i2c/lpc32xx_i2c.c index ad11e978cc..f89f7955e4 100644 --- a/drivers/i2c/lpc32xx_i2c.c +++ b/drivers/i2c/lpc32xx_i2c.c @@ -42,7 +42,7 @@ #define LPC32XX_I2C_STAT_NAI 0x00000004 #define LPC32XX_I2C_STAT_TDI 0x00000001 -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) static struct lpc32xx_i2c_base *lpc32xx_i2c[] = { (struct lpc32xx_i2c_base *)I2C1_BASE, (struct lpc32xx_i2c_base *)I2C2_BASE, @@ -224,7 +224,7 @@ static int __i2c_write(struct lpc32xx_i2c_base *base, u8 dev, uint addr, return 0; } -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) static void lpc32xx_i2c_init(struct i2c_adapter *adap, int requested_speed, int slaveadd) { diff --git a/drivers/i2c/mv_i2c.c b/drivers/i2c/mv_i2c.c index ef1007de14..20c5de0007 100644 --- a/drivers/i2c/mv_i2c.c +++ b/drivers/i2c/mv_i2c.c @@ -370,7 +370,7 @@ static int __i2c_write(struct mv_i2c *base, uchar chip, u8 *addr, int alen, return 0; } -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) static struct mv_i2c *base_glob; diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c index 5df69f1459..d33e2c7c9d 100644 --- a/drivers/i2c/mvtwsi.c +++ b/drivers/i2c/mvtwsi.c @@ -16,7 +16,7 @@ #include <asm/io.h> #include <linux/bitops.h> #include <linux/compat.h> -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) #include <dm.h> #endif @@ -27,7 +27,7 @@ DECLARE_GLOBAL_DATA_PTR; * settings */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #if defined(CONFIG_ARCH_ORION5X) #include <asm/arch/orion5x.h> #elif (defined(CONFIG_ARCH_KIRKWOOD) || defined(CONFIG_ARCH_MVEBU)) @@ -43,7 +43,7 @@ DECLARE_GLOBAL_DATA_PTR; * On SUNXI, we get CONFIG_SYS_TCLK from this include, so we want to * always have it. */ -#if defined(CONFIG_DM_I2C) && defined(CONFIG_ARCH_SUNXI) +#if CONFIG_IS_ENABLED(DM_I2C) && defined(CONFIG_ARCH_SUNXI) #include <asm/arch/i2c.h> #endif @@ -83,7 +83,7 @@ struct mvtwsi_registers { #endif -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) struct mvtwsi_i2c_dev { /* TWSI Register base for the device */ struct mvtwsi_registers *base; @@ -184,7 +184,7 @@ inline uint calc_tick(uint speed) return (1000000000u / speed) + 100; } -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) /* * twsi_get_base() - Get controller register base for specified adapter @@ -481,7 +481,7 @@ static uint __twsi_i2c_set_bus_speed(struct mvtwsi_registers *twsi, writel(baud, &twsi->baudrate); /* Wait for controller for one tick */ -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) ndelay(calc_tick(highest_speed)); #else ndelay(10000); @@ -516,7 +516,7 @@ static void __twsi_i2c_init(struct mvtwsi_registers *twsi, int speed, writel(slaveadd, &twsi->slave_address); writel(0, &twsi->xtnd_slave_addr); /* Assert STOP, but don't care for the result */ -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) (void) twsi_stop(twsi, calc_tick(*actual_speed)); #else (void) twsi_stop(twsi, 10000); @@ -683,7 +683,7 @@ static int __twsi_i2c_write(struct mvtwsi_registers *twsi, uchar chip, return status != 0 ? status : stop_status; } -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) static void twsi_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd) { diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index 3c91515bff..003aa33f6e 100644 --- a/drivers/i2c/mxc_i2c.c +++ b/drivers/i2c/mxc_i2c.c @@ -394,7 +394,7 @@ static struct mxc_i2c_bus mxc_i2c_buses[] = { #endif }; -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) int i2c_idle_bus(struct mxc_i2c_bus *i2c_bus) { if (i2c_bus && i2c_bus->idle_bus_fn) @@ -646,7 +646,7 @@ int __enable_i2c_clk(unsigned char enable, unsigned int i2c_num) int enable_i2c_clk(unsigned char enable, unsigned int i2c_num) __attribute__((weak, alias("__enable_i2c_clk"))); -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) /* * Read data from I2C device * diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c index 1355dc274e..71f6f5f7ac 100644 --- a/drivers/i2c/omap24xx_i2c.c +++ b/drivers/i2c/omap24xx_i2c.c @@ -836,7 +836,7 @@ wr_exit: return i2c_error; } -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) /* * The legacy I2C functions. These need to get removed once * all users of this driver are converted to DM. |