Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
bcmsdhost.h File Reference
#include "ultibo/threads.h"
#include "ultibo/mmc.h"

Go to the source code of this file.

Data Structures

struct  _BCMSDHOST_MAILBOX_TAG_SET_SDHOST_CLOCK
struct  _BCMSDHOST_HOST

Macros

#define BCMSDHOST_DESCRIPTION   "Broadcom BCM27XX SDHOST"
 Description of BCMSDHOST device.
#define BCMSDHOST_FIFO_READ_THRESHOLD   4
#define BCMSDHOST_FIFO_WRITE_THRESHOLD   4
#define BCMSDHOST_ALLOW_CMD23_READ   1
#define BCMSDHOST_ALLOW_CMD23_WRITE   0
#define BCMSDHOST_SDDATA_FIFO_PIO_BURST   8
#define BCMSDHOST_CMD_DALLY_US   1
#define BCMSDHOST_SDCMD   0x00
 Command to SD card - 16 R/W.
#define BCMSDHOST_SDARG   0x04
 Argument to SD card - 32 R/W.
#define BCMSDHOST_SDTOUT   0x08
 Start value for timeout counter - 32 R/W.
#define BCMSDHOST_SDCDIV   0x0c
 Start value for clock divider - 11 R/W.
#define BCMSDHOST_SDRSP0   0x10
 SD card response (31:0) - 32 R.
#define BCMSDHOST_SDRSP1   0x14
 SD card response (63:32) - 32 R.
#define BCMSDHOST_SDRSP2   0x18
 SD card response (95:64) - 32 R.
#define BCMSDHOST_SDRSP3   0x1c
 SD card response (127:96) - 32 R.
#define BCMSDHOST_SDHSTS   0x20
 SD host status - 11 R.
#define BCMSDHOST_SDVDD   0x30
 SD card power control - 1 R/W.
#define BCMSDHOST_SDEDM   0x34
 Emergency Debug Mode - 13 R/W.
#define BCMSDHOST_SDHCFG   0x38
 Host configuration - 2 R/W.
#define BCMSDHOST_SDHBCT   0x3c
 Host byte count (debug) - 32 R/W.
#define BCMSDHOST_SDDATA   0x40
 Data to/from SD card - 32 R/W.
#define BCMSDHOST_SDHBLC   0x50
 Host block count (SDIO/SDHC) - 9 R/W.
