# drivers/sdmmc/mcihost.c File Reference

SD/MMC MCI host driver. More...

`#include <stdbool.h>`
`#include <string.h>`
`#include <debug.h>`
`#include <delayed_work.h>`
`#include <bitops.h>`
`#include <io.h>`
`#include <interrupt.h>`
`#include <irq_handler.h>`
`#include <softirq.h>`
`#include <status-codes.h>`
`#include <util.h>`
`#include <slist.h>`
`#include <timeout.h>`
`#include <workqueue.h>`
`#include <buffer.h>`
`#include <malloc.h>`
`#include <dmac/dma_controller.h>`
`#include <chip/clk.h>`
`#include <chip/portmux.h>`
`#include <chip/irq-map.h>`
`#include <sdmmc/sdmmc.h>`
`#include <sdmmc/mcihost.h>`
`#include "protocol.h"`
`#include "mci_regs.h"`
`#include <board/sdmmc.h>`
`#include <app/softirq.h>`
`#include <app/timer.h>`
`#include <app/workqueue.h>`

Include dependency graph for mcihost.c:

Go to the source code of this file.

## Enumerations
enum | sdmmc_mcihost_state { STATE_IDLE = 0, STATE_SENDING_CMD, STATE_DATA_XFER, STATE_SENDING_STOP, STATE_FINISH_REQ, STATE_CARD_STATUS }
enum | mci_send_cmd_flags { MCI_SEND_CMD_STOP, MCI_SEND_CMD_WRITE }
## Functions
static void | sdmmc_mcihost_load_data (struct sdmmc_mcihost *mcihost)
| Process the DMA queue.
struct sdmmc_host * | sdmmc_mcihost_init ()
| Initialize SD/MMC MCI host driver.

## Detailed Description

SD/MMC MCI host driver.

SD/MMC MCI host driver providing interface between host layer and hardware.

- Compiler: IAR EWAVR32 and GNU GCC for AVR32
- Supported devices: All devices
- AppNote:

Author:
  Atmel Corporation: http://www.atmel.com
  Support and FAQ: http://support.atmel.no/

Definition in file mcihost.c.

## Enumeration Type Documentation

enum mci_send_cmd_flags

Enumerator:

  MCI_SEND_CMD_STOP | CMD is a STOP command
  MCI_SEND_CMD_WRITE | CMD is a write command

Definition at line 135 of file mcihost.c.

enum sdmmc_mcihost_state

Enumerator:

  STATE_IDLE | Initial state.
  STATE_SENDING_CMD | Sending initial command.
  STATE_DATA_XFER | Data transfer to/from card.
  STATE_SENDING_STOP | Sending STOP command.
  STATE_FINISH_REQ | Waiting for XFRDONE.
  STATE_CARD_STATUS | Check card status.

Definition at line 96 of file mcihost.c.

## Function Documentation

struct sdmmc_host* sdmmc_mcihost_init | ( | void |  | ) | `[read]`

Initialize SD/MMC MCI host driver.

Returns:
  0 on success, or a negative error code on failure.

Definition at line 1090 of file mcihost.c.

References BOARD_MCISLOT_A_CD, dbg_panic, dbg_printf, delayed_work_init(), DMAC_REG_WIDTH_32BIT, dmac_req_init(), get_mci_pclk_rate(), memset(), min, sdmmc_cd_init(), SDMMC_OCR_V_32_33, SDMMC_OCR_V_33_34, sdmmc_slot_init(), setup_irq_handler, slist_init(), softirq_set_handler(), and workqueue_init_item().

Here is the call graph for this function:

static void sdmmc_mcihost_load_data | ( | struct sdmmc_mcihost * | mcihost | ) | `[static]`

Process the DMA queue.

For internal use only.

Note:
  Must be called with softirq disabled

Definition at line 567 of file mcihost.c.

References assert, sdmmc_request::block_size, sdmmc_request::blocks, sdmmc_request::buf_list, dmac_request::buf_list, sdmmc_request::buf_list_done, dmac_request::bytes_xfered, sdmmc_request::bytes_xfered, dbg_error, dbg_verbose, dmac_chan_submit_request(), slist_init(), slist_is_empty(), slist_move_to_tail(), sdmmc_request::status, dmac_request::status, and STATUS_IN_PROGRESS.

Here is the call graph for this function: