qcom_common.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __RPROC_QCOM_COMMON_H__
  7. #define __RPROC_QCOM_COMMON_H__
  8. #include <linux/timer.h>
  9. #include <linux/remoteproc.h>
  10. #include "remoteproc_internal.h"
  11. #include <linux/soc/qcom/qmi.h>
  12. #include <linux/remoteproc/qcom_rproc.h>
  13. #include <linux/soc/qcom/qcom_aoss.h>
  14. static const char * const subdevice_state_string[] = {
  15. [QCOM_SSR_BEFORE_POWERUP] = "before_powerup",
  16. [QCOM_SSR_AFTER_POWERUP] = "after_powerup",
  17. [QCOM_SSR_BEFORE_SHUTDOWN] = "before_shutdown",
  18. [QCOM_SSR_AFTER_SHUTDOWN] = "after_shutdown",
  19. };
  20. struct reg_info {
  21. struct regulator *reg;
  22. int uV;
  23. int uA;
  24. };
  25. struct qcom_sysmon;
  26. struct qcom_rproc_glink {
  27. struct rproc_subdev subdev;
  28. const char *ssr_name;
  29. struct device *dev;
  30. struct device_node *node;
  31. struct qcom_glink *edge;
  32. struct notifier_block nb;
  33. void *notifier_handle;
  34. };
  35. struct qcom_rproc_subdev {
  36. struct rproc_subdev subdev;
  37. struct device *dev;
  38. struct device_node *node;
  39. struct qcom_smd_edge *edge;
  40. };
  41. struct qcom_ssr_subsystem;
  42. struct qcom_rproc_ssr {
  43. struct rproc_subdev subdev;
  44. enum qcom_ssr_notify_type notification;
  45. struct timer_list timer;
  46. struct qcom_ssr_subsystem *info;
  47. };
  48. extern bool qcom_device_shutdown_in_progress;
  49. typedef void (*rproc_dumpfn_t)(struct rproc *rproc, struct rproc_dump_segment *segment,
  50. void *dest, size_t offset, size_t size);
  51. void qcom_minidump(struct rproc *rproc, struct device *md_dev,
  52. unsigned int minidump_id, rproc_dumpfn_t dumpfn, bool both_dumps);
  53. int qcom_rproc_toggle_load_state(struct qmp *qmp, const char *name, bool enable);
  54. void qcom_add_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glink,
  55. const char *ssr_name);
  56. void qcom_remove_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glink);
  57. int qcom_register_dump_segments(struct rproc *rproc, const struct firmware *fw);
  58. void qcom_add_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd);
  59. void qcom_remove_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd);
  60. void qcom_add_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr,
  61. const char *ssr_name);
  62. void qcom_notify_early_ssr_clients(struct rproc_subdev *subdev);
  63. void qcom_remove_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr);
  64. void qcom_rproc_update_recovery_status(struct rproc *rproc, bool enable);
  65. struct qcom_ssr_subsystem *qcom_ssr_get_subsys(const char *name);
  66. int qcom_notify_ssr_clients(struct qcom_ssr_subsystem *info, int state,
  67. struct qcom_ssr_notify_data *data);
  68. #if IS_ENABLED(CONFIG_QCOM_SYSMON)
  69. struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc,
  70. const char *name,
  71. int ssctl_instance);
  72. void qcom_remove_sysmon_subdev(struct qcom_sysmon *sysmon);
  73. bool qcom_sysmon_shutdown_acked(struct qcom_sysmon *sysmon);
  74. uint32_t qcom_sysmon_get_txn_id(struct qcom_sysmon *sysmon);
  75. int qcom_sysmon_get_reason(struct qcom_sysmon *sysmon, char *buf, size_t len);
  76. #else
  77. static inline struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc,
  78. const char *name,
  79. int ssctl_instance)
  80. {
  81. return NULL;
  82. }
  83. static inline void qcom_remove_sysmon_subdev(struct qcom_sysmon *sysmon)
  84. {
  85. }
  86. static inline bool qcom_sysmon_shutdown_acked(struct qcom_sysmon *sysmon)
  87. {
  88. return false;
  89. }
  90. static inline uint32_t qcom_sysmon_get_txn_id(struct qcom_sysmon *sysmon)
  91. {
  92. return 0;
  93. }
  94. int qcom_sysmon_get_reason(struct qcom_sysmon *sysmon, char *buf, size_t len)
  95. {
  96. return -ENODEV;
  97. }
  98. #endif
  99. #endif