#define BCMSDHOST_SDCMD_NEW_FLAG   0x8000
#define BCMSDHOST_SDCMD_FAIL_FLAG   0x4000
#define BCMSDHOST_SDCMD_BUSYWAIT   0x800
#define BCMSDHOST_SDCMD_NO_RESPONSE   0x400
#define BCMSDHOST_SDCMD_LONG_RESPONSE   0x200
#define BCMSDHOST_SDCMD_WRITE_CMD   0x80
#define BCMSDHOST_SDCMD_READ_CMD   0x40
#define BCMSDHOST_SDCMD_CMD_MASK   0x3f
#define BCMSDHOST_SDCDIV_MAX_CDIV   0x7ff
#define BCMSDHOST_SDHSTS_BUSY_IRPT   0x400
#define BCMSDHOST_SDHSTS_BLOCK_IRPT   0x200
#define BCMSDHOST_SDHSTS_SDIO_IRPT   0x100
#define BCMSDHOST_SDHSTS_REW_TIME_OUT   0x80
#define BCMSDHOST_SDHSTS_CMD_TIME_OUT   0x40
#define BCMSDHOST_SDHSTS_CRC16_ERROR   0x20
#define BCMSDHOST_SDHSTS_CRC7_ERROR   0x10
#define BCMSDHOST_SDHSTS_FIFO_ERROR   0x08
#define BCMSDHOST_SDHSTS_DATA_FLAG   0x01
#define BCMSDHOST_SDHSTS_TRANSFER_ERROR_MASK   BCMSDHOST_SDHSTS_CRC7_ERROR | BCMSDHOST_SDHSTS_CRC16_ERROR | BCMSDHOST_SDHSTS_REW_TIME_OUT | BCMSDHOST_SDHSTS_FIFO_ERROR
#define BCMSDHOST_SDHSTS_ERROR_MASK   BCMSDHOST_SDHSTS_CMD_TIME_OUT | BCMSDHOST_SDHSTS_TRANSFER_ERROR_MASK
#define BCMSDHOST_SDHCFG_BUSY_IRPT_EN   (1 << 10)
#define BCMSDHOST_SDHCFG_BLOCK_IRPT_EN   (1 << 8)
#define BCMSDHOST_SDHCFG_SDIO_IRPT_EN   (1 << 5)
#define BCMSDHOST_SDHCFG_DATA_IRPT_EN   (1 << 4)
#define BCMSDHOST_SDHCFG_SLOW_CARD   (1 << 3)
#define BCMSDHOST_SDHCFG_WIDE_EXT_BUS   (1 << 2)
#define BCMSDHOST_SDHCFG_WIDE_INT_BUS   (1 << 1)
#define BCMSDHOST_SDHCFG_REL_CMD_LINE   (1 << 0)
#define BCMSDHOST_SDEDM_FORCE_DATA_MODE   (1 << 19)
#define BCMSDHOST_SDEDM_CLOCK_PULSE   (1 << 20)
#define BCMSDHOST_SDEDM_BYPASS   (1 << 21)
#define BCMSDHOST_SDEDM_WRITE_THRESHOLD_SHIFT   9
#define BCMSDHOST_SDEDM_READ_THRESHOLD_SHIFT   14
#define BCMSDHOST_SDEDM_THRESHOLD_MASK   0x1f
#define BCMSDHOST_SDEDM_FSM_MASK   0xf
#define BCMSDHOST_SDEDM_FSM_IDENTMODE   0x0
#define BCMSDHOST_SDEDM_FSM_DATAMODE   0x1
#define BCMSDHOST_SDEDM_FSM_READDATA   0x2
#define BCMSDHOST_SDEDM_FSM_WRITEDATA   0x3
#define BCMSDHOST_SDEDM_FSM_READWAIT   0x4
#define BCMSDHOST_SDEDM_FSM_READCRC   0x5
#define BCMSDHOST_SDEDM_FSM_WRITECRC   0x6
#define BCMSDHOST_SDEDM_FSM_WRITEWAIT1   0x7
#define BCMSDHOST_SDEDM_FSM_POWERDOWN   0x8
#define BCMSDHOST_SDEDM_FSM_POWERUP   0x9
#define BCMSDHOST_SDEDM_FSM_WRITESTART1   0xa
#define BCMSDHOST_SDEDM_FSM_WRITESTART2   0xb
#define BCMSDHOST_SDEDM_FSM_GENPULSES   0xc
#define BCMSDHOST_SDEDM_FSM_WRITEWAIT2   0xd
#define BCMSDHOST_SDEDM_FSM_STARTPOWDOWN   0xf
#define BCMSDHOST_SDDATA_FIFO_WORDS   16
#define BCMSDHOST_USE_CMD23_FLAGS   (BCMSDHOST_ALLOW_CMD23_READ * MMC_DATA_READ) | (BCMSDHOST_ALLOW_CMD23_WRITE * MMC_DATA_WRITE)
#define BCMSDHOST_MBOX_TAG_SET_SDHOST_CLOCK   0x00038042
 Tell the firmware the SD Host clock setting so it will be adjusted for changes in core frequency.

Typedefs

typedef struct _BCMSDHOST_MAILBOX_TAG_SET_SDHOST_CLOCK BCMSDHOST_MAILBOX_TAG_SET_SDHOST_CLOCK
typedef struct _BCMSDHOST_HOST BCMSDHOST_HOST

Functions

void STDCALL bcmsdhost_init (void)
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.
uint32_t STDCALL bcmsdhost_destroy (SDHCI_HOST *sdhci)
 Stop, deregister and destroy a BCMSDHOST SDHCI device created by this driver.

Macro Definition Documentation

◆ BCMSDHOST_DESCRIPTION

#define BCMSDHOST_DESCRIPTION   "Broadcom BCM27XX SDHOST"

Description of BCMSDHOST device.

BCMSDHOST specific constants

◆ BCMSDHOST_FIFO_READ_THRESHOLD

#define BCMSDHOST_FIFO_READ_THRESHOLD   4

◆ BCMSDHOST_FIFO_WRITE_THRESHOLD

#define BCMSDHOST_FIFO_WRITE_THRESHOLD   4

◆ BCMSDHOST_ALLOW_CMD23_READ

#define BCMSDHOST_ALLOW_CMD23_READ   1

◆ BCMSDHOST_ALLOW_CMD23_WRITE

