1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2022 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 * $FreeBSD$ 28 */ 29 30 #ifndef _LINUXKPI_LINUX_MHI_H 31 #define _LINUXKPI_LINUX_MHI_H 32 33 #include <linux/types.h> 34 35 /* Modem Host Interface (MHI) */ 36 37 /* XXX FIXME */ 38 #define MHI_DB_BRST_DISABLE 0 39 #define MHI_ER_CTRL 0 40 41 enum mhi_callback { 42 MHI_CB_SYS_ERROR, 43 }; 44 45 struct mhi_channel_config { 46 const char *name; 47 int auto_queue, dir, doorbell, doorbell_mode_switch, ee_mask, event_ring, lpm_notify, num, num_elements, offload_channel, pollcfg; 48 }; 49 50 struct mhi_event_config { 51 int client_managed, data_type, hardware_event, irq, irq_moderation_ms, mode, num_elements, offload_channel, priority; 52 }; 53 54 struct mhi_device { 55 }; 56 57 struct mhi_controller_config { 58 struct mhi_channel_config *ch_cfg; 59 struct mhi_event_config *event_cfg; 60 61 int buf_len, max_channels, num_channels, num_events, use_bounce_buf; 62 63 uint32_t timeout_ms; 64 }; 65 66 struct mhi_controller { 67 struct device *cntrl_dev; 68 struct mhi_device *mhi_dev; 69 void *regs; 70 int *irq; 71 const char *fw_image; 72 73 bool fbc_download; 74 size_t sbl_size; 75 size_t seg_len; 76 size_t reg_len; 77 int nr_irqs; 78 unsigned long irq_flags; 79 uint32_t timeout_ms; 80 81 dma_addr_t iova_start; 82 dma_addr_t iova_stop; 83 84 int (*runtime_get)(struct mhi_controller *); 85 void (*runtime_put)(struct mhi_controller *); 86 void (*status_cb)(struct mhi_controller *, enum mhi_callback); 87 int (*read_reg)(struct mhi_controller *, void __iomem *, uint32_t *); 88 void (*write_reg)(struct mhi_controller *, void __iomem *, uint32_t); 89 }; 90 91 /* -------------------------------------------------------------------------- */ 92 93 struct mhi_controller *linuxkpi_mhi_alloc_controller(void); 94 void linuxkpi_mhi_free_controller(struct mhi_controller *); 95 int linuxkpi_mhi_register_controller(struct mhi_controller *, 96 struct mhi_controller_config *); 97 void linuxkpi_mhi_unregister_controller(struct mhi_controller *); 98 99 /* -------------------------------------------------------------------------- */ 100 101 static inline struct mhi_controller * 102 mhi_alloc_controller(void) 103 { 104 105 /* Keep allocations internal to our implementation. */ 106 return (linuxkpi_mhi_alloc_controller()); 107 } 108 109 static inline void 110 mhi_free_controller(struct mhi_controller *mhi_ctrl) 111 { 112 113 linuxkpi_mhi_free_controller(mhi_ctrl); 114 } 115 116 static inline int 117 mhi_register_controller(struct mhi_controller *mhi_ctrl, 118 struct mhi_controller_config *cfg) 119 { 120 121 return (linuxkpi_mhi_register_controller(mhi_ctrl, cfg)); 122 } 123 124 static inline void 125 mhi_unregister_controller(struct mhi_controller *mhi_ctrl) 126 { 127 128 linuxkpi_mhi_unregister_controller(mhi_ctrl); 129 } 130 131 /* -------------------------------------------------------------------------- */ 132 133 static __inline void 134 mhi_device_get_sync(struct mhi_device *mhi_dev) 135 { 136 /* XXX TODO */ 137 } 138 139 static __inline void 140 mhi_device_put(struct mhi_device *mhi_dev) 141 { 142 /* XXX TODO */ 143 } 144 145 /* -------------------------------------------------------------------------- */ 146 147 static __inline int 148 mhi_prepare_for_power_up(struct mhi_controller *mhi_ctrl) 149 { 150 /* XXX TODO */ 151 return (0); 152 } 153 154 static __inline int 155 mhi_async_power_up(struct mhi_controller *mhi_ctrl) 156 { 157 /* XXX TODO */ 158 return (0); 159 } 160 161 static __inline void 162 mhi_power_down(struct mhi_controller *mhi_ctrl, bool x) 163 { 164 /* XXX TODO */ 165 } 166 167 static __inline void 168 mhi_unprepare_after_power_down(struct mhi_controller *mhi_ctrl) 169 { 170 /* XXX TODO */ 171 } 172 173 /* -------------------------------------------------------------------------- */ 174 175 static __inline int 176 mhi_pm_suspend(struct mhi_controller *mhi_ctrl) 177 { 178 /* XXX TODO */ 179 return (0); 180 } 181 182 static __inline int 183 mhi_pm_resume_force(struct mhi_controller *mhi_ctrl) 184 { 185 /* XXX TODO */ 186 return (0); 187 } 188 189 /* -------------------------------------------------------------------------- */ 190 191 static __inline int 192 mhi_force_rddm_mode(struct mhi_controller *mhi_ctrl) 193 { 194 /* XXX TODO */ 195 return (0); 196 } 197 198 #endif /* _LINUXKPI_LINUX_MHI_H */ 199