xref: /OK3568_Linux_fs/kernel/include/linux/adb.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Definitions for ADB (Apple Desktop Bus) support.
4*4882a593Smuzhiyun  */
5*4882a593Smuzhiyun #ifndef __ADB_H
6*4882a593Smuzhiyun #define __ADB_H
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun #include <uapi/linux/adb.h>
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun struct adb_request {
12*4882a593Smuzhiyun 	unsigned char data[32];
13*4882a593Smuzhiyun 	int nbytes;
14*4882a593Smuzhiyun 	unsigned char reply[32];
15*4882a593Smuzhiyun 	int reply_len;
16*4882a593Smuzhiyun 	unsigned char reply_expected;
17*4882a593Smuzhiyun 	unsigned char sent;
18*4882a593Smuzhiyun 	unsigned char complete;
19*4882a593Smuzhiyun 	void (*done)(struct adb_request *);
20*4882a593Smuzhiyun 	void *arg;
21*4882a593Smuzhiyun 	struct adb_request *next;
22*4882a593Smuzhiyun };
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun struct adb_ids {
25*4882a593Smuzhiyun 	int nids;
26*4882a593Smuzhiyun 	unsigned char id[16];
27*4882a593Smuzhiyun };
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun /* Structure which encapsulates a low-level ADB driver */
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun struct adb_driver {
32*4882a593Smuzhiyun 	char name[16];
33*4882a593Smuzhiyun 	int (*probe)(void);
34*4882a593Smuzhiyun 	int (*init)(void);
35*4882a593Smuzhiyun 	int (*send_request)(struct adb_request *req, int sync);
36*4882a593Smuzhiyun 	int (*autopoll)(int devs);
37*4882a593Smuzhiyun 	void (*poll)(void);
38*4882a593Smuzhiyun 	int (*reset_bus)(void);
39*4882a593Smuzhiyun };
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun /* Values for adb_request flags */
42*4882a593Smuzhiyun #define ADBREQ_REPLY	1	/* expect reply */
43*4882a593Smuzhiyun #define ADBREQ_SYNC	2	/* poll until done */
44*4882a593Smuzhiyun #define ADBREQ_NOSEND	4	/* build the request, but don't send it */
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun /* Messages sent thru the client_list notifier. You should NOT stop
47*4882a593Smuzhiyun    the operation, at least not with this version */
48*4882a593Smuzhiyun enum adb_message {
49*4882a593Smuzhiyun     ADB_MSG_POWERDOWN,	/* Currently called before sleep only */
50*4882a593Smuzhiyun     ADB_MSG_PRE_RESET,	/* Called before resetting the bus */
51*4882a593Smuzhiyun     ADB_MSG_POST_RESET	/* Called after resetting the bus (re-do init & register) */
52*4882a593Smuzhiyun };
53*4882a593Smuzhiyun extern struct blocking_notifier_head adb_client_list;
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun int adb_request(struct adb_request *req, void (*done)(struct adb_request *),
56*4882a593Smuzhiyun 		int flags, int nbytes, ...);
57*4882a593Smuzhiyun int adb_register(int default_id,int handler_id,struct adb_ids *ids,
58*4882a593Smuzhiyun 		 void (*handler)(unsigned char *, int, int));
59*4882a593Smuzhiyun int adb_unregister(int index);
60*4882a593Smuzhiyun void adb_poll(void);
61*4882a593Smuzhiyun void adb_input(unsigned char *, int, int);
62*4882a593Smuzhiyun int adb_reset_bus(void);
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun int adb_try_handler_change(int address, int new_id);
65*4882a593Smuzhiyun int adb_get_infos(int address, int *original_address, int *handler_id);
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun #endif /* __ADB_H */
68