#define BCMSDHOST_ALLOW_CMD23_WRITE   0

◆ BCMSDHOST_SDDATA_FIFO_PIO_BURST

#define BCMSDHOST_SDDATA_FIFO_PIO_BURST   8

◆ BCMSDHOST_CMD_DALLY_US

#define BCMSDHOST_CMD_DALLY_US   1

◆ BCMSDHOST_SDCMD

#define BCMSDHOST_SDCMD   0x00

Command to SD card - 16 R/W.

BCMSDHOST register constants

◆ BCMSDHOST_SDARG

#define BCMSDHOST_SDARG   0x04

Argument to SD card - 32 R/W.

◆ BCMSDHOST_SDTOUT

#define BCMSDHOST_SDTOUT   0x08

Start value for timeout counter - 32 R/W.

◆ BCMSDHOST_SDCDIV

#define BCMSDHOST_SDCDIV   0x0c

Start value for clock divider - 11 R/W.

◆ BCMSDHOST_SDRSP0

#define BCMSDHOST_SDRSP0   0x10

SD card response (31:0) - 32 R.

◆ BCMSDHOST_SDRSP1

#define BCMSDHOST_SDRSP1   0x14

SD card response (63:32) - 32 R.

◆ BCMSDHOST_SDRSP2

#define BCMSDHOST_SDRSP2   0x18

SD card response (95:64) - 32 R.

◆ BCMSDHOST_SDRSP3

#define BCMSDHOST_SDRSP3   0x1c

SD card response (127:96) - 32 R.

◆ BCMSDHOST_SDHSTS

#define BCMSDHOST_SDHSTS   0x20

SD host status - 11 R.

◆ BCMSDHOST_SDVDD

#define BCMSDHOST_SDVDD   0x30

SD card power control - 1 R/W.

◆ BCMSDHOST_SDEDM

#define BCMSDHOST_SDEDM   0x34

Emergency Debug Mode - 13 R/W.

◆ BCMSDHOST_SDHCFG

#define BCMSDHOST_SDHCFG   0x38

Host configuration - 2 R/W.

◆ BCMSDHOST_SDHBCT

#define BCMSDHOST_SDHBCT   0x3c

Host byte count (debug) - 32 R/W.

◆ BCMSDHOST_SDDATA

#define BCMSDHOST_SDDATA   0x40

Data to/from SD card - 32 R/W.

◆ BCMSDHOST_SDHBLC

#define BCMSDHOST_SDHBLC   0x50

Host block count (SDIO/SDHC) - 9 R/W.

◆ BCMSDHOST_SDCMD_NEW_FLAG

#define BCMSDHOST_SDCMD_NEW_FLAG   0x8000

BCMSDHOST command register constants

◆ BCMSDHOST_SDCMD_FAIL_FLAG

#define BCMSDHOST_SDCMD_FAIL_FLAG   0x4000

◆ BCMSDHOST_SDCMD_BUSYWAIT

#define BCMSDHOST_SDCMD_BUSYWAIT   0x800

◆ BCMSDHOST_SDCMD_NO_RESPONSE

#define BCMSDHOST_SDCMD_NO_RESPONSE   0x400

◆ BCMSDHOST_SDCMD_LONG_RESPONSE

#define BCMSDHOST_SDCMD_LONG_RESPONSE   0x200

◆ BCMSDHOST_SDCMD_WRITE_CMD

#define BCMSDHOST_SDCMD_WRITE_CMD   0x80

◆ BCMSDHOST_SDCMD_READ_CMD

#define BCMSDHOST_SDCMD_READ_CMD   0x40

◆ BCMSDHOST_SDCMD_CMD_MASK

#define BCMSDHOST_SDCMD_CMD_MASK   0x3f

◆ BCMSDHOST_SDCDIV_MAX_CDIV

#define BCMSDHOST_SDCDIV_MAX_CDIV   0x7ff

BCMSDHOST clock divider register constants

◆ BCMSDHOST_SDHSTS_BUSY_IRPT

#define BCMSDHOST_SDHSTS_BUSY_IRPT   0x400

BCMSDHOST host status register constants

◆ BCMSDHOST_SDHSTS_BLOCK_IRPT

#define BCMSDHOST_SDHSTS_BLOCK_IRPT   0x200

◆ BCMSDHOST_SDHSTS_SDIO_IRPT

#define BCMSDHOST_SDHSTS_SDIO_IRPT   0x100

