cmd.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 command/response related stuff
  8. */
  9. #ifndef CMD_H
  10. #define CMD_H
  11. /*
  12. * Those bits are common to all descriptor formats and
  13. * may be manipulated by the core code.
  14. */
  15. #define CMD_0_TOC W0_BIT_(31)
  16. #define CMD_0_ROC W0_BIT_(30)
  17. #define CMD_0_ATTR W0_MASK(2, 0)
  18. /*
  19. * Response Descriptor Structure
  20. */
  21. #define RESP_STATUS(resp) FIELD_GET(GENMASK(31, 28), resp)
  22. #define RESP_TID(resp) FIELD_GET(GENMASK(27, 24), resp)
  23. #define RESP_DATA_LENGTH(resp) FIELD_GET(GENMASK(21, 0), resp)
  24. #define RESP_ERR_FIELD GENMASK(31, 28)
  25. enum hci_resp_err {
  26. RESP_SUCCESS = 0x0,
  27. RESP_ERR_CRC = 0x1,
  28. RESP_ERR_PARITY = 0x2,
  29. RESP_ERR_FRAME = 0x3,
  30. RESP_ERR_ADDR_HEADER = 0x4,
  31. RESP_ERR_BCAST_NACK_7E = 0x4,
  32. RESP_ERR_NACK = 0x5,
  33. RESP_ERR_OVL = 0x6,
  34. RESP_ERR_I3C_SHORT_READ = 0x7,
  35. RESP_ERR_HC_TERMINATED = 0x8,
  36. RESP_ERR_I2C_WR_DATA_NACK = 0x9,
  37. RESP_ERR_BUS_XFER_ABORTED = 0x9,
  38. RESP_ERR_NOT_SUPPORTED = 0xa,
  39. RESP_ERR_ABORTED_WITH_CRC = 0xb,
  40. /* 0xc to 0xf are reserved for transfer specific errors */
  41. };
  42. /* TID generation (4 bits wide in all cases) */
  43. #define hci_get_tid(bits) \
  44. (atomic_inc_return_relaxed(&hci->next_cmd_tid) % (1U << 4))
  45. /* This abstracts operations with our command descriptor formats */
  46. struct hci_cmd_ops {
  47. int (*prep_ccc)(struct i3c_hci *hci, struct hci_xfer *xfer,
  48. u8 ccc_addr, u8 ccc_cmd, bool raw);
  49. void (*prep_i3c_xfer)(struct i3c_hci *hci, struct i3c_dev_desc *dev,
  50. struct hci_xfer *xfer);
  51. void (*prep_i2c_xfer)(struct i3c_hci *hci, struct i2c_dev_desc *dev,
  52. struct hci_xfer *xfer);
  53. int (*perform_daa)(struct i3c_hci *hci);
  54. };
  55. /* Our various instances */
  56. extern const struct hci_cmd_ops mipi_i3c_hci_cmd_v1;
  57. extern const struct hci_cmd_ops mipi_i3c_hci_cmd_v2;
  58. #endif