Lines Matching +full:slave +full:- +full:dev

1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Common SPI Interface: Controller-specific definitions
22 #define SPI_LSB_FIRST BIT(3) /* per-word bits-on-wire */
25 #define SPI_SLAVE BIT(6) /* slave mode */
46 * struct dm_spi_platdata - platform data for all SPI slaves
48 * This describes a SPI slave, a child device of the SPI bus. To obtain this
49 * struct from a spi_slave, use dev_get_parent_platdata(dev) or
50 * dev_get_parent_platdata(slave->dev).
55 * @cs: Chip select number (0..n-1)
56 * @max_hz: Maximum bus speed that this slave can tolerate
68 * struct spi_slave - Representation of a SPI slave
70 * For driver model this is the per-child data used by the SPI bus. It can
71 * be accessed using dev_get_parent_priv() on the slave device. The SPI uclass
78 * controller-specific data.
80 * @dev: SPI slave device
81 * @max_hz: Maximum speed for this slave
84 * @bus: ID of the bus that the slave is attached to. For
86 * bus (bus->seq) so does not need to be stored
87 * @cs: ID of the chip select connected to the slave.
88 * @mode: SPI mode to use for this slave (see SPI mode flags)
90 * @max_read_size: If non-zero, the maximum number of bytes which can
92 * @max_write_size: If non-zero, the maximum number of bytes which can
94 * @memory_map: Address of read-only SPI flash access.
99 struct udevice *dev; /* struct spi_slave is dev->parentdata */ member
121 * spi_do_alloc_slave - Allocate a new SPI slave (internal)
123 * Allocate and zero all fields in the spi slave, and set the bus/chip
126 * @offset: Offset of struct spi_slave within slave structure.
127 * @size: Size of slave structure.
128 * @bus: Bus ID of the slave chip.
129 * @cs: Chip select ID of the slave chip on the specified bus.
135 * spi_alloc_slave - Allocate a new SPI slave
137 * Allocate and zero all fields in the spi slave, and set the bus/chip
141 * This structure must contain a member 'struct spi_slave *slave'.
142 * @bus: Bus ID of the slave chip.
143 * @cs: Chip select ID of the slave chip on the specified bus.
146 spi_do_alloc_slave(offsetof(_struct, slave), \
150 * spi_alloc_slave_base - Allocate a new SPI slave with no private data
152 * Allocate and zero all fields in the spi slave, and set the bus/chip
155 * @bus: Bus ID of the slave chip.
156 * @cs: Chip select ID of the slave chip on the specified bus.
162 * Set up communications parameters for a SPI slave.
164 * This must be called once for each slave. Note that this function
169 * @bus: Bus ID of the slave chip.
170 * @cs: Chip select ID of the slave chip on the specified bus.
181 * Free any memory associated with a SPI slave.
183 * @slave: The SPI slave
185 void spi_free_slave(struct spi_slave *slave);
188 * Claim the bus and prepare it for communication with a given slave.
190 * This must be called before doing any transfers with a SPI slave. It
196 * @slave: The SPI slave
201 int spi_claim_bus(struct spi_slave *slave);
210 * @slave: The SPI slave
212 void spi_release_bus(struct spi_slave *slave);
219 * @slave: The SPI slave
222 * Returns: 0 on success, -1 on failure.
224 int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen);
239 * @slave: The SPI slave which will be sending/receiving the data.
248 int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
256 * This function is provided by the board if the low-level SPI driver
270 * to the device identified by "slave".
272 void spi_cs_activate(struct spi_slave *slave);
279 * select to the device identified by "slave".
281 void spi_cs_deactivate(struct spi_slave *slave);
286 * @slave: The SPI slave
289 void spi_set_speed(struct spi_slave *slave, uint hz);
294 * @slave: The SPI slave we're communicating with
301 static inline int spi_w8r8(struct spi_slave *slave, unsigned char byte) in spi_w8r8() argument
310 ret = spi_xfer(slave, 16, dout, din, SPI_XFER_BEGIN | SPI_XFER_END); in spi_w8r8()
317 * struct spi_cs_info - Information about a bus chip select
319 * @dev: Connected device, or NULL if none
322 struct udevice *dev; member
326 * struct struct dm_spi_ops - Driver model SPI operations
335 * The device provided is the slave device. It's parent controller
338 * This must be called before doing any transfers with a SPI slave. It
344 * @dev: The SPI slave
349 int (*claim_bus)(struct udevice *dev);
358 * @dev: The SPI slave
360 int (*release_bus)(struct udevice *dev);
367 * @bus: The SPI slave
370 * Returns: 0 on success, -ve on failure.
372 int (*set_wordlen)(struct udevice *dev, unsigned int wordlen);
388 * @dev: The slave device to communicate with
395 * Returns: 0 on success, not -1 on failure
397 int (*xfer)(struct udevice *dev, unsigned int bitlen, const void *dout,
401 * Optimized handlers for SPI memory-like operations.
414 * @return 0 if OK, -ve on error
426 * @return 0 if OK, -ve on error
438 * @cs: The chip select (0..n-1)
440 * On entry info->dev is NULL
441 * @return 0 if OK (and @info is set up), -ENODEV if the chip select
442 * is invalid, other -ve value on error
446 int (*mem_ctrl_wlock)(struct udevice *dev, u32 offset, size_t len);
447 int (*mem_ctrl_wunlock)(struct udevice *dev, u32 offset, size_t len);
456 * works. Here the device is a slave.
465 * @slave: The SPI slave which will be sending/receiving the data.
473 * Returns: 0 on success, not -1 on failure
475 int (*xfer)(struct udevice *slave, unsigned int bitlen,
480 * spi_find_bus_and_cs() - Find bus and slave devices by number
483 * device and slave device. Neither device is activated by this function,
489 * @devp: Return slave device
490 * @return 0 if found, -ENODEV on error
496 * spi_get_bus_and_cs() - Find and activate bus and slave devices by number
499 * device and slave device.
501 * If no such slave exists, and drv_name is not NULL, then a new slave device
504 * Ths new slave device is probed ready for use with the given speed and mode.
508 * @speed: SPI speed to use for this slave
509 * @mode: SPI mode to use for this slave
513 * @devp: Return slave device
514 * @return 0 if found, -ve on error
521 * spi_chip_select() - Get the chip select for a slave
523 * @return the chip select this slave is attached to
525 int spi_chip_select(struct udevice *slave);
528 * spi_find_chip_select() - Find the slave attached to chip select
532 * @devp: Returns the slave device if found
533 * @return 0 if found, -ENODEV on error
538 * spi_slave_ofdata_to_platdata() - decode standard SPI platform data
540 * This decodes the speed and mode for a slave from a device tree node
546 int spi_slave_ofdata_to_platdata(struct udevice *dev,
550 * spi_cs_info() - Check information on a chip select
556 * @cs: The chip select (0..n-1)
558 * @return 0 if OK (and @info is set up), -ENODEV if the chip select
559 * is invalid, other -ve value on error
566 * sandbox_spi_get_emul() - get an emulator for a SPI slave
569 * slave, so that xfer() operations on the slave will be handled by the
575 * @slave: SPI slave device requesting the emulator
577 * @return 0 if OK, -ve on error
580 struct udevice *bus, struct udevice *slave,
584 * Claim the bus and prepare it for communication with a given slave.
586 * This must be called before doing any transfers with a SPI slave. It
592 * @dev: The SPI slave device
597 int dm_spi_claim_bus(struct udevice *dev);
606 * @slave: The SPI slave device
608 void dm_spi_release_bus(struct udevice *dev);
623 * @dev: The SPI slave device which will be sending/receiving the data.
632 int dm_spi_xfer(struct udevice *dev, unsigned int bitlen,
636 #define spi_get_ops(dev) ((struct dm_spi_ops *)(dev)->driver->ops) argument
637 #define spi_emul_get_ops(dev) ((struct dm_spi_emul_ops *)(dev)->driver->ops) argument