Lines Matching full:mmc
11 #include <mmc.h>
16 static inline void *get_regbase(const struct mmc *mmc) in get_regbase() argument
18 struct meson_mmc_platdata *pdata = mmc->priv; in get_regbase()
23 static inline uint32_t meson_read(struct mmc *mmc, int offset) in meson_read() argument
25 return readl(get_regbase(mmc) + offset); in meson_read()
28 static inline void meson_write(struct mmc *mmc, uint32_t val, int offset) in meson_write() argument
30 writel(val, get_regbase(mmc) + offset); in meson_write()
33 static void meson_mmc_config_clock(struct mmc *mmc) in meson_mmc_config_clock() argument
39 if (mmc->clock > 16000000) { in meson_mmc_config_clock()
46 clk_div = DIV_ROUND_UP(clk, mmc->clock); in meson_mmc_config_clock()
58 meson_write(mmc, meson_mmc_clk, MESON_SD_EMMC_CLOCK); in meson_mmc_config_clock()
63 struct mmc *mmc = mmc_get_mmc_dev(dev); in meson_dm_mmc_set_ios() local
66 meson_mmc_config_clock(mmc); in meson_dm_mmc_set_ios()
68 meson_mmc_cfg = meson_read(mmc, MESON_SD_EMMC_CFG); in meson_dm_mmc_set_ios()
71 if (mmc->bus_width == 1) in meson_dm_mmc_set_ios()
73 else if (mmc->bus_width == 4) in meson_dm_mmc_set_ios()
75 else if (mmc->bus_width == 8) in meson_dm_mmc_set_ios()
92 meson_write(mmc, meson_mmc_cfg, MESON_SD_EMMC_CFG); in meson_dm_mmc_set_ios()
97 static void meson_mmc_setup_cmd(struct mmc *mmc, struct mmc_data *data, in meson_mmc_setup_cmd() argument
118 cfg = meson_read(mmc, MESON_SD_EMMC_CFG); in meson_mmc_setup_cmd()
121 meson_write(mmc, cfg, MESON_SD_EMMC_CFG); in meson_mmc_setup_cmd()
133 meson_write(mmc, meson_mmc_cmd, MESON_SD_EMMC_CMD_CFG); in meson_mmc_setup_cmd()
136 static void meson_mmc_setup_addr(struct mmc *mmc, struct mmc_data *data) in meson_mmc_setup_addr() argument
138 struct meson_mmc_platdata *pdata = mmc->priv; in meson_mmc_setup_addr()
157 meson_write(mmc, data_addr, MESON_SD_EMMC_CMD_DAT); in meson_mmc_setup_addr()
160 static void meson_mmc_read_response(struct mmc *mmc, struct mmc_cmd *cmd) in meson_mmc_read_response() argument
163 cmd->response[0] = meson_read(mmc, MESON_SD_EMMC_CMD_RSP3); in meson_mmc_read_response()
164 cmd->response[1] = meson_read(mmc, MESON_SD_EMMC_CMD_RSP2); in meson_mmc_read_response()
165 cmd->response[2] = meson_read(mmc, MESON_SD_EMMC_CMD_RSP1); in meson_mmc_read_response()
166 cmd->response[3] = meson_read(mmc, MESON_SD_EMMC_CMD_RSP); in meson_mmc_read_response()
168 cmd->response[0] = meson_read(mmc, MESON_SD_EMMC_CMD_RSP); in meson_mmc_read_response()
175 struct mmc *mmc = mmc_get_mmc_dev(dev); in meson_dm_mmc_send_cmd() local
176 struct meson_mmc_platdata *pdata = mmc->priv; in meson_dm_mmc_send_cmd()
185 meson_mmc_setup_cmd(mmc, data, cmd); in meson_dm_mmc_send_cmd()
186 meson_mmc_setup_addr(mmc, data); in meson_dm_mmc_send_cmd()
188 meson_write(mmc, cmd->cmdarg, MESON_SD_EMMC_CMD_ARG); in meson_dm_mmc_send_cmd()
193 status = meson_read(mmc, MESON_SD_EMMC_STATUS); in meson_dm_mmc_send_cmd()
203 meson_mmc_read_response(mmc, cmd); in meson_dm_mmc_send_cmd()
209 meson_write(mmc, STATUS_MASK, MESON_SD_EMMC_STATUS); in meson_dm_mmc_send_cmd()
237 struct mmc *mmc = &pdata->mmc; in meson_mmc_probe() local
250 mmc->priv = pdata; in meson_mmc_probe()
251 upriv->mmc = mmc; in meson_mmc_probe()
253 mmc_set_clock(mmc, cfg->f_min); in meson_mmc_probe()
256 meson_write(mmc, STATUS_MASK, MESON_SD_EMMC_STATUS); in meson_mmc_probe()
259 meson_write(mmc, 0, MESON_SD_EMMC_IRQ_EN); in meson_mmc_probe()
262 val = meson_read(mmc, MESON_SD_EMMC_CFG); in meson_mmc_probe()
265 meson_write(mmc, val, MESON_SD_EMMC_CFG); in meson_mmc_probe()
274 return mmc_bind(dev, &pdata->mmc, &pdata->cfg); in meson_mmc_bind()
278 { .compatible = "amlogic,meson-gx-mmc" },