blob: 2f4c18db2625340ddfa574580d9e4a2c9229852a [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/*
2 * Copyright (C) 2008 HTC, Inc.
3 * Copyright (C) 2008 Google, Inc.
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
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 */
15
16#ifndef __ASM_ARCH_HTC_HEADSET_H
17#define __ASM_ARCH_HTC_HEADSET_H
18
19struct h2w_platform_data {
20 char *power_name;
21 int cable_in1;
22 int cable_in2;
23 int h2w_clk;
24 int h2w_data;
25 int debug_uart;
26 void (*config_cpld)(int);
27 void (*init_cpld)(void);
28 void (*set_dat)(int);
29 void (*set_clk)(int);
30 void (*set_dat_dir)(int);
31 void (*set_clk_dir)(int);
32 int (*get_dat)(void);
33 int (*get_clk)(void);
34};
35
36#define BIT_HEADSET (1 << 0)
37#define BIT_HEADSET_NO_MIC (1 << 1)
38#define BIT_TTY (1 << 2)
39#define BIT_FM_HEADSET (1 << 3)
40#define BIT_FM_SPEAKER (1 << 4)
41
42enum {
43 H2W_NO_DEVICE = 0,
44 H2W_HTC_HEADSET = 1,
45/* H2W_TTY_DEVICE = 2,*/
46 NORMAL_HEARPHONE= 2,
47 H2W_DEVICE = 3,
48 H2W_USB_CRADLE = 4,
49 H2W_UART_DEBUG = 5,
50};
51
52enum {
53 H2W_GPIO = 0,
54 H2W_UART1 = 1,
55 H2W_UART3 = 2,
56 H2W_BT = 3
57};
58
59#define RESEND_DELAY (3) /* ms */
60#define MAX_ACK_RESEND_TIMES (6) /* follow spec */
61#define MAX_HOST_RESEND_TIMES (3) /* follow spec */
62#define MAX_HYGEIA_RESEND_TIMES (5)
63
64#define H2W_ASCR_DEVICE_INI (0x01)
65#define H2W_ASCR_ACT_EN (0x02)
66#define H2W_ASCR_PHONE_IN (0x04)
67#define H2W_ASCR_RESET (0x08)
68#define H2W_ASCR_AUDIO_IN (0x10)
69
70#define H2W_LED_OFF (0x0)
71#define H2W_LED_BKL (0x1)
72#define H2W_LED_MTL (0x2)
73
74typedef enum {
75 /* === system group 0x0000~0x00FF === */
76 /* (R) Accessory type register */
77 H2W_SYSTEM = 0x0000,
78 /* (R) Maximum group address */
79 H2W_MAX_GP_ADD = 0x0001,
80 /* (R/W) Accessory system control register0 */
81 H2W_ASCR0 = 0x0002,
82
83 /* === key group 0x0100~0x01FF === */
84 /* (R) Key group maximum sub address */
85 H2W_KEY_MAXADD = 0x0100,
86 /* (R) ASCII key press down flag */
87 H2W_ASCII_DOWN = 0x0101,
88 /* (R) ASCII key release up flag */
89 H2W_ASCII_UP = 0x0102,
90 /* (R) Function key status flag */
91 H2W_FNKEY_UPDOWN = 0x0103,
92 /* (R/W) Key device status */
93 H2W_KD_STATUS = 0x0104,
94
95 /* === led group 0x0200~0x02FF === */
96 /* (R) LED group maximum sub address */
97 H2W_LED_MAXADD = 0x0200,
98 /* (R/W) LED control register0 */
99 H2W_LEDCT0 = 0x0201,
100
101 /* === crdl group 0x0300~0x03FF === */
102 /* (R) Cardle group maximum sub address */
103 H2W_CRDL_MAXADD = 0x0300,
104 /* (R/W) Cardle group function control register0 */
105 H2W_CRDLCT0 = 0x0301,
106
107 /* === car kit group 0x0400~0x04FF === */
108 H2W_CARKIT_MAXADD = 0x0400,
109
110 /* === usb host group 0x0500~0x05FF === */
111 H2W_USBHOST_MAXADD = 0x0500,
112
113 /* === medical group 0x0600~0x06FF === */
114 H2W_MED_MAXADD = 0x0600,
115 H2W_MED_CONTROL = 0x0601,
116 H2W_MED_IN_DATA = 0x0602,
117} H2W_ADDR;
118
119
120typedef struct H2W_INFO {
121 /* system group */
122 unsigned char CLK_SP;
123 int SLEEP_PR;
124 unsigned char HW_REV;
125 int AUDIO_DEVICE;
126 unsigned char ACC_CLASS;
127 unsigned char MAX_GP_ADD;
128
129 /* key group */
130 int KEY_MAXADD;
131 int ASCII_DOWN;
132 int ASCII_UP;
133 int FNKEY_UPDOWN;
134 int KD_STATUS;
135
136 /* led group */
137 int LED_MAXADD;
138 int LEDCT0;
139
140 /* medical group */
141 int MED_MAXADD;
142 unsigned char AP_ID;
143 unsigned char AP_EN;
144 unsigned char DATA_EN;
145} H2W_INFO;
146
147typedef enum {
148 H2W_500KHz = 1,
149 H2W_250KHz = 2,
150 H2W_166KHz = 3,
151 H2W_125KHz = 4,
152 H2W_100KHz = 5,
153 H2W_83KHz = 6,
154 H2W_71KHz = 7,
155 H2W_62KHz = 8,
156 H2W_55KHz = 9,
157 H2W_50KHz = 10,
158} H2W_SPEED;
159
160typedef enum {
161 H2W_KEY_INVALID = -1,
162 H2W_KEY_PLAY = 0,
163 H2W_KEY_FORWARD = 1,
164 H2W_KEY_BACKWARD = 2,
165 H2W_KEY_VOLUP = 3,
166 H2W_KEY_VOLDOWN = 4,
167 H2W_KEY_PICKUP = 5,
168 H2W_KEY_HANGUP = 6,
169 H2W_KEY_MUTE = 7,
170 H2W_KEY_HOLD = 8,
171 H2W_NUM_KEYFUNC = 9,
172} KEYFUNC;
173#endif