use the soc family name, not specific chip name(s)
[AROS.git] / arch / arm-native / soc / broadcom / 2708 / sdcard / sdcard_bcm283xbus.c
blob150f90d008f5eb5c5de53c225b130a7595b66964
1 /*
2 Copyright © 2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "sdcard_intern.h"
7 #include "timer.h"
9 void FNAME_BCMSDCBUS(BCMLEDCtrl)(int lvl)
11 if (lvl > 0)
13 // Activity LED ON
14 if (__arm_periiobase == BCM2835_PERIPHYSBASE)
15 *(volatile unsigned int *)GPCLR0 = (1 << 16);
16 else
17 *(volatile unsigned int *)GPCLR1 = (1 << (47 - 32));
19 else
21 // Activity LED OFF
22 if (__arm_periiobase == BCM2835_PERIPHYSBASE)
23 *(volatile unsigned int *)GPSET0 = (1 << 16);
24 else
25 *(volatile unsigned int *)GPSET1 = (1 << (47 - 32));
29 ULONG FNAME_SDCBUS(GetClockDiv)(ULONG speed, struct sdcard_Bus *bus)
31 ULONG __BCMClkDiv;
33 for (__BCMClkDiv = 0; __BCMClkDiv < V300_MAXCLKDIV; __BCMClkDiv++) {
34 if ((bus->sdcb_ClockMax / (__BCMClkDiv + 1)) <= speed)
35 break;
38 return __BCMClkDiv;
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))
64 sdcard_Udelay(1);
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);