1 /* 2 * User Mode Init manager - For shared transport 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program;if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 */ 18 19 #ifndef UIM_H 20 #define UIM_H 21 22 /* Paramaters to set the baud rate*/ 23 #define FLOW_CTL 0x0001 24 #define BOTHER 0x00001000 25 #define ARM_NCCS 19 26 27 #define TCGETS2 _IOR('T',0x2A, struct termios2) 28 #define TCSETS2 _IOW('T',0x2B, struct termios2) 29 30 /*HCI Command and Event information*/ 31 #define HCI_HDR_OPCODE 0xff36 32 #define WRITE_BD_ADDR_OPCODE 0xFC06 33 #define RESP_PREFIX 0x04 34 #define MAX_TRY 10 35 36 /* HCI Packet types */ 37 #define HCI_COMMAND_PKT 0x01 38 #define HCI_EVENT_PKT 0x04 39 40 /* HCI command macros*/ 41 #define HCI_EVENT_HDR_SIZE 2 42 #define HCI_COMMAND_HDR_SIZE 3 43 #define UIM_WRITE_BD_ADDR_CP_SIZE 6 44 45 46 /* HCI event macros*/ 47 #define EVT_CMD_COMPLETE_SIZE 3 48 #define EVT_CMD_STATUS_SIZE 4 49 #define EVT_CMD_COMPLETE 0x0E 50 #define EVT_CMD_STATUS 0x0F 51 52 53 #define VERBOSE 54 #ifdef ANDROID 55 #define LOG_TAG "uim-sysfs" 56 #define UIM_ERR(fmt, arg...) ALOGE("uim:"fmt"\n" , ##arg) 57 #if defined(UIM_DEBUG) /* limited debug messages */ 58 #define UIM_START_FUNC() ALOGE("uim: Inside %s", __FUNCTION__) 59 #define UIM_DBG(fmt, arg...) ALOGE("uim:"fmt"\n" , ## arg) 60 #define UIM_VER(fmt, arg...) 61 #elif defined(VERBOSE) /* very verbose */ 62 #define UIM_START_FUNC() ALOGE("uim: Inside %s", __FUNCTION__) 63 #define UIM_DBG(fmt, arg...) ALOGE("uim:"fmt"\n" , ## arg) 64 #define UIM_VER(fmt, arg...) ALOGE("uim:"fmt"\n" , ## arg) 65 #else /* error msgs only */ 66 #define UIM_START_FUNC() 67 #define UIM_DBG(fmt, arg...) 68 #define UIM_VER(fmt, arg...) 69 #endif 70 #endif /* ANDROID */ 71 72 /*Termios2 structure for setting the Custom baud rate*/ 73 struct termios2 { 74 tcflag_t c_iflag; /* input mode flags */ 75 tcflag_t c_oflag; /* output mode flags */ 76 tcflag_t c_cflag; /* control mode flags */ 77 tcflag_t c_lflag; /* local mode flags */ 78 cc_t c_line; /* line discipline */ 79 cc_t c_cc[ARM_NCCS]; /* control characters */ 80 speed_t c_ispeed; /* input speed */ 81 speed_t c_ospeed; /* output speed */ 82 }; 83 84 /* HCI command header*/ 85 typedef struct { 86 uint16_t opcode; /* OCF & OGF */ 87 uint8_t plen; 88 } __attribute__ ((packed)) hci_command_hdr; 89 90 /* HCI event header*/ 91 typedef struct { 92 uint8_t evt; 93 uint8_t plen; 94 } __attribute__ ((packed)) hci_event_hdr; 95 96 /* HCI command complete event*/ 97 typedef struct { 98 uint8_t ncmd; 99 uint16_t opcode; 100 } __attribute__ ((packed)) evt_cmd_complete; 101 102 /* HCI event status*/ 103 typedef struct { 104 uint8_t status; 105 uint8_t ncmd; 106 uint16_t opcode; 107 } __attribute__ ((packed)) evt_cmd_status; 108 109 /* HCI Event structure to set the cusrom baud rate*/ 110 typedef struct { 111 uint8_t uart_prefix; 112 hci_event_hdr hci_hdr; 113 evt_cmd_complete cmd_complete; 114 uint8_t status; 115 uint8_t data[16]; 116 } __attribute__ ((packed)) command_complete_t; 117 118 /* HCI Command structure to set the cusrom baud rate*/ 119 typedef struct { 120 uint8_t uart_prefix; 121 hci_command_hdr hci_hdr; 122 uint32_t speed; 123 } __attribute__ ((packed)) uim_speed_change_cmd; 124 125 /* BD address structure to set the uim BD address*/ 126 typedef struct { 127 unsigned char b[6]; 128 } __attribute__((packed)) bdaddr_t; 129 130 /* HCI Command structure to set the uim BD address*/ 131 typedef struct { 132 uint8_t uart_prefix; 133 hci_command_hdr hci_hdr; 134 bdaddr_t addr; 135 } __attribute__ ((packed)) uim_bdaddr_change_cmd; 136 137 #define INSTALL_SYSFS_ENTRY "/sys/devices/platform/kim/install" 138 #define DEV_NAME_SYSFS "/sys/devices/platform/kim/dev_name" 139 #define BAUD_RATE_SYSFS "/sys/devices/platform/kim/baud_rate" 140 #define FLOW_CTRL_SYSFS "/sys/devices/platform/kim/flow_cntrl" 141 142 /* Functions to insert and remove the kernel modules from the system*/ 143 extern int init_module(void *, unsigned int, const char *); 144 extern int delete_module(const char *, unsigned int); 145 extern int load_file(const char *, unsigned int *); 146 147 #endif /* UIM_H */ 148