2018-03-28 18:43:57 +03:00
/* SPDX-License-Identifier: GPL-2.0 */
2015-09-22 15:47:10 +03:00
/*
* System Trace Module ( STM ) infrastructure
* Copyright ( c ) 2014 , Intel Corporation .
*
* STM class implements generic infrastructure for System Trace Module devices
* as defined in MIPI STPv2 specification .
*/
# ifndef _STM_STM_H_
# define _STM_STM_H_
2018-10-05 15:42:54 +03:00
# include <linux/configfs.h>
2015-09-22 15:47:10 +03:00
struct stp_policy ;
struct stp_policy_node ;
2018-10-05 15:42:54 +03:00
struct stm_protocol_driver ;
2015-09-22 15:47:10 +03:00
int stp_configfs_init ( void ) ;
void stp_configfs_exit ( void ) ;
2018-10-05 15:42:54 +03:00
void * stp_policy_node_priv ( struct stp_policy_node * pn ) ;
2015-09-22 15:47:10 +03:00
struct stp_master {
unsigned int nr_free ;
2020-05-28 17:35:11 +03:00
unsigned long chan_map [ ] ;
2015-09-22 15:47:10 +03:00
} ;
struct stm_device {
struct device dev ;
struct module * owner ;
struct stp_policy * policy ;
struct mutex policy_mutex ;
int major ;
unsigned int sw_nmasters ;
struct stm_data * data ;
2015-12-22 18:25:19 +03:00
struct mutex link_mutex ;
2015-09-22 15:47:10 +03:00
spinlock_t link_lock ;
struct list_head link_list ;
2018-10-05 15:42:54 +03:00
/* framing protocol in use */
const struct stm_protocol_driver * pdrv ;
const struct config_item_type * pdrv_node_type ;
2015-09-22 15:47:10 +03:00
/* master allocation */
spinlock_t mc_lock ;
2020-05-28 17:35:11 +03:00
struct stp_master * masters [ ] ;
2015-09-22 15:47:10 +03:00
} ;
# define to_stm_device(_d) \
container_of ( ( _d ) , struct stm_device , dev )
2018-10-05 15:42:54 +03:00
struct stp_policy_node *
stp_policy_node_lookup ( struct stm_device * stm , char * s ) ;
void stp_policy_node_put ( struct stp_policy_node * policy_node ) ;
void stp_policy_unbind ( struct stp_policy * policy ) ;
void stp_policy_node_get_ranges ( struct stp_policy_node * policy_node ,
unsigned int * mstart , unsigned int * mend ,
unsigned int * cstart , unsigned int * cend ) ;
const struct config_item_type *
get_policy_node_type ( struct configfs_attribute * * attrs ) ;
2015-09-22 15:47:10 +03:00
struct stm_output {
2016-02-15 20:12:06 +03:00
spinlock_t lock ;
2015-09-22 15:47:10 +03:00
unsigned int master ;
unsigned int channel ;
unsigned int nr_chans ;
2018-10-05 15:42:54 +03:00
void * pdrv_private ;
2015-09-22 15:47:10 +03:00
} ;
struct stm_file {
struct stm_device * stm ;
struct stm_output output ;
} ;
struct stm_device * stm_find_device ( const char * name ) ;
void stm_put_device ( struct stm_device * stm ) ;
struct stm_source_device {
struct device dev ;
struct stm_source_data * data ;
spinlock_t link_lock ;
2015-10-06 12:47:17 +03:00
struct stm_device __rcu * link ;
2015-09-22 15:47:10 +03:00
struct list_head link_entry ;
/* one output per stm_source device */
struct stm_output output ;
} ;
# define to_stm_source_device(_d) \
container_of ( ( _d ) , struct stm_source_device , dev )
2018-10-05 15:42:54 +03:00
void * to_pdrv_policy_node ( struct config_item * item ) ;
struct stm_protocol_driver {
struct module * owner ;
const char * name ;
ssize_t ( * write ) ( struct stm_data * data ,
struct stm_output * output , unsigned int chan ,
const char * buf , size_t count ) ;
void ( * policy_node_init ) ( void * arg ) ;
int ( * output_open ) ( void * priv , struct stm_output * output ) ;
void ( * output_close ) ( struct stm_output * output ) ;
ssize_t priv_sz ;
struct configfs_attribute * * policy_attr ;
} ;
int stm_register_protocol ( const struct stm_protocol_driver * pdrv ) ;
void stm_unregister_protocol ( const struct stm_protocol_driver * pdrv ) ;
int stm_lookup_protocol ( const char * name ,
const struct stm_protocol_driver * * pdrv ,
const struct config_item_type * * type ) ;
void stm_put_protocol ( const struct stm_protocol_driver * pdrv ) ;
2018-10-05 15:42:55 +03:00
ssize_t stm_data_write ( struct stm_data * data , unsigned int m ,
unsigned int c , bool ts_first , const void * buf ,
size_t count ) ;
2018-10-05 15:42:54 +03:00
2015-09-22 15:47:10 +03:00
# endif /* _STM_STM_H_ */