◆ BCMSDHOST_SDHSTS_REW_TIME_OUT

#define BCMSDHOST_SDHSTS_REW_TIME_OUT   0x80

◆ BCMSDHOST_SDHSTS_CMD_TIME_OUT

#define BCMSDHOST_SDHSTS_CMD_TIME_OUT   0x40

◆ BCMSDHOST_SDHSTS_CRC16_ERROR

#define BCMSDHOST_SDHSTS_CRC16_ERROR   0x20

◆ BCMSDHOST_SDHSTS_CRC7_ERROR

#define BCMSDHOST_SDHSTS_CRC7_ERROR   0x10

◆ BCMSDHOST_SDHSTS_FIFO_ERROR

#define BCMSDHOST_SDHSTS_FIFO_ERROR   0x08

◆ BCMSDHOST_SDHSTS_DATA_FLAG

#define BCMSDHOST_SDHSTS_DATA_FLAG   0x01

04 Reserved 02 Reserved

◆ BCMSDHOST_SDHSTS_TRANSFER_ERROR_MASK

◆ BCMSDHOST_SDHSTS_ERROR_MASK

#define BCMSDHOST_SDHSTS_ERROR_MASK   BCMSDHOST_SDHSTS_CMD_TIME_OUT | BCMSDHOST_SDHSTS_TRANSFER_ERROR_MASK

◆ BCMSDHOST_SDHCFG_BUSY_IRPT_EN

#define BCMSDHOST_SDHCFG_BUSY_IRPT_EN   (1 << 10)

BCMSDHOST host configuration register constants

◆ BCMSDHOST_SDHCFG_BLOCK_IRPT_EN

#define BCMSDHOST_SDHCFG_BLOCK_IRPT_EN   (1 << 8)

◆ BCMSDHOST_SDHCFG_SDIO_IRPT_EN

#define BCMSDHOST_SDHCFG_SDIO_IRPT_EN   (1 << 5)

◆ BCMSDHOST_SDHCFG_DATA_IRPT_EN

#define BCMSDHOST_SDHCFG_DATA_IRPT_EN   (1 << 4)

◆ BCMSDHOST_SDHCFG_SLOW_CARD

#define BCMSDHOST_SDHCFG_SLOW_CARD   (1 << 3)

◆ BCMSDHOST_SDHCFG_WIDE_EXT_BUS

#define BCMSDHOST_SDHCFG_WIDE_EXT_BUS   (1 << 2)

◆ BCMSDHOST_SDHCFG_WIDE_INT_BUS

#define BCMSDHOST_SDHCFG_WIDE_INT_BUS   (1 << 1)

◆ BCMSDHOST_SDHCFG_REL_CMD_LINE

#define BCMSDHOST_SDHCFG_REL_CMD_LINE   (1 << 0)

◆ BCMSDHOST_SDEDM_FORCE_DATA_MODE

#define BCMSDHOST_SDEDM_FORCE_DATA_MODE   (1 << 19)

BCMSDHOST emergency debug mode register constants

◆ BCMSDHOST_SDEDM_CLOCK_PULSE

#define BCMSDHOST_SDEDM_CLOCK_PULSE   (1 << 20)

◆ BCMSDHOST_SDEDM_BYPASS

#define BCMSDHOST_SDEDM_BYPASS   (1 << 21)

◆ BCMSDHOST_SDEDM_WRITE_THRESHOLD_SHIFT

#define BCMSDHOST_SDEDM_WRITE_THRESHOLD_SHIFT   9

◆ BCMSDHOST_SDEDM_READ_THRESHOLD_SHIFT

#define BCMSDHOST_SDEDM_READ_THRESHOLD_SHIFT   14

◆ BCMSDHOST_SDEDM_THRESHOLD_MASK

#define BCMSDHOST_SDEDM_THRESHOLD_MASK   0x1f

◆ BCMSDHOST_SDEDM_FSM_MASK

#define BCMSDHOST_SDEDM_FSM_MASK   0xf

◆ BCMSDHOST_SDEDM_FSM_IDENTMODE

#define BCMSDHOST_SDEDM_FSM_IDENTMODE   0x0

◆ BCMSDHOST_SDEDM_FSM_DATAMODE

#define BCMSDHOST_SDEDM_FSM_DATAMODE   0x1

◆ BCMSDHOST_SDEDM_FSM_READDATA

#define BCMSDHOST_SDEDM_FSM_READDATA   0x2

