Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * System Trace Module (STM) infrastructure
0004  * Copyright (c) 2014, Intel Corporation.
0005  *
0006  * STM class implements generic infrastructure for  System Trace Module devices
0007  * as defined in MIPI STPv2 specification.
0008  */
0009 
0010 #ifndef _STM_STM_H_
0011 #define _STM_STM_H_
0012 
0013 #include <linux/configfs.h>
0014 
0015 struct stp_policy;
0016 struct stp_policy_node;
0017 struct stm_protocol_driver;
0018 
0019 int stp_configfs_init(void);
0020 void stp_configfs_exit(void);
0021 
0022 void *stp_policy_node_priv(struct stp_policy_node *pn);
0023 
0024 struct stp_master {
0025     unsigned int    nr_free;
0026     unsigned long   chan_map[];
0027 };
0028 
0029 struct stm_device {
0030     struct device       dev;
0031     struct module       *owner;
0032     struct stp_policy   *policy;
0033     struct mutex        policy_mutex;
0034     int         major;
0035     unsigned int        sw_nmasters;
0036     struct stm_data     *data;
0037     struct mutex        link_mutex;
0038     spinlock_t      link_lock;
0039     struct list_head    link_list;
0040     /* framing protocol in use */
0041     const struct stm_protocol_driver    *pdrv;
0042     const struct config_item_type       *pdrv_node_type;
0043     /* master allocation */
0044     spinlock_t      mc_lock;
0045     struct stp_master   *masters[];
0046 };
0047 
0048 #define to_stm_device(_d)               \
0049     container_of((_d), struct stm_device, dev)
0050 
0051 struct stp_policy_node *
0052 stp_policy_node_lookup(struct stm_device *stm, char *s);
0053 void stp_policy_node_put(struct stp_policy_node *policy_node);
0054 void stp_policy_unbind(struct stp_policy *policy);
0055 
0056 void stp_policy_node_get_ranges(struct stp_policy_node *policy_node,
0057                 unsigned int *mstart, unsigned int *mend,
0058                 unsigned int *cstart, unsigned int *cend);
0059 
0060 const struct config_item_type *
0061 get_policy_node_type(struct configfs_attribute **attrs);
0062 
0063 struct stm_output {
0064     spinlock_t      lock;
0065     unsigned int        master;
0066     unsigned int        channel;
0067     unsigned int        nr_chans;
0068     void            *pdrv_private;
0069 };
0070 
0071 struct stm_file {
0072     struct stm_device   *stm;
0073     struct stm_output   output;
0074 };
0075 
0076 struct stm_device *stm_find_device(const char *name);
0077 void stm_put_device(struct stm_device *stm);
0078 
0079 struct stm_source_device {
0080     struct device       dev;
0081     struct stm_source_data  *data;
0082     spinlock_t      link_lock;
0083     struct stm_device __rcu *link;
0084     struct list_head    link_entry;
0085     /* one output per stm_source device */
0086     struct stm_output   output;
0087 };
0088 
0089 #define to_stm_source_device(_d)                \
0090     container_of((_d), struct stm_source_device, dev)
0091 
0092 void *to_pdrv_policy_node(struct config_item *item);
0093 
0094 struct stm_protocol_driver {
0095     struct module   *owner;
0096     const char  *name;
0097     ssize_t     (*write)(struct stm_data *data,
0098                  struct stm_output *output, unsigned int chan,
0099                  const char *buf, size_t count);
0100     void        (*policy_node_init)(void *arg);
0101     int     (*output_open)(void *priv, struct stm_output *output);
0102     void        (*output_close)(struct stm_output *output);
0103     ssize_t     priv_sz;
0104     struct configfs_attribute   **policy_attr;
0105 };
0106 
0107 int stm_register_protocol(const struct stm_protocol_driver *pdrv);
0108 void stm_unregister_protocol(const struct stm_protocol_driver *pdrv);
0109 int stm_lookup_protocol(const char *name,
0110             const struct stm_protocol_driver **pdrv,
0111             const struct config_item_type **type);
0112 void stm_put_protocol(const struct stm_protocol_driver *pdrv);
0113 ssize_t stm_data_write(struct stm_data *data, unsigned int m,
0114                unsigned int c, bool ts_first, const void *buf,
0115                size_t count);
0116 
0117 #endif /* _STM_STM_H_ */