stm.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. struct mutex link_mutex;
  43. spinlock_t link_lock;
  44. struct list_head link_list;
  45. /* master allocation */
  46. spinlock_t mc_lock;
  47. struct stp_master *masters[0];
  48. };
  49. #define to_stm_device(_d) \
  50. container_of((_d), struct stm_device, dev)
  51. struct stm_output {
  52. spinlock_t lock;
  53. unsigned int master;
  54. unsigned int channel;
  55. unsigned int nr_chans;
  56. };
  57. struct stm_file {
  58. struct stm_device *stm;
  59. struct stp_policy_node *policy_node;
  60. struct stm_output output;
  61. };
  62. struct stm_device *stm_find_device(const char *name);
  63. void stm_put_device(struct stm_device *stm);
  64. struct stm_source_device {
  65. struct device dev;
  66. struct stm_source_data *data;
  67. spinlock_t link_lock;
  68. struct stm_device __rcu *link;
  69. struct list_head link_entry;
  70. /* one output per stm_source device */
  71. struct stp_policy_node *policy_node;
  72. struct stm_output output;
  73. };
  74. #define to_stm_source_device(_d) \
  75. container_of((_d), struct stm_source_device, dev)
  76. #endif /* _STM_STM_H_ */