120-04-v5.18-spi-spi-mem-Introduce-a-capability-structure.patch 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. From 3e45577e70cbf8fdc5c13033114989794a3797d5 Mon Sep 17 00:00:00 2001
  2. From: Miquel Raynal <[email protected]>
  3. Date: Thu, 27 Jan 2022 10:17:56 +0100
  4. Subject: [PATCH 04/15] spi: spi-mem: Introduce a capability structure
  5. Create a spi_controller_mem_caps structure and put it within the
  6. spi_controller structure close to the spi_controller_mem_ops
  7. strucure. So far the only field in this structure is the support for dtr
  8. operations, but soon we will add another parameter.
  9. Also create a helper to parse the capabilities and check if the
  10. requested capability has been set or not.
  11. Signed-off-by: Miquel Raynal <[email protected]>
  12. Reviewed-by: Pratyush Yadav <[email protected]>
  13. Reviewed-by: Boris Brezillon <[email protected]>
  14. Reviewed-by: Tudor Ambarus <[email protected]>
  15. Reviewed-by: Mark Brown <[email protected]>
  16. Link: https://lore.kernel.org/linux-mtd/[email protected]
  17. (cherry picked from commit 4a3cc7fb6e63bcfdedec25364738f1493345bd20)
  18. ---
  19. include/linux/spi/spi-mem.h | 11 +++++++++++
  20. include/linux/spi/spi.h | 3 +++
  21. 2 files changed, 14 insertions(+)
  22. --- a/include/linux/spi/spi-mem.h
  23. +++ b/include/linux/spi/spi-mem.h
  24. @@ -286,6 +286,17 @@ struct spi_controller_mem_ops {
  25. };
  26. /**
  27. + * struct spi_controller_mem_caps - SPI memory controller capabilities
  28. + * @dtr: Supports DTR operations
  29. + */
  30. +struct spi_controller_mem_caps {
  31. + bool dtr;
  32. +};
  33. +
  34. +#define spi_mem_controller_is_capable(ctlr, cap) \
  35. + ((ctlr)->mem_caps && (ctlr)->mem_caps->cap)
  36. +
  37. +/**
  38. * struct spi_mem_driver - SPI memory driver
  39. * @spidrv: inherit from a SPI driver
  40. * @probe: probe a SPI memory. Usually where detection/initialization takes
  41. --- a/include/linux/spi/spi.h
  42. +++ b/include/linux/spi/spi.h
  43. @@ -23,6 +23,7 @@ struct software_node;
  44. struct spi_controller;
  45. struct spi_transfer;
  46. struct spi_controller_mem_ops;
  47. +struct spi_controller_mem_caps;
  48. /*
  49. * INTERFACES between SPI master-side drivers and SPI slave protocol handlers,
  50. @@ -419,6 +420,7 @@ extern struct spi_device *spi_new_ancill
  51. * @mem_ops: optimized/dedicated operations for interactions with SPI memory.
  52. * This field is optional and should only be implemented if the
  53. * controller has native support for memory like operations.
  54. + * @mem_caps: controller capabilities for the handling of memory operations.
  55. * @unprepare_message: undo any work done by prepare_message().
  56. * @slave_abort: abort the ongoing transfer request on an SPI slave controller
  57. * @cs_gpios: LEGACY: array of GPIO descs to use as chip select lines; one per
  58. @@ -643,6 +645,7 @@ struct spi_controller {
  59. /* Optimized handlers for SPI memory-like operations. */
  60. const struct spi_controller_mem_ops *mem_ops;
  61. + const struct spi_controller_mem_caps *mem_caps;
  62. /* gpio chip select */
  63. int *cs_gpios;