ibi.h 933 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* SPDX-License-Identifier: BSD-3-Clause */
  2. /*
  3. * Copyright (c) 2020, MIPI Alliance, Inc.
  4. *
  5. * Author: Nicolas Pitre <[email protected]>
  6. *
  7. * Common IBI related stuff
  8. */
  9. #ifndef IBI_H
  10. #define IBI_H
  11. /*
  12. * IBI Status Descriptor bits
  13. */
  14. #define IBI_STS BIT(31)
  15. #define IBI_ERROR BIT(30)
  16. #define IBI_STATUS_TYPE BIT(29)
  17. #define IBI_HW_CONTEXT GENMASK(28, 26)
  18. #define IBI_TS BIT(25)
  19. #define IBI_LAST_STATUS BIT(24)
  20. #define IBI_CHUNKS GENMASK(23, 16)
  21. #define IBI_ID GENMASK(15, 8)
  22. #define IBI_TARGET_ADDR GENMASK(15, 9)
  23. #define IBI_TARGET_RNW BIT(8)
  24. #define IBI_DATA_LENGTH GENMASK(7, 0)
  25. /* handy helpers */
  26. static inline struct i3c_dev_desc *
  27. i3c_hci_addr_to_dev(struct i3c_hci *hci, unsigned int addr)
  28. {
  29. struct i3c_bus *bus = i3c_master_get_bus(&hci->master);
  30. struct i3c_dev_desc *dev;
  31. i3c_bus_for_each_i3cdev(bus, dev) {
  32. if (dev->info.dyn_addr == addr)
  33. return dev;
  34. }
  35. return NULL;
  36. }
  37. #endif