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>
22 int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card) in mmc_app_cmd() argument
27 if (WARN_ON(card && card->host != host)) in mmc_app_cmd()
28 return -EINVAL; in mmc_app_cmd()
32 if (card) { in mmc_app_cmd()
33 cmd.arg = card->rca << 16; in mmc_app_cmd()
44 /* Check that card supported application commands */ in mmc_app_cmd()
46 return -EOPNOTSUPP; in mmc_app_cmd()
52 static int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card, in mmc_wait_for_app_cmd() argument
56 int i, err = -EIO; in mmc_wait_for_app_cmd()
63 err = mmc_app_cmd(host, card); in mmc_wait_for_app_cmd()
67 if (cmd->resp[0] & R1_SPI_ILLEGAL_COMMAND) in mmc_wait_for_app_cmd()
75 memset(cmd->resp, 0, sizeof(cmd->resp)); in mmc_wait_for_app_cmd()
76 cmd->retries = 0; in mmc_wait_for_app_cmd()
79 cmd->data = NULL; in mmc_wait_for_app_cmd()
83 err = cmd->error; in mmc_wait_for_app_cmd()
84 if (!cmd->error) in mmc_wait_for_app_cmd()
89 if (cmd->resp[0] & R1_SPI_ILLEGAL_COMMAND) in mmc_wait_for_app_cmd()
97 int mmc_app_set_bus_width(struct mmc_card *card, int width) in mmc_app_set_bus_width() argument
112 return -EINVAL; in mmc_app_set_bus_width()
115 return mmc_wait_for_app_cmd(card->host, card, &cmd); in mmc_app_set_bus_width()
130 for (i = 100; i; i--) { in mmc_send_app_op_cond()
148 err = -ETIMEDOUT; in mmc_send_app_op_cond()
154 pr_err("%s: card never left busy state\n", mmc_hostname(host)); in mmc_send_app_op_cond()
189 return -EIO; in __mmc_send_if_cond()
208 if (host->caps2 & MMC_CAP2_SD_EXP) { in mmc_send_if_cond_pcie()
209 /* Probe card for SD express support via PCIe. */ in mmc_send_if_cond_pcie()
211 if (host->caps2 & MMC_CAP2_SD_EXP_1_2V) in mmc_send_if_cond_pcie()
220 /* Continue with the SD express init, if the card supports it. */ in mmc_send_if_cond_pcie()
224 host->ios.timing = MMC_TIMING_SD_EXP_1_2V; in mmc_send_if_cond_pcie()
226 host->ios.timing = MMC_TIMING_SD_EXP; in mmc_send_if_cond_pcie()
232 return host->ops->init_sd_express(host, &host->ios); in mmc_send_if_cond_pcie()
256 int mmc_app_send_scr(struct mmc_card *card) in mmc_app_send_scr() argument
265 /* NOTE: caller guarantees scr is heap-allocated */ in mmc_app_send_scr()
267 err = mmc_app_cmd(card->host, card); in mmc_app_send_scr()
272 * routine normally provide temporary on-stack buffers ... in mmc_app_send_scr()
274 scr = kmalloc(sizeof(card->raw_scr), GFP_KERNEL); in mmc_app_send_scr()
276 return -ENOMEM; in mmc_app_send_scr()
293 mmc_set_data_timeout(&data, card); in mmc_app_send_scr()
295 mmc_wait_for_req(card->host, &mrq); in mmc_app_send_scr()
297 card->raw_scr[0] = be32_to_cpu(scr[0]); in mmc_app_send_scr()
298 card->raw_scr[1] = be32_to_cpu(scr[1]); in mmc_app_send_scr()
310 int mmc_sd_switch(struct mmc_card *card, int mode, int group, in mmc_sd_switch() argument
315 /* NOTE: caller guarantees resp is heap-allocated */ in mmc_sd_switch()
323 return mmc_send_adtc_data(card, card->host, SD_SWITCH, cmd_args, resp, in mmc_sd_switch()
328 int mmc_app_sd_status(struct mmc_card *card, void *ssr) in mmc_app_sd_status() argument
336 /* NOTE: caller guarantees ssr is heap-allocated */ in mmc_app_sd_status()
338 err = mmc_app_cmd(card->host, card); in mmc_app_sd_status()
357 mmc_set_data_timeout(&data, card); in mmc_app_sd_status()
359 mmc_wait_for_req(card->host, &mrq); in mmc_app_sd_status()