ti_sci_proc.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Texas Instruments TI-SCI Processor Controller Helper Functions
  4. *
  5. * Copyright (C) 2018-2020 Texas Instruments Incorporated - https://www.ti.com/
  6. * Suman Anna <s-anna@ti.com>
  7. */
  8. #ifndef REMOTEPROC_TI_SCI_PROC_H
  9. #define REMOTEPROC_TI_SCI_PROC_H
  10. #include <linux/soc/ti/ti_sci_protocol.h>
  11. /**
  12. * struct ti_sci_proc - structure representing a processor control client
  13. * @sci: cached TI-SCI protocol handle
  14. * @ops: cached TI-SCI proc ops
  15. * @dev: cached client device pointer
  16. * @proc_id: processor id for the consumer remoteproc device
  17. * @host_id: host id to pass the control over for this consumer remoteproc
  18. * device
  19. */
  20. struct ti_sci_proc {
  21. const struct ti_sci_handle *sci;
  22. const struct ti_sci_proc_ops *ops;
  23. struct device *dev;
  24. u8 proc_id;
  25. u8 host_id;
  26. };
  27. static inline int ti_sci_proc_request(struct ti_sci_proc *tsp)
  28. {
  29. int ret;
  30. ret = tsp->ops->request(tsp->sci, tsp->proc_id);
  31. if (ret)
  32. dev_err(tsp->dev, "ti-sci processor request failed: %d\n",
  33. ret);
  34. return ret;
  35. }
  36. static inline int ti_sci_proc_release(struct ti_sci_proc *tsp)
  37. {
  38. int ret;
  39. ret = tsp->ops->release(tsp->sci, tsp->proc_id);
  40. if (ret)
  41. dev_err(tsp->dev, "ti-sci processor release failed: %d\n",
  42. ret);
  43. return ret;
  44. }
  45. static inline int ti_sci_proc_handover(struct ti_sci_proc *tsp)
  46. {
  47. int ret;
  48. ret = tsp->ops->handover(tsp->sci, tsp->proc_id, tsp->host_id);
  49. if (ret)
  50. dev_err(tsp->dev, "ti-sci processor handover of %d to %d failed: %d\n",
  51. tsp->proc_id, tsp->host_id, ret);
  52. return ret;
  53. }
  54. static inline int ti_sci_proc_set_config(struct ti_sci_proc *tsp,
  55. u64 boot_vector,
  56. u32 cfg_set, u32 cfg_clr)
  57. {
  58. int ret;
  59. ret = tsp->ops->set_config(tsp->sci, tsp->proc_id, boot_vector,
  60. cfg_set, cfg_clr);
  61. if (ret)
  62. dev_err(tsp->dev, "ti-sci processor set_config failed: %d\n",
  63. ret);
  64. return ret;
  65. }
  66. static inline int ti_sci_proc_set_control(struct ti_sci_proc *tsp,
  67. u32 ctrl_set, u32 ctrl_clr)
  68. {
  69. int ret;
  70. ret = tsp->ops->set_control(tsp->sci, tsp->proc_id, ctrl_set, ctrl_clr);
  71. if (ret)
  72. dev_err(tsp->dev, "ti-sci processor set_control failed: %d\n",
  73. ret);
  74. return ret;
  75. }
  76. static inline int ti_sci_proc_get_status(struct ti_sci_proc *tsp,
  77. u64 *boot_vector, u32 *cfg_flags,
  78. u32 *ctrl_flags, u32 *status_flags)
  79. {
  80. int ret;
  81. ret = tsp->ops->get_status(tsp->sci, tsp->proc_id, boot_vector,
  82. cfg_flags, ctrl_flags, status_flags);
  83. if (ret)
  84. dev_err(tsp->dev, "ti-sci processor get_status failed: %d\n",
  85. ret);
  86. return ret;
  87. }
  88. #endif /* REMOTEPROC_TI_SCI_PROC_H */