/*
* Copyright (C) 1994 Bradley A. Grantham
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
switch (mac68k_machine.machineid) {
case MACH_MACPB140:
case MACH_MACPB145:
case MACH_MACPB160:
case MACH_MACPB165:
case MACH_MACPB165C:
case MACH_MACPB170:
case MACH_MACPB180:
case MACH_MACPB180C:
case MACH_MACPB150:
/* Reqired on machines with in-built trackballs. */
printf("... Waiting 5 seconds for adb devices to "
"settle.");
kpause("adb-slp", false, mstohz(5000), NULL);
break;
default:
break;
}
/* for each ADB device */
for (adbindex = 1; adbindex <= totaladbs; adbindex++) {
/* Get the ADB information */
adbaddr = GetIndADB(&adbdata, adbindex);
int
adbprint(void *args, const char *name)
{
struct adb_attach_args *aa_args = (struct adb_attach_args *)args;
int rv = UNCONF;
if (name) { /* no configured device matched */
rv = UNSUPP; /* most ADB device types are unsupported */
/* print out what kind of ADB device we have found */
aprint_normal("%s addr %d: ", name, aa_args->adbaddr);
switch(aa_args->origaddr) {
case 0:
#ifdef DIAGNOSTIC
aprint_normal("ADB event device");
#endif
rv = UNCONF;
break;
#ifdef DIAGNOSTIC
case ADBADDR_SECURE:
aprint_normal("security dongle (%d)",
aa_args->handler_id);
break;
#endif
case ADBADDR_MAP:
aprint_normal("mapped device (%d)",
aa_args->handler_id);
rv = UNCONF;
break;
case ADBADDR_REL:
aprint_normal("relative positioning device (%d)",
aa_args->handler_id);
rv = UNCONF;
break;
#ifdef DIAGNOSTIC
case ADBADDR_ABS:
switch (aa_args->handler_id) {
case ADB_ARTPAD:
aprint_normal("WACOM ArtPad II");
break;
default:
aprint_normal("absolute positioning device (%d)",
aa_args->handler_id);
break;
}
break;
case ADBADDR_DATATX:
aprint_normal("data transfer device (modem?) (%d)",
aa_args->handler_id);
break;
case ADBADDR_MISC:
switch (aa_args->handler_id) {
case ADB_POWERKEY:
aprint_normal("Sophisticated Circuits PowerKey");
break;
default:
aprint_normal("misc. device (remote control?) (%d)",
aa_args->handler_id);
break;
}
break;
default:
aprint_normal("unknown type device, (handler %d)",
aa_args->handler_id);
break;
#endif /* DIAGNOSTIC */
}
} else /* a device matched and was configured */
aprint_normal(" addr %d: ", aa_args->adbaddr);
return (rv);
}
/*
* adb_op_sync
*
* This routine does exactly what the adb_op routine does, except that after
* the adb_op is called, it waits until the return value is present before
* returning.
*
* NOTE: The user specified compRout is ignored, since this routine specifies
* its own to adb_op, which is why you really called this in the first place
* anyway.
*/
int
adb_op_sync(Ptr buffer, Ptr compRout, Ptr data, short command)
{
int result;
volatile int flag = 0;
result = ADBOp(buffer, (void *)adb_op_comprout, __UNVOLATILE(&flag),
command); /* send command */
if (result == 0) { /* send ok? */
adb_spin(&flag);
if (!flag)
result = -2;
}
return result;
}
/*
* adb_spin
*
* Implements a spin-wait with timeout to be used for synchronous
* operations on the ADB bus.
*
* Total time to wait is calculated as follows:
* - Tlt (stop to start time): 260 usec
* - start bit: 100 usec
* - up to 8 data bytes: 64 * 100 usec = 6400 usec
* - stop bit (with SRQ): 140 usec
* Total: 6900 usec
*
* This is the total time allowed by the specification. Any device that
* doesn't conform to this will fail to operate properly on some Apple
* systems. In spite of this we double the time to wait; Cuda-based
* systems apparently queue commands and allow the main CPU to continue
* processing (how radical!). To be safe, allow time for two complete
* ADB transactions to occur.
*/
void
adb_spin(volatile int *fp)
{
int tmout;
/*
* adb_op_comprout
*
* This function is used by the adb_op_sync routine so it knows when the
* function is done.
*/
void
adb_op_comprout(void)
{
__asm("movw #1,%a2@ | update flag value");
}