2 Copyright © 2013, The AROS Development Team. All rights reserved.
6 #include "sdcard_intern.h"
9 void FNAME_BCMSDCBUS(BCMLEDCtrl
)(int lvl
)
12 *(volatile ULONG
*)GPCLR0
= (1 << 16); // Turn Activity LED ON
14 *(volatile ULONG
*)GPSET0
= (1 << 16); // Turn Activity LED OFF
17 ULONG
FNAME_SDCBUS(GetClockDiv
)(ULONG speed
, struct sdcard_Bus
*bus
)
21 for (__BCMClkDiv
= 0; __BCMClkDiv
< V300_MAXCLKDIV
; __BCMClkDiv
++) {
22 if ((bus
->sdcb_ClockMax
/ (__BCMClkDiv
+ 1)) <= speed
)
29 UBYTE
FNAME_BCMSDCBUS(BCMMMIOReadByte
)(ULONG reg
, struct sdcard_Bus
*bus
)
31 ULONG val
= *(volatile ULONG
*)(((ULONG
)bus
->sdcb_IOBase
+ reg
) & ~3);
33 return (val
>> ((reg
& 3) << 3)) & 0xFF;
36 UWORD
FNAME_BCMSDCBUS(BCMMMIOReadWord
)(ULONG reg
, struct sdcard_Bus
*bus
)
38 ULONG val
= *(volatile ULONG
*)(((ULONG
)bus
->sdcb_IOBase
+ reg
) & ~3);
40 return (val
>> (((reg
>> 1) & 1) << 4)) & 0xFFFF;
43 ULONG
FNAME_BCMSDCBUS(BCMMMIOReadLong
)(ULONG reg
, struct sdcard_Bus
*bus
)
45 return *(volatile ULONG
*)(bus
->sdcb_IOBase
+ reg
);
48 static void FNAME_BCMSDCBUS(BCM2835WriteLong
)(ULONG reg
, ULONG val
, struct sdcard_Bus
*bus
)
50 /* Bug: two SDC clock cycle delay required between successive chipset writes */
51 while (sdcard_CurrentTime() < (bus
->sdcb_Private
+ 6))
54 *(volatile ULONG
*)(bus
->sdcb_IOBase
+ reg
) = val
;
55 bus
->sdcb_Private
= (IPTR
)sdcard_CurrentTime();
58 void FNAME_BCMSDCBUS(BCMMMIOWriteByte
)(ULONG reg
, UBYTE val
, struct sdcard_Bus
*bus
)
60 ULONG currval
= *(volatile ULONG
*)(((ULONG
)bus
->sdcb_IOBase
+ reg
) & ~3);
61 ULONG shift
= (reg
& 3) << 3;
62 ULONG mask
= 0xFF << shift
;
63 ULONG newval
= (currval
& ~mask
) | (val
<< shift
);
65 FNAME_BCMSDCBUS(BCM2835WriteLong
)(reg
& ~3, newval
, bus
);
68 void FNAME_BCMSDCBUS(BCMMMIOWriteWord
)(ULONG reg
, UWORD val
, struct sdcard_Bus
*bus
)
70 ULONG currval
= *(volatile ULONG
*)(((ULONG
)bus
->sdcb_IOBase
+ reg
) & ~3);
71 ULONG shift
= ((reg
>> 1) & 1) << 4;
72 ULONG mask
= 0xFFFF << shift
;
73 ULONG newval
= (currval
& ~mask
) | (val
<< shift
);
75 FNAME_BCMSDCBUS(BCM2835WriteLong
)(reg
& ~3, newval
, bus
);
78 void FNAME_BCMSDCBUS(BCMMMIOWriteLong
)(ULONG reg
, ULONG val
, struct sdcard_Bus
*bus
)
80 FNAME_BCMSDCBUS(BCM2835WriteLong
)(reg
, val
, bus
);