◆ BCMSDHOST_SDEDM_FSM_WRITEDATA

#define BCMSDHOST_SDEDM_FSM_WRITEDATA   0x3

◆ BCMSDHOST_SDEDM_FSM_READWAIT

#define BCMSDHOST_SDEDM_FSM_READWAIT   0x4

◆ BCMSDHOST_SDEDM_FSM_READCRC

#define BCMSDHOST_SDEDM_FSM_READCRC   0x5

◆ BCMSDHOST_SDEDM_FSM_WRITECRC

#define BCMSDHOST_SDEDM_FSM_WRITECRC   0x6

◆ BCMSDHOST_SDEDM_FSM_WRITEWAIT1

#define BCMSDHOST_SDEDM_FSM_WRITEWAIT1   0x7

◆ BCMSDHOST_SDEDM_FSM_POWERDOWN

#define BCMSDHOST_SDEDM_FSM_POWERDOWN   0x8

◆ BCMSDHOST_SDEDM_FSM_POWERUP

#define BCMSDHOST_SDEDM_FSM_POWERUP   0x9

◆ BCMSDHOST_SDEDM_FSM_WRITESTART1

#define BCMSDHOST_SDEDM_FSM_WRITESTART1   0xa

◆ BCMSDHOST_SDEDM_FSM_WRITESTART2

#define BCMSDHOST_SDEDM_FSM_WRITESTART2   0xb

◆ BCMSDHOST_SDEDM_FSM_GENPULSES

#define BCMSDHOST_SDEDM_FSM_GENPULSES   0xc

◆ BCMSDHOST_SDEDM_FSM_WRITEWAIT2

#define BCMSDHOST_SDEDM_FSM_WRITEWAIT2   0xd

◆ BCMSDHOST_SDEDM_FSM_STARTPOWDOWN

#define BCMSDHOST_SDEDM_FSM_STARTPOWDOWN   0xf

◆ BCMSDHOST_SDDATA_FIFO_WORDS

#define BCMSDHOST_SDDATA_FIFO_WORDS   16

◆ BCMSDHOST_USE_CMD23_FLAGS

#define BCMSDHOST_USE_CMD23_FLAGS   (BCMSDHOST_ALLOW_CMD23_READ * MMC_DATA_READ) | (BCMSDHOST_ALLOW_CMD23_WRITE * MMC_DATA_WRITE)

◆ BCMSDHOST_MBOX_TAG_SET_SDHOST_CLOCK

#define BCMSDHOST_MBOX_TAG_SET_SDHOST_CLOCK   0x00038042

Tell the firmware the SD Host clock setting so it will be adjusted for changes in core frequency.

Mailbox constants

Typedef Documentation

◆ BCMSDHOST_MAILBOX_TAG_SET_SDHOST_CLOCK

BCMSDHOST specific types Mailbox tag request for BCMSDHOST_MBOX_TAG_SET_SDHOST_CLOCK

◆ BCMSDHOST_HOST

Function Documentation

◆ bcmsdhost_init()

void STDCALL bcmsdhost_init ( void )

Initialization Functions

◆ bcmsdhost_create()

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.

BCMSDHOST Functions

Parameters
AddressThe address of the BCMSDHOST registers
NameThe text description of this device which will show in the device list (Optional)
IRQThe interrupt number for the BCMSDHOST
DREQThe DMA data request ID for the BCMSDHOST
ClockMinimumThe minimum frequency for the BCMSDHOST clock
ClockMaximumThe maximum frequency for the BCMSDHOST clock
GPIOFirstThe starting pin number for GPIO assignments (or GPIO_PIN_UNKNOWN if externally configured)
GPIOLastThe ending pin number for GPIO assignments (or GPIO_PIN_UNKNOWN if externally configured)
GPIOFunctionThe function number for GPIO assignments (or GPIO_FUNCTION_UNKNOWN if externally configured)
EnableFIQEnable fast interrupt support for the BCMSDHOST
Returns
Pointer to the new SDHCI device or nil if the SDHCI device could not be created

◆ bcmsdhost_destroy()

uint32_t STDCALL bcmsdhost_destroy ( SDHCI_HOST * sdhci)

Stop, deregister and destroy a BCMSDHOST SDHCI device created by this driver.

Parameters
SDHCIThe SDHCI device to destroy
Returns
ERROR_SUCCESS if completed or another error code on failure