Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 1 | /* |
Scott Jiang | fea9b69 | 2014-11-13 15:30:53 +0800 | [diff] [blame] | 2 | * i2c.c - driver for ADI TWI/I2C |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 3 | * |
Scott Jiang | fea9b69 | 2014-11-13 15:30:53 +0800 | [diff] [blame] | 4 | * Copyright (c) 2006-2014 Analog Devices Inc. |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 5 | * |
| 6 | * Licensed under the GPL-2 or later. |
| 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Simon Glass | 24b852a | 2015-11-08 23:47:45 -0700 | [diff] [blame^] | 10 | #include <console.h> |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 11 | #include <i2c.h> |
| 12 | |
Sonic Zhang | d6a320d | 2014-01-28 13:53:34 +0800 | [diff] [blame] | 13 | #include <asm/clock.h> |
Scott Jiang | fea9b69 | 2014-11-13 15:30:53 +0800 | [diff] [blame] | 14 | #include <asm/twi.h> |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 15 | #include <asm/io.h> |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 16 | |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 17 | static struct twi_regs *i2c_get_base(struct i2c_adapter *adap); |
| 18 | |
Mike Frysinger | b5cebb4 | 2010-05-05 03:20:30 -0400 | [diff] [blame] | 19 | /* Every register is 32bit aligned, but only 16bits in size */ |
| 20 | #define ureg(name) u16 name; u16 __pad_##name; |
| 21 | struct twi_regs { |
| 22 | ureg(clkdiv); |
| 23 | ureg(control); |
| 24 | ureg(slave_ctl); |
| 25 | ureg(slave_stat); |
| 26 | ureg(slave_addr); |
| 27 | ureg(master_ctl); |
| 28 | ureg(master_stat); |
| 29 | ureg(master_addr); |
| 30 | ureg(int_stat); |
| 31 | ureg(int_mask); |
| 32 | ureg(fifo_ctl); |
| 33 | ureg(fifo_stat); |
| 34 | char __pad[0x50]; |
| 35 | ureg(xmt_data8); |
| 36 | ureg(xmt_data16); |
| 37 | ureg(rcv_data8); |
| 38 | ureg(rcv_data16); |
| 39 | }; |
| 40 | #undef ureg |
| 41 | |
Mike Frysinger | b5cebb4 | 2010-05-05 03:20:30 -0400 | [diff] [blame] | 42 | #ifdef TWI_CLKDIV |
| 43 | #define TWI0_CLKDIV TWI_CLKDIV |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 44 | # ifdef CONFIG_SYS_MAX_I2C_BUS |
| 45 | # undef CONFIG_SYS_MAX_I2C_BUS |
| 46 | # endif |
| 47 | #define CONFIG_SYS_MAX_I2C_BUS 1 |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 48 | #endif |
Mike Frysinger | 08a1c62 | 2009-10-14 19:27:27 -0400 | [diff] [blame] | 49 | |
| 50 | /* |
| 51 | * The way speed is changed into duty often results in integer truncation |
| 52 | * with 50% duty, so we'll force rounding up to the next duty by adding 1 |
| 53 | * to the max. In practice this will get us a speed of something like |
| 54 | * 385 KHz. The other limit is easy to handle as it is only 8 bits. |
| 55 | */ |
| 56 | #define I2C_SPEED_MAX 400000 |
| 57 | #define I2C_SPEED_TO_DUTY(speed) (5000000 / (speed)) |
| 58 | #define I2C_DUTY_MAX (I2C_SPEED_TO_DUTY(I2C_SPEED_MAX) + 1) |
| 59 | #define I2C_DUTY_MIN 0xff /* 8 bit limited */ |
| 60 | #define SYS_I2C_DUTY I2C_SPEED_TO_DUTY(CONFIG_SYS_I2C_SPEED) |
| 61 | /* Note: duty is inverse of speed, so the comparisons below are correct */ |
| 62 | #if SYS_I2C_DUTY < I2C_DUTY_MAX || SYS_I2C_DUTY > I2C_DUTY_MIN |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 63 | # error "The I2C hardware can only operate 20KHz - 400KHz" |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 64 | #endif |
| 65 | |
| 66 | /* All transfers are described by this data structure */ |
Simon Glass | fffff72 | 2015-02-05 21:41:33 -0700 | [diff] [blame] | 67 | struct adi_i2c_msg { |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 68 | u8 flags; |
| 69 | #define I2C_M_COMBO 0x4 |
| 70 | #define I2C_M_STOP 0x2 |
| 71 | #define I2C_M_READ 0x1 |
| 72 | int len; /* msg length */ |
| 73 | u8 *buf; /* pointer to msg data */ |
| 74 | int alen; /* addr length */ |
| 75 | u8 *abuf; /* addr buffer */ |
| 76 | }; |
| 77 | |
Mike Frysinger | 3814ea4 | 2009-10-14 19:27:26 -0400 | [diff] [blame] | 78 | /* Allow msec timeout per ~byte transfer */ |
| 79 | #define I2C_TIMEOUT 10 |
| 80 | |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 81 | /** |
| 82 | * wait_for_completion - manage the actual i2c transfer |
| 83 | * @msg: the i2c msg |
| 84 | */ |
Simon Glass | fffff72 | 2015-02-05 21:41:33 -0700 | [diff] [blame] | 85 | static int wait_for_completion(struct twi_regs *twi, struct adi_i2c_msg *msg) |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 86 | { |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 87 | u16 int_stat, ctl; |
Mike Frysinger | 3814ea4 | 2009-10-14 19:27:26 -0400 | [diff] [blame] | 88 | ulong timebase = get_timer(0); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 89 | |
Mike Frysinger | 3814ea4 | 2009-10-14 19:27:26 -0400 | [diff] [blame] | 90 | do { |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 91 | int_stat = readw(&twi->int_stat); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 92 | |
| 93 | if (int_stat & XMTSERV) { |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 94 | writew(XMTSERV, &twi->int_stat); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 95 | if (msg->alen) { |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 96 | writew(*(msg->abuf++), &twi->xmt_data8); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 97 | --msg->alen; |
| 98 | } else if (!(msg->flags & I2C_M_COMBO) && msg->len) { |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 99 | writew(*(msg->buf++), &twi->xmt_data8); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 100 | --msg->len; |
| 101 | } else { |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 102 | ctl = readw(&twi->master_ctl); |
| 103 | if (msg->flags & I2C_M_COMBO) |
| 104 | writew(ctl | RSTART | MDIR, |
| 105 | &twi->master_ctl); |
| 106 | else |
| 107 | writew(ctl | STOP, &twi->master_ctl); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 108 | } |
| 109 | } |
| 110 | if (int_stat & RCVSERV) { |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 111 | writew(RCVSERV, &twi->int_stat); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 112 | if (msg->len) { |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 113 | *(msg->buf++) = readw(&twi->rcv_data8); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 114 | --msg->len; |
| 115 | } else if (msg->flags & I2C_M_STOP) { |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 116 | ctl = readw(&twi->master_ctl); |
| 117 | writew(ctl | STOP, &twi->master_ctl); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 118 | } |
| 119 | } |
| 120 | if (int_stat & MERR) { |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 121 | writew(MERR, &twi->int_stat); |
Mike Frysinger | 3814ea4 | 2009-10-14 19:27:26 -0400 | [diff] [blame] | 122 | return msg->len; |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 123 | } |
| 124 | if (int_stat & MCOMP) { |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 125 | writew(MCOMP, &twi->int_stat); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 126 | if (msg->flags & I2C_M_COMBO && msg->len) { |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 127 | ctl = readw(&twi->master_ctl); |
| 128 | ctl = (ctl & ~RSTART) | |
Mike Frysinger | b5cebb4 | 2010-05-05 03:20:30 -0400 | [diff] [blame] | 129 | (min(msg->len, 0xff) << 6) | MEN | MDIR; |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 130 | writew(ctl, &twi->master_ctl); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 131 | } else |
| 132 | break; |
| 133 | } |
Mike Frysinger | 3814ea4 | 2009-10-14 19:27:26 -0400 | [diff] [blame] | 134 | |
| 135 | /* If we were able to do something, reset timeout */ |
| 136 | if (int_stat) |
| 137 | timebase = get_timer(0); |
| 138 | |
| 139 | } while (get_timer(timebase) < I2C_TIMEOUT); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 140 | |
| 141 | return msg->len; |
| 142 | } |
| 143 | |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 144 | static int i2c_transfer(struct i2c_adapter *adap, uint8_t chip, uint addr, |
| 145 | int alen, uint8_t *buffer, int len, uint8_t flags) |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 146 | { |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 147 | struct twi_regs *twi = i2c_get_base(adap); |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 148 | int ret; |
| 149 | u16 ctl; |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 150 | uchar addr_buffer[] = { |
| 151 | (addr >> 0), |
| 152 | (addr >> 8), |
| 153 | (addr >> 16), |
| 154 | }; |
Simon Glass | fffff72 | 2015-02-05 21:41:33 -0700 | [diff] [blame] | 155 | struct adi_i2c_msg msg = { |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 156 | .flags = flags | (len >= 0xff ? I2C_M_STOP : 0), |
| 157 | .buf = buffer, |
| 158 | .len = len, |
| 159 | .abuf = addr_buffer, |
| 160 | .alen = alen, |
| 161 | }; |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 162 | |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 163 | /* wait for things to settle */ |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 164 | while (readw(&twi->master_stat) & BUSBUSY) |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 165 | if (ctrlc()) |
| 166 | return 1; |
| 167 | |
| 168 | /* Set Transmit device address */ |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 169 | writew(chip, &twi->master_addr); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 170 | |
| 171 | /* Clear the FIFO before starting things */ |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 172 | writew(XMTFLUSH | RCVFLUSH, &twi->fifo_ctl); |
| 173 | writew(0, &twi->fifo_ctl); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 174 | |
| 175 | /* prime the pump */ |
| 176 | if (msg.alen) { |
Peter Meerwald | 98ab14e | 2009-06-29 15:48:33 -0400 | [diff] [blame] | 177 | len = (msg.flags & I2C_M_COMBO) ? msg.alen : msg.alen + len; |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 178 | writew(*(msg.abuf++), &twi->xmt_data8); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 179 | --msg.alen; |
| 180 | } else if (!(msg.flags & I2C_M_READ) && msg.len) { |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 181 | writew(*(msg.buf++), &twi->xmt_data8); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 182 | --msg.len; |
| 183 | } |
| 184 | |
| 185 | /* clear int stat */ |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 186 | writew(-1, &twi->master_stat); |
| 187 | writew(-1, &twi->int_stat); |
| 188 | writew(0, &twi->int_mask); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 189 | |
| 190 | /* Master enable */ |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 191 | ctl = readw(&twi->master_ctl); |
| 192 | ctl = (ctl & FAST) | (min(len, 0xff) << 6) | MEN | |
| 193 | ((msg.flags & I2C_M_READ) ? MDIR : 0); |
| 194 | writew(ctl, &twi->master_ctl); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 195 | |
| 196 | /* process the rest */ |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 197 | ret = wait_for_completion(twi, &msg); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 198 | |
| 199 | if (ret) { |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 200 | ctl = readw(&twi->master_ctl) & ~MEN; |
| 201 | writew(ctl, &twi->master_ctl); |
| 202 | ctl = readw(&twi->control) & ~TWI_ENA; |
| 203 | writew(ctl, &twi->control); |
| 204 | ctl = readw(&twi->control) | TWI_ENA; |
| 205 | writew(ctl, &twi->control); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | return ret; |
| 209 | } |
| 210 | |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 211 | static uint adi_i2c_setspeed(struct i2c_adapter *adap, uint speed) |
Mike Frysinger | 08a1c62 | 2009-10-14 19:27:27 -0400 | [diff] [blame] | 212 | { |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 213 | struct twi_regs *twi = i2c_get_base(adap); |
Mike Frysinger | 08a1c62 | 2009-10-14 19:27:27 -0400 | [diff] [blame] | 214 | u16 clkdiv = I2C_SPEED_TO_DUTY(speed); |
| 215 | |
| 216 | /* Set TWI interface clock */ |
| 217 | if (clkdiv < I2C_DUTY_MAX || clkdiv > I2C_DUTY_MIN) |
| 218 | return -1; |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 219 | clkdiv = (clkdiv << 8) | (clkdiv & 0xff); |
| 220 | writew(clkdiv, &twi->clkdiv); |
Mike Frysinger | 08a1c62 | 2009-10-14 19:27:27 -0400 | [diff] [blame] | 221 | |
| 222 | /* Don't turn it on */ |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 223 | writew(speed > 100000 ? FAST : 0, &twi->master_ctl); |
Mike Frysinger | 08a1c62 | 2009-10-14 19:27:27 -0400 | [diff] [blame] | 224 | |
| 225 | return 0; |
| 226 | } |
| 227 | |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 228 | static void adi_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr) |
Mike Frysinger | 08a1c62 | 2009-10-14 19:27:27 -0400 | [diff] [blame] | 229 | { |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 230 | struct twi_regs *twi = i2c_get_base(adap); |
| 231 | u16 prescale = ((get_i2c_clk() / 1000 / 1000 + 5) / 10) & 0x7F; |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 232 | |
| 233 | /* Set TWI internal clock as 10MHz */ |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 234 | writew(prescale, &twi->control); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 235 | |
| 236 | /* Set TWI interface clock as specified */ |
Mike Frysinger | 08a1c62 | 2009-10-14 19:27:27 -0400 | [diff] [blame] | 237 | i2c_set_bus_speed(speed); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 238 | |
Mike Frysinger | 08a1c62 | 2009-10-14 19:27:27 -0400 | [diff] [blame] | 239 | /* Enable it */ |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 240 | writew(TWI_ENA | prescale, &twi->control); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 241 | } |
| 242 | |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 243 | static int adi_i2c_read(struct i2c_adapter *adap, uint8_t chip, |
| 244 | uint addr, int alen, uint8_t *buffer, int len) |
| 245 | { |
| 246 | return i2c_transfer(adap, chip, addr, alen, buffer, |
| 247 | len, alen ? I2C_M_COMBO : I2C_M_READ); |
| 248 | } |
| 249 | |
| 250 | static int adi_i2c_write(struct i2c_adapter *adap, uint8_t chip, |
| 251 | uint addr, int alen, uint8_t *buffer, int len) |
| 252 | { |
| 253 | return i2c_transfer(adap, chip, addr, alen, buffer, len, 0); |
| 254 | } |
| 255 | |
| 256 | static int adi_i2c_probe(struct i2c_adapter *adap, uint8_t chip) |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 257 | { |
| 258 | u8 byte; |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 259 | return adi_i2c_read(adap, chip, 0, 0, &byte, 1); |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 260 | } |
| 261 | |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 262 | static struct twi_regs *i2c_get_base(struct i2c_adapter *adap) |
Mike Frysinger | be853bf | 2008-10-06 04:16:47 -0400 | [diff] [blame] | 263 | { |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 264 | switch (adap->hwadapnr) { |
| 265 | #if CONFIG_SYS_MAX_I2C_BUS > 2 |
| 266 | case 2: |
| 267 | return (struct twi_regs *)TWI2_CLKDIV; |
Mike Frysinger | b5cebb4 | 2010-05-05 03:20:30 -0400 | [diff] [blame] | 268 | #endif |
| 269 | #if CONFIG_SYS_MAX_I2C_BUS > 1 |
Scott Jiang | a6be70f | 2014-11-13 15:30:54 +0800 | [diff] [blame] | 270 | case 1: |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 271 | return (struct twi_regs *)TWI1_CLKDIV; |
Mike Frysinger | b5cebb4 | 2010-05-05 03:20:30 -0400 | [diff] [blame] | 272 | #endif |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 273 | case 0: |
| 274 | return (struct twi_regs *)TWI0_CLKDIV; |
| 275 | |
| 276 | default: |
| 277 | printf("wrong hwadapnr: %d\n", adap->hwadapnr); |
Mike Frysinger | b5cebb4 | 2010-05-05 03:20:30 -0400 | [diff] [blame] | 278 | } |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 279 | |
| 280 | return NULL; |
Mike Frysinger | b5cebb4 | 2010-05-05 03:20:30 -0400 | [diff] [blame] | 281 | } |
| 282 | |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 283 | U_BOOT_I2C_ADAP_COMPLETE(adi_i2c0, adi_i2c_init, adi_i2c_probe, |
| 284 | adi_i2c_read, adi_i2c_write, |
| 285 | adi_i2c_setspeed, |
| 286 | CONFIG_SYS_I2C_SPEED, |
| 287 | 0, |
| 288 | 0) |
| 289 | |
Mike Frysinger | b5cebb4 | 2010-05-05 03:20:30 -0400 | [diff] [blame] | 290 | #if CONFIG_SYS_MAX_I2C_BUS > 1 |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 291 | U_BOOT_I2C_ADAP_COMPLETE(adi_i2c1, adi_i2c_init, adi_i2c_probe, |
| 292 | adi_i2c_read, adi_i2c_write, |
| 293 | adi_i2c_setspeed, |
| 294 | CONFIG_SYS_I2C_SPEED, |
| 295 | 0, |
| 296 | 1) |
Mike Frysinger | b5cebb4 | 2010-05-05 03:20:30 -0400 | [diff] [blame] | 297 | #endif |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 298 | |
Mike Frysinger | b5cebb4 | 2010-05-05 03:20:30 -0400 | [diff] [blame] | 299 | #if CONFIG_SYS_MAX_I2C_BUS > 2 |
Scott Jiang | c469703 | 2014-11-13 15:30:55 +0800 | [diff] [blame] | 300 | U_BOOT_I2C_ADAP_COMPLETE(adi_i2c2, adi_i2c_init, adi_i2c_probe, |
| 301 | adi_i2c_read, adi_i2c_write, |
| 302 | adi_i2c_setspeed, |
| 303 | CONFIG_SYS_I2C_SPEED, |
| 304 | 0, |
| 305 | 2) |
Mike Frysinger | b5cebb4 | 2010-05-05 03:20:30 -0400 | [diff] [blame] | 306 | #endif |