blob: c88d9cc466a10cc6629f9a19cd7bf5bf8b004608 [file] [log] [blame]
John Stultz5c69c8c2015-11-23 17:13:51 -08001/*
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 Stultz5c69c8c2015-11-23 17:13:51 -080029#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
72
73#define VERBOSE
74/*Debug logs*/
75#define UIM_ERR(fmt, arg...) printf("uim:"fmt"\n" , ##arg)
76#if defined(UIM_DEBUG) /* limited debug messages */
77#define UIM_START_FUNC() printf("uim: Inside %s", __FUNCTION__)
78#define UIM_DBG(fmt, arg...) printf("uim:"fmt"\n" , ## arg)
79#define UIM_VER(fmt, arg...)
80#elif defined(VERBOSE) /* very verbose */
81#define UIM_START_FUNC() printf("uim:@ %s\n", __FUNCTION__)
82#define UIM_DBG(fmt, arg...) printf("uim:"fmt"\n" , ## arg)
83#define UIM_VER(fmt, arg...) printf("uim:"fmt"\n" , ## arg)
84#else /* error msgs only */
85#define UIM_START_FUNC()
86#define UIM_DBG(fmt, arg...)
87#define UIM_VER(fmt, arg...)
88#endif
89
90/* HCI command header*/
91typedef struct {
92 uint16_t opcode; /* OCF & OGF */
93 uint8_t plen;
94} __attribute__ ((packed)) hci_command_hdr;
95
96/* HCI event header*/
97typedef struct {
98 uint8_t evt;
99 uint8_t plen;
100} __attribute__ ((packed)) hci_event_hdr;
101
102/* HCI command complete event*/
103typedef struct {
104 uint8_t ncmd;
105 uint16_t opcode;
106} __attribute__ ((packed)) evt_cmd_complete;
107
108/* HCI event status*/
109typedef struct {
110 uint8_t status;
111 uint8_t ncmd;
112 uint16_t opcode;
113} __attribute__ ((packed)) evt_cmd_status;
114
115/* HCI Event structure to set the cusrom baud rate*/
116typedef struct {
117 uint8_t uart_prefix;
118 hci_event_hdr hci_hdr;
119 evt_cmd_complete cmd_complete;
120 uint8_t status;
121 uint8_t data[16];
122} __attribute__ ((packed)) command_complete_t;
123
124/* HCI Command structure to set the cusrom baud rate*/
125typedef struct {
126 uint8_t uart_prefix;
127 hci_command_hdr hci_hdr;
128 uint32_t speed;
129} __attribute__ ((packed)) uim_speed_change_cmd;
130
131/* BD address structure to set the uim BD address*/
132typedef struct {
133 unsigned char b[6];
134} __attribute__((packed)) bdaddr_t;
135
136/* HCI Command structure to set the uim BD address*/
137typedef struct {
138 uint8_t uart_prefix;
139 hci_command_hdr hci_hdr;
140 bdaddr_t addr;
141} __attribute__ ((packed)) uim_bdaddr_change_cmd;\
142
143#endif /* UIM_H */