stm.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * System Trace Module (STM) infrastructure
  3. * Copyright (c) 2014, Intel Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * STM class implements generic infrastructure for System Trace Module devices
  15. * as defined in MIPI STPv2 specification.
  16. */
  17. #ifndef _STM_STM_H_
  18. #define _STM_STM_H_
  19. struct stp_policy;
  20. struct stp_policy_node;
  21. struct stp_policy_node *
  22. stp_policy_node_lookup(struct stm_device *stm, char *s);
  23. void stp_policy_node_put(struct stp_policy_node *policy_node);
  24. void stp_policy_unbind(struct stp_policy *policy);
  25. void stp_policy_node_get_ranges(struct stp_policy_node *policy_node,
  26. unsigned int *mstart, unsigned int *mend,
  27. unsigned int *cstart, unsigned int *cend);
  28. int stp_configfs_init(void);
  29. void stp_configfs_exit(void);
  30. struct stp_master {
  31. unsigned int nr_free;
  32. unsigned long chan_map[0];
  33. };
  34. struct stm_device {
  35. struct device dev;
  36. struct module *owner;
  37. struct stp_policy *policy;
  38. struct mutex policy_mutex;
  39. int major;
  40. unsigned int sw_nmasters;
  41. struct stm_data *data;
  42. spinlock_t link_lock;
  43. struct list_head link_list;
  44. /* master allocation */
  45. spinlock_t mc_lock;
  46. struct stp_master *masters[0];
  47. };
  48. #define to_stm_device(_d) \
  49. container_of((_d), struct stm_device, dev)
  50. struct stm_output {
  51. unsigned int master;
  52. unsigned int channel;
  53. unsigned int nr_chans;
  54. };
  55. struct stm_file {
  56. struct stm_device *stm;
  57. struct stp_policy_node *policy_node;
  58. struct stm_output output;
  59. };
  60. struct stm_device *stm_find_device(const char *name);
  61. void stm_put_device(struct stm_device *stm);
  62. struct stm_source_device {
  63. struct device dev;
  64. struct stm_source_data *data;
  65. spinlock_t link_lock;
  66. struct stm_device __rcu *link;
  67. struct list_head link_entry;
  68. /* one output per stm_source device */
  69. struct stp_policy_node *policy_node;
  70. struct stm_output output;
  71. };
  72. #define to_stm_source_device(_d) \
  73. container_of((_d), struct stm_source_device, dev)
  74. #endif /* _STM_STM_H_ */