Lines Matching +full:max +full:- +full:speed
1 // SPDX-License-Identifier: GPL-2.0+
17 int max = ll_entry_count(struct i2c_adapter, i2c); in i2c_get_adapter() local
20 if (index >= max) { in i2c_get_adapter()
21 printf("Error, wrong i2c adapter %d max %d possible\n", in i2c_get_adapter()
22 index, max); in i2c_get_adapter()
44 * -------------
64 /* channel < 0 - turn off the mux */ in i2c_mux_set()
67 ret = adap->write(adap, chip, 0, 0, &buf, 1); in i2c_mux_set()
77 return -1; in i2c_mux_set()
82 return -1; in i2c_mux_set()
87 return -1; in i2c_mux_set()
92 return -1; in i2c_mux_set()
97 return -1; in i2c_mux_set()
100 ret = adap->write(adap, chip, 0, 0, &buf, 1); in i2c_mux_set()
113 if (i2c_bus_tmp->next_hop[0].chip != 0) { in i2c_mux_set_all()
118 if (i2c_bus_tmp->next_hop[i].chip == 0) in i2c_mux_set_all()
122 i2c_bus_tmp->next_hop[i].mux.id, in i2c_mux_set_all()
123 i2c_bus_tmp->next_hop[i].chip, in i2c_mux_set_all()
124 i2c_bus_tmp->next_hop[i].channel); in i2c_mux_set_all()
138 if (I2C_ADAP->init_done == 0) in i2c_mux_disconnect_all()
142 if ((i2c_bus_tmp->next_hop[0].chip != 0) && in i2c_mux_disconnect_all()
143 (I2C_ADAP->init_done != 0)) { in i2c_mux_disconnect_all()
149 chip = i2c_bus_tmp->next_hop[--i].chip; in i2c_mux_disconnect_all()
153 ret = I2C_ADAP->write(I2C_ADAP, chip, 0, 0, &buf, 1); in i2c_mux_disconnect_all()
167 * ---------------
172 static void i2c_init_bus(unsigned int bus_no, int speed, int slaveaddr) in i2c_init_bus() argument
177 I2C_ADAP->init(I2C_ADAP, speed, slaveaddr); in i2c_init_bus()
179 if (gd->flags & GD_FLG_RELOC) { in i2c_init_bus()
180 I2C_ADAP->init_done = 1; in i2c_init_bus()
181 I2C_ADAP->speed = speed; in i2c_init_bus()
182 I2C_ADAP->slaveaddr = slaveaddr; in i2c_init_bus()
202 * data, including speed and slaveaddr.
213 * ------------------
215 * Returns index of currently active I2C bus. Zero-based.
219 return gd->cur_i2c_bus; in i2c_get_bus_num()
224 * ------------------
232 * bus - bus index, zero based
238 int max; in i2c_set_bus_num() local
240 if ((bus == I2C_BUS) && (I2C_ADAP->init_done > 0)) in i2c_set_bus_num()
245 return -1; in i2c_set_bus_num()
248 max = ll_entry_count(struct i2c_adapter, i2c); in i2c_set_bus_num()
249 if (I2C_ADAPTER(bus) >= max) { in i2c_set_bus_num()
250 printf("Error, wrong i2c adapter %d max %d possible\n", in i2c_set_bus_num()
251 I2C_ADAPTER(bus), max); in i2c_set_bus_num()
252 return -2; in i2c_set_bus_num()
259 gd->cur_i2c_bus = bus; in i2c_set_bus_num()
260 if (I2C_ADAP->init_done == 0) in i2c_set_bus_num()
261 i2c_init_bus(bus, I2C_ADAP->speed, I2C_ADAP->slaveaddr); in i2c_set_bus_num()
275 return I2C_ADAP->probe(I2C_ADAP, chip); in i2c_probe()
293 return I2C_ADAP->read(I2C_ADAP, chip, addr, alen, buffer, len); in i2c_read()
299 return I2C_ADAP->write(I2C_ADAP, chip, addr, alen, buffer, len); in i2c_write()
302 unsigned int i2c_set_bus_speed(unsigned int speed) in i2c_set_bus_speed() argument
306 if (I2C_ADAP->set_bus_speed == NULL) in i2c_set_bus_speed()
308 ret = I2C_ADAP->set_bus_speed(I2C_ADAP, speed); in i2c_set_bus_speed()
309 if (gd->flags & GD_FLG_RELOC) in i2c_set_bus_speed()
310 I2C_ADAP->speed = (ret == 0) ? speed : 0; in i2c_set_bus_speed()
318 return cur->speed; in i2c_get_bus_speed()
345 __weak void i2c_init(int speed, int slaveaddr) in i2c_init() argument
347 i2c_init_bus(i2c_get_bus_num(), speed, slaveaddr); in i2c_init()