1 /* 2 * Copyright (C) 2009/2010 Motorola Inc. 3 * All Rights Reserved. 4 * Motorola Confidential Restricted. 5 */ 6 7 8 #ifndef MASTERCLEAR_BP_H_ 9 #define MASTERCLEAR_BP_H_ 10 11 #define CMD_ENGINE_FD_NOT_INIT -1 12 #define CMD_ENGINE_DEVICE "/dev/ttyUSB3" 13 /* Number of times to try to connect to aux engine */ 14 #define CMD_ENGINE_CONNECT_MAX_TRY 30 15 /* Delay between each aux engine connect try, in microseconds */ 16 #define CMD_ENGINE_CONNECT_TRY_DELAY 1000000 17 #define CMD_CMN_DRV_BP_MASTERCLEAR_OPCODE 0x0012 18 #define CMD_BP_MASTER_CLEAR 0x01 19 #define CMD_BP_MASTER_RESET 0x00 20 #define CMD_BP_MASTER_RESET_DATALENTH 0x01 21 22 #define MDM_CTRL_DEVICE "/sys/class/radio/mdm6600/command" 23 #define MDM_CMD_SHUTDONW "shutdown" 24 #define MDM_CMD_POWERUP "powerup" 25 #define MDM_CMD_FLASH_MODE "bootmode_flash" 26 #define MDM_CMD_NORMAL_MODE "bootmode_normal" 27 28 #define CMD_DEFS_RSP_FLAG_FAIL 0x04 29 #define TC_DBG_MAX_DUMP_COLS 16 30 /* CMD header values */ 31 #define CMD_DEFS_HDR_FLAG_CMD_RSP_COMMAND 0 /**< Header indicates a command */ 32 #define CMD_DEFS_HDR_FLAG_CMD_RSP_RESPONSE 1 /**< Header indicates a response */ 33 34 #define CMD_DEFS_HDR_FLAG_RESPONSE_EXPECTED 0 /**< Header indicates a response is expected */ 35 #define CMD_DEFS_HDR_FLAG_RESPONSE_NOT_EXPECTED 1 /**< Header indicates a response is not expected */ 36 37 #define CMD_DEFS_HDR_FLAG_RESPONSE_SOLICITED 0 /**< Header indicates a solicited response */ 38 #define CMD_DEFS_HDR_FLAG_RESPONSE_UNSOLICITED 1 /**< Header indicates a unsolicited response */ 39 40 #define CMD_DEFS_HDR_FLAG_DATA_NOT_PRESENT 0 /**< Header indicates response data present */ 41 #define CMD_DEFS_HDR_FLAG_DATA_PRESENT 1 /**< Header indicates no response data present */ 42 43 #define CMD_DEFS_HDR_FLAG_CMD_NOT_FAILED 0 /**< Header indicates command did not fail */ 44 #define CMD_DEFS_HDR_FLAG_CMD_FAILED 1 /**< Header indicates command failed */ 45 46 #define CMD_DBG_MAX_DUMP_COLS 16 47 48 #define CMD_DEFS_OPCODE_T UINT16 49 50 #ifndef TRUE 51 #define TRUE 1 52 #define FALSE 0 53 #endif 54 55 56 static const char *USB1_SETUP_FILE = "/sys/bus/usb/devices/usb2/power/control"; 57 static const char setup_cmd[] = "on"; 58 59 typedef unsigned char UINT8; /**< Unsigned 8 bit integer */ 60 typedef signed char INT8; /**< Signed 8 bit integer */ 61 typedef unsigned short int UINT16; /**< Unsigned 16 bit integer */ 62 typedef signed short int INT16; /**< Signed 16 bit integer */ 63 typedef unsigned int UINT32; /**< Unsigned 32 bit integer */ 64 typedef signed int INT32; /**< Signed 32 bit integer */ 65 typedef signed long long INT64; /**< Signed 64 bit integer */ 66 typedef unsigned long long UINT64; /**< Unsigned 64 bit integer */ 67 typedef unsigned char BOOLEAN; /**< Boolean type */ 68 typedef BOOLEAN BOOL; /**< Boolean type */ 69 typedef unsigned short W_CHAR; /**< Wide char */ 70 71 typedef enum 72 { 73 CMD_RSP_CODE_PAR_ERR_LENGTH = 0x00, /**< Parser length error */ 74 CMD_RSP_CODE_PAR_ERR_SECUR = 0x01, /**< Parser security error */ 75 CMD_RSP_CODE_PAR_ERR_PROT = 0x02, /**< Parser protocol error */ 76 CMD_RSP_CODE_PAR_ERR_MODE = 0x03, /**< Parser mode error */ 77 CMD_RSP_CODE_PAR_ERR_OPCODE = 0x04, /**< Parser opcode error */ 78 CMD_RSP_CODE_PAR_ERR_PARM = 0x05, /**< Parser parameter error */ 79 CMD_RSP_CODE_CMD_RSP_GENERIC = 0x06, /**< Generic Response */ 80 CMD_RSP_CODE_CMD_RSP_GEN_FAIL = 0x07, /**< General failure */ 81 CMD_RSP_CODE_CMD_MALLOC_FAIL = 0x0A, /**< Error allocating memory */ 82 CMD_RSP_CODE_CMD_INTL_ERR = 0x0B, /**< Tcmd internal error */ 83 CMD_RSP_CODE_CMD_RSP_TIMEOUT = 0x0C, /**< Timeout error */ 84 CMD_RSP_CODE_CMD_PAR_ERR_SUBMODE = 0x0D, /**< Parser submode error */ 85 CMD_RSP_CODE_CMD_TRANS_LEN_ERR = 0x0E, /**< Transport length error */ 86 CMD_RSP_CODE_CMD_RSP_IRRE_ERR = 0x0F, /**< Irrecoverable error */ 87 CMD_RSP_CODE_CMD_RSP_MUX_ERR = 0x11, /**< Open mux channel error */ 88 89 CMD_RSP_CODE_ASCII_ERR_LENGTH = 0x80, /**< ASCII length error */ 90 CMD_RSP_CODE_ASCII_ERR_MODE = 0x83, /**< ASCII mode error */ 91 CMD_RSP_CODE_ASCII_ERR_OPCODE = 0x84, /**< ASCII opcode error */ 92 CMD_RSP_CODE_ASCII_ERR_PARM = 0x85, /**< ASCII parameter error */ 93 CMD_RSP_CODE_ASCII_RSP_GEN_FAIL = 0x87, /**< ASCII Generic Failure */ 94 CMD_RSP_CODE_ASCII_MALLOC_FAIL = 0x8A, /**< ASCII allocating memory error */ 95 CMD_RSP_CODE_ASCII_RSP_TIMEOUT = 0x8C, /**< ASCII timeout error */ 96 CMD_RSP_CODE_ASCII_RSP_MUX_ERR = 0x91, /**< ASCII mux channel error */ 97 98 /** Add all new standard response codes before CMD_RSP_CODE_NOT_SET */ 99 CMD_RSP_CODE_NOT_SET 100 } CMD_RSP_CODE_T; 101 102 static int cmd_engine_fd = CMD_ENGINE_FD_NOT_INIT; /**< Handle to the aux engine */ 103 104 typedef enum 105 { 106 CMD_ENGINE_INIT_SUCCESS = 0, 107 CMD_ENGINE_INIT_FAIL = 1, 108 CMD_ENGINE_INIT_NOT_PRESENT = 2 109 } CMD_ENGINE_INIT_T; 110 /** The Command Protocol Header (Bulk Endpoint/12 byte) - Request Header */ 111 typedef struct 112 { 113 UINT8 reserved1 : 7; /**< Reserved */ 114 UINT8 cmd_rsp_flag : 1; /**< Command/Response Flag */ 115 UINT8 seq_tag; /**< Sequence Tag */ 116 CMD_DEFS_OPCODE_T opcode; /**< Opcode */ 117 UINT8 reserved2; /**< Reserved */ 118 UINT8 no_rsp_reqd_flag : 1; /**< No Response Required Flag */ 119 UINT8 reserved3 : 7; /**< Reserved */ 120 UINT16 reserved4; /**< Reserved */ 121 UINT32 length; /**< Data Length of Request */ 122 } CMD_DEFS_CMD_REQ_HDR_T; 123 124 /** The Command Protocol Header (Bulk Endpoint/12 byte) - Response Header */ 125 typedef struct 126 { 127 UINT8 unsol_rsp_flag : 1; /**< Unsolicited Response Flag */ 128 UINT8 data_flag : 1; /**< Response Data Flag */ 129 UINT8 fail_flag : 1; /**< Fail Flag */ 130 UINT8 cmd_version : 4; /**< CMD Version Number */ 131 UINT8 cmd_rsp_flag : 1; /**< Command/Response Flag */ 132 UINT8 seq_tag; /**< Sequence Tag */ 133 CMD_DEFS_OPCODE_T opcode; /**< Opcode */ 134 UINT8 reserved1; /**< Reserved */ 135 UINT8 rsp_code; /**< Response Code. For real */ 136 UINT16 reserved2; /**< Reserved */ 137 UINT32 length; /**< Data Length of Response */ 138 139 } CMD_DEFS_CMD_RSP_HDR_T; 140 141 /* 142 * BP master clear 143 * BP master clear 144 * Parameters: 145 * none 146 * Return code: 147 * 0 - BP master clear successfully 148 * other - error code 149 */ 150 151 int bp_master_clear(void); 152 153 154 #endif 155