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>
19 #include "card.h"
37 int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card) in mmc_app_cmd() argument
42 if (WARN_ON(card && card->host != host)) in mmc_app_cmd()
43 return -EINVAL; in mmc_app_cmd()
49 if (host->uhs2_sd_tran) { in mmc_app_cmd()
50 host->uhs2_app_cmd = true; in mmc_app_cmd()
56 if (card) { in mmc_app_cmd()
57 cmd.arg = card->rca << 16; in mmc_app_cmd()
68 /* Check that card supported application commands */ in mmc_app_cmd()
70 return -EOPNOTSUPP; in mmc_app_cmd()
76 static int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card, in mmc_wait_for_app_cmd() argument
80 int i, err = -EIO; in mmc_wait_for_app_cmd()
87 err = mmc_app_cmd(host, card); in mmc_wait_for_app_cmd()
91 if (cmd->resp[0] & R1_SPI_ILLEGAL_COMMAND) in mmc_wait_for_app_cmd()
99 memset(cmd->resp, 0, sizeof(cmd->resp)); in mmc_wait_for_app_cmd()
100 cmd->retries = 0; in mmc_wait_for_app_cmd()
103 cmd->data = NULL; in mmc_wait_for_app_cmd()
107 err = cmd->error; in mmc_wait_for_app_cmd()
108 if (!cmd->error) in mmc_wait_for_app_cmd()
113 if (cmd->resp[0] & R1_SPI_ILLEGAL_COMMAND) in mmc_wait_for_app_cmd()
121 int mmc_app_set_bus_width(struct mmc_card *card, int width) in mmc_app_set_bus_width() argument
136 return -EINVAL; in mmc_app_set_bus_width()
139 return mmc_wait_for_app_cmd(card->host, card, &cmd); in mmc_app_set_bus_width()
145 struct mmc_host *host = data->host; in sd_app_op_cond_cb()
146 struct mmc_command *cmd = data->cmd; in sd_app_op_cond_cb()
147 u32 ocr = data->ocr; in sd_app_op_cond_cb()
162 if (!(cmd->resp[0] & R1_SPI_IDLE)) in sd_app_op_cond_cb()
164 } else if (cmd->resp[0] & MMC_CARD_BUSY) { in sd_app_op_cond_cb()
209 if (!mmc_card_ult_capacity(host->card)) in mmc_send_ext_addr()
242 return -EIO; in __mmc_send_if_cond()
261 if (host->caps2 & MMC_CAP2_SD_EXP) { in mmc_send_if_cond_pcie()
262 /* Probe card for SD express support via PCIe. */ in mmc_send_if_cond_pcie()
264 if (host->caps2 & MMC_CAP2_SD_EXP_1_2V) in mmc_send_if_cond_pcie()
273 /* Continue with the SD express init, if the card supports it. */ in mmc_send_if_cond_pcie()
277 host->ios.timing = MMC_TIMING_SD_EXP_1_2V; in mmc_send_if_cond_pcie()
279 host->ios.timing = MMC_TIMING_SD_EXP; in mmc_send_if_cond_pcie()
285 return host->ops->init_sd_express(host, &host->ios); in mmc_send_if_cond_pcie()
309 int mmc_app_send_scr(struct mmc_card *card) in mmc_app_send_scr() argument
318 /* NOTE: caller guarantees scr is heap-allocated */ in mmc_app_send_scr()
320 err = mmc_app_cmd(card->host, card); in mmc_app_send_scr()
325 * routine normally provide temporary on-stack buffers ... in mmc_app_send_scr()
327 scr = kmalloc(sizeof(card->raw_scr), GFP_KERNEL); in mmc_app_send_scr()
329 return -ENOMEM; in mmc_app_send_scr()
346 mmc_set_data_timeout(&data, card); in mmc_app_send_scr()
348 mmc_wait_for_req(card->host, &mrq); in mmc_app_send_scr()
350 card->raw_scr[0] = be32_to_cpu(scr[0]); in mmc_app_send_scr()
351 card->raw_scr[1] = be32_to_cpu(scr[1]); in mmc_app_send_scr()
363 int mmc_sd_switch(struct mmc_card *card, bool mode, int group, in mmc_sd_switch() argument
368 /* NOTE: caller guarantees resp is heap-allocated */ in mmc_sd_switch()
375 return mmc_send_adtc_data(card, card->host, SD_SWITCH, cmd_args, resp, in mmc_sd_switch()
380 int mmc_app_sd_status(struct mmc_card *card, void *ssr) in mmc_app_sd_status() argument
388 /* NOTE: caller guarantees ssr is heap-allocated */ in mmc_app_sd_status()
390 err = mmc_app_cmd(card->host, card); in mmc_app_sd_status()
409 mmc_set_data_timeout(&data, card); in mmc_app_sd_status()
411 mmc_wait_for_req(card->host, &mrq); in mmc_app_sd_status()