ppc64: Don't set Kp bit on SLB
[openbios/afaerber.git] / drivers / adb_bus.h
blob205b375369a764d597af7ffb7c89c026a111e888
1 /*
2 * ADB bus definitions for Open Hack'Ware
4 * Copyright (c) 2004-2005 Jocelyn Mayer
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License V2
8 * as published by the Free Software Foundation
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
20 typedef struct adb_bus_t adb_bus_t;
21 typedef struct adb_dev_t adb_dev_t;
23 #define ADB_BUF_SIZE 8
24 struct adb_bus_t {
25 void *host;
26 int (*req)(void *host, const uint8_t *snd_buf, int len, uint8_t *rcv_buf);
27 adb_dev_t *devices;
30 struct adb_dev_t {
31 adb_dev_t *next;
32 adb_bus_t *bus;
33 uint8_t addr;
34 uint8_t type;
35 void *state;
38 #define ADB_BUF_SIZE 8
40 /* ADB commands */
41 enum {
42 ADB_SEND_RESET = 0x00,
43 ADB_FLUSH = 0x01,
44 ADB_LISTEN = 0x08,
45 ADB_TALK = 0x0C,
47 /* ADB default IDs before relocation */
48 enum {
49 ADB_PROTECT = 0x01,
50 ADB_KEYBD = 0x02,
51 ADB_MOUSE = 0x03,
52 ADB_ABS = 0x04,
53 ADB_MODEM = 0x05,
54 ADB_RES = 0x06,
55 ADB_MISC = 0x07,
57 /* ADB special device handlers IDs */
58 enum {
59 ADB_CHADDR = 0x00,
60 ADB_CHADDR_ACTIV = 0xFD,
61 ADB_CHADDR_NOCOLL = 0xFE,
62 ADB_SELF_TEST = 0xFF,
65 int adb_cmd (adb_dev_t *dev, uint8_t cmd, uint8_t reg,
66 uint8_t *buf, int len);
67 void adb_bus_reset (adb_bus_t *bus);
68 adb_bus_t *adb_bus_new (void *host,
69 int (*req)(void *host, const uint8_t *snd_buf,
70 int len, uint8_t *rcv_buf));
71 int adb_bus_init (char *path, adb_bus_t *bus);
73 static inline int adb_reset (adb_bus_t *bus)
75 adb_dev_t fake_device;
77 memset(&fake_device, 0, sizeof(adb_dev_t));
78 fake_device.bus = bus;
80 return adb_cmd(&fake_device, ADB_SEND_RESET, 0, NULL, 0);
83 static inline int adb_flush (adb_dev_t *dev)
85 return adb_cmd(dev, ADB_FLUSH, 0, NULL, 0);
88 static inline int adb_reg_get (adb_dev_t *dev, uint8_t reg, uint8_t *buf)
90 return adb_cmd(dev, ADB_TALK, reg, buf, 0);
93 static inline int adb_reg_set (adb_dev_t *dev, uint8_t reg,
94 uint8_t *buf, int len)
96 return adb_cmd(dev, ADB_LISTEN, reg, buf, len);
99 #ifdef DEBUG_ADB
100 #define ADB_DPRINTF(fmt, args...) \
101 do { printk("ADB - %s: " fmt, __func__ , ##args); } while (0)
102 #else
103 #define ADB_DPRINTF(fmt, args...) do { } while (0)
104 #endif