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
26 int (*req
)(void *host
, const uint8_t *snd_buf
, int len
, uint8_t *rcv_buf
);
38 #define ADB_BUF_SIZE 8
42 ADB_SEND_RESET
= 0x00,
47 /* ADB default IDs before relocation */
57 /* ADB special device handlers IDs */
60 ADB_CHADDR_ACTIV
= 0xFD,
61 ADB_CHADDR_NOCOLL
= 0xFE,
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
);
100 #define ADB_DPRINTF(fmt, args...) \
101 do { printk("ADB - %s: " fmt, __func__ , ##args); } while (0)
103 #define ADB_DPRINTF(fmt, args...) do { } while (0)