1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2022-2023 Bjoern A. Zeeb 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28 #ifndef _LINUXKPI_LINUX_SOC_QCOM_QMI_H 29 #define _LINUXKPI_LINUX_SOC_QCOM_QMI_H 30 31 /* QMI (Qualcomm MSM Interface) */ 32 33 #include <linux/qrtr.h> 34 35 enum soc_qcom_qmi_data_type { 36 QMI_EOTI, 37 QMI_DATA_LEN, 38 QMI_OPT_FLAG, 39 QMI_UNSIGNED_1_BYTE, 40 QMI_UNSIGNED_2_BYTE, 41 QMI_UNSIGNED_4_BYTE, 42 QMI_UNSIGNED_8_BYTE, 43 QMI_SIGNED_4_BYTE_ENUM, 44 QMI_STRUCT, 45 QMI_STRING, 46 }; 47 48 #define QMI_RESULT_SUCCESS_V01 __LINE__ 49 #define QMI_INDICATION __LINE__ 50 51 struct qmi_handle; 52 53 enum soc_qcom_qmi_array_type { 54 NO_ARRAY, 55 STATIC_ARRAY, 56 VAR_LEN_ARRAY, 57 }; 58 59 /* Should this become an enum? */ 60 #define QMI_COMMON_TLV_TYPE 0 61 62 struct qmi_elem_info { 63 enum soc_qcom_qmi_data_type data_type; 64 uint32_t elem_len; 65 uint32_t elem_size; 66 enum soc_qcom_qmi_array_type array_type; 67 uint8_t tlv_type; 68 uint32_t offset; 69 const struct qmi_elem_info *ei_array; 70 }; 71 72 struct qmi_response_type_v01 { 73 uint16_t result; 74 uint16_t error; 75 }; 76 77 struct qmi_txn { 78 }; 79 80 struct qmi_service { 81 uint32_t node; 82 uint32_t port; 83 }; 84 85 struct qmi_msg_handler { 86 uint32_t type; 87 uint32_t msg_id; 88 const struct qmi_elem_info *ei; 89 size_t decoded_size; 90 void (*fn)(struct qmi_handle *, struct sockaddr_qrtr *, struct qmi_txn *, const void *); 91 }; 92 93 struct qmi_ops { 94 int (*new_server)(struct qmi_handle *, struct qmi_service *); 95 void (*del_server)(struct qmi_handle *, struct qmi_service *); 96 }; 97 98 struct qmi_handle { 99 int sock; 100 101 const struct qmi_msg_handler *handler; 102 struct qmi_ops ops; 103 }; 104 105 106 /* XXX-TODO need implementation somewhere... it is not in ath1xk* */ 107 extern struct qmi_elem_info qmi_response_type_v01_ei[]; 108 109 static inline int 110 qmi_handle_init(struct qmi_handle *handle, size_t resp_len_max, 111 const struct qmi_ops *ops, const struct qmi_msg_handler *handler) 112 { 113 114 handle->handler = handler; 115 if (ops != NULL) 116 handle->ops = *ops; 117 118 /* We will find out what else to do here. */ 119 /* XXX TODO */ 120 121 return (0); 122 } 123 124 static __inline int 125 qmi_add_lookup(struct qmi_handle *handle, uint32_t service, uint32_t version, 126 uint32_t service_ins_id) 127 { 128 129 /* XXX TODO */ 130 return (0); 131 } 132 133 static __inline void 134 qmi_handle_release(struct qmi_handle *handle) 135 { 136 137 /* XXX TODO */ 138 } 139 140 static __inline int 141 qmi_send_request(struct qmi_handle *handle, void *x, struct qmi_txn *txn, 142 uint32_t msd_id, size_t len, const struct qmi_elem_info *ei, void *req) 143 { 144 145 /* XXX TODO */ 146 return (-ENXIO); 147 } 148 149 static __inline void 150 qmi_txn_cancel(struct qmi_txn *txn) 151 { 152 153 /* XXX TODO */ 154 } 155 156 static __inline int 157 qmi_txn_init(struct qmi_handle *handle, struct qmi_txn *txn, 158 const struct qmi_elem_info *ei, void *resp) 159 { 160 161 /* XXX TODO */ 162 return (-ENXIO); 163 } 164 165 static __inline int 166 qmi_txn_wait(struct qmi_txn *txn, uint64_t jiffies) 167 { 168 169 /* XXX TODO */ 170 return (-ENXIO); 171 } 172 173 #endif /* _LINUXKPI_LINUX_SOC_QCOM_QMI_H */ 174