Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Definitions for talking to ADB and CUDA. The CUDA is a microcontroller |
| 3 | * which controls the ADB, system power, RTC, and various other things on |
| 4 | * later Macintoshes |
| 5 | * |
| 6 | * Copyright (C) 1996 Paul Mackerras. |
| 7 | */ |
| 8 | |
| 9 | /* First byte sent to or received from CUDA */ |
| 10 | #define ADB_PACKET 0 |
| 11 | #define CUDA_PACKET 1 |
| 12 | #define ERROR_PACKET 2 |
| 13 | #define TIMER_PACKET 3 |
| 14 | #define POWER_PACKET 4 |
| 15 | #define MACIIC_PACKET 5 |
| 16 | |
| 17 | /* ADB commands (2nd byte) */ |
| 18 | #define ADB_BUSRESET 0 |
| 19 | #define ADB_FLUSH(id) (1 + ((id) << 4)) |
| 20 | #define ADB_WRITEREG(id, reg) (8 + (reg) + ((id) << 4)) |
| 21 | #define ADB_READREG(id, reg) (0xc + (reg) + ((id) << 4)) |
| 22 | |
| 23 | /* ADB default device IDs (upper 4 bits of 2nd byte) */ |
| 24 | #define ADB_DONGLE 1 /* "software execution control" devices */ |
| 25 | #define ADB_KEYBOARD 2 |
| 26 | #define ADB_MOUSE 3 |
| 27 | #define ADB_TABLET 4 |
| 28 | #define ADB_MODEM 5 |
| 29 | #define ADB_MISC 7 /* maybe a monitor */ |
| 30 | |
| 31 | /* CUDA commands (2nd byte) */ |
| 32 | #define CUDA_WARM_START 0 |
| 33 | #define CUDA_AUTOPOLL 1 |
| 34 | #define CUDA_GET_6805_ADDR 2 |
| 35 | #define CUDA_GET_TIME 3 |
| 36 | #define CUDA_GET_PRAM 7 |
| 37 | #define CUDA_SET_6805_ADDR 8 |
| 38 | #define CUDA_SET_TIME 9 |
| 39 | #define CUDA_POWERDOWN 0xa |
| 40 | #define CUDA_POWERUP_TIME 0xb |
| 41 | #define CUDA_SET_PRAM 0xc |
| 42 | #define CUDA_MS_RESET 0xd |
| 43 | #define CUDA_SEND_DFAC 0xe |
| 44 | #define CUDA_RESET_SYSTEM 0x11 |
| 45 | #define CUDA_SET_IPL 0x12 |
| 46 | #define CUDA_SET_AUTO_RATE 0x14 |
| 47 | #define CUDA_GET_AUTO_RATE 0x16 |
| 48 | #define CUDA_SET_DEVICE_LIST 0x19 |
| 49 | #define CUDA_GET_DEVICE_LIST 0x1a |
| 50 | #define CUDA_GET_SET_IIC 0x22 |
| 51 | |
| 52 | #ifdef __KERNEL__ |
| 53 | |
| 54 | struct adb_request { |
| 55 | unsigned char data[16]; |
| 56 | int nbytes; |
| 57 | unsigned char reply[16]; |
| 58 | int reply_len; |
| 59 | unsigned char reply_expected; |
| 60 | unsigned char sent; |
| 61 | unsigned char got_reply; |
| 62 | void (*done)(struct adb_request *); |
| 63 | void *arg; |
| 64 | struct adb_request *next; |
| 65 | }; |
| 66 | |
| 67 | void via_adb_init(void); |
| 68 | int adb_request(struct adb_request *req, |
| 69 | void (*done)(struct adb_request *), int nbytes, ...); |
| 70 | int adb_send_request(struct adb_request *req); |
| 71 | void adb_poll(void); |
| 72 | int adb_register(int default_id, |
| 73 | void (*handler)(unsigned char *, int, struct pt_regs *)); |
| 74 | |
| 75 | #endif /* __KERNEL */ |