Lines Matching +full:mmc +full:- +full:card

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * linux/drivers/mmc/core/sd_ops.h
5 * Copyright 2006-2007 Pierre Ossman
13 #include <linux/mmc/host.h>
14 #include <linux/mmc/card.h>
15 #include <linux/mmc/mmc.h>
16 #include <linux/mmc/sd.h>
36 int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card) in mmc_app_cmd() argument
41 if (WARN_ON(card && card->host != host)) in mmc_app_cmd()
42 return -EINVAL; in mmc_app_cmd()
46 if (card) { in mmc_app_cmd()
47 cmd.arg = card->rca << 16; in mmc_app_cmd()
58 /* Check that card supported application commands */ in mmc_app_cmd()
60 return -EOPNOTSUPP; in mmc_app_cmd()
66 static int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card, in mmc_wait_for_app_cmd() argument
70 int i, err = -EIO; in mmc_wait_for_app_cmd()
77 err = mmc_app_cmd(host, card); in mmc_wait_for_app_cmd()
81 if (cmd->resp[0] & R1_SPI_ILLEGAL_COMMAND) in mmc_wait_for_app_cmd()
89 memset(cmd->resp, 0, sizeof(cmd->resp)); in mmc_wait_for_app_cmd()
90 cmd->retries = 0; in mmc_wait_for_app_cmd()
93 cmd->data = NULL; in mmc_wait_for_app_cmd()
97 err = cmd->error; in mmc_wait_for_app_cmd()
98 if (!cmd->error) in mmc_wait_for_app_cmd()
103 if (cmd->resp[0] & R1_SPI_ILLEGAL_COMMAND) in mmc_wait_for_app_cmd()
111 int mmc_app_set_bus_width(struct mmc_card *card, int width) in mmc_app_set_bus_width() argument
126 return -EINVAL; in mmc_app_set_bus_width()
129 return mmc_wait_for_app_cmd(card->host, card, &cmd); in mmc_app_set_bus_width()
135 struct mmc_host *host = data->host; in sd_app_op_cond_cb()
136 struct mmc_command *cmd = data->cmd; in sd_app_op_cond_cb()
137 u32 ocr = data->ocr; in sd_app_op_cond_cb()
152 if (!(cmd->resp[0] & R1_SPI_IDLE)) in sd_app_op_cond_cb()
154 } else if (cmd->resp[0] & MMC_CARD_BUSY) { in sd_app_op_cond_cb()
218 return -EIO; in __mmc_send_if_cond()
237 if (host->caps2 & MMC_CAP2_SD_EXP) { in mmc_send_if_cond_pcie()
238 /* Probe card for SD express support via PCIe. */ in mmc_send_if_cond_pcie()
240 if (host->caps2 & MMC_CAP2_SD_EXP_1_2V) in mmc_send_if_cond_pcie()
249 /* Continue with the SD express init, if the card supports it. */ in mmc_send_if_cond_pcie()
253 host->ios.timing = MMC_TIMING_SD_EXP_1_2V; in mmc_send_if_cond_pcie()
255 host->ios.timing = MMC_TIMING_SD_EXP; in mmc_send_if_cond_pcie()
261 return host->ops->init_sd_express(host, &host->ios); in mmc_send_if_cond_pcie()
285 int mmc_app_send_scr(struct mmc_card *card) in mmc_app_send_scr() argument
294 /* NOTE: caller guarantees scr is heap-allocated */ in mmc_app_send_scr()
296 err = mmc_app_cmd(card->host, card); in mmc_app_send_scr()
301 * routine normally provide temporary on-stack buffers ... in mmc_app_send_scr()
303 scr = kmalloc(sizeof(card->raw_scr), GFP_KERNEL); in mmc_app_send_scr()
305 return -ENOMEM; in mmc_app_send_scr()
322 mmc_set_data_timeout(&data, card); in mmc_app_send_scr()
324 mmc_wait_for_req(card->host, &mrq); in mmc_app_send_scr()
326 card->raw_scr[0] = be32_to_cpu(scr[0]); in mmc_app_send_scr()
327 card->raw_scr[1] = be32_to_cpu(scr[1]); in mmc_app_send_scr()
339 int mmc_sd_switch(struct mmc_card *card, bool mode, int group, in mmc_sd_switch() argument
344 /* NOTE: caller guarantees resp is heap-allocated */ in mmc_sd_switch()
351 return mmc_send_adtc_data(card, card->host, SD_SWITCH, cmd_args, resp, in mmc_sd_switch()
356 int mmc_app_sd_status(struct mmc_card *card, void *ssr) in mmc_app_sd_status() argument
364 /* NOTE: caller guarantees ssr is heap-allocated */ in mmc_app_sd_status()
366 err = mmc_app_cmd(card->host, card); in mmc_app_sd_status()
385 mmc_set_data_timeout(&data, card); in mmc_app_sd_status()
387 mmc_wait_for_req(card->host, &mrq); in mmc_app_sd_status()