Lines Matching +full:on +full:- +full:chip

1 /* SPDX-License-Identifier: GPL-2.0+ */
4 * Copyright (C) 2009 - 2013 Heiko Schocher <hs@denx.de>
12 * AIRVENT SAM s.p.a - RIMINI(ITALY)
20 * For now there are essentially two parts to this file - driver model
28 DM_I2C_CHIP_10BIT = 1 << 0, /* Use 10-bit addressing */
35 * struct dm_i2c_chip - information about an i2c chip
37 * An I2C chip is a device on the I2C bus. It sits at a particular address
38 * and normally supports 7-bit or 10-bit addressing.
41 * the chip to examine.
43 * @chip_addr: Chip address on bus
47 * @flags: Flags for this chip (dm_i2c_chip_flags)
51 * completely within the chip address itself.
52 * e.g. a devce with chip address of 0x2c with 512
56 * This means it will respond to chip address 0x2c and
61 * @emul: Emulator for this chip address (only used for emulation)
75 * struct dm_i2c_bus- information about an i2c bus
77 * An I2C bus contains 0 or more chips on it, each at its own address. The
91 * Not all of these flags are implemented in the U-Boot API
94 I2C_M_TEN = 0x0010, /* ten-bit chip address */
100 I2C_M_NO_RD_ACK = 0x0800, /* skip the Ack bit on reads */
105 * struct i2c_msg - an I2C message
120 * struct i2c_msg_list - a list of I2C messages
123 * appropriate in U-Boot.
134 * dm_i2c_read() - read bytes from an I2C chip
136 * To obtain an I2C device (called a 'chip') given the I2C bus address you
143 * @dev: Chip to read from
144 * @offset: Offset within chip to start reading
148 * @return 0 on success, -ve on failure
153 * dm_i2c_write() - write bytes to an I2C chip
157 * @dev: Chip to write to
158 * @offset: Offset within chip to start writing
162 * @return 0 on success, -ve on failure
168 * dm_i2c_probe() - probe a particular chip address
170 * This can be useful to check for the existence of a chip on the bus.
171 * It is typically implemented by writing the chip address to the bus
172 * and checking that the chip replies with an ACK.
175 * @chip_addr: 7-bit address to probe (10-bit and others are not supported)
178 * @return 0 if a chip was found at that address, -ve if not
184 * dm_i2c_reg_read() - Read a value from an I2C register
186 * This reads a single value from the given address in an I2C chip
190 * @return value read, or -ve on error
195 * dm_i2c_reg_write() - Write a value to an I2C register
197 * This writes a single value to the given address in an I2C chip
202 * @return 0 on success, -ve on error
207 * dm_i2c_xfer() - Transfer messages over I2C
215 * @return 0 on success, -ve on error
220 * dm_i2c_set_bus_speed() - set the speed of a bus
224 * @return 0 if OK, -EINVAL for invalid values
229 * dm_i2c_get_bus_speed() - get the speed of a bus
232 * @return speed of selected I2C bus in Hz, -ve on error
237 * i2c_set_chip_flags() - set flags for a chip
239 * Typically addresses are 7 bits, but for 10-bit addresses you should set
240 * flags to DM_I2C_CHIP_10BIT. All accesses will then use 10-bit addressing.
242 * @dev: Chip to adjust
244 * @return 0 if OK, -EINVAL if value is unsupported, other -ve value on error
249 * i2c_get_chip_flags() - get flags for a chip
251 * @dev: Chip to check
253 * @return 0 if OK, other -ve value on error
258 * i2c_set_offset_len() - set the offset length for a chip
260 * The offset used to access a chip may be up to 4 bytes long. Typically it
270 * i2c_get_offset_len() - get the offset length for a chip
277 * i2c_set_chip_addr_offset_mask() - set mask of address bits usable by offset
279 * Some devices listen on multiple chip addresses to achieve larger offsets
284 * @return 0 if OK, other -ve value on error
289 * i2c_get_chip_addr_offset_mask() - get mask of address bits usable by offset
291 * @return current chip addr offset mask
296 * i2c_deblock() - recover a bus that is in an unknown state
301 * @return 0 if OK, -ve on error
307 * i2c_probe() - Compatibility function for driver model
309 * Calls dm_i2c_probe() on the current bus
314 * i2c_read() - Compatibility function for driver model
323 * i2c_write() - Compatibility function for driver model
332 * i2c_get_bus_num_fdt() - Compatibility function for driver model
339 * i2c_get_bus_num() - Compatibility function for driver model
346 * i2c_set_bus_num() - Compatibility function for driver model
363 * i2c_init() - Compatibility function for driver model
370 * board_i2c_init() - Compatibility function for driver model
386 * struct dm_i2c_ops - driver operations for I2C uclass
394 * xfer() - transfer a list of I2C messages
399 * @return 0 if OK, -EREMOTEIO if the slave did not ACK a byte,
400 * -ECOMM if the speed cannot be supported, -EPROTO if the chip
401 * flags cannot be supported, other -ve value on some other error
406 * probe_chip() - probe for the presense of a chip address
412 * @chip_addr: Chip address to probe
414 * @return 0 if chip was found, -EREMOTEIO if not, -ENOSYS to fall back
415 * to default probem other -ve value on error
420 * set_bus_speed() - set the speed of a bus (optional)
423 * does not return an error. This method is optional - if it is not
425 * dev_get_uclass_priv(bus)->speed_hz
429 * @return 0 if OK, -EINVAL for invalid values
434 * get_bus_speed() - get the speed of a bus (optional)
439 * normally be expected to return dev_get_uclass_priv(bus)->speed_hz.
442 * @return speed of selected I2C bus in Hz, -ve on error
447 * set_flags() - set the flags for a chip (optional)
454 * @dev: Chip to adjust
456 * @return 0 if OK, -EINVAL if value is unsupported
461 * deblock() - recover a bus that is in an unknown state
477 #define i2c_get_ops(dev) ((struct dm_i2c_ops *)(dev)->driver->ops)
480 * struct i2c_mux_ops - operations for an I2C mux
490 * select() - select one of of I2C buses attached to a mux
499 * @return 0 if OK, -ve on error
504 * deselect() - select one of of I2C buses attached to a mux
511 * @return 0 if OK, -ve on error
516 #define i2c_mux_get_ops(dev) ((struct i2c_mux_ops *)(dev)->driver->ops)
519 * i2c_get_chip() - get a device to use to access a chip on a bus
521 * This returns the device for the given chip address. The device can then
525 * @chip_addr: Chip address for the new device
527 * @devp: Returns pointer to new device if found or -ENODEV if not
534 * i2c_get_chip_for_busnum() - get a device to use to access a chip on
537 * This returns the device for the given chip address on a particular bus
541 * @chip_addr: Chip address for the new device
543 * @devp: Returns pointer to new device if found or -ENODEV if not
550 * i2c_chip_ofdata_to_platdata() - Decode standard I2C platform data
552 * This decodes the chip address from a device tree node and puts it into
560 int i2c_chip_ofdata_to_platdata(struct udevice *dev, struct dm_i2c_chip *chip);
563 * i2c_dump_msgs() - Dump a list of I2C messages
573 * i2c_emul_find() - Find an emulator for an i2c sandbox device
579 * @return 0 if OK, -ENOENT or -ENODEV if not found
584 * i2c_emul_get_device() - Find the device being emulated
601 * use of stack-based variables are OK (the initial stack size is
633 int (*probe)(struct i2c_adapter *adap, uint8_t chip);
634 int (*read)(struct i2c_adapter *adap, uint8_t chip,
637 int (*write)(struct i2c_adapter *adap, uint8_t chip,
681 uint8_t chip; member
689 #define I2C_NULL_HOP {{-1, ""}, 0, 0}
696 #define I2C_BUS gd->cur_i2c_bus
699 #define I2C_ADAP I2C_ADAP_NR(gd->cur_i2c_bus)
700 #define I2C_ADAP_HWNR (I2C_ADAP->hwadapnr)
736 * Initialization, must be called once on start up, may be called
749 * Returns index of currently active I2C bus. Zero-based.
759 * bus - bus index, zero based
761 * Returns: 0 on success, not 0 on failure
771 * speed and slaveaddr. Returns 0 on success, non-0 on failure.
776 * Probe the given I2C chip address. Returns 0 if a chip responded,
777 * not 0 on failure.
779 int i2c_probe(uint8_t chip);
783 * chip: I2C chip address, range 0..127
784 * addr: Memory (register) address within the chip
791 * Returns: 0 on success, not 0 on failure
793 int i2c_read(uint8_t chip, unsigned int addr, int alen,
796 int i2c_write(uint8_t chip, unsigned int addr, int alen,
811 * speed - bus speed in Hz
829 * Probe the given I2C chip address. Returns 0 if a chip responded,
830 * not 0 on failure.
832 int i2c_probe(uchar chip);
836 * chip: I2C chip address, range 0..127
837 * addr: Memory (register) address within the chip
844 * Returns: 0 on success, not 0 on failure
846 int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len);
847 int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len);
885 * bus - bus index, zero based
887 * Returns: 0 on success, not 0 on failure
895 * Returns index of currently active I2C bus. Zero-based.
905 * speed - bus speed in Hz
907 * Returns: 0 on success, not 0 on failure
968 * @return the number of I2C bus (zero based), or -1 on error
977 * @return 0 if port was reset, -1 if not found