26#ifndef _ULTIBO_BCMSDHOST_H
27#define _ULTIBO_BCMSDHOST_H
37#define BCMSDHOST_DESCRIPTION "Broadcom BCM27XX SDHOST"
39#define BCMSDHOST_FIFO_READ_THRESHOLD 4
40#define BCMSDHOST_FIFO_WRITE_THRESHOLD 4
41#define BCMSDHOST_ALLOW_CMD23_READ 1
42#define BCMSDHOST_ALLOW_CMD23_WRITE 0
43#define BCMSDHOST_SDDATA_FIFO_PIO_BURST 8
44#define BCMSDHOST_CMD_DALLY_US 1
47#define BCMSDHOST_SDCMD 0x00
48#define BCMSDHOST_SDARG 0x04
49#define BCMSDHOST_SDTOUT 0x08
50#define BCMSDHOST_SDCDIV 0x0c
51#define BCMSDHOST_SDRSP0 0x10
52#define BCMSDHOST_SDRSP1 0x14
53#define BCMSDHOST_SDRSP2 0x18
54#define BCMSDHOST_SDRSP3 0x1c
55#define BCMSDHOST_SDHSTS 0x20
56#define BCMSDHOST_SDVDD 0x30
57#define BCMSDHOST_SDEDM 0x34
58#define BCMSDHOST_SDHCFG 0x38
59#define BCMSDHOST_SDHBCT 0x3c
60#define BCMSDHOST_SDDATA 0x40
61#define BCMSDHOST_SDHBLC 0x50
64#define BCMSDHOST_SDCMD_NEW_FLAG 0x8000
65#define BCMSDHOST_SDCMD_FAIL_FLAG 0x4000
66#define BCMSDHOST_SDCMD_BUSYWAIT 0x800
67#define BCMSDHOST_SDCMD_NO_RESPONSE 0x400
68#define BCMSDHOST_SDCMD_LONG_RESPONSE 0x200
69#define BCMSDHOST_SDCMD_WRITE_CMD 0x80
70#define BCMSDHOST_SDCMD_READ_CMD 0x40
71#define BCMSDHOST_SDCMD_CMD_MASK 0x3f
74#define BCMSDHOST_SDCDIV_MAX_CDIV 0x7ff
77#define BCMSDHOST_SDHSTS_BUSY_IRPT 0x400
78#define BCMSDHOST_SDHSTS_BLOCK_IRPT 0x200
79#define BCMSDHOST_SDHSTS_SDIO_IRPT 0x100
80#define BCMSDHOST_SDHSTS_REW_TIME_OUT 0x80
81#define BCMSDHOST_SDHSTS_CMD_TIME_OUT 0x40
82#define BCMSDHOST_SDHSTS_CRC16_ERROR 0x20
83#define BCMSDHOST_SDHSTS_CRC7_ERROR 0x10
84#define BCMSDHOST_SDHSTS_FIFO_ERROR 0x08
87#define BCMSDHOST_SDHSTS_DATA_FLAG 0x01
89#define BCMSDHOST_SDHSTS_TRANSFER_ERROR_MASK BCMSDHOST_SDHSTS_CRC7_ERROR | BCMSDHOST_SDHSTS_CRC16_ERROR | BCMSDHOST_SDHSTS_REW_TIME_OUT | BCMSDHOST_SDHSTS_FIFO_ERROR
90#define BCMSDHOST_SDHSTS_ERROR_MASK BCMSDHOST_SDHSTS_CMD_TIME_OUT | BCMSDHOST_SDHSTS_TRANSFER_ERROR_MASK
93#define BCMSDHOST_SDHCFG_BUSY_IRPT_EN (1 << 10)
94#define BCMSDHOST_SDHCFG_BLOCK_IRPT_EN (1 << 8)
95#define BCMSDHOST_SDHCFG_SDIO_IRPT_EN (1 << 5)
96#define BCMSDHOST_SDHCFG_DATA_IRPT_EN (1 << 4)
97#define BCMSDHOST_SDHCFG_SLOW_CARD (1 << 3)
98#define BCMSDHOST_SDHCFG_WIDE_EXT_BUS (1 << 2)
99#define BCMSDHOST_SDHCFG_WIDE_INT_BUS (1 << 1)
100#define BCMSDHOST_SDHCFG_REL_CMD_LINE (1 << 0)
103#define BCMSDHOST_SDEDM_FORCE_DATA_MODE (1 << 19)
104#define BCMSDHOST_SDEDM_CLOCK_PULSE (1 << 20)
105#define BCMSDHOST_SDEDM_BYPASS (1 << 21)
107#define BCMSDHOST_SDEDM_WRITE_THRESHOLD_SHIFT 9
108#define BCMSDHOST_SDEDM_READ_THRESHOLD_SHIFT 14
109#define BCMSDHOST_SDEDM_THRESHOLD_MASK 0x1f
111#define BCMSDHOST_SDEDM_FSM_MASK 0xf
112#define BCMSDHOST_SDEDM_FSM_IDENTMODE 0x0
113#define BCMSDHOST_SDEDM_FSM_DATAMODE 0x1
114#define BCMSDHOST_SDEDM_FSM_READDATA 0x2
115#define BCMSDHOST_SDEDM_FSM_WRITEDATA 0x3
116#define BCMSDHOST_SDEDM_FSM_READWAIT 0x4
117#define BCMSDHOST_SDEDM_FSM_READCRC 0x5
118#define BCMSDHOST_SDEDM_FSM_WRITECRC 0x6
119#define BCMSDHOST_SDEDM_FSM_WRITEWAIT1 0x7
120#define BCMSDHOST_SDEDM_FSM_POWERDOWN 0x8
121#define BCMSDHOST_SDEDM_FSM_POWERUP 0x9
122#define BCMSDHOST_SDEDM_FSM_WRITESTART1 0xa
123#define BCMSDHOST_SDEDM_FSM_WRITESTART2 0xb
124#define BCMSDHOST_SDEDM_FSM_GENPULSES 0xc
125#define BCMSDHOST_SDEDM_FSM_WRITEWAIT2 0xd
126#define BCMSDHOST_SDEDM_FSM_STARTPOWDOWN 0xf
128#define BCMSDHOST_SDDATA_FIFO_WORDS 16
130#define BCMSDHOST_USE_CMD23_FLAGS (BCMSDHOST_ALLOW_CMD23_READ * MMC_DATA_READ) | (BCMSDHOST_ALLOW_CMD23_WRITE * MMC_DATA_WRITE)
133#define BCMSDHOST_MBOX_TAG_SET_SDHOST_CLOCK 0x00038042
198SDHCI_HOST *
STDCALL bcmsdhost_create(
size_t address,
char *name, uint32_t irq, uint32_t dreq, uint32_t clockminimum, uint32_t clockmaximum, uint32_t gpiofirst, uint32_t gpiolast, uint32_t gpiofunction,
BOOL enablefiq);
uint32_t STDCALL bcmsdhost_destroy(SDHCI_HOST *sdhci)
Stop, deregister and destroy a BCMSDHOST SDHCI device created by this driver.
struct _BCMSDHOST_HOST BCMSDHOST_HOST
Definition bcmsdhost.h:145
SDHCI_HOST *STDCALL bcmsdhost_create(size_t address, char *name, uint32_t irq, uint32_t dreq, uint32_t clockminimum, uint32_t clockmaximum, uint32_t gpiofirst, uint32_t gpiolast, uint32_t gpiofunction, BOOL enablefiq)
Create and register a new BCMSDHOST SDHCI device which can be accessed using the SDHCI API.
void STDCALL bcmsdhost_init(void)
struct _BCMSDHOST_MAILBOX_TAG_SET_SDHOST_CLOCK BCMSDHOST_MAILBOX_TAG_SET_SDHOST_CLOCK
Definition bcmsdhost.h:137
int32_t LONGBOOL
Compatibility with FPC LongBool type (4 bytes).
Definition globaltypes.h:56
#define STDCALL
Definition globaltypes.h:45
HANDLE SPIN_HANDLE
Definition globaltypes.h:104
_Bool BOOL
Built in Boolean type (1 byte) (Redeclared here for flexibility).
Definition globaltypes.h:55
struct _SDHCI_HOST SDHCI_HOST
Definition mmc.h:2237
Definition bcmsdhost.h:147
LONGBOOL allowdma
Allow DMA to be used for data transfers.
Definition bcmsdhost.h:162
uint32_t hostconfiguration
Cached Host Configuration (HCFG) register.
Definition bcmsdhost.h:158
uint32_t irq
The IRQ number for this device.
Definition bcmsdhost.h:151
uint32_t drainoffset
Offset for data during FIFO drain on DMA read.
Definition bcmsdhost.h:167
LONGBOOL firmwaresetsclockdivider
True if the firmware controls the clock divider.
Definition bcmsdhost.h:159
uint32_t commandquickpollretries
Definition bcmsdhost.h:160
uint32_t overclock
Current frequency if overclocked, else zero (in Hz).
Definition bcmsdhost.h:174
uint32_t overclock50
Frequency to use when 50MHz is requested (in MHz).
Definition bcmsdhost.h:173
SPIN_HANDLE lock
Host lock (Differs from lock in Host portion) (Spin lock due to use by interrupt handler).
Definition bcmsdhost.h:152
LONGBOOL enablefiq
Use FIQ instead of IRQ.
Definition bcmsdhost.h:153
uint32_t useroverclock50
User's preferred frequency to use when 50MHz is requested (in MHz).
Definition bcmsdhost.h:172
uint32_t piotimeout
PIO Read or Write block timeout (in milliseconds).
Definition bcmsdhost.h:176
SDHCI_HOST sdhci
Definition bcmsdhost.h:149
uint32_t piolimit
Maximum block count for PIO (0 = always DMA / 0x7FFFFFF = always PIO).
Definition bcmsdhost.h:175
uint32_t delayafterthisstop
Minimum time between this stop and subsequent data transfer (in Microseconds).
Definition bcmsdhost.h:171
uint32_t nanosecondsperfifoword
Definition bcmsdhost.h:161
LONGBOOL usebusy
Wait for busy interrupt on current command.
Definition bcmsdhost.h:169
LONGBOOL resetclock
Reset the clock for the next request.
Definition bcmsdhost.h:163
uint32_t clockdivider
Cached Clock Divider (CDIV) register.
Definition bcmsdhost.h:157
uint32_t gpiolast
The ending pin number for GPIO assignments (or GPIO_PIN_UNKNOWN if externally configured).
Definition bcmsdhost.h:155
uint32_t gpiofunction
The function number for GPIO assignments (or GPIO_FUNCTION_UNKNOWN if externally configured).
Definition bcmsdhost.h:156
LONGBOOL usesbc
Use CMD23 (Set Block Count) for the current transfer.
Definition bcmsdhost.h:168
uint32_t drainwords
Last words of FIFO to drain on DMA read.
Definition bcmsdhost.h:166
uint32_t gpiofirst
The starting pin number for GPIO assignments (or GPIO_PIN_UNKNOWN if externally configured).
Definition bcmsdhost.h:154
int64_t stoptime
When the last stop was issued (in Clock Ticks).
Definition bcmsdhost.h:165
uint32_t delayafterstop
Minimum time between stop and subsequent data transfer (in Microseconds).
Definition bcmsdhost.h:170
uint32_t maxdelay
Maximum length of time spent waiting (in Milliseconds).
Definition bcmsdhost.h:164
Definition bcmsdhost.h:139
uint32_t value1
Definition bcmsdhost.h:141
uint32_t value2
Definition bcmsdhost.h:142
uint32_t clock
Definition bcmsdhost.h:140