internals.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2018 Cadence Design Systems Inc.
  4. *
  5. * Author: Boris Brezillon <boris.brezillon@bootlin.com>
  6. */
  7. #ifndef I3C_INTERNALS_H
  8. #define I3C_INTERNALS_H
  9. #include <linux/i3c/master.h>
  10. #include <linux/io.h>
  11. int __must_check i3c_bus_rpm_get(struct i3c_bus *bus);
  12. void i3c_bus_rpm_put(struct i3c_bus *bus);
  13. bool i3c_bus_rpm_ibi_allowed(struct i3c_bus *bus);
  14. void i3c_bus_normaluse_lock(struct i3c_bus *bus);
  15. void i3c_bus_normaluse_unlock(struct i3c_bus *bus);
  16. int i3c_dev_setdasa_locked(struct i3c_dev_desc *dev);
  17. int i3c_dev_do_xfers_locked(struct i3c_dev_desc *dev,
  18. struct i3c_xfer *xfers,
  19. int nxfers, enum i3c_xfer_mode mode);
  20. int i3c_dev_disable_ibi_locked(struct i3c_dev_desc *dev);
  21. int i3c_dev_enable_ibi_locked(struct i3c_dev_desc *dev);
  22. int i3c_dev_request_ibi_locked(struct i3c_dev_desc *dev,
  23. const struct i3c_ibi_setup *req);
  24. void i3c_dev_free_ibi_locked(struct i3c_dev_desc *dev);
  25. /**
  26. * i3c_writel_fifo - Write data buffer to 32bit FIFO
  27. * @addr: FIFO Address to write to
  28. * @buf: Pointer to the data bytes to write
  29. * @nbytes: Number of bytes to write
  30. */
  31. static inline void i3c_writel_fifo(void __iomem *addr, const void *buf,
  32. int nbytes)
  33. {
  34. writesl(addr, buf, nbytes / 4);
  35. if (nbytes & 3) {
  36. u32 tmp = 0;
  37. memcpy(&tmp, buf + (nbytes & ~3), nbytes & 3);
  38. /*
  39. * writesl() instead of writel() to keep FIFO
  40. * byteorder on big-endian targets
  41. */
  42. writesl(addr, &tmp, 1);
  43. }
  44. }
  45. /**
  46. * i3c_readl_fifo - Read data buffer from 32bit FIFO
  47. * @addr: FIFO Address to read from
  48. * @buf: Pointer to the buffer to store read bytes
  49. * @nbytes: Number of bytes to read
  50. */
  51. static inline void i3c_readl_fifo(const void __iomem *addr, void *buf,
  52. int nbytes)
  53. {
  54. readsl(addr, buf, nbytes / 4);
  55. if (nbytes & 3) {
  56. u32 tmp;
  57. /*
  58. * readsl() instead of readl() to keep FIFO
  59. * byteorder on big-endian targets
  60. */
  61. readsl(addr, &tmp, 1);
  62. memcpy(buf + (nbytes & ~3), &tmp, nbytes & 3);
  63. }
  64. }
  65. #endif /* I3C_INTERNAL_H */