#ifndef _FSL_MC_PRIVATE_H_
#define _FSL_MC_PRIVATE_H_
#include <linux/fsl/mc.h>
#include <linux/mutex.h>
#include <linux/ioctl.h>
#include <linux/miscdevice.h>
#define DPMNG_CMD_BASE_VERSION 1
#define DPMNG_CMD_ID_OFFSET 4
#define DPMNG_CMD(id) (((id) << DPMNG_CMD_ID_OFFSET) | DPMNG_CMD_BASE_VERSION)
#define DPMNG_CMDID_GET_VERSION DPMNG_CMD(0x831)
struct dpmng_rsp_get_version {
__le32 revision;
__le32 version_major;
__le32 version_minor;
};
#define DPMCP_MIN_VER_MAJOR 3
#define DPMCP_MIN_VER_MINOR 0
#define DPMCP_CMD_BASE_VERSION 1
#define DPMCP_CMD_ID_OFFSET 4
#define DPMCP_CMD(id) (((id) << DPMCP_CMD_ID_OFFSET) | DPMCP_CMD_BASE_VERSION)
#define DPMCP_CMDID_CLOSE DPMCP_CMD(0x800)
#define DPMCP_CMDID_RESET DPMCP_CMD(0x005)
struct dpmcp_cmd_open {
__le32 dpmcp_id;
};
int dpmcp_open(struct fsl_mc_io *mc_io,
u32 cmd_flags,
int dpmcp_id,
u16 *token);
int dpmcp_close(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token);
int dpmcp_reset(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token);
#define DPRC_MIN_VER_MAJOR 6
#define DPRC_MIN_VER_MINOR 0
#define DPRC_CMD_BASE_VERSION 1
#define DPRC_CMD_2ND_VERSION 2
#define DPRC_CMD_3RD_VERSION 3
#define DPRC_CMD_ID_OFFSET 4
#define DPRC_CMD(id) (((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_BASE_VERSION)
#define DPRC_CMD_V2(id) (((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_2ND_VERSION)
#define DPRC_CMD_V3(id) (((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_3RD_VERSION)
#define DPRC_CMDID_CLOSE DPRC_CMD(0x800)
#define DPRC_CMDID_GET_API_VERSION DPRC_CMD(0xa05)
#define DPRC_CMDID_GET_ATTR DPRC_CMD(0x004)
#define DPRC_CMDID_RESET_CONT DPRC_CMD(0x005)
#define DPRC_CMDID_RESET_CONT_V2 DPRC_CMD_V2(0x005)
#define DPRC_CMDID_SET_IRQ DPRC_CMD(0x010)
#define DPRC_CMDID_SET_IRQ_ENABLE DPRC_CMD(0x012)
#define DPRC_CMDID_SET_IRQ_MASK DPRC_CMD(0x014)
#define DPRC_CMDID_GET_IRQ_STATUS DPRC_CMD(0x016)
#define DPRC_CMDID_CLEAR_IRQ_STATUS DPRC_CMD(0x017)
#define DPRC_CMDID_GET_CONT_ID DPRC_CMD(0x830)
#define DPRC_CMDID_GET_OBJ_COUNT DPRC_CMD(0x159)
#define DPRC_CMDID_GET_OBJ DPRC_CMD(0x15A)
#define DPRC_CMDID_GET_OBJ_REG DPRC_CMD(0x15E)
#define DPRC_CMDID_GET_OBJ_REG_V2 DPRC_CMD_V2(0x15E)
#define DPRC_CMDID_GET_OBJ_REG_V3 DPRC_CMD_V3(0x15E)
#define DPRC_CMDID_SET_OBJ_IRQ DPRC_CMD(0x15F)
#define DPRC_CMDID_GET_CONNECTION DPRC_CMD(0x16C)
struct dprc_cmd_open {
__le32 container_id;
};
struct dprc_cmd_reset_container {
__le32 child_container_id;
__le32 options;
};
struct dprc_cmd_set_irq {
__le32 irq_val;
u8 irq_index;
u8 pad[3];
__le64 irq_addr;
__le32 irq_num;
};
#define DPRC_ENABLE 0x1
struct dprc_cmd_set_irq_enable {
u8 enable;
u8 pad[3];
u8 irq_index;
};
struct dprc_cmd_set_irq_mask {
__le32 mask;
u8 irq_index;
};
struct dprc_cmd_get_irq_status {
__le32 status;
u8 irq_index;
};
struct dprc_rsp_get_irq_status {
__le32 status;
};
struct dprc_cmd_clear_irq_status {
__le32 status;
u8 irq_index;
};
struct dprc_rsp_get_attributes {
__le32 container_id;
__le32 icid;
__le32 options;
__le32 portal_id;
};
struct dprc_rsp_get_obj_count {
__le32 pad;
__le32 obj_count;
};
struct dprc_cmd_get_obj {
__le32 obj_index;
};
struct dprc_rsp_get_obj {
__le32 pad0;
__le32 id;
__le16 vendor;
u8 irq_count;
u8 region_count;
__le32 state;
__le16 version_major;
__le16 version_minor;
__le16 flags;
__le16 pad1;
u8 type[16];
u8 label[16];
};
struct dprc_cmd_get_obj_region {
__le32 obj_id;
__le16 pad0;
u8 region_index;
u8 pad1;
__le64 pad2[2];
u8 obj_type[16];
};
struct dprc_rsp_get_obj_region {
__le64 pad0;
__le64 base_offset;
__le32 size;
u8 type;
u8 pad2[3];
__le32 flags;
__le32 pad3;
__le64 base_addr;
};
struct dprc_cmd_set_obj_irq {
__le32 irq_val;
u8 irq_index;
u8 pad[3];
__le64 irq_addr;
__le32 irq_num;
__le32 obj_id;
u8 obj_type[16];
};
struct dprc_cmd_get_connection {
__le32 ep1_id;
__le16 ep1_interface_id;
u8 pad[2];
u8 ep1_type[16];
};
struct dprc_rsp_get_connection {
__le64 pad[3];
__le32 ep2_id;
__le16 ep2_interface_id;
__le16 pad1;
u8 ep2_type[16];
__le32 state;
};
int dprc_open(struct fsl_mc_io *mc_io,
u32 cmd_flags,
int container_id,
u16 *token);
int dprc_close(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token);
#define DPRC_IRQ_EVENT_OBJ_ADDED 0x00000001
#define DPRC_IRQ_EVENT_OBJ_REMOVED 0x00000002
#define DPRC_IRQ_EVENT_CONTAINER_DESTROYED 0x00000010
#define DPRC_IRQ_EVENT_OBJ_DESTROYED 0x00000020
#define DPRC_IRQ_EVENT_OBJ_CREATED 0x00000040
struct dprc_irq_cfg {
phys_addr_t paddr;
u32 val;
int irq_num;
};
int dprc_set_irq(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token,
u8 irq_index,
struct dprc_irq_cfg *irq_cfg);
int dprc_set_irq_enable(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token,
u8 irq_index,
u8 en);
int dprc_set_irq_mask(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token,
u8 irq_index,
u32 mask);
int dprc_get_irq_status(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token,
u8 irq_index,
u32 *status);
int dprc_clear_irq_status(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token,
u8 irq_index,
u32 status);
struct dprc_attributes {
int container_id;
u32 icid;
int portal_id;
u64 options;
};
int dprc_get_attributes(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token,
struct dprc_attributes *attributes);
int dprc_get_obj_count(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token,
int *obj_count);
int dprc_get_obj(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token,
int obj_index,
struct fsl_mc_obj_desc *obj_desc);
int dprc_set_obj_irq(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token,
char *obj_type,
int obj_id,
u8 irq_index,
struct dprc_irq_cfg *irq_cfg);
enum dprc_region_type {
DPRC_REGION_TYPE_MC_PORTAL,
DPRC_REGION_TYPE_QBMAN_PORTAL,
DPRC_REGION_TYPE_QBMAN_MEM_BACKED_PORTAL
};
struct dprc_region_desc {
u32 base_offset;
u32 size;
u32 flags;
enum dprc_region_type type;
u64 base_address;
};
int dprc_get_obj_region(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token,
char *obj_type,
int obj_id,
u8 region_index,
struct dprc_region_desc *region_desc);
int dprc_get_api_version(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 *major_ver,
u16 *minor_ver);
int dprc_get_container_id(struct fsl_mc_io *mc_io,
u32 cmd_flags,
int *container_id);
struct dprc_endpoint {
char type[16];
int id;
u16 if_id;
};
int dprc_get_connection(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token,
const struct dprc_endpoint *endpoint1,
struct dprc_endpoint *endpoint2,
int *state);
#define DPBP_VER_MAJOR 3
#define DPBP_VER_MINOR 2
#define DPBP_CMD_BASE_VERSION 1
#define DPBP_CMD_ID_OFFSET 4
#define DPBP_CMD(id) (((id) << DPBP_CMD_ID_OFFSET) | DPBP_CMD_BASE_VERSION)
#define DPBP_CMDID_CLOSE DPBP_CMD(0x800)
#define DPBP_CMDID_ENABLE DPBP_CMD(0x002)
#define DPBP_CMDID_DISABLE DPBP_CMD(0x003)
#define DPBP_CMDID_GET_ATTR DPBP_CMD(0x004)
#define DPBP_CMDID_RESET DPBP_CMD(0x005)
struct dpbp_cmd_open {
__le32 dpbp_id;
};
#define DPBP_ENABLE 0x1
struct dpbp_rsp_get_attributes {
__le16 pad;
__le16 bpid;
__le32 id;
__le16 version_major;
__le16 version_minor;
};
#define DPCON_VER_MAJOR 3
#define DPCON_VER_MINOR 2
#define DPCON_CMD_BASE_VERSION 1
#define DPCON_CMD_ID_OFFSET 4
#define DPCON_CMD(id) (((id) << DPCON_CMD_ID_OFFSET) | DPCON_CMD_BASE_VERSION)
#define DPCON_CMDID_CLOSE DPCON_CMD(0x800)
#define DPCON_CMDID_ENABLE DPCON_CMD(0x002)
#define DPCON_CMDID_DISABLE DPCON_CMD(0x003)
#define DPCON_CMDID_GET_ATTR DPCON_CMD(0x004)
#define DPCON_CMDID_RESET DPCON_CMD(0x005)
#define DPCON_CMDID_SET_NOTIFICATION DPCON_CMD(0x100)
struct dpcon_cmd_open {
__le32 dpcon_id;
};
#define DPCON_ENABLE 1
struct dpcon_rsp_get_attr {
__le32 id;
__le16 qbman_ch_id;
u8 num_priorities;
u8 pad;
};
struct dpcon_cmd_set_notification {
__le32 dpio_id;
u8 priority;
u8 pad[3];
__le64 user_ctx;
};
#define OBJ_CMD_BASE_VERSION 1
#define OBJ_CMD_ID_OFFSET 4
#define OBJ_CMD(id) (((id) << OBJ_CMD_ID_OFFSET) | OBJ_CMD_BASE_VERSION)
#define DPRTC_CMDID_OPEN OBJ_CMD(0x810)
#define DPNI_CMDID_OPEN OBJ_CMD(0x801)
#define DPSW_CMDID_OPEN OBJ_CMD(0x802)
#define DPIO_CMDID_OPEN OBJ_CMD(0x803)
#define DPBP_CMDID_OPEN OBJ_CMD(0x804)
#define DPRC_CMDID_OPEN OBJ_CMD(0x805)
#define DPDMUX_CMDID_OPEN OBJ_CMD(0x806)
#define DPCI_CMDID_OPEN OBJ_CMD(0x807)
#define DPCON_CMDID_OPEN OBJ_CMD(0x808)
#define DPSECI_CMDID_OPEN OBJ_CMD(0x809)
#define DPAIOP_CMDID_OPEN OBJ_CMD(0x80a)
#define DPMCP_CMDID_OPEN OBJ_CMD(0x80b)
#define DPMAC_CMDID_OPEN OBJ_CMD(0x80c)
#define DPDCEI_CMDID_OPEN OBJ_CMD(0x80d)
#define DPDMAI_CMDID_OPEN OBJ_CMD(0x80e)
#define DPDBG_CMDID_OPEN OBJ_CMD(0x80f)
#define OBJ_CMDID_CLOSE OBJ_CMD(0x800)
#define OBJ_CMDID_RESET OBJ_CMD(0x005)
struct fsl_mc_obj_cmd_open {
__le32 obj_id;
};
struct fsl_mc_resource_pool {
enum fsl_mc_pool_type type;
int max_count;
int free_count;
struct mutex mutex;
struct list_head free_list;
struct fsl_mc_bus *mc_bus;
};
struct fsl_mc_uapi {
struct miscdevice misc;
struct device *device;
struct mutex mutex;
u32 local_instance_in_use;
struct fsl_mc_io *static_mc_io;
};
struct fsl_mc_bus {
struct fsl_mc_device mc_dev;
struct fsl_mc_resource_pool resource_pools[FSL_MC_NUM_POOL_TYPES];
struct fsl_mc_device_irq *irq_resources;
struct mutex scan_mutex;
struct dprc_attributes dprc_attr;
struct fsl_mc_uapi uapi_misc;
int irq_enabled;
};
#define to_fsl_mc_bus(_mc_dev) \
container_of(_mc_dev, struct fsl_mc_bus, mc_dev)
int __must_check fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
struct fsl_mc_io *mc_io,
struct device *parent_dev,
struct fsl_mc_device **new_mc_dev);
void fsl_mc_device_remove(struct fsl_mc_device *mc_dev);
int __init dprc_driver_init(void);
void dprc_driver_exit(void);
int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
bool alloc_interrupts);
int __init fsl_mc_allocator_driver_init(void);
void fsl_mc_allocator_driver_exit(void);
void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus,
enum fsl_mc_pool_type pool_type,
struct fsl_mc_resource
**new_resource);
void fsl_mc_resource_free(struct fsl_mc_resource *resource);
int fsl_mc_msi_domain_alloc_irqs(struct device *dev,
unsigned int irq_count);
void fsl_mc_msi_domain_free_irqs(struct device *dev);
struct irq_domain *fsl_mc_find_msi_domain(struct device *dev);
int __must_check fsl_create_mc_io(struct device *dev,
phys_addr_t mc_portal_phys_addr,
u32 mc_portal_size,
struct fsl_mc_device *dpmcp_dev,
u32 flags, struct fsl_mc_io **new_mc_io);
void fsl_destroy_mc_io(struct fsl_mc_io *mc_io);
bool fsl_mc_is_root_dprc(struct device *dev);
void fsl_mc_get_root_dprc(struct device *dev,
struct device **root_dprc_dev);
struct fsl_mc_device *fsl_mc_device_lookup(struct fsl_mc_obj_desc *obj_desc,
struct fsl_mc_device *mc_bus_dev);
u16 mc_cmd_hdr_read_cmdid(struct fsl_mc_command *cmd);
#ifdef CONFIG_FSL_MC_UAPI_SUPPORT
int fsl_mc_uapi_create_device_file(struct fsl_mc_bus *mc_bus);
void fsl_mc_uapi_remove_device_file(struct fsl_mc_bus *mc_bus);
#else
static inline int fsl_mc_uapi_create_device_file(struct fsl_mc_bus *mc_bus)
{
return 0;
}
static inline void fsl_mc_uapi_remove_device_file(struct fsl_mc_bus *mc_bus)
{
}
#endif
int disable_dprc_irq(struct fsl_mc_device *mc_dev);
int enable_dprc_irq(struct fsl_mc_device *mc_dev);
int get_dprc_irq_state(struct fsl_mc_device *mc_dev);
#endif /* _FSL_MC_PRIVATE_H_ */