1 /* SPDX-License-Identifier: GPL-2.0 */
6 #include <linux/spinlock.h>
7 #include <linux/device.h>
8 #include <linux/mod_devicetable.h>
9 #include <dt-bindings/soc/qcom,apr.h>
11 extern struct bus_type aprbus;
13 #define APR_HDR_LEN(hdr_len) ((hdr_len)/4)
22 #define APR_HDR_FIELD(msg_type, hdr_len, ver)\
23 (((msg_type & 0x3) << 8) | ((hdr_len & 0xF) << 4) | (ver & 0xF))
25 #define APR_HDR_SIZE sizeof(struct apr_hdr)
26 #define APR_SEQ_CMD_HDR_FIELD APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, \
27 APR_HDR_LEN(APR_HDR_SIZE), \
30 #define APR_PKT_VER 0x0
32 /* Command and Response Types */
33 #define APR_MSG_TYPE_EVENT 0x0
34 #define APR_MSG_TYPE_CMD_RSP 0x1
35 #define APR_MSG_TYPE_SEQ_CMD 0x2
36 #define APR_MSG_TYPE_NSEQ_CMD 0x3
37 #define APR_MSG_TYPE_MAX 0x04
39 /* APR Basic Response Message */
40 #define APR_BASIC_RSP_RESULT 0x000110E8
41 #define APR_RSP_ACCEPTED 0x000100BE
43 struct aprv2_ibasic_rsp_result_t {
48 /* hdr field Ver [0:3], Size [4:7], Message type [8:10] */
49 #define APR_HDR_FIELD_VER(h) (h & 0x000F)
50 #define APR_HDR_FIELD_SIZE(h) ((h & 0x00F0) >> 4)
51 #define APR_HDR_FIELD_SIZE_BYTES(h) (((h & 0x00F0) >> 4) * 4)
52 #define APR_HDR_FIELD_MT(h) ((h & 0x0300) >> 8)
78 /* Bits 0 to 15 -- Minor version, Bits 16 to 31 -- Major version */
79 #define APR_SVC_MAJOR_VERSION(v) ((v >> 16) & 0xFF)
80 #define APR_SVC_MINOR_VERSION(v) (v & 0xFF)
87 char name[APR_NAME_SIZE];
88 const char *service_path;
90 struct list_head node;
93 #define to_apr_device(d) container_of(d, struct apr_device, dev)
96 int (*probe)(struct apr_device *sl);
97 int (*remove)(struct apr_device *sl);
98 int (*callback)(struct apr_device *a,
99 struct apr_resp_pkt *d);
100 struct device_driver driver;
101 const struct apr_device_id *id_table;
104 #define to_apr_driver(d) container_of(d, struct apr_driver, driver)
107 * use a macro to avoid include chaining to get THIS_MODULE
109 #define apr_driver_register(drv) __apr_driver_register(drv, THIS_MODULE)
111 int __apr_driver_register(struct apr_driver *drv, struct module *owner);
112 void apr_driver_unregister(struct apr_driver *drv);
115 * module_apr_driver() - Helper macro for registering a aprbus driver
116 * @__aprbus_driver: aprbus_driver struct
118 * Helper macro for aprbus drivers which do not do anything special in
119 * module init/exit. This eliminates a lot of boilerplate. Each module
120 * may only use this macro once, and calling it replaces module_init()
123 #define module_apr_driver(__apr_driver) \
124 module_driver(__apr_driver, apr_driver_register, \
125 apr_driver_unregister)
127 int apr_send_pkt(struct apr_device *adev, struct apr_pkt *pkt);
129 #endif /* __QCOM_APR_H_ */