1/* 2 * Definitions for ADB (Apple Desktop Bus) support. 3 */ 4#ifndef __ADB_H 5#define __ADB_H 6 7/* ADB commands */ 8#define ADB_BUSRESET 0 9#define ADB_FLUSH(id) (0x01 | ((id) << 4)) 10#define ADB_WRITEREG(id, reg) (0x08 | (reg) | ((id) << 4)) 11#define ADB_READREG(id, reg) (0x0C | (reg) | ((id) << 4)) 12 13/* ADB default device IDs (upper 4 bits of ADB command byte) */ 14#define ADB_DONGLE 1 /* "software execution control" devices */ 15#define ADB_KEYBOARD 2 16#define ADB_MOUSE 3 17#define ADB_TABLET 4 18#define ADB_MODEM 5 19#define ADB_MISC 7 /* maybe a monitor */ 20 21#define ADB_RET_OK 0 22#define ADB_RET_TIMEOUT 3 23 24/* The kind of ADB request. The controller may emulate some 25 or all of those CUDA/PMU packet kinds */ 26#define ADB_PACKET 0 27#define CUDA_PACKET 1 28#define ERROR_PACKET 2 29#define TIMER_PACKET 3 30#define POWER_PACKET 4 31#define MACIIC_PACKET 5 32#define PMU_PACKET 6 33 34#ifdef __KERNEL__ 35 36struct adb_request { 37 unsigned char data[32]; 38 int nbytes; 39 unsigned char reply[32]; 40 int reply_len; 41 unsigned char reply_expected; 42 unsigned char sent; 43 unsigned char complete; 44 void (*done)(struct adb_request *); 45 void *arg; 46 struct adb_request *next; 47}; 48 49struct adb_ids { 50 int nids; 51 unsigned char id[16]; 52}; 53 54/* Structure which encapsulates a low-level ADB driver */ 55 56struct adb_driver { 57 char name[16]; 58 int (*probe)(void); 59 int (*init)(void); 60 int (*send_request)(struct adb_request *req, int sync); 61 int (*autopoll)(int devs); 62 void (*poll)(void); 63 int (*reset_bus)(void); 64}; 65 66/* Values for adb_request flags */ 67#define ADBREQ_REPLY 1 /* expect reply */ 68#define ADBREQ_SYNC 2 /* poll until done */ 69#define ADBREQ_NOSEND 4 /* build the request, but don't send it */ 70 71/* Messages sent thru the client_list notifier. You should NOT stop 72 the operation, at least not with this version */ 73enum adb_message { 74 ADB_MSG_POWERDOWN, /* Currently called before sleep only */ 75 ADB_MSG_PRE_RESET, /* Called before resetting the bus */ 76 ADB_MSG_POST_RESET /* Called after resetting the bus (re-do init & register) */ 77}; 78extern struct adb_driver *adb_controller; 79extern struct notifier_block *adb_client_list; 80 81int adb_request(struct adb_request *req, void (*done)(struct adb_request *), 82 int flags, int nbytes, ...); 83int adb_register(int default_id,int handler_id,struct adb_ids *ids, 84 void (*handler)(unsigned char *, int, struct pt_regs *, int)); 85int adb_unregister(int index); 86void adb_poll(void); 87void adb_input(unsigned char *, int, struct pt_regs *, int); 88int adb_reset_bus(void); 89 90int adb_try_handler_change(int address, int new_id); 91int adb_get_infos(int address, int *original_address, int *handler_id); 92 93#endif /* __KERNEL__ */ 94 95#endif /* __ADB_H */ 96