2011-10-20 22:52:46 +08: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>
|
|
|
|
*
|
|
|
|
* This software is licensed under the terms of the GNU General Public
|
|
|
|
* License version 2, as published by the Free Software Foundation, and
|
|
|
|
* may be copied, distributed, and modified under those terms.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef REMOTEPROC_INTERNAL_H
|
|
|
|
#define REMOTEPROC_INTERNAL_H
|
|
|
|
|
|
|
|
#include <linux/irqreturn.h>
|
2012-07-15 16:25:27 +08:00
|
|
|
#include <linux/firmware.h>
|
2011-10-20 22:52:46 +08:00
|
|
|
|
|
|
|
struct rproc;
|
|
|
|
|
2012-06-19 15:08:18 +08:00
|
|
|
/**
|
|
|
|
* struct rproc_fw_ops - firmware format specific operations.
|
2013-02-22 01:15:34 +08:00
|
|
|
* @find_rsc_table: find the resource table inside the firmware image
|
|
|
|
* @find_loaded_rsc_table: find the loaded resouce table
|
2012-06-19 15:08:18 +08:00
|
|
|
* @load: load firmeware to memory, where the remote processor
|
|
|
|
* expects to find it
|
|
|
|
* @sanity_check: sanity check the fw image
|
|
|
|
* @get_boot_addr: get boot address to entry point specified in firmware
|
|
|
|
*/
|
|
|
|
struct rproc_fw_ops {
|
2015-02-28 07:18:23 +08:00
|
|
|
struct resource_table *(*find_rsc_table)(struct rproc *rproc,
|
2016-08-13 07:42:20 +08:00
|
|
|
const struct firmware *fw,
|
|
|
|
int *tablesz);
|
|
|
|
struct resource_table *(*find_loaded_rsc_table)(
|
|
|
|
struct rproc *rproc, const struct firmware *fw);
|
2012-06-19 15:08:18 +08:00
|
|
|
int (*load)(struct rproc *rproc, const struct firmware *fw);
|
|
|
|
int (*sanity_check)(struct rproc *rproc, const struct firmware *fw);
|
|
|
|
u32 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw);
|
|
|
|
};
|
|
|
|
|
2011-10-20 22:52:46 +08:00
|
|
|
/* from remoteproc_core.c */
|
|
|
|
void rproc_release(struct kref *kref);
|
|
|
|
irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id);
|
2016-10-20 10:40:06 +08:00
|
|
|
void rproc_vdev_release(struct kref *ref);
|
2011-10-20 22:52:46 +08:00
|
|
|
|
2012-02-14 05:30:39 +08:00
|
|
|
/* from remoteproc_virtio.c */
|
|
|
|
int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id);
|
|
|
|
void rproc_remove_virtio_dev(struct rproc_vdev *rvdev);
|
2011-10-20 22:52:46 +08: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,
|
2016-08-13 07:42:20 +08:00
|
|
|
struct rproc_mem_entry *trace);
|
2011-10-20 22:52:46 +08: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 20:05:47 +08:00
|
|
|
/* from remoteproc_sysfs.c */
|
|
|
|
extern struct class rproc_class;
|
|
|
|
int rproc_init_sysfs(void);
|
|
|
|
void rproc_exit_sysfs(void);
|
|
|
|
|
2012-05-17 19:23:59 +08:00
|
|
|
void rproc_free_vring(struct rproc_vring *rvring);
|
|
|
|
int rproc_alloc_vring(struct rproc_vdev *rvdev, int i);
|
2012-07-15 16:25:27 +08:00
|
|
|
|
|
|
|
void *rproc_da_to_va(struct rproc *rproc, u64 da, int len);
|
2012-08-31 02:26:13 +08:00
|
|
|
int rproc_trigger_recovery(struct rproc *rproc);
|
2012-07-15 16:25:27 +08:00
|
|
|
|
2012-06-19 15:08:18 +08:00
|
|
|
static inline
|
|
|
|
int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)
|
|
|
|
{
|
|
|
|
if (rproc->fw_ops->sanity_check)
|
|
|
|
return rproc->fw_ops->sanity_check(rproc, fw);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw)
|
|
|
|
{
|
|
|
|
if (rproc->fw_ops->get_boot_addr)
|
|
|
|
return rproc->fw_ops->get_boot_addr(rproc, fw);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
int rproc_load_segments(struct rproc *rproc, const struct firmware *fw)
|
|
|
|
{
|
|
|
|
if (rproc->fw_ops->load)
|
|
|
|
return rproc->fw_ops->load(rproc, fw);
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
2012-07-15 16:25:27 +08:00
|
|
|
struct resource_table *rproc_find_rsc_table(struct rproc *rproc,
|
2016-08-13 07:42:20 +08:00
|
|
|
const struct firmware *fw,
|
|
|
|
int *tablesz)
|
2012-06-19 15:08:18 +08:00
|
|
|
{
|
|
|
|
if (rproc->fw_ops->find_rsc_table)
|
|
|
|
return rproc->fw_ops->find_rsc_table(rproc, fw, tablesz);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-02-22 01:15:34 +08:00
|
|
|
static inline
|
|
|
|
struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc,
|
2016-08-13 07:42:20 +08:00
|
|
|
const struct firmware *fw)
|
2013-02-22 01:15:34 +08:00
|
|
|
{
|
|
|
|
if (rproc->fw_ops->find_loaded_rsc_table)
|
|
|
|
return rproc->fw_ops->find_loaded_rsc_table(rproc, fw);
|
|
|
|
|
2013-06-30 16:33:05 +08:00
|
|
|
return NULL;
|
2013-02-22 01:15:34 +08:00
|
|
|
}
|
|
|
|
|
2012-06-19 15:08:18 +08:00
|
|
|
extern const struct rproc_fw_ops rproc_elf_fw_ops;
|
2012-07-15 16:25:27 +08:00
|
|
|
|
2011-10-20 22:52:46 +08:00
|
|
|
#endif /* REMOTEPROC_INTERNAL_H */
|