rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2005 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | /***************************************************************************** |
| 37 | * |
| 38 | * Filename: |
| 39 | * --------- |
| 40 | * usbc_custom.h |
| 41 | * |
| 42 | * Project: |
| 43 | * -------- |
| 44 | * MOLY |
| 45 | * |
| 46 | * Description: |
| 47 | * ------------ |
| 48 | * This file intends for usb customization parameter definition |
| 49 | * |
| 50 | * Author: |
| 51 | * ------- |
| 52 | * ------- |
| 53 | * |
| 54 | *============================================================================ |
| 55 | * HISTORY |
| 56 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 57 | *------------------------------------------------------------------------------ |
| 58 | * |
| 59 | *------------------------------------------------------------------------------ |
| 60 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 61 | *============================================================================ |
| 62 | ****************************************************************************/ |
| 63 | #ifndef _USBC_CUSTOM_H_ |
| 64 | #define _USBC_CUSTOM_H_ |
| 65 | |
| 66 | #include "usbc_custom_def.h" |
| 67 | #include "kal_general_types.h" |
| 68 | |
| 69 | /* |
| 70 | Sample Diagram to illustrate the combination of USB Dev Param |
| 71 | |
| 72 | USB Dev Param |
| 73 | | |
| 74 | |-- USB Mode 1 (MSD) |
| 75 | | | |
| 76 | | |-- USB Cfg1 |
| 77 | | | |
| 78 | | |-- USB class 1 (MS) |
| 79 | | |
| 80 | |-- USB Mode 2 |
| 81 | | ... |
| 82 | | |
| 83 | |-- USB Mode 3 |
| 84 | | | |
| 85 | | |-- USB Cfg 1 |
| 86 | | | | |
| 87 | | | |-- USB class 1 (MS) |
| 88 | | | | |
| 89 | | | |-- USB class 2 (ACM2) |
| 90 | | | | |
| 91 | | | |-- USB class 3 (RNDIS) |
| 92 | | | |
| 93 | | |-- USB Cfg 2 |
| 94 | | | |
| 95 | | |-- USB Cfg 3 |
| 96 | | |
| 97 | |-- USB Mode 4 |
| 98 | | |
| 99 | |-- USB Mode 5 |
| 100 | ... |
| 101 | |
| 102 | */ |
| 103 | |
| 104 | #define USB_MAX_CLASS_NUM 16 |
| 105 | #define USB_MAX_CFG_NUM 8 |
| 106 | |
| 107 | |
| 108 | typedef enum { |
| 109 | USB_OS_WIN8 = 0, |
| 110 | USB_OS_WIN, // non-win8 windows |
| 111 | USB_OS_LINUX, |
| 112 | USB_OS_MAC, |
| 113 | USB_OS_OTHERS, |
| 114 | |
| 115 | USB_OS_NUM |
| 116 | } usb_os_type_e; |
| 117 | |
| 118 | typedef enum { |
| 119 | USB_CLASS_MS = 0, |
| 120 | #ifdef __USB_ACM_SUPPORT__ |
| 121 | USB_CLASS_ACM1, /* 1T1R, 1 interface */ |
| 122 | USB_CLASS_ACM2, /* 2T1R, 2 interface, IAD */ |
| 123 | USB_CLASS_ACM3, /* 2T1R, 1 interface */ |
| 124 | #endif |
| 125 | #ifdef __USB_MBIM_SUPPORT__ |
| 126 | USB_CLASS_MBIM, |
| 127 | #endif |
| 128 | #ifdef __USB_RNDIS_SUPPORT__ |
| 129 | USB_CLASS_RNDIS, |
| 130 | #endif |
| 131 | #ifdef __USB_ECM_SUPPORT__ |
| 132 | USB_CLASS_ECM, |
| 133 | #endif |
| 134 | USB_CLASS_ADB, |
| 135 | USB_CLASS_NUM |
| 136 | } usb_class_type_e; |
| 137 | |
| 138 | typedef enum{ |
| 139 | USB_CLASS_OWNER_MD = 0, |
| 140 | USB_CLASS_OWNER_AP, |
| 141 | USB_CLASS_OWNER_NONE, |
| 142 | USB_CLASS_OWNER_NUM |
| 143 | }usb_class_owner_e; |
| 144 | |
| 145 | typedef enum{ |
| 146 | USB_NETWORK_CLASS_RNDIS = 0, |
| 147 | USB_NETWORK_CLASS_MBIM, |
| 148 | USB_NETWORK_CLASS_ECM, |
| 149 | USB_NETWORK_CLASS_MAX |
| 150 | }usb_network_class_type_e; |
| 151 | |
| 152 | // definition for double FIFO enabling of bulk endpoint |
| 153 | #define USB_CLASS_GET_DATA_IN_FIFO_N(n) (n & 0xf) |
| 154 | #define USB_CLASS_GET_DATA_OUT_FIFO_N(n) ((n & 0xf0) >> 4) |
| 155 | |
| 156 | #define USB_MODE_MORPHING_CFG1 1 |
| 157 | #define USB_MODE_MORPHING_CFG2 2 |
| 158 | |
| 159 | typedef struct { |
| 160 | kal_uint32 class_num; |
| 161 | usb_class_type_e class_type[USB_MAX_CLASS_NUM]; |
| 162 | /* device mapping for each function. ex. ACM->port, RNDIS/MBIM->network interface id */ |
| 163 | void *class_ctxt[USB_MAX_CLASS_NUM]; |
| 164 | |
| 165 | /* The 8-bit is used to describe the num of Bulk FIFO, [0...3]IN, [4..7]OUT. */ |
| 166 | kal_uint8 bulk_fifo_n[USB_MAX_CLASS_NUM]; |
| 167 | /*usb port ownership, 0 for modem, 1 for AP, ...*/ |
| 168 | usb_class_owner_e class_owner[USB_MAX_CLASS_NUM]; |
| 169 | } usb_cfg_param_t; |
| 170 | |
| 171 | typedef struct { |
| 172 | kal_uint16 vendor_id; /* idVendor */ |
| 173 | kal_uint16 product_id; /* idProduct */ |
| 174 | kal_uint8 device_class; /* bDeviceClass */ |
| 175 | kal_uint8 device_sub_class; /* bDeviceSubClass */ |
| 176 | kal_uint8 device_protocol; /* bDeviceProtocol */ |
| 177 | kal_uint8 cfg_num; |
| 178 | usb_cfg_param_t cfg_param[USB_MAX_CFG_NUM]; |
| 179 | usb_mode_owner_e mode_owner; |
| 180 | kal_uint32 mode_index; |
| 181 | } usb_mode_param_t; |
| 182 | |
| 183 | /* custom parameter for usb device */ |
| 184 | typedef struct { |
| 185 | kal_uint16 bcd_device; /* bcdDevice */ |
| 186 | kal_uint16 *manufacture_string; |
| 187 | kal_uint8 manufacture_string_size; |
| 188 | kal_uint16 *product_string; |
| 189 | kal_uint8 product_string_size; |
| 190 | kal_uint16 *serial_number; |
| 191 | kal_uint8 serial_number_size; |
| 192 | kal_uint8 morphing_sub_id; |
| 193 | usb_mode_param_t mode_param[USB_MODE_MAX]; |
| 194 | /* USB Mode which each USB OS corresponds to */ |
| 195 | usb_mode_e usb_mode[USB_OS_NUM]; |
| 196 | } usb_dev_param_t; |
| 197 | |
| 198 | typedef struct { |
| 199 | usb_class_type_e class_type; |
| 200 | kal_uint32 uart_port; |
| 201 | kal_uint32 bulk_fifo_n; |
| 202 | usb_class_owner_e class_owner; |
| 203 | } usb_current_cfg_param_t; |
| 204 | |
| 205 | /* custom parameter for each class type */ |
| 206 | typedef struct |
| 207 | { |
| 208 | kal_uint16 *interface_string; |
| 209 | kal_uint8 interface_string_size; |
| 210 | } usb_class_acm1_param_t; |
| 211 | |
| 212 | typedef struct |
| 213 | { |
| 214 | kal_uint16 *comm_interface_string; |
| 215 | kal_uint8 comm_interface_string_size; |
| 216 | kal_uint16 *data_interface_string; |
| 217 | kal_uint8 data_interface_string_size; |
| 218 | kal_uint16 *iad_string; |
| 219 | kal_uint8 iad_string_size; |
| 220 | } usb_class_acm2_param_t; |
| 221 | |
| 222 | typedef struct |
| 223 | { |
| 224 | kal_uint16 *interface_string; |
| 225 | kal_uint8 interface_string_size; |
| 226 | } usb_class_acm3_param_t; |
| 227 | |
| 228 | typedef struct |
| 229 | { |
| 230 | kal_uint16 *comm_interface_string; |
| 231 | kal_uint8 comm_interface_string_size; |
| 232 | kal_uint16 *null_data_interface_string; |
| 233 | kal_uint8 null_data_interface_string_size; |
| 234 | kal_uint16 *data_interface_string; |
| 235 | kal_uint8 data_interface_string_size; |
| 236 | kal_uint16 *iad_string; |
| 237 | kal_uint8 iad_string_size; |
| 238 | } usb_class_mbim_param_t; |
| 239 | |
| 240 | typedef struct |
| 241 | { |
| 242 | kal_uint16 *comm_interface_string; |
| 243 | kal_uint8 comm_interface_string_size; |
| 244 | kal_uint16 *data_interface_string; |
| 245 | kal_uint8 data_interface_string_size; |
| 246 | kal_uint16 *iad_string; |
| 247 | kal_uint8 iad_string_size; |
| 248 | } usb_class_rndis_param_t; |
| 249 | |
| 250 | typedef struct |
| 251 | { |
| 252 | kal_uint16 *comm_interface_string; |
| 253 | kal_uint8 comm_interface_string_size; |
| 254 | kal_uint16 *null_data_interface_string; |
| 255 | kal_uint8 null_data_interface_string_size; |
| 256 | kal_uint16 *data_interface_string; |
| 257 | kal_uint8 data_interface_string_size; |
| 258 | kal_uint16 *iad_string; |
| 259 | kal_uint8 iad_string_size; |
| 260 | kal_uint16 *mac_addr_string[3];// max is 3 |
| 261 | kal_uint8 mac_addr_string_size[3];// max is 3 |
| 262 | } usb_class_ecm_param_t; |
| 263 | |
| 264 | typedef struct |
| 265 | { |
| 266 | kal_uint16 *interface_string; |
| 267 | kal_uint8 interface_string_size; |
| 268 | } usb_class_adb_param_t; |
| 269 | |
| 270 | typedef struct |
| 271 | { |
| 272 | kal_uint16 *interface_string; |
| 273 | kal_uint8 interface_string_size; |
| 274 | } usb_class_ms_param_t; |
| 275 | |
| 276 | #if 0 |
| 277 | /* under construction !*/ |
| 278 | /* under construction !*/ |
| 279 | /* under construction !*/ |
| 280 | /* under construction !*/ |
| 281 | /* under construction !*/ |
| 282 | /* under construction !*/ |
| 283 | /* under construction !*/ |
| 284 | /* under construction !*/ |
| 285 | /* under construction !*/ |
| 286 | /* under construction !*/ |
| 287 | /* under construction !*/ |
| 288 | /* under construction !*/ |
| 289 | /* under construction !*/ |
| 290 | /* under construction !*/ |
| 291 | /* under construction !*/ |
| 292 | /* under construction !*/ |
| 293 | /* under construction !*/ |
| 294 | /* under construction !*/ |
| 295 | #endif |
| 296 | |
| 297 | /* get parameter function pointer */ |
| 298 | typedef const usb_dev_param_t* (*usb_get_device_param_f)(void); |
| 299 | |
| 300 | #if 0 |
| 301 | /* under construction !*/ |
| 302 | #endif |
| 303 | typedef const usb_class_ms_param_t* (*usb_get_ms_param_f)(void); |
| 304 | |
| 305 | typedef const usb_class_acm1_param_t* (*usb_get_acm1_param_f)(void); |
| 306 | typedef const usb_class_acm2_param_t* (*usb_get_acm2_param_f)(void); |
| 307 | typedef const usb_class_acm3_param_t* (*usb_get_acm3_param_f)(void); |
| 308 | typedef const usb_class_mbim_param_t* (*usb_get_mbim_param_f)(void); |
| 309 | typedef const usb_class_rndis_param_t* (*usb_get_rndis_param_f)(void); |
| 310 | typedef const usb_class_ecm_param_t* (*usb_get_ecm_param_f)(void); |
| 311 | typedef const usb_class_adb_param_t* (*usb_get_adb_param_f)(void); |
| 312 | |
| 313 | /* get parameter functions*/ |
| 314 | typedef struct |
| 315 | { |
| 316 | usb_get_device_param_f get_device_param_func; |
| 317 | usb_get_ms_param_f get_ms_param_func; |
| 318 | usb_get_acm1_param_f get_acm1_param_func; |
| 319 | usb_get_acm2_param_f get_acm2_param_func; |
| 320 | usb_get_acm3_param_f get_acm3_param_func; |
| 321 | usb_get_mbim_param_f get_mbim_param_func; |
| 322 | usb_get_rndis_param_f get_rndis_param_func; |
| 323 | usb_get_ecm_param_f get_ecm_param_func; |
| 324 | usb_get_adb_param_f get_adb_param_func; |
| 325 | } usb_custom_func_t; |
| 326 | |
| 327 | |
| 328 | extern const usb_custom_func_t* usb_get_custom_func(void); |
| 329 | void usb_register_mode_param(usb_mode_param_t *mode_param); |
| 330 | void usb_replace_mode_param(usb_mode_param_t *mode_param, kal_uint8 index); |
| 331 | void usb_mode_qeznk_register(); |
| 332 | void usb_mode_inusj_register(); |
| 333 | void usb_mode_ufpm_register(); |
| 334 | void usb_mode_base_register(); |
| 335 | void usb_mode_customization_register(); |
| 336 | void usb_mode_replace_metadbg_mode(kal_uint8 index); |
| 337 | void usb_mode_factory_register(); |
| 338 | kal_uint16 usb_get_factory_mode_pid(); |
| 339 | kal_bool usb_get_factory_mode_support(); |
| 340 | usb_network_class_type_e usbc_get_network_type(); |
| 341 | |
| 342 | |
| 343 | #endif /* _USBC_CUSTOM_H_ */ |
| 344 | |