stm.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * System Trace Module (STM) infrastructure
  4. * Copyright (c) 2014, Intel Corporation.
  5. *
  6. * STM class implements generic infrastructure for System Trace Module devices
  7. * as defined in MIPI STPv2 specification.
  8. */
  9. #ifndef _STM_STM_H_
  10. #define _STM_STM_H_
  11. struct stp_policy;
  12. struct stp_policy_node;
  13. struct stp_policy_node *
  14. stp_policy_node_lookup(struct stm_device *stm, char *s);
  15. void stp_policy_node_put(struct stp_policy_node *policy_node);
  16. void stp_policy_unbind(struct stp_policy *policy);
  17. void stp_policy_node_get_ranges(struct stp_policy_node *policy_node,
  18. unsigned int *mstart, unsigned int *mend,
  19. unsigned int *cstart, unsigned int *cend);
  20. int stp_configfs_init(void);
  21. void stp_configfs_exit(void);
  22. struct stp_master {
  23. unsigned int nr_free;
  24. unsigned long chan_map[0];
  25. };
  26. struct stm_device {
  27. struct device dev;
  28. struct module *owner;
  29. struct stp_policy *policy;
  30. struct mutex policy_mutex;
  31. int major;
  32. unsigned int sw_nmasters;
  33. struct stm_data *data;
  34. struct mutex link_mutex;
  35. spinlock_t link_lock;
  36. struct list_head link_list;
  37. /* master allocation */
  38. spinlock_t mc_lock;
  39. struct stp_master *masters[0];
  40. };
  41. #define to_stm_device(_d) \
  42. container_of((_d), struct stm_device, dev)
  43. struct stm_output {
  44. spinlock_t lock;
  45. unsigned int master;
  46. unsigned int channel;
  47. unsigned int nr_chans;
  48. };
  49. struct stm_file {
  50. struct stm_device *stm;
  51. struct stp_policy_node *policy_node;
  52. struct stm_output output;
  53. };
  54. struct stm_device *stm_find_device(const char *name);
  55. void stm_put_device(struct stm_device *stm);
  56. struct stm_source_device {
  57. struct device dev;
  58. struct stm_source_data *data;
  59. spinlock_t link_lock;
  60. struct stm_device __rcu *link;
  61. struct list_head link_entry;
  62. /* one output per stm_source device */
  63. struct stp_policy_node *policy_node;
  64. struct stm_output output;
  65. };
  66. #define to_stm_source_device(_d) \
  67. container_of((_d), struct stm_source_device, dev)
  68. #endif /* _STM_STM_H_ */