coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
msdc.c File Reference
#include <assert.h>
#include <cbmem.h>
#include <commonlib/bsd/helpers.h>
#include <commonlib/storage/sd_mmc.h>
#include <console/console.h>
#include <delay.h>
#include <device/mmio.h>
#include <lib.h>
#include <soc/msdc.h>
#include <string.h>
#include <timer.h>
Include dependency graph for msdc.c:

Go to the source code of this file.

Functions

static void msdc_set_field (void *reg, u32 field, u32 val)
 
static int msdc_poll_timeout (void *addr, u32 mask)
 
static int msdc_wait_done (void *addr, u32 mask, u32 *status)
 
static void msdc_reset_hw (struct msdc_ctrlr *host)
 
static void msdc_init_hw (struct msdc_ctrlr *host)
 
static void msdc_fifo_clr (struct msdc_ctrlr *host)
 
static u32 msdc_cmd_find_resp (struct msdc_ctrlr *host, struct mmc_command *cmd)
 
static bool msdc_cmd_is_ready (struct msdc_ctrlr *host)
 
static u32 msdc_cmd_prepare_raw_cmd (struct msdc_ctrlr *host, struct mmc_command *cmd, struct mmc_data *data)
 
static int msdc_cmd_done (struct msdc_ctrlr *host, int events, struct mmc_command *cmd)
 
static int msdc_start_command (struct msdc_ctrlr *host, struct mmc_command *cmd, struct mmc_data *data)
 
static int msdc_send_command (struct sd_mmc_ctrlr *ctrlr, struct mmc_command *cmd, struct mmc_data *data)
 
static void msdc_set_clock (struct msdc_ctrlr *host, u32 clock)
 
static void msdc_set_buswidth (struct msdc_ctrlr *host, u32 width)
 
static void msdc_set_ios (struct sd_mmc_ctrlr *ctrlr)
 
static void msdc_update_pointers (struct msdc_ctrlr *host)
 
static void add_msdc (struct msdc_ctrlr *host)
 
static void msdc_controller_init (struct msdc_ctrlr *host, void *base, void *top_base)
 
static void set_early_mmc_wake_status (int32_t status)
 
int mtk_emmc_early_init (void *base, void *top_base)
 

Function Documentation

◆ add_msdc()

static void add_msdc ( struct msdc_ctrlr host)
static

Definition at line 410 of file msdc.c.

References sd_mmc_ctrlr::caps, sd_mmc_ctrlr::f_max, sd_mmc_ctrlr::f_min, msdc_init_hw(), msdc_trace, msdc_update_pointers(), msdc_ctrlr::sd_mmc_ctrlr, and sd_mmc_ctrlr::voltages.

Referenced by msdc_controller_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ msdc_cmd_done()

static int msdc_cmd_done ( struct msdc_ctrlr host,
int  events,
struct mmc_command cmd 
)
static

Definition at line 242 of file msdc.c.

References msdc_ctrlr::base, CARD_RSP_136, CARD_RSP_PRESENT, mmc_command::cmdidx, EIO, ETIMEDOUT, MMC_CMD_AUTO_TUNING_SEQUENCE, MSDC_INT_CMDRDY, MSDC_INT_CMDTMO, msdc_reset_hw(), read32(), mmc_command::resp_type, mmc_command::response, SDC_RESP0, SDC_RESP1, SDC_RESP2, and SDC_RESP3.

Referenced by msdc_start_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ msdc_cmd_find_resp()

static u32 msdc_cmd_find_resp ( struct msdc_ctrlr host,
struct mmc_command cmd 
)
static

Definition at line 156 of file msdc.c.

References CARD_RSP_NONE, CARD_RSP_R1, CARD_RSP_R1b, CARD_RSP_R2, CARD_RSP_R3, and mmc_command::resp_type.

Referenced by msdc_cmd_prepare_raw_cmd().

Here is the caller graph for this function:

◆ msdc_cmd_is_ready()

static bool msdc_cmd_is_ready ( struct msdc_ctrlr host)
static

Definition at line 173 of file msdc.c.

References msdc_ctrlr::base, msdc_error, msdc_poll_timeout(), msdc_reset_hw(), MSDC_SUCCESS, read32(), SDC_STS, SDC_STS_CMDBUSY, and SDC_STS_SDCBUSY.

Referenced by msdc_start_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ msdc_cmd_prepare_raw_cmd()

◆ msdc_controller_init()

static void msdc_controller_init ( struct msdc_ctrlr host,
void base,
void top_base 
)
static

Definition at line 430 of file msdc.c.

References add_msdc(), base, msdc_ctrlr::base, memset(), msdc_ctrlr::src_hz, and msdc_ctrlr::top_base.

Referenced by mtk_emmc_early_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ msdc_fifo_clr()

static void msdc_fifo_clr ( struct msdc_ctrlr host)
static

Definition at line 148 of file msdc.c.

References msdc_ctrlr::base, msdc_error, MSDC_FIFOCS, MSDC_FIFOCS_CLR, msdc_poll_timeout(), MSDC_SUCCESS, and setbits32.

Referenced by msdc_start_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ msdc_init_hw()

◆ msdc_poll_timeout()

static int msdc_poll_timeout ( void addr,
u32  mask 
)
static

Definition at line 30 of file msdc.c.

References addr, mask, MSDC_NOT_READY, MSDC_SUCCESS, MSDC_TIMEOUT_US, read32(), stopwatch_expired(), stopwatch_init_usecs_expire(), and udelay().

Referenced by msdc_cmd_is_ready(), msdc_fifo_clr(), and msdc_reset_hw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ msdc_reset_hw()

static void msdc_reset_hw ( struct msdc_ctrlr host)
static

Definition at line 72 of file msdc.c.

References msdc_ctrlr::base, MSDC_CFG, MSDC_CFG_RST, msdc_error, MSDC_FIFOCS, MSDC_FIFOCS_CLR, MSDC_INT, msdc_poll_timeout(), MSDC_SUCCESS, read32(), setbits32, val, and write32().

Referenced by msdc_cmd_done(), msdc_cmd_is_ready(), msdc_init_hw(), and msdc_start_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ msdc_send_command()

static int msdc_send_command ( struct sd_mmc_ctrlr ctrlr,
struct mmc_command cmd,
struct mmc_data data 
)
static

Definition at line 311 of file msdc.c.

References container_of, and msdc_start_command().

Referenced by msdc_update_pointers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ msdc_set_buswidth()

static void msdc_set_buswidth ( struct msdc_ctrlr host,
u32  width 
)
static

Definition at line 358 of file msdc.c.

References msdc_ctrlr::base, MSDC_BUS_1BITS, MSDC_BUS_4BITS, MSDC_BUS_8BITS, msdc_trace, read32(), SDC_CFG, SDC_CFG_BUSWIDTH, val, width, and write32().

Referenced by msdc_set_ios().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ msdc_set_clock()

static void msdc_set_clock ( struct msdc_ctrlr host,
u32  clock 
)
static

Definition at line 321 of file msdc.c.

References assert, msdc_ctrlr::base, sd_mmc_ctrlr::bus_hz, clrsetbits_le32, DIV_ROUND_UP, MSDC_CFG, MSDC_CFG_CKSTB, msdc_debug, msdc_error, MSDC_SUCCESS, msdc_wait_done(), NULL, msdc_ctrlr::sd_mmc_ctrlr, and msdc_ctrlr::src_hz.

Referenced by msdc_set_ios().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ msdc_set_field()

static void msdc_set_field ( void reg,
u32  field,
u32  val 
)
inlinestatic

Definition at line 17 of file msdc.c.

References __ffs(), clrsetbits32, and val.

Referenced by msdc_init_hw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ msdc_set_ios()

static void msdc_set_ios ( struct sd_mmc_ctrlr ctrlr)
static

Definition at line 381 of file msdc.c.

References sd_mmc_ctrlr::bus_hz, sd_mmc_ctrlr::bus_width, container_of, msdc_set_buswidth(), msdc_set_clock(), and sd_mmc_ctrlr::request_hz.

Referenced by msdc_update_pointers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ msdc_start_command()

static int msdc_start_command ( struct msdc_ctrlr host,
struct mmc_command cmd,
struct mmc_data data 
)
static

◆ msdc_update_pointers()

static void msdc_update_pointers ( struct msdc_ctrlr host)
static

Definition at line 395 of file msdc.c.

References sd_mmc_ctrlr::bus_width, sd_mmc_ctrlr::caps, DRVR_CAP_HC, DRVR_CAP_HS, sd_mmc_ctrlr::f_max, sd_mmc_ctrlr::f_min, msdc_send_command(), msdc_set_ios(), msdc_ctrlr::sd_mmc_ctrlr, sd_mmc_ctrlr::send_cmd, sd_mmc_ctrlr::set_ios, and sd_mmc_ctrlr::voltages.

Referenced by add_msdc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ msdc_wait_done()

static int msdc_wait_done ( void addr,
u32  mask,
u32 status 
)
static

Definition at line 50 of file msdc.c.

References addr, CMD_TIMEOUT_MS, mask, MSDC_NOT_READY, MSDC_SUCCESS, read32(), stopwatch_expired(), stopwatch_init_usecs_expire(), and udelay().

Referenced by msdc_set_clock(), and msdc_start_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mtk_emmc_early_init()

int mtk_emmc_early_init ( void base,
void top_base 
)

◆ set_early_mmc_wake_status()

static void set_early_mmc_wake_status ( int32_t  status)
static

Definition at line 440 of file msdc.c.

References BIOS_DEBUG, BIOS_ERR, cbmem_add(), CBMEM_ID_MMC_STATUS, NULL, and printk.

Referenced by mtk_emmc_early_init().

Here is the call graph for this function:
Here is the caller graph for this function: