1 /* SPDX-License-Identifier: GPL-2.0 */
3 * System Trace Module (STM) infrastructure
4 * Copyright (c) 2014, Intel Corporation.
6 * STM class implements generic infrastructure for System Trace Module devices
7 * as defined in MIPI STPv2 specification.
13 #include <linux/configfs.h>
16 struct stp_policy_node
;
17 struct stm_protocol_driver
;
19 int stp_configfs_init(void);
20 void stp_configfs_exit(void);
22 void *stp_policy_node_priv(struct stp_policy_node
*pn
);
26 unsigned long chan_map
[];
32 struct stp_policy
*policy
;
33 struct mutex policy_mutex
;
35 unsigned int sw_nmasters
;
36 struct stm_data
*data
;
37 struct mutex link_mutex
;
39 struct list_head link_list
;
40 /* framing protocol in use */
41 const struct stm_protocol_driver
*pdrv
;
42 const struct config_item_type
*pdrv_node_type
;
43 /* master allocation */
45 struct stp_master
*masters
[];
48 #define to_stm_device(_d) \
49 container_of((_d), struct stm_device, dev)
51 struct stp_policy_node
*
52 stp_policy_node_lookup(struct stm_device
*stm
, char *s
);
53 void stp_policy_node_put(struct stp_policy_node
*policy_node
);
54 void stp_policy_unbind(struct stp_policy
*policy
);
56 void stp_policy_node_get_ranges(struct stp_policy_node
*policy_node
,
57 unsigned int *mstart
, unsigned int *mend
,
58 unsigned int *cstart
, unsigned int *cend
);
60 const struct config_item_type
*
61 get_policy_node_type(struct configfs_attribute
**attrs
);
67 unsigned int nr_chans
;
72 struct stm_device
*stm
;
73 struct stm_output output
;
76 struct stm_device
*stm_find_device(const char *name
);
77 void stm_put_device(struct stm_device
*stm
);
79 struct stm_source_device
{
81 struct stm_source_data
*data
;
83 struct stm_device __rcu
*link
;
84 struct list_head link_entry
;
85 /* one output per stm_source device */
86 struct stm_output output
;
89 #define to_stm_source_device(_d) \
90 container_of((_d), struct stm_source_device, dev)
92 void *to_pdrv_policy_node(struct config_item
*item
);
94 struct stm_protocol_driver
{
97 ssize_t (*write
)(struct stm_data
*data
,
98 struct stm_output
*output
, unsigned int chan
,
99 const char *buf
, size_t count
);
100 void (*policy_node_init
)(void *arg
);
101 int (*output_open
)(void *priv
, struct stm_output
*output
);
102 void (*output_close
)(struct stm_output
*output
);
104 struct configfs_attribute
**policy_attr
;
107 int stm_register_protocol(const struct stm_protocol_driver
*pdrv
);
108 void stm_unregister_protocol(const struct stm_protocol_driver
*pdrv
);
109 int stm_lookup_protocol(const char *name
,
110 const struct stm_protocol_driver
**pdrv
,
111 const struct config_item_type
**type
);
112 void stm_put_protocol(const struct stm_protocol_driver
*pdrv
);
113 ssize_t
stm_data_write(struct stm_data
*data
, unsigned int m
,
114 unsigned int c
, bool ts_first
, const void *buf
,
117 #endif /* _STM_STM_H_ */