Add 'qcom/opensource/mmrm-driver/' from commit '35211a9255b69d52ddc2b82dc8b1dd2840b98868'
git-subtree-dir: qcom/opensource/mmrm-driver git-subtree-mainline:f9b254670f
git-subtree-split:35211a9255
Change-Id: repo: https://git.codelinaro.org/clo/la/platform/vendor/opensource/mmrm-driver tag: VIDEO.LA.4.0.r2-06100-lanai.0
This commit is contained in:
63
qcom/opensource/mmrm-driver/vm/common/inc/mmrm_vm_debug.h
Normal file
63
qcom/opensource/mmrm-driver/vm/common/inc/mmrm_vm_debug.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __MMRM_VM_DEBUG__
|
||||
#define __MMRM_VM_DEBUG__
|
||||
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/printk.h>
|
||||
|
||||
#ifndef MMRM_VM_DBG_LABEL
|
||||
#define MMRM_VM_DBG_LABEL "mmrm_vm"
|
||||
#endif
|
||||
|
||||
#define MMRM_VM_DBG_TAG MMRM_VM_DBG_LABEL ": %4s: "
|
||||
|
||||
/* To enable messages OR these values and
|
||||
* echo the result to debugfs file.
|
||||
*/
|
||||
enum mmrm_msg_prio {
|
||||
MMRM_VM_ERR = 0x000001,
|
||||
MMRM_VM_HIGH = 0x000002,
|
||||
MMRM_VM_LOW = 0x000004,
|
||||
MMRM_VM_WARN = 0x000008,
|
||||
MMRM_VM_PRINTK = 0x010000,
|
||||
};
|
||||
|
||||
extern int mmrm_vm_debug;
|
||||
|
||||
#define dprintk(__level, __fmt, ...) \
|
||||
do { \
|
||||
if (mmrm_vm_debug & __level) { \
|
||||
if (mmrm_vm_debug & MMRM_VM_PRINTK) { \
|
||||
pr_info(MMRM_VM_DBG_TAG __fmt, \
|
||||
get_debug_level_str(__level), \
|
||||
##__VA_ARGS__); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define d_mpr_e(__fmt, ...) dprintk(MMRM_VM_ERR, __fmt, ##__VA_ARGS__)
|
||||
#define d_mpr_h(__fmt, ...) dprintk(MMRM_VM_HIGH, __fmt, ##__VA_ARGS__)
|
||||
#define d_mpr_l(__fmt, ...) dprintk(MMRM_VM_LOW, __fmt, ##__VA_ARGS__)
|
||||
#define d_mpr_w(__fmt, ...) dprintk(MMRM_VM_WARN, __fmt, ##__VA_ARGS__)
|
||||
|
||||
static inline char *get_debug_level_str(int level)
|
||||
{
|
||||
switch (level) {
|
||||
case MMRM_VM_ERR:
|
||||
return "err ";
|
||||
case MMRM_VM_HIGH:
|
||||
return "high";
|
||||
case MMRM_VM_LOW:
|
||||
return "low ";
|
||||
case MMRM_VM_WARN:
|
||||
return "warn";
|
||||
default:
|
||||
return "????";
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __MMRM_VM_DEBUG__ */
|
246
qcom/opensource/mmrm-driver/vm/common/inc/mmrm_vm_interface.h
Normal file
246
qcom/opensource/mmrm-driver/vm/common/inc/mmrm_vm_interface.h
Normal file
@@ -0,0 +1,246 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __MMRM_VM_INTERNAL_H__
|
||||
#define __MMRM_VM_INTERNAL_H__
|
||||
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/soc/qcom/msm_mmrm.h>
|
||||
|
||||
#include <mmrm_vm_msgq.h>
|
||||
|
||||
/**
|
||||
* mmrm_vm_thread_info - message listener & workqueue info
|
||||
* @msgq_listener_thread: handle to msgq listener thread that is used
|
||||
* to receive/send messages through gunyah interface
|
||||
* @msg_workq: message workqueue pointer
|
||||
* @msgq_work: message work, worker thread to process the messages
|
||||
* @queued_msg: message queue head
|
||||
*/
|
||||
struct mmrm_vm_thread_info {
|
||||
struct task_struct *msgq_listener_thread;
|
||||
struct workqueue_struct *msg_workq;
|
||||
struct delayed_work msgq_work;
|
||||
struct mutex list_lock;
|
||||
struct list_head queued_msg;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mmrm_vm_data_priv -- device driver private part
|
||||
* @dev: device pointer
|
||||
* @msg_info: gunyah message info
|
||||
* @thread_info: message lister & workqueue info
|
||||
* @clk_client_tbl: index and client handler LUT
|
||||
* @debugfs_root: debug fs, /sys/kernel/debug
|
||||
* @vm_pvt_data: pointer to fe/be specific data
|
||||
*/
|
||||
struct mmrm_vm_driver_data {
|
||||
struct device *dev;
|
||||
struct mmrm_vm_gh_msgq_info msg_info;
|
||||
struct mmrm_vm_thread_info thread_info;
|
||||
struct mmrm_client **clk_client_tbl;
|
||||
|
||||
/* debugfs */
|
||||
struct dentry *debugfs_root;
|
||||
void *vm_pvt_data;
|
||||
};
|
||||
|
||||
/**
|
||||
* enum mmrm_vm_api_msg_id -- request/response cmd ID
|
||||
*/
|
||||
enum mmrm_vm_api_msg_id {
|
||||
MMRM_VM_REQUEST_REGISTER = 1,
|
||||
MMRM_VM_REQUEST_SETVALUE,
|
||||
MMRM_VM_REQUEST_SETVALUE_INRANGE,
|
||||
MMRM_VM_REQUEST_GETVALUE,
|
||||
MMRM_VM_REQUEST_DEREGISTER,
|
||||
MMRM_VM_REQUEST_NOOP, // this is for debug purpose,calculating msgq roundtrip time
|
||||
|
||||
MMRM_VM_RESPONSE_REGISTER = MMRM_VM_REQUEST_REGISTER | 0x800,
|
||||
MMRM_VM_RESPONSE_SETVALUE,
|
||||
MMRM_VM_RESPONSE_SETVALUE_INRANGE,
|
||||
MMRM_VM_RESPONSE_GETVALUE,
|
||||
MMRM_VM_RESPONSE_DEREGISTER,
|
||||
MMRM_VM_RESPONSE_NOOP, // this is for debug purpose,calculating msgq roundtrip time
|
||||
MMRM_VM_RESPONSE_INVALID_PKT,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct msg_head -- message head
|
||||
* @cmd_id: mmrm API message cmd id
|
||||
* @seq_no: message sequence id
|
||||
*/
|
||||
struct mmrm_vm_api_msg_head {
|
||||
enum mmrm_vm_api_msg_id cmd_id;
|
||||
int seq_no;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct register_request -- mmrm register parameters
|
||||
* @client_type: client type, definition see msm_mmrm.h
|
||||
* @priority: client priority, definition see msm_mmrm.h
|
||||
* @desc: client description, definition see msm_mmrm.h
|
||||
*/
|
||||
struct mmrm_vm_register_request {
|
||||
enum mmrm_client_type client_type;
|
||||
enum mmrm_client_priority priority;
|
||||
struct mmrm_clk_client_desc desc;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct deregister_request -- mmrm deregister parameters
|
||||
* @client: client registered handle
|
||||
*/
|
||||
struct mmrm_vm_deregister_request {
|
||||
u32 client_id;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mmrm_vm_noop_request -- noop request parameters
|
||||
* @client: 32 bits value transfered
|
||||
*/
|
||||
struct mmrm_vm_noop_request {
|
||||
u32 client_id;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct setvalue_request -- mmrm setvalue parameters
|
||||
* @client: client type, definition see msm_mmrm.h
|
||||
* @data: client info, definition see msm_mmrm.h
|
||||
* @val: new clock rate value
|
||||
*/
|
||||
struct mmrm_vm_setvalue_request {
|
||||
u32 client_id;
|
||||
struct mmrm_client_data data;
|
||||
unsigned long val;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mmrm_vm_setvalue_inrange_request -- mmrm setvalue_inrange parameters
|
||||
* @client: client type, definition see msm_mmrm.h
|
||||
* @data: client info, definition see msm_mmrm.h
|
||||
* @val: new clock rate value range, definition see msm_mmrm.h
|
||||
*/
|
||||
struct mmrm_vm_setvalue_inrange_request {
|
||||
u32 client_id;
|
||||
struct mmrm_client_data data;
|
||||
struct mmrm_client_res_value val;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mmrm_vm_getvalue_request -- mmrm getvalue parameters
|
||||
* @client: client type, definition see msm_mmrm.h
|
||||
* @val: current clock rate value range, definition see msm_mmrm.h
|
||||
*/
|
||||
struct mmrm_vm_getvalue_request {
|
||||
u32 client_id;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mmrm_vm_api_request_msg -- mmrm request API message unified data definition
|
||||
* @hd: mmrm API request message head
|
||||
* @data: parameters mmrm API needs per API message cmd id
|
||||
*/
|
||||
struct mmrm_vm_api_request_msg {
|
||||
struct mmrm_vm_api_msg_head hd;
|
||||
union {
|
||||
struct mmrm_vm_register_request reg;
|
||||
struct mmrm_vm_deregister_request dereg;
|
||||
struct mmrm_vm_setvalue_request setval;
|
||||
struct mmrm_vm_setvalue_inrange_request setval_range;
|
||||
struct mmrm_vm_getvalue_request getval;
|
||||
struct mmrm_vm_noop_request lptest;
|
||||
} data;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mmrm_vm_register_response -- mmrm_client_register API response message
|
||||
* @client: handle for registered client
|
||||
*/
|
||||
struct mmrm_vm_register_response {
|
||||
u32 client_id;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mmrm_vm_deregister_response -- mmrm_client_deregister API response message
|
||||
* @ret_code: indicates if the mmrm_client_deregister is successful
|
||||
*/
|
||||
struct mmrm_vm_deregister_response {
|
||||
int ret_code;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mmrm_vm_noop_response -- noop request's response message
|
||||
* @ret_code: return inetger
|
||||
*/
|
||||
struct mmrm_vm_noop_response {
|
||||
int ret_code;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mmrm_vm_setvalue_response -- mmrm_client_set_value API response message
|
||||
* @val: value that mmrm_client_set_value return
|
||||
*/
|
||||
struct mmrm_vm_setvalue_response {
|
||||
unsigned long val;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mmrm_vm_setvalue_inrange_response -- mmrm_client_set_value_in_range API response message
|
||||
* @ret_code: value that mmrm_client_set_value_in_range return
|
||||
*/
|
||||
struct mmrm_vm_setvalue_inrange_response {
|
||||
int ret_code;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mmrm_vm_getvalue_response -- mmrm_client_get_value API response message
|
||||
* @val: value that mmrm_client_get_value return
|
||||
*/
|
||||
struct mmrm_vm_getvalue_response {
|
||||
struct mmrm_client_res_value val;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mmrm_vm_api_response_msg -- mmrm response message unified data
|
||||
* @hd: mmrm API response message head
|
||||
* @data: data that mmrm API return per API response message id
|
||||
*/
|
||||
struct mmrm_vm_api_response_msg {
|
||||
struct mmrm_vm_api_msg_head hd;
|
||||
union {
|
||||
struct mmrm_vm_register_response reg;
|
||||
struct mmrm_vm_deregister_response dereg;
|
||||
struct mmrm_vm_setvalue_response setval;
|
||||
struct mmrm_vm_setvalue_inrange_response setval_range;
|
||||
struct mmrm_vm_getvalue_response getval;
|
||||
struct mmrm_vm_noop_response lptest;
|
||||
} data;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mmrm_vm_request_msg_pkt -- mmrm request packet that is sent through gunyah API
|
||||
* @hdr: message head for checking message valid
|
||||
* @msg: data that is needed by mmrm API
|
||||
*/
|
||||
struct mmrm_vm_request_msg_pkt {
|
||||
struct mmrm_vm_msg_hdr hdr;
|
||||
struct mmrm_vm_api_request_msg msg;
|
||||
u64 start_time_ns;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mmrm_vm_response_msg_pkt -- mmrm response packet that is sent through gunyah API
|
||||
* @hdr: message head for checking message valid
|
||||
* @msg: data that is returned by mmrm API
|
||||
*/
|
||||
struct mmrm_vm_response_msg_pkt {
|
||||
struct mmrm_vm_msg_hdr hdr;
|
||||
struct mmrm_vm_api_response_msg msg;
|
||||
};
|
||||
|
||||
#endif /* __MMRM_VM_INTERNAL_H__ */
|
||||
|
||||
|
104
qcom/opensource/mmrm-driver/vm/common/inc/mmrm_vm_msgq.h
Normal file
104
qcom/opensource/mmrm-driver/vm/common/inc/mmrm_vm_msgq.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __MMRM_VM_MSGQ_H__
|
||||
#define __MMRM_VM_MSGQ_H__
|
||||
|
||||
#include <linux/gunyah/gh_msgq.h>
|
||||
|
||||
#define MMRM_VM_VER_1 1 // mmrm version, for message valid check
|
||||
|
||||
#define MMRM_VM_MAX_PKT_SZ 1024 // mmrm max gunyah packet size
|
||||
|
||||
#define MMRM_VM_MSG_STATUS_NOTIFIER 0x01
|
||||
|
||||
/**
|
||||
* mmrm_vm_pkt_type: mmrm transfer type, for message valid check
|
||||
* @MMRM_VM_TYPE_DATA: request/response data
|
||||
*/
|
||||
enum mmrm_vm_pkt_type {
|
||||
MMRM_VM_TYPE_DATA = 1,
|
||||
};
|
||||
|
||||
struct mmrm_vm_driver_data;
|
||||
|
||||
/**
|
||||
* struct mmrm_vm_msg_hdr - mmrm vm packet header
|
||||
* @version: protocol version
|
||||
* @type: packet type; one of MMRM_VM_TYPE_* in mmrm_vm_pkt_type
|
||||
* @flags: Reserved for future use
|
||||
* @size: length of packet, excluding this header
|
||||
*/
|
||||
struct mmrm_vm_msg_hdr {
|
||||
u8 version;
|
||||
u8 type;
|
||||
u8 flags;
|
||||
u8 resv;
|
||||
u32 size;
|
||||
};
|
||||
|
||||
/**
|
||||
* mmrm_vm_msg - message that be received.
|
||||
* @link - list head
|
||||
* @msg_size - message size
|
||||
* @msg_buf - message buffer
|
||||
*/
|
||||
struct mmrm_vm_msg {
|
||||
struct list_head link;
|
||||
size_t msg_size;
|
||||
u8 msg_buf[GH_MSGQ_MAX_MSG_SIZE_BYTES];
|
||||
};
|
||||
|
||||
/**
|
||||
* mmrm_vm_msgq_info - gunyah info.
|
||||
* @peer_id: notification callback check if message is from SVM
|
||||
* @msgq_handle - registered msg queue handle with gunyah api
|
||||
* @msgq_label - message queue label
|
||||
* @status: indicate init status
|
||||
* @pvt_nb - notifier info
|
||||
*/
|
||||
struct mmrm_vm_gh_msgq_info {
|
||||
int peer_id;
|
||||
void *msgq_handle;
|
||||
int msgq_label;
|
||||
int status;
|
||||
struct notifier_block pvt_nb;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mmrm_vm_msg_q -- svm mmrm API caller queue that wait for mmrm API return
|
||||
* @link: list head
|
||||
* @m_req: request message pointer
|
||||
* @m_resp: response message buffer pointer
|
||||
* @complete: sync mmrm API response and caller
|
||||
*/
|
||||
struct mmrm_vm_msg_q {
|
||||
struct list_head link;
|
||||
struct mmrm_vm_request_msg_pkt *m_req;
|
||||
struct mmrm_vm_response_msg_pkt *m_resp;
|
||||
struct completion complete;
|
||||
};
|
||||
|
||||
/**
|
||||
* mmrm_vm_msgq_init - initialize display message queue: both TX and RX
|
||||
* @mmrm_vm - handle to mmrm_vm_data_priv
|
||||
*/
|
||||
int mmrm_vm_msgq_init(struct mmrm_vm_driver_data *mmrm_vm);
|
||||
|
||||
/**
|
||||
* mmrm_vm_msgq_deinit - deinitialize display message queue: both TX and RX
|
||||
* @mmrm_vm - handle to mmrm_vm_data_priv
|
||||
*/
|
||||
int mmrm_vm_msgq_deinit(struct mmrm_vm_driver_data *mmrm_vm);
|
||||
|
||||
/**
|
||||
* mmrm_vm_msgq_send - send custom messages across VM's
|
||||
* @mmrm_vm - handle to mmrm_vm_data_priv
|
||||
* @msg - payload data
|
||||
* @msg_size - size of the payload_data
|
||||
*/
|
||||
int mmrm_vm_msgq_send(struct mmrm_vm_driver_data *mmrm_vm, void *msg, size_t msg_size);
|
||||
#endif // __MMRM_VM_MSGQ_H__
|
||||
|
44
qcom/opensource/mmrm-driver/vm/common/src/mmrm_vm_debug.c
Normal file
44
qcom/opensource/mmrm-driver/vm/common/src/mmrm_vm_debug.c
Normal file
@@ -0,0 +1,44 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include "mmrm_vm_debug.h"
|
||||
|
||||
int mmrm_vm_debug = MMRM_VM_ERR | MMRM_VM_WARN | MMRM_VM_PRINTK;
|
||||
|
||||
/**
|
||||
* msm_mmrm_debugfs_init - init debug sys entry
|
||||
*/
|
||||
struct dentry *msm_mmrm_debugfs_init(void)
|
||||
{
|
||||
struct dentry *dir;
|
||||
|
||||
/* create a directory in debugfs root (/sys/kernel/debug) */
|
||||
dir = debugfs_create_dir("mmrm_vm", NULL);
|
||||
if (IS_ERR_OR_NULL(dir)) {
|
||||
d_mpr_e("%s: Call to debugfs_create_dir(%s) failed!\n", __func__, "mmrm");
|
||||
goto failed_create_dir;
|
||||
}
|
||||
|
||||
/* add other params here */
|
||||
debugfs_create_u32("debug_level", 0644, dir, &mmrm_vm_debug);
|
||||
|
||||
return dir;
|
||||
|
||||
failed_create_dir:
|
||||
d_mpr_e("%s: error\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* msm_mmrm_debugfs_deinit - de-init debug sys entry
|
||||
* dir: directory in debugfs root
|
||||
*/
|
||||
void msm_mmrm_debugfs_deinit(struct dentry *dir)
|
||||
{
|
||||
debugfs_remove_recursive(dir);
|
||||
}
|
||||
|
Reference in New Issue
Block a user