2 Copyright © 2013, The AROS Development Team. All rights reserved.
6 #include "sdcard_intern.h"
9 void FNAME_BCMSDCBUS(BCMLEDCtrl
)(int lvl
)
14 if (__arm_periiobase
== BCM2835_PERIPHYSBASE
)
15 *(volatile unsigned int *)GPCLR0
= (1 << 16);
17 *(volatile unsigned int *)GPCLR1
= (1 << (47 - 32));
22 if (__arm_periiobase
== BCM2835_PERIPHYSBASE
)
23 *(volatile unsigned int *)GPSET0
= (1 << 16);
25 *(volatile unsigned int *)GPSET1
= (1 << (47 - 32));
29 ULONG
FNAME_SDCBUS(GetClockDiv
)(ULONG speed
, struct sdcard_Bus
*bus
)
33 for (__BCMClkDiv
= 0; __BCMClkDiv
< V300_MAXCLKDIV
; __BCMClkDiv
++) {
34 if ((bus
->sdcb_ClockMax
/ (__BCMClkDiv
+ 1)) <= speed
)
41 UBYTE
FNAME_BCMSDCBUS(BCMMMIOReadByte
)(ULONG reg
, struct sdcard_Bus
*bus
)
43 ULONG val
= *(volatile ULONG
*)(((ULONG
)bus
->sdcb_IOBase
+ reg
) & ~3);
45 return (val
>> ((reg
& 3) << 3)) & 0xFF;
48 UWORD
FNAME_BCMSDCBUS(BCMMMIOReadWord
)(ULONG reg
, struct sdcard_Bus
*bus
)
50 ULONG val
= *(volatile ULONG
*)(((ULONG
)bus
->sdcb_IOBase
+ reg
) & ~3);
52 return (val
>> (((reg
>> 1) & 1) << 4)) & 0xFFFF;
55 ULONG
FNAME_BCMSDCBUS(BCMMMIOReadLong
)(ULONG reg
, struct sdcard_Bus
*bus
)
57 return *(volatile ULONG
*)(bus
->sdcb_IOBase
+ reg
);
60 static void FNAME_BCMSDCBUS(BCM283xWriteLong
)(ULONG reg
, ULONG val
, struct sdcard_Bus
*bus
)
62 /* Bug: two SDC clock cycle delay required between successive chipset writes */
63 while (sdcard_CurrentTime() < (bus
->sdcb_Private
+ 6))
66 *(volatile ULONG
*)(bus
->sdcb_IOBase
+ reg
) = val
;
67 bus
->sdcb_Private
= (IPTR
)sdcard_CurrentTime();
70 void FNAME_BCMSDCBUS(BCMMMIOWriteByte
)(ULONG reg
, UBYTE val
, struct sdcard_Bus
*bus
)
72 ULONG currval
= *(volatile ULONG
*)(((ULONG
)bus
->sdcb_IOBase
+ reg
) & ~3);
73 ULONG shift
= (reg
& 3) << 3;
74 ULONG mask
= 0xFF << shift
;
75 ULONG newval
= (currval
& ~mask
) | (val
<< shift
);
77 FNAME_BCMSDCBUS(BCM283xWriteLong
)(reg
& ~3, newval
, bus
);
80 void FNAME_BCMSDCBUS(BCMMMIOWriteWord
)(ULONG reg
, UWORD val
, struct sdcard_Bus
*bus
)
82 ULONG currval
= *(volatile ULONG
*)(((ULONG
)bus
->sdcb_IOBase
+ reg
) & ~3);
83 ULONG shift
= ((reg
>> 1) & 1) << 4;
84 ULONG mask
= 0xFFFF << shift
;
85 ULONG newval
= (currval
& ~mask
) | (val
<< shift
);
87 FNAME_BCMSDCBUS(BCM283xWriteLong
)(reg
& ~3, newval
, bus
);
90 void FNAME_BCMSDCBUS(BCMMMIOWriteLong
)(ULONG reg
, ULONG val
, struct sdcard_Bus
*bus
)
92 FNAME_BCMSDCBUS(BCM283xWriteLong
)(reg
, val
, bus
);