John Stultz | 5c69c8c | 2015-11-23 17:13:51 -0800 | [diff] [blame] | 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 | /* the line discipline ideally should be coming |
| 23 | * from tty.h |
| 24 | */ |
| 25 | #define N_TI_WL 22 |
| 26 | |
| 27 | /* Paramaters to set the baud rate*/ |
| 28 | #define FLOW_CTL 0x0001 |
John Stultz | 5c69c8c | 2015-11-23 17:13:51 -0800 | [diff] [blame] | 29 | #define ARM_NCCS 19 |
| 30 | |
| 31 | #ifndef TCGETS2 |
| 32 | #define TCGETS2 _IOR('T',0x2A, struct termios2) |
| 33 | #endif |
| 34 | #ifndef TCSETS2 |
| 35 | #define TCSETS2 _IOW('T',0x2B, struct termios2) |
| 36 | #endif |
| 37 | |
| 38 | /*HCI Command and Event information*/ |
| 39 | #define HCI_HDR_OPCODE 0xff36 |
| 40 | #define WRITE_BD_ADDR_OPCODE 0xFC06 |
| 41 | #define RESP_PREFIX 0x04 |
| 42 | #define MAX_TRY 10 |
| 43 | |
| 44 | /* HCI Packet types */ |
| 45 | #define HCI_COMMAND_PKT 0x01 |
| 46 | #define HCI_EVENT_PKT 0x04 |
| 47 | |
| 48 | /* HCI command macros*/ |
| 49 | #define HCI_EVENT_HDR_SIZE 2 |
| 50 | #define HCI_COMMAND_HDR_SIZE 3 |
| 51 | #define HCI_COMMAND_HDR_SIZE 3 |
| 52 | |
| 53 | /* HCI event macros*/ |
| 54 | #define EVT_CMD_COMPLETE_SIZE 3 |
| 55 | #define EVT_CMD_STATUS_SIZE 4 |
| 56 | #define EVT_CMD_COMPLETE 0x0E |
| 57 | #define EVT_CMD_STATUS 0x0F |
| 58 | |
| 59 | /* use it for string lengths and buffers */ |
| 60 | #define UART_DEV_NAME_LEN 32 |
| 61 | /* BD address length in format xx:xx:xx:xx:xx:xx */ |
| 62 | #define BD_ADDR_LEN 17 |
| 63 | |
| 64 | /* the sysfs entries with device configuration set by |
| 65 | * shared transport driver |
| 66 | */ |
| 67 | #define INSTALL_SYSFS_ENTRY "/sys/devices/platform/kim/install" |
| 68 | #define DEV_NAME_SYSFS "/sys/devices/platform/kim/dev_name" |
| 69 | #define BAUD_RATE_SYSFS "/sys/devices/platform/kim/baud_rate" |
| 70 | #define FLOW_CTRL_SYSFS "/sys/devices/platform/kim/flow_cntrl" |
| 71 | |
Dmitry Shmidt | 6cb9146 | 2017-05-11 16:22:30 -0700 | [diff] [blame] | 72 | #define INSTALL_SYSFS_ENTRY_OLD "/sys/devices/kim/install" |
| 73 | #define DEV_NAME_SYSFS_OLD "/sys/devices/kim/dev_name" |
| 74 | #define BAUD_RATE_SYSFS_OLD "/sys/devices/kim/baud_rate" |
| 75 | #define FLOW_CTRL_SYSFS_OLD "/sys/devices/kim/flow_cntrl" |
John Stultz | 5c69c8c | 2015-11-23 17:13:51 -0800 | [diff] [blame] | 76 | |
| 77 | #define VERBOSE |
| 78 | /*Debug logs*/ |
| 79 | #define UIM_ERR(fmt, arg...) printf("uim:"fmt"\n" , ##arg) |
| 80 | #if defined(UIM_DEBUG) /* limited debug messages */ |
| 81 | #define UIM_START_FUNC() printf("uim: Inside %s", __FUNCTION__) |
| 82 | #define UIM_DBG(fmt, arg...) printf("uim:"fmt"\n" , ## arg) |
| 83 | #define UIM_VER(fmt, arg...) |
| 84 | #elif defined(VERBOSE) /* very verbose */ |
| 85 | #define UIM_START_FUNC() printf("uim:@ %s\n", __FUNCTION__) |
| 86 | #define UIM_DBG(fmt, arg...) printf("uim:"fmt"\n" , ## arg) |
| 87 | #define UIM_VER(fmt, arg...) printf("uim:"fmt"\n" , ## arg) |
| 88 | #else /* error msgs only */ |
| 89 | #define UIM_START_FUNC() |
| 90 | #define UIM_DBG(fmt, arg...) |
| 91 | #define UIM_VER(fmt, arg...) |
| 92 | #endif |
| 93 | |
| 94 | /* HCI command header*/ |
| 95 | typedef struct { |
| 96 | uint16_t opcode; /* OCF & OGF */ |
| 97 | uint8_t plen; |
| 98 | } __attribute__ ((packed)) hci_command_hdr; |
| 99 | |
| 100 | /* HCI event header*/ |
| 101 | typedef struct { |
| 102 | uint8_t evt; |
| 103 | uint8_t plen; |
| 104 | } __attribute__ ((packed)) hci_event_hdr; |
| 105 | |
| 106 | /* HCI command complete event*/ |
| 107 | typedef struct { |
| 108 | uint8_t ncmd; |
| 109 | uint16_t opcode; |
| 110 | } __attribute__ ((packed)) evt_cmd_complete; |
| 111 | |
| 112 | /* HCI event status*/ |
| 113 | typedef struct { |
| 114 | uint8_t status; |
| 115 | uint8_t ncmd; |
| 116 | uint16_t opcode; |
| 117 | } __attribute__ ((packed)) evt_cmd_status; |
| 118 | |
| 119 | /* HCI Event structure to set the cusrom baud rate*/ |
| 120 | typedef struct { |
| 121 | uint8_t uart_prefix; |
| 122 | hci_event_hdr hci_hdr; |
| 123 | evt_cmd_complete cmd_complete; |
| 124 | uint8_t status; |
| 125 | uint8_t data[16]; |
| 126 | } __attribute__ ((packed)) command_complete_t; |
| 127 | |
| 128 | /* HCI Command structure to set the cusrom baud rate*/ |
| 129 | typedef struct { |
| 130 | uint8_t uart_prefix; |
| 131 | hci_command_hdr hci_hdr; |
| 132 | uint32_t speed; |
| 133 | } __attribute__ ((packed)) uim_speed_change_cmd; |
| 134 | |
| 135 | /* BD address structure to set the uim BD address*/ |
| 136 | typedef struct { |
| 137 | unsigned char b[6]; |
| 138 | } __attribute__((packed)) bdaddr_t; |
| 139 | |
| 140 | /* HCI Command structure to set the uim BD address*/ |
| 141 | typedef struct { |
| 142 | uint8_t uart_prefix; |
| 143 | hci_command_hdr hci_hdr; |
| 144 | bdaddr_t addr; |
| 145 | } __attribute__ ((packed)) uim_bdaddr_change_cmd;\ |
| 146 | |
| 147 | #endif /* UIM_H */ |