Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * System Trace Module (STM) infrastructure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (c) 2014, Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * STM class implements generic infrastructure for  System Trace Module devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * as defined in MIPI STPv2 specification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #ifndef _STM_STM_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define _STM_STM_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/configfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) struct stp_policy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) struct stp_policy_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) struct stm_protocol_driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) int stp_configfs_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) void stp_configfs_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) void *stp_policy_node_priv(struct stp_policy_node *pn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) struct stp_master {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	unsigned int	nr_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	unsigned long	chan_map[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) struct stm_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	struct device		dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	struct module		*owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	struct stp_policy	*policy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	struct mutex		policy_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	int			major;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	unsigned int		sw_nmasters;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	struct stm_data		*data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	struct mutex		link_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	spinlock_t		link_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	struct list_head	link_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	/* framing protocol in use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	const struct stm_protocol_driver	*pdrv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	const struct config_item_type		*pdrv_node_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	/* master allocation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	spinlock_t		mc_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	struct stp_master	*masters[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define to_stm_device(_d)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	container_of((_d), struct stm_device, dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) struct stp_policy_node *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) stp_policy_node_lookup(struct stm_device *stm, char *s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) void stp_policy_node_put(struct stp_policy_node *policy_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) void stp_policy_unbind(struct stp_policy *policy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) void stp_policy_node_get_ranges(struct stp_policy_node *policy_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 				unsigned int *mstart, unsigned int *mend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 				unsigned int *cstart, unsigned int *cend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) const struct config_item_type *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) get_policy_node_type(struct configfs_attribute **attrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) struct stm_output {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	spinlock_t		lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	unsigned int		master;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	unsigned int		channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	unsigned int		nr_chans;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	void			*pdrv_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) struct stm_file {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	struct stm_device	*stm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	struct stm_output	output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) struct stm_device *stm_find_device(const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) void stm_put_device(struct stm_device *stm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) struct stm_source_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	struct device		dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	struct stm_source_data	*data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	spinlock_t		link_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	struct stm_device __rcu	*link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	struct list_head	link_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	/* one output per stm_source device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	struct stm_output	output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) #define to_stm_source_device(_d)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	container_of((_d), struct stm_source_device, dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) void *to_pdrv_policy_node(struct config_item *item);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) struct stm_protocol_driver {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	struct module	*owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	const char	*name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	ssize_t		(*write)(struct stm_data *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 				 struct stm_output *output, unsigned int chan,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 				 const char *buf, size_t count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	void		(*policy_node_init)(void *arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	int		(*output_open)(void *priv, struct stm_output *output);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	void		(*output_close)(struct stm_output *output);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	ssize_t		priv_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	struct configfs_attribute	**policy_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int stm_register_protocol(const struct stm_protocol_driver *pdrv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) void stm_unregister_protocol(const struct stm_protocol_driver *pdrv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) int stm_lookup_protocol(const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 			const struct stm_protocol_driver **pdrv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			const struct config_item_type **type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) void stm_put_protocol(const struct stm_protocol_driver *pdrv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) ssize_t stm_data_write(struct stm_data *data, unsigned int m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		       unsigned int c, bool ts_first, const void *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		       size_t count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #endif /* _STM_STM_H_ */