Lines Matching +full:spi +full:- +full:device
2 * Common SPI Interface: Controller-specific definitions
7 * SPDX-License-Identifier: GPL-2.0+
15 /* SPI mode flags */
23 #define SPI_LSB_FIRST BIT(3) /* per-word bits-on-wire */
44 * struct dm_spi_bus - SPI bus info
46 * This contains information about a SPI bus. To obtain this structure, use
47 * dev_get_uclass_priv(bus) where bus is the SPI bus udevice.
62 * struct dm_spi_platdata - platform data for all SPI slaves
64 * This describes a SPI slave, a child device of the SPI bus. To obtain this
66 * dev_get_parent_platdata(slave->dev).
68 * This data is immuatable. Each time the device is probed, @max_hz and @mode
71 * @cs: Chip select number (0..n-1)
73 * @mode: SPI mode to use for this device (see SPI mode flags)
82 * struct spi_slave - Representation of a SPI slave
84 * For driver model this is the per-child data used by the SPI bus. It can
85 * be accessed using dev_get_parent_priv() on the slave device. The SPI uclass
92 * controller-specific data.
94 * @dev: SPI slave device
97 * driver model this is the sequence number of the SPI
98 * bus (bus->seq) so does not need to be stored
100 * @mode: SPI mode to use for this slave (see SPI mode flags)
101 * @wordlen: Size of SPI word in number of bits
102 * @max_read_size: If non-zero, the maximum number of bytes which can
104 * @max_write_size: If non-zero, the maximum number of bytes which can
106 * @memory_map: Address of read-only SPI flash access.
107 * @flags: Indication of SPI flags.
111 struct udevice *dev; /* struct spi_slave is dev->parentdata */
141 * spi_do_alloc_slave - Allocate a new SPI slave (internal)
143 * Allocate and zero all fields in the spi slave, and set the bus/chip
155 * spi_alloc_slave - Allocate a new SPI slave
157 * Allocate and zero all fields in the spi slave, and set the bus/chip
170 * spi_alloc_slave_base - Allocate a new SPI slave with no private data
172 * Allocate and zero all fields in the spi slave, and set the bus/chip
182 * Set up communications parameters for a SPI slave.
194 * Returns: A spi_slave reference that can be used in subsequent SPI
201 * Free any memory associated with a SPI slave.
203 * @slave: The SPI slave
210 * This must be called before doing any transfers with a SPI slave. It
211 * will enable and initialize any SPI hardware as necessary, and make
216 * @slave: The SPI slave
224 * Release the SPI bus
227 * all transfers have finished. It may disable any SPI hardware as
230 * @slave: The SPI slave
235 * Set the word length for SPI transactions
237 * Set the word length (number of bits per word) for SPI transactions.
239 * @slave: The SPI slave
242 * Returns: 0 on success, -1 on failure.
247 * SPI transfer (optional if mem_ops is used)
249 * This writes "bitlen" bits out the SPI MOSI port and simultaneously clocks
250 * "bitlen" bits in the SPI MISO port. That's just the way SPI works.
259 * @slave: The SPI slave which will be sending/receiving the data.
272 * spi_write_then_read - SPI synchronous write followed by read
275 * is to send the opcode and if the length of buf is non-zero then it start
278 * @slave: The SPI slave device with which opcode/data will be exchanged
295 * Determine if a SPI chipselect is valid.
296 * This function is provided by the board if the low-level SPI driver
306 * Activate a SPI chipselect.
310 * to the device identified by "slave".
315 * Deactivate a SPI chipselect.
319 * select to the device identified by "slave".
326 * @slave: The SPI slave
334 * @slave: The SPI slave we're communicating with
357 * struct spi_cs_info - Information about a bus chip select
359 * @dev: Connected device, or NULL if none
366 * struct struct dm_spi_ops - Driver model SPI operations
368 * The uclass interface is implemented by all SPI devices which use
375 * The device provided is the slave device. It's parent controller
378 * This must be called before doing any transfers with a SPI slave. It
379 * will enable and initialize any SPI hardware as necessary, and make
384 * @dev: The SPI slave
392 * Release the SPI bus
395 * all transfers have finished. It may disable any SPI hardware as
398 * @dev: The SPI slave
403 * Set the word length for SPI transactions
405 * Set the word length (number of bits per word) for SPI transactions.
407 * @bus: The SPI slave
410 * Returns: 0 on success, -ve on failure.
415 * SPI transfer
417 * This writes "bitlen" bits out the SPI MOSI port and simultaneously
418 * clocks "bitlen" bits in the SPI MISO port. That's just the way SPI
428 * @dev: The slave device to communicate with
435 * Returns: 0 on success, not -1 on failure
441 * Optimized handlers for SPI memory-like operations.
443 * Optimized/dedicated operations for interactions with SPI memory. This
452 * @bus: The SPI bus
454 * @return 0 if OK, -ve on error
459 * Set the SPI mode/flags
464 * @bus: The SPI bus
465 * @mode: Requested SPI mode (SPI_... flags)
466 * @return 0 if OK, -ve on error
473 * This is only called when the SPI uclass does not know about a
474 * chip select, i.e. it has no attached device. It gives the driver
477 * @bus: The SPI bus
478 * @cs: The chip select (0..n-1)
480 * On entry info->dev is NULL
481 * @return 0 if OK (and @info is set up), -ENODEV if the chip select
482 * is invalid, other -ve value on error
487 * get_mmap() - Get memory-mapped SPI
489 * @dev: The SPI flash slave device
490 * @map_basep: Returns base memory address for mapped SPI
491 * @map_sizep: Returns size of mapped SPI
492 * @offsetp: Returns start offset of SPI flash where the map works
494 * @return 0 if OK, -EFAULT if memory mapping is not available
502 * SPI transfer
504 * This writes "bitlen" bits out the SPI MOSI port and simultaneously
505 * clocks "bitlen" bits in the SPI MISO port. That's just the way SPI
506 * works. Here the device is a slave.
515 * @slave: The SPI slave which will be sending/receiving the data.
517 * @dout: Pointer to a string of bits sent to the device. The
523 * Returns: 0 on success, not -1 on failure
530 * spi_find_bus_and_cs() - Find bus and slave devices by number
533 * device and slave device. Neither device is activated by this function,
536 * @busnum: SPI bus number
538 * @busp: Returns bus device
539 * @devp: Return slave device
540 * @return 0 if found, -ENODEV on error
546 * spi_get_bus_and_cs() - Find and activate bus and slave devices by number
549 * device and slave device.
551 * If no such slave exists, and drv_name is not NULL, then a new slave device
554 * Ths new slave device is probed ready for use with the speed and mode
557 * @busnum: SPI bus number
559 * @speed: SPI speed to use for this slave when not available in platdata
560 * @mode: SPI mode to use for this slave when not available in platdata
562 * @dev_name: Name of the new device thus created
563 * @busp: Returns bus device
564 * @devp: Return slave device
565 * @return 0 if found, -ve on error
572 * spi_chip_select() - Get the chip select for a slave
579 * spi_find_chip_select() - Find the slave attached to chip select
581 * @bus: SPI bus to search
583 * @devp: Returns the slave device if found
584 * @return 0 if found, -EINVAL if cs is invalid, -ENODEV if no device attached,
585 * other -ve value on error
590 * spi_slave_ofdata_to_platdata() - decode standard SPI platform data
592 * This decodes the speed and mode for a slave from a device tree node
594 * @blob: Device tree blob
602 * spi_cs_info() - Check information on a chip select
604 * This checks a particular chip select on a bus to see if it has a device
607 * @bus: The SPI bus
608 * @cs: The chip select (0..n-1)
610 * @return 0 if OK (and @info is set up), -ENODEV if the chip select
611 * is invalid, other -ve value on error
618 * sandbox_spi_get_emul() - get an emulator for a SPI slave
620 * This provides a way to attach an emulated SPI device to a particular SPI
626 * @bus: SPI bus requesting the emulator
627 * @slave: SPI slave device requesting the emulator
629 * @return 0 if OK, -ve on error
638 * This must be called before doing any transfers with a SPI slave. It
639 * will enable and initialize any SPI hardware as necessary, and make
644 * @dev: The SPI slave device
652 * Release the SPI bus
655 * all transfers have finished. It may disable any SPI hardware as
658 * @slave: The SPI slave device
663 * SPI transfer
665 * This writes "bitlen" bits out the SPI MOSI port and simultaneously clocks
666 * "bitlen" bits in the SPI MISO port. That's just the way SPI works.
675 * @dev: The SPI slave device which will be sending/receiving the data.
688 * spi_get_mmap() - Get memory-mapped SPI
690 * @dev: SPI slave device to check
691 * @map_basep: Returns base memory address for mapped SPI
692 * @map_sizep: Returns size of mapped SPI
693 * @offsetp: Returns start offset of SPI flash where the map works
695 * @return 0 if OK, -ENOSYS if no operation, -EFAULT if memory mapping is not
701 /* Access the operations for a SPI device */
702 #define spi_get_ops(dev) ((struct dm_spi_ops *)(dev)->driver->ops)
703 #define spi_emul_get_ops(dev) ((struct dm_spi_emul_ops *)(dev)->driver->ops)