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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #if !defined(__OHW_ADB_H__)
23 typedef struct adb_bus_t adb_bus_t
;
24 typedef struct adb_dev_t adb_dev_t
;
26 #define ADB_BUF_SIZE 8
29 int (*req
)(void *host
, const uint8_t *snd_buf
, int len
, uint8_t *rcv_buf
);
41 #define ADB_BUF_SIZE 8
45 ADB_SEND_RESET
= 0x00,
50 /* ADB default IDs before relocation */
60 /* ADB special device handlers IDs */
63 ADB_CHADDR_ACTIV
= 0xFD,
64 ADB_CHADDR_NOCOLL
= 0xFE,
68 int adb_cmd (adb_dev_t
*dev
, uint8_t cmd
, uint8_t reg
,
69 uint8_t *buf
, int len
);
70 void adb_bus_reset (adb_bus_t
*bus
);
71 adb_bus_t
*adb_bus_new (void *host
,
72 int (*req
)(void *host
, const uint8_t *snd_buf
,
73 int len
, uint8_t *rcv_buf
));
74 int adb_bus_init (adb_bus_t
*bus
);
76 static inline int adb_reset (adb_bus_t
*bus
)
78 adb_dev_t fake_device
;
80 memset(&fake_device
, 0, sizeof(adb_dev_t
));
81 fake_device
.bus
= bus
;
83 return adb_cmd(&fake_device
, ADB_SEND_RESET
, 0, NULL
, 0);
86 static inline int adb_flush (adb_dev_t
*dev
)
88 return adb_cmd(dev
, ADB_FLUSH
, 0, NULL
, 0);
91 static inline int adb_reg_get (adb_dev_t
*dev
, uint8_t reg
, uint8_t *buf
)
93 return adb_cmd(dev
, ADB_TALK
, reg
, buf
, 0);
96 static inline int adb_reg_set (adb_dev_t
*dev
, uint8_t reg
,
97 uint8_t *buf
, int len
)
99 return adb_cmd(dev
, ADB_LISTEN
, reg
, buf
, len
);
102 #endif /* !defined(__OHW_ADB_H__) */