64 }
while (!(reg &
mask));
179 msdc_error(
"CMD bus busy detected, SDC_STS: %#x\n",
187 msdc_error(
"SD controller busy detected, SDC_STS: %#x\n",
288 msdc_error(
"TX/RX FIFO non-empty before start of IO. Reset\n");
323 u32 mode, mode_shift;
325 const u32 div_width = 12;
336 if (clock >= (hclk / 2)) {
341 sclk = (hclk >> 2) / div;
345 div_mask = (1 << div_width) - 1;
346 mode_shift = 8 + div_width;
350 (mode << mode_shift) | (div << 8));
352 msdc_error(
"Failed while wait clock stable!\n");
403 ctrlr->
f_min = 400 * 1000;
404 ctrlr->
f_max = 52 * 1000 * 1000;
422 ctrlr->
f_max / 1000000,
423 (ctrlr->
f_max / 1000) % 1000);
425 ctrlr->
f_min / 1000000,
426 (ctrlr->
f_min / 1000) % 1000);
432 memset(host, 0,
sizeof(*host));
435 host->
src_hz = 50 * 1000 * 1000;
446 if (ms_cbmem ==
NULL) {
448 "%s: Failed to add early mmc wake status to cbmem!\n",
static void write32(void *addr, uint32_t val)
static uint32_t read32(const void *addr)
void * memset(void *dstpp, int c, size_t len)
#define assert(statement)
#define DIV_ROUND_UP(x, y)
void * cbmem_add(u32 id, u64 size)
#define CBMEM_ID_MMC_STATUS
static int msdc_wait_done(void *addr, u32 mask, u32 *status)
static void msdc_fifo_clr(struct msdc_ctrlr *host)
int mtk_emmc_early_init(void *base, void *top_base)
static int msdc_send_command(struct sd_mmc_ctrlr *ctrlr, struct mmc_command *cmd, struct mmc_data *data)
static void msdc_set_ios(struct sd_mmc_ctrlr *ctrlr)
static void msdc_update_pointers(struct msdc_ctrlr *host)
static int msdc_poll_timeout(void *addr, u32 mask)
static void msdc_set_buswidth(struct msdc_ctrlr *host, u32 width)
static bool msdc_cmd_is_ready(struct msdc_ctrlr *host)
static void msdc_init_hw(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_start_command(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 void msdc_reset_hw(struct msdc_ctrlr *host)
static void add_msdc(struct msdc_ctrlr *host)
static void set_early_mmc_wake_status(int32_t status)
static void msdc_set_field(void *reg, u32 field, u32 val)
static void msdc_controller_init(struct msdc_ctrlr *host, void *base, void *top_base)
static void msdc_set_clock(struct msdc_ctrlr *host, u32 clock)
static u32 msdc_cmd_find_resp(struct msdc_ctrlr *host, struct mmc_command *cmd)
#define printk(level,...)
int mmc_send_op_cond(struct storage_media *media)
#define container_of(ptr, type, member)
container_of - cast a member of a structure out to the containing structure
#define setbits32(addr, set)
#define clrsetbits32(addr, clear, set)
#define clrbits32(addr, clear)
#define clrsetbits_le32(addr, clear, set)
static int stopwatch_expired(struct stopwatch *sw)
static void stopwatch_init_usecs_expire(struct stopwatch *sw, long us)
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
#define msdc_debug(format...)
#define MSDC_PB2_RESPWAIT
#define SDC_FIFO_CFG_WRVALIDSEL
#define MSDC_IOCON_DDLSEL
#define SDC_CMD_BLK_LEN_S
#define msdc_error(format...)
#define msdc_trace(format...)
#define SDC_CMD_BLK_LEN_M
#define MSDC_PATCH_BIT1_STOP_DLY
#define SDC_DAT1_IRQ_TRIGGER
#define PAD_DAT_RD_RXDLY_SEL
#define PAD_CMD_RD_RXDLY_SEL
#define MSDC_PATCH_BIT2_CFGRESP
#define SDC_FIFO_CFG_RDVALIDSEL
#define MSDC_CKGEN_MSDC_DLY_SEL
#define MSDC_PATCH_BIT2_CFGCRCSTS
#define MSDC_FIFOCS_RXCNT
#define MSDC_PAD_TUNE_RD_SEL
#define MSDC_PAD_TUNE_CMD_SEL
#define SDC_RX_ENHANCE_EN
#define EMMC50_CFG_CFCSTS_SEL
#define MSDC_FIFOCS_TXCNT
int sd_mmc_go_idle(struct storage_media *media)
#define SET_BUS_WIDTH(ctrlr, width)
#define SET_CLOCK(ctrlr, clock_hz)
#define MMC_CMD_WRITE_MULTIPLE_BLOCK
#define MMC_CMD_SEND_STATUS
#define MMC_CMD_READ_SINGLE_BLOCK
#define MMC_CMD_READ_MULTIPLE_BLOCK
#define MMC_CMD_AUTO_TUNING_SEQUENCE
#define MMC_CMD_STOP_TRANSMISSION
#define MMC_CMD_WRITE_SINGLE_BLOCK
@ MMC_STATUS_CMD1_IN_PROGRESS
struct sd_mmc_ctrlr sd_mmc_ctrlr
int(* send_cmd)(struct sd_mmc_ctrlr *ctrlr, struct mmc_command *cmd, struct mmc_data *data)
void(* set_ios)(struct sd_mmc_ctrlr *ctrlr)