]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
dm: i2c: Make API accessible even without CONFIG_DM
authorSimon Glass <sjg@chromium.org>
Fri, 6 Feb 2015 04:41:33 +0000 (21:41 -0700)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 1 Sep 2015 11:50:46 +0000 (13:50 +0200)
Make the driver model I2C API available always, even if driver model
is not enabled. This allows for a 'soft' switch-over, where drivers can
use the new structures in code which is compiled but not yet used. This
makes migration easier in some cases.

Fix up the existing drivers which define their own 'struct i2c_msg'.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de>
drivers/i2c/adi_i2c.c
drivers/i2c/kona_i2c.c
drivers/i2c/mv_i2c.c
include/i2c.h

index 20495b1d7f8c86f28e84ba12255f6024c02f971c..c58f14a36e5217624f398c2cbb0ec540cb1c474c 100644 (file)
@@ -63,7 +63,7 @@ struct twi_regs {
 #endif
 
 /* All transfers are described by this data structure */
-struct i2c_msg {
+struct adi_i2c_msg {
        u8 flags;
 #define I2C_M_COMBO            0x4
 #define I2C_M_STOP             0x2
@@ -81,7 +81,7 @@ struct i2c_msg {
  * wait_for_completion - manage the actual i2c transfer
  *     @msg: the i2c msg
  */
-static int wait_for_completion(struct twi_regs *twi, struct i2c_msg *msg)
+static int wait_for_completion(struct twi_regs *twi, struct adi_i2c_msg *msg)
 {
        u16 int_stat, ctl;
        ulong timebase = get_timer(0);
@@ -151,7 +151,7 @@ static int i2c_transfer(struct i2c_adapter *adap, uint8_t chip, uint addr,
                (addr >>  8),
                (addr >> 16),
        };
-       struct i2c_msg msg = {
+       struct adi_i2c_msg msg = {
                .flags = flags | (len >= 0xff ? I2C_M_STOP : 0),
                .buf   = buffer,
                .len   = len,
index 5eab338cfc470fbc57ae1fd4cff2166d122fa536..9af496bbb1cdbd8454c5fd927bfda5b1bf44b53e 100644 (file)
@@ -156,7 +156,7 @@ static struct bcm_kona_i2c_dev g_i2c_devs[CONFIG_SYS_MAX_I2C_BUS] = {
 #define I2C_M_RD       0x0001  /* read data */
 #define I2C_M_NOSTART  0x4000  /* no restart between msgs */
 
-struct i2c_msg {
+struct kona_i2c_msg {
        uint16_t addr;
        uint16_t flags;
        uint16_t len;
@@ -297,7 +297,7 @@ static int bcm_kona_i2c_read_fifo_single(struct bcm_kona_i2c_dev *dev,
 
 /* Read any amount of data using the RX FIFO from the i2c bus */
 static int bcm_kona_i2c_read_fifo(struct bcm_kona_i2c_dev *dev,
-                                 struct i2c_msg *msg)
+                                 struct kona_i2c_msg *msg)
 {
        unsigned int bytes_to_read = MAX_RX_FIFO_SIZE;
        unsigned int last_byte_nak = 0;
@@ -392,7 +392,7 @@ static int bcm_kona_i2c_write_fifo_single(struct bcm_kona_i2c_dev *dev,
 
 /* Write any amount of data using TX FIFO to the i2c bus */
 static int bcm_kona_i2c_write_fifo(struct bcm_kona_i2c_dev *dev,
-                                  struct i2c_msg *msg)
+                                  struct kona_i2c_msg *msg)
 {
        unsigned int bytes_to_write = MAX_TX_FIFO_SIZE;
        unsigned int bytes_written = 0;
@@ -418,7 +418,7 @@ static int bcm_kona_i2c_write_fifo(struct bcm_kona_i2c_dev *dev,
 
 /* Send i2c address */
 static int bcm_kona_i2c_do_addr(struct bcm_kona_i2c_dev *dev,
-                               struct i2c_msg *msg)
+                               struct kona_i2c_msg *msg)
 {
        unsigned char addr;
 
@@ -480,9 +480,9 @@ static void bcm_kona_i2c_config_timing(struct bcm_kona_i2c_dev *dev)
 
 /* Master transfer function */
 static int bcm_kona_i2c_xfer(struct bcm_kona_i2c_dev *dev,
-                            struct i2c_msg msgs[], int num)
+                            struct kona_i2c_msg msgs[], int num)
 {
-       struct i2c_msg *pmsg;
+       struct kona_i2c_msg *pmsg;
        int rc = 0;
        int i;
 
@@ -635,7 +635,7 @@ static int kona_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
                         int alen, uchar *buffer, int len)
 {
        /* msg[0] writes the addr, msg[1] reads the data */
-       struct i2c_msg msg[2];
+       struct kona_i2c_msg msg[2];
        unsigned char msgbuf0[64];
        struct bcm_kona_i2c_dev *dev = kona_get_dev(adap);
 
@@ -663,7 +663,7 @@ static int kona_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
 static int kona_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
                          int alen, uchar *buffer, int len)
 {
-       struct i2c_msg msg[1];
+       struct kona_i2c_msg msg[1];
        unsigned char msgbuf0[64];
        unsigned int i;
        struct bcm_kona_i2c_dev *dev = kona_get_dev(adap);
index dac346334d8100f46b90e18eb82a6b74eff8b100..e65cce0d8e7e1f3c7903e79a5bc19479856d79f4 100644 (file)
@@ -31,7 +31,7 @@
 #endif
 
 /* All transfers are described by this data structure */
-struct i2c_msg {
+struct mv_i2c_msg {
        u8 condition;
        u8 acknack;
        u8 direction;
@@ -157,7 +157,7 @@ static int i2c_isr_set_cleared(unsigned long set_mask,
  *          -5: illegal parameters
  *          -6: bus is busy and couldn't be aquired
  */
-int i2c_transfer(struct i2c_msg *msg)
+int i2c_transfer(struct mv_i2c_msg *msg)
 {
        int ret;
 
@@ -286,7 +286,7 @@ void i2c_init(int speed, int slaveaddr)
  */
 int i2c_probe(uchar chip)
 {
-       struct i2c_msg msg;
+       struct mv_i2c_msg msg;
 
        i2c_reset();
 
@@ -322,7 +322,7 @@ int i2c_probe(uchar chip)
  */
 int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
 {
-       struct i2c_msg msg;
+       struct mv_i2c_msg msg;
        u8 addr_bytes[3]; /* lowest...highest byte of data address */
 
        PRINTD(("i2c_read(chip=0x%02x, addr=0x%02x, alen=0x%02x, "
@@ -410,7 +410,7 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
  */
 int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 {
-       struct i2c_msg msg;
+       struct mv_i2c_msg msg;
        u8 addr_bytes[3]; /* lowest...highest byte of data address */
 
        PRINTD(("i2c_write(chip=0x%02x, addr=0x%02x, alen=0x%02x, "
index 1635e9ac06ca0e8432a35f99e5654a16c29e1de2..31b038991e57fb56525354e976ba922706bd8630 100644 (file)
  * enough as to be incompatible for compilation purposes.
  */
 
-#ifdef CONFIG_DM_I2C
-
 enum dm_i2c_chip_flags {
        DM_I2C_CHIP_10BIT       = 1 << 0, /* Use 10-bit addressing */
        DM_I2C_CHIP_RD_ADDRESS  = 1 << 1, /* Send address for each read byte */
        DM_I2C_CHIP_WR_ADDRESS  = 1 << 2, /* Send address for each write byte */
 };
 
+struct udevice;
 /**
  * struct dm_i2c_chip - information about an i2c chip
  *
@@ -439,8 +438,6 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len,
 int i2c_chip_ofdata_to_platdata(const void *blob, int node,
                                struct dm_i2c_chip *chip);
 
-#endif
-
 #ifndef CONFIG_DM_I2C
 
 /*