2019-05-29 07:17:56 -07:00
/* SPDX-License-Identifier: GPL-2.0-only */
2011-10-20 16:52:46 +02:00
/*
* Remote processor framework
*
* Copyright ( C ) 2011 Texas Instruments , Inc .
* Copyright ( C ) 2011 Google , Inc .
*
* Ohad Ben - Cohen < ohad @ wizery . com >
* Brian Swetland < swetland @ google . com >
*/
# ifndef REMOTEPROC_INTERNAL_H
# define REMOTEPROC_INTERNAL_H
# include <linux/irqreturn.h>
2012-07-15 11:25:27 +03:00
# include <linux/firmware.h>
2011-10-20 16:52:46 +02:00
struct rproc ;
2019-01-10 14:49:10 +01:00
struct rproc_debug_trace {
struct rproc * rproc ;
struct dentry * tfile ;
struct list_head node ;
struct rproc_mem_entry trace_mem ;
} ;
2011-10-20 16:52:46 +02:00
/* from remoteproc_core.c */
void rproc_release ( struct kref * kref ) ;
irqreturn_t rproc_vq_interrupt ( struct rproc * rproc , int vq_id ) ;
2016-10-19 19:40:06 -07:00
void rproc_vdev_release ( struct kref * ref ) ;
2011-10-20 16:52:46 +02:00
2012-02-13 22:30:39 +01:00
/* from remoteproc_virtio.c */
int rproc_add_virtio_dev ( struct rproc_vdev * rvdev , int id ) ;
2019-01-21 14:55:15 +01:00
int rproc_remove_virtio_dev ( struct device * dev , void * data ) ;
2011-10-20 16:52:46 +02:00
/* from remoteproc_debugfs.c */
void rproc_remove_trace_file ( struct dentry * tfile ) ;
struct dentry * rproc_create_trace_file ( const char * name , struct rproc * rproc ,
2019-01-10 14:49:10 +01:00
struct rproc_debug_trace * trace ) ;
2011-10-20 16:52:46 +02:00
void rproc_delete_debug_dir ( struct rproc * rproc ) ;
void rproc_create_debug_dir ( struct rproc * rproc ) ;
void rproc_init_debugfs ( void ) ;
void rproc_exit_debugfs ( void ) ;
2016-10-19 13:05:47 +01:00
/* from remoteproc_sysfs.c */
extern struct class rproc_class ;
int rproc_init_sysfs ( void ) ;
void rproc_exit_sysfs ( void ) ;
2012-05-17 14:23:59 +03:00
void rproc_free_vring ( struct rproc_vring * rvring ) ;
int rproc_alloc_vring ( struct rproc_vdev * rvdev , int i ) ;
2012-07-15 11:25:27 +03:00
2020-03-02 10:38:55 +01:00
void * rproc_da_to_va ( struct rproc * rproc , u64 da , size_t len ) ;
2019-01-10 14:50:49 +01:00
phys_addr_t rproc_va_to_pa ( void * cpu_addr ) ;
2012-08-30 13:26:13 -05:00
int rproc_trigger_recovery ( struct rproc * rproc ) ;
2012-07-15 11:25:27 +03:00
2018-01-05 15:58:01 -08:00
int rproc_elf_sanity_check ( struct rproc * rproc , const struct firmware * fw ) ;
u32 rproc_elf_get_boot_addr ( struct rproc * rproc , const struct firmware * fw ) ;
int rproc_elf_load_segments ( struct rproc * rproc , const struct firmware * fw ) ;
2018-01-05 15:58:03 -08:00
int rproc_elf_load_rsc_table ( struct rproc * rproc , const struct firmware * fw ) ;
2018-01-05 15:58:01 -08:00
struct resource_table * rproc_elf_find_loaded_rsc_table ( struct rproc * rproc ,
const struct firmware * fw ) ;
2018-07-27 15:14:47 +02:00
struct rproc_mem_entry *
rproc_find_carveout_by_name ( struct rproc * rproc , const char * name , . . . ) ;
2018-01-05 15:58:01 -08:00
2012-06-19 10:08:18 +03:00
static inline
int rproc_fw_sanity_check ( struct rproc * rproc , const struct firmware * fw )
{
2018-01-05 15:58:01 -08:00
if ( rproc - > ops - > sanity_check )
return rproc - > ops - > sanity_check ( rproc , fw ) ;
2012-06-19 10:08:18 +03:00
return 0 ;
}
static inline
u32 rproc_get_boot_addr ( struct rproc * rproc , const struct firmware * fw )
{
2018-01-05 15:58:01 -08:00
if ( rproc - > ops - > get_boot_addr )
return rproc - > ops - > get_boot_addr ( rproc , fw ) ;
2012-06-19 10:08:18 +03:00
return 0 ;
}
static inline
int rproc_load_segments ( struct rproc * rproc , const struct firmware * fw )
{
2018-01-05 15:58:01 -08:00
if ( rproc - > ops - > load )
return rproc - > ops - > load ( rproc , fw ) ;
2012-06-19 10:08:18 +03:00
return - EINVAL ;
}
2018-01-05 16:04:18 -08:00
static inline int rproc_parse_fw ( struct rproc * rproc , const struct firmware * fw )
2012-06-19 10:08:18 +03:00
{
2018-01-05 16:04:18 -08:00
if ( rproc - > ops - > parse_fw )
return rproc - > ops - > parse_fw ( rproc , fw ) ;
2012-06-19 10:08:18 +03:00
2018-01-05 15:58:03 -08:00
return 0 ;
2012-06-19 10:08:18 +03:00
}
2019-06-17 14:57:30 +02:00
static inline
int rproc_handle_rsc ( struct rproc * rproc , u32 rsc_type , void * rsc , int offset ,
int avail )
{
if ( rproc - > ops - > handle_rsc )
return rproc - > ops - > handle_rsc ( rproc , rsc_type , rsc , offset ,
avail ) ;
return RSC_IGNORED ;
}
2013-02-21 18:15:34 +01:00
static inline
struct resource_table * rproc_find_loaded_rsc_table ( struct rproc * rproc ,
2016-08-12 18:42:20 -05:00
const struct firmware * fw )
2013-02-21 18:15:34 +01:00
{
2018-01-05 15:58:01 -08:00
if ( rproc - > ops - > find_loaded_rsc_table )
return rproc - > ops - > find_loaded_rsc_table ( rproc , fw ) ;
2013-02-21 18:15:34 +01:00
2013-06-30 11:33:05 +03:00
return NULL ;
2013-02-21 18:15:34 +01:00
}
2011-10-20 16:52:46 +02:00
# endif /* REMOTEPROC_INTERNAL_H */