revert between 56095 -> 55830 in arch
[AROS.git] / arch / m68k-amiga / devs / ata / waitnano.c
blob619f09eb517778c97e8b68e5b917702370f16fbd
1 /*
2 Copyright © 2013, The AROS Development Team. All rights reserved
3 $Id$
4 */
6 #include <exec/types.h>
7 #include <exec/io.h>
8 #include <hardware/cia.h>
9 #include <aros/debug.h>
11 #include "timer.h"
12 #include "ata.h"
14 BOOL ata_Calibrate(struct IORequest* tmr, struct ataBase *base)
16 base->ata_ItersPer100ns = 1;
17 return TRUE;
20 static void busywait(UWORD cnt)
22 asm volatile (
23 "move.w %0,%%d0\n"
24 "lea 0xbfe001,%%a0\n"
25 "0:\n"
26 "tst.b (%%a0)\n"
27 "tst.b (%%a0)\n"
28 "tst.b (%%a0)\n"
29 "tst.b (%%a0)\n"
30 "dbf %%d0,0b\n"
31 : : "m" (cnt) : "d0", "a0");
34 /* Single CIA access = 1 E-clock */
35 void ata_WaitNano(ULONG ns, struct ataBase *base)
37 ns /= 2;
38 if (!(SysBase->AttnFlags & AFF_68020))
39 ns /= 2;
40 while (ns >= 65536 * 4) {
41 busywait(65535);
42 ns -= 65536 * 4;
44 if (ns >= 4)
45 busywait(ns / 4);