Lines Matching refs:mmc
15 static inline void *get_regbase(const struct mmc *mmc) in get_regbase() argument
17 struct meson_mmc_platdata *pdata = mmc->priv; in get_regbase()
22 static inline uint32_t meson_read(struct mmc *mmc, int offset) in meson_read() argument
24 return readl(get_regbase(mmc) + offset); in meson_read()
27 static inline void meson_write(struct mmc *mmc, uint32_t val, int offset) in meson_write() argument
29 writel(val, get_regbase(mmc) + offset); in meson_write()
32 static void meson_mmc_config_clock(struct mmc *mmc) in meson_mmc_config_clock() argument
37 if (!mmc->clock) in meson_mmc_config_clock()
41 if (mmc->clock > 16000000) { in meson_mmc_config_clock()
48 clk_div = DIV_ROUND_UP(clk, mmc->clock); in meson_mmc_config_clock()
60 meson_write(mmc, meson_mmc_clk, MESON_SD_EMMC_CLOCK); in meson_mmc_config_clock()
65 struct mmc *mmc = mmc_get_mmc_dev(dev); in meson_dm_mmc_set_ios() local
68 meson_mmc_config_clock(mmc); in meson_dm_mmc_set_ios()
70 meson_mmc_cfg = meson_read(mmc, MESON_SD_EMMC_CFG); in meson_dm_mmc_set_ios()
73 if (mmc->bus_width == 1) in meson_dm_mmc_set_ios()
75 else if (mmc->bus_width == 4) in meson_dm_mmc_set_ios()
77 else if (mmc->bus_width == 8) in meson_dm_mmc_set_ios()
94 meson_write(mmc, meson_mmc_cfg, MESON_SD_EMMC_CFG); in meson_dm_mmc_set_ios()
99 static void meson_mmc_setup_cmd(struct mmc *mmc, struct mmc_data *data, in meson_mmc_setup_cmd() argument
120 cfg = meson_read(mmc, MESON_SD_EMMC_CFG); in meson_mmc_setup_cmd()
123 meson_write(mmc, cfg, MESON_SD_EMMC_CFG); in meson_mmc_setup_cmd()
135 meson_write(mmc, meson_mmc_cmd, MESON_SD_EMMC_CMD_CFG); in meson_mmc_setup_cmd()
138 static void meson_mmc_setup_addr(struct mmc *mmc, struct mmc_data *data) in meson_mmc_setup_addr() argument
140 struct meson_mmc_platdata *pdata = mmc->priv; in meson_mmc_setup_addr()
159 meson_write(mmc, data_addr, MESON_SD_EMMC_CMD_DAT); in meson_mmc_setup_addr()
162 static void meson_mmc_read_response(struct mmc *mmc, struct mmc_cmd *cmd) in meson_mmc_read_response() argument
165 cmd->response[0] = meson_read(mmc, MESON_SD_EMMC_CMD_RSP3); in meson_mmc_read_response()
166 cmd->response[1] = meson_read(mmc, MESON_SD_EMMC_CMD_RSP2); in meson_mmc_read_response()
167 cmd->response[2] = meson_read(mmc, MESON_SD_EMMC_CMD_RSP1); in meson_mmc_read_response()
168 cmd->response[3] = meson_read(mmc, MESON_SD_EMMC_CMD_RSP); in meson_mmc_read_response()
170 cmd->response[0] = meson_read(mmc, MESON_SD_EMMC_CMD_RSP); in meson_mmc_read_response()
177 struct mmc *mmc = mmc_get_mmc_dev(dev); in meson_dm_mmc_send_cmd() local
178 struct meson_mmc_platdata *pdata = mmc->priv; in meson_dm_mmc_send_cmd()
187 meson_mmc_setup_cmd(mmc, data, cmd); in meson_dm_mmc_send_cmd()
188 meson_mmc_setup_addr(mmc, data); in meson_dm_mmc_send_cmd()
190 meson_write(mmc, cmd->cmdarg, MESON_SD_EMMC_CMD_ARG); in meson_dm_mmc_send_cmd()
195 status = meson_read(mmc, MESON_SD_EMMC_STATUS); in meson_dm_mmc_send_cmd()
205 meson_mmc_read_response(mmc, cmd); in meson_dm_mmc_send_cmd()
211 meson_write(mmc, STATUS_MASK, MESON_SD_EMMC_STATUS); in meson_dm_mmc_send_cmd()
239 struct mmc *mmc = &pdata->mmc; in meson_mmc_probe() local
252 mmc->priv = pdata; in meson_mmc_probe()
253 upriv->mmc = mmc; in meson_mmc_probe()
255 mmc_set_clock(mmc, cfg->f_min, MMC_CLK_ENABLE); in meson_mmc_probe()
258 meson_write(mmc, STATUS_MASK, MESON_SD_EMMC_STATUS); in meson_mmc_probe()
261 meson_write(mmc, 0, MESON_SD_EMMC_IRQ_EN); in meson_mmc_probe()
264 val = meson_read(mmc, MESON_SD_EMMC_CFG); in meson_mmc_probe()
267 meson_write(mmc, val, MESON_SD_EMMC_CFG); in meson_mmc_probe()
276 return mmc_bind(dev, &pdata->mmc, &pdata->cfg); in meson_mmc_bind()