2019-05-27 14:55:01 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2006-12-25 05:46:55 +08:00
|
|
|
/*
|
2007-07-12 02:04:50 +08:00
|
|
|
* linux/drivers/mmc/core/mmc_ops.h
|
2006-12-25 05:46:55 +08:00
|
|
|
*
|
|
|
|
* Copyright 2006-2007 Pierre Ossman
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MMC_MMC_OPS_H
|
|
|
|
#define _MMC_MMC_OPS_H
|
|
|
|
|
2017-01-13 21:14:07 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
|
2020-02-04 16:54:45 +08:00
|
|
|
enum mmc_busy_cmd {
|
|
|
|
MMC_BUSY_CMD6,
|
|
|
|
MMC_BUSY_ERASE,
|
2020-02-04 16:54:47 +08:00
|
|
|
MMC_BUSY_HPI,
|
2021-05-11 18:13:59 +08:00
|
|
|
MMC_BUSY_EXTR_SINGLE,
|
2021-07-02 21:42:27 +08:00
|
|
|
MMC_BUSY_IO,
|
2020-02-04 16:54:45 +08:00
|
|
|
};
|
|
|
|
|
2017-01-13 21:14:07 +08:00
|
|
|
struct mmc_host;
|
|
|
|
struct mmc_card;
|
2021-05-05 00:12:12 +08:00
|
|
|
struct mmc_command;
|
2017-01-13 21:14:07 +08:00
|
|
|
|
2006-12-25 05:46:55 +08:00
|
|
|
int mmc_select_card(struct mmc_card *card);
|
|
|
|
int mmc_deselect_cards(struct mmc_host *host);
|
2014-08-19 16:45:51 +08:00
|
|
|
int mmc_set_dsr(struct mmc_host *host);
|
2006-12-25 05:46:55 +08:00
|
|
|
int mmc_go_idle(struct mmc_host *host);
|
|
|
|
int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr);
|
|
|
|
int mmc_set_relative_addr(struct mmc_card *card);
|
2021-05-05 00:12:17 +08:00
|
|
|
int mmc_send_adtc_data(struct mmc_card *card, struct mmc_host *host, u32 opcode,
|
|
|
|
u32 args, void *buf, unsigned len);
|
2006-12-25 05:46:55 +08:00
|
|
|
int mmc_send_csd(struct mmc_card *card, u32 *csd);
|
2017-05-22 16:23:58 +08:00
|
|
|
int __mmc_send_status(struct mmc_card *card, u32 *status, unsigned int retries);
|
2006-12-25 05:46:55 +08:00
|
|
|
int mmc_send_status(struct mmc_card *card, u32 *status);
|
MMC core learns about SPI
Teach the MMC/SD/SDIO core about using SPI mode.
- Use mmc_host_is_spi() so enumeration works through SPI signaling
and protocols, not just the native versions.
- Provide the SPI response type flags with each request issued,
including requests from the new lock/unlock code.
- Understand that cmd->resp[0] and mmc_get_status() results for SPI
return different values than for "native" MMC/SD protocol; this
affects resetting, checking card lock status, and some others.
- Understand that some commands act a bit differently ... notably:
* OP_COND command doesn't return the OCR
* APP_CMD status doesn't have an R1_APP_CMD analogue
Those changes required some new and updated primitives:
- Provide utilities to access two SPI-only requests, and one
request that wasn't previously needed:
* mmc_spi_read_ocr() ... SPI only
* mmc_spi_set_crc() ... SPI only (override by module parm)
* mmc_send_cid() ... for use without broadcast mode
- Updated internal routines:
* Previous mmc_send_csd() modified into mmc_send_cxd_native();
it uses native "R2" responses, which include 16 bytes of data.
* Previous mmc_send_ext_csd() becomes new mmc_send_cxd_data()
helper for command-and-data access
* Bugfix to that mmc_send_cxd_data() code: dma-to-stack is
unsafe/nonportable, so kmalloc a bounce buffer instead.
- Modified mmc_send_ext_csd() now uses mmc_send_cxd_data() helper
- Modified mmc_send_csd(), and new mmc_spi_send_cid(), routines use
those helper routines based on whether they're native or SPI
The newest categories of cards supported by the MMC stack aren't expected
to work yet with SPI: MMC or SD cards with over 4GB data, and SDIO.
All those cards support SPI mode, so eventually they should work too.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
2007-08-09 00:11:32 +08:00
|
|
|
int mmc_send_cid(struct mmc_host *host, u32 *cid);
|
|
|
|
int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp);
|
|
|
|
int mmc_spi_set_crc(struct mmc_host *host, int use_crc);
|
2010-12-15 15:14:24 +08:00
|
|
|
int mmc_bus_test(struct mmc_card *card, u8 bus_width);
|
2014-10-20 17:33:53 +08:00
|
|
|
int mmc_can_ext_csd(struct mmc_card *card);
|
2020-02-04 16:54:40 +08:00
|
|
|
int mmc_switch_status(struct mmc_card *card, bool crc_err_fatal);
|
2021-05-05 00:12:12 +08:00
|
|
|
bool mmc_prepare_busy_cmd(struct mmc_host *host, struct mmc_command *cmd,
|
|
|
|
unsigned int timeout_ms);
|
2022-03-04 18:56:56 +08:00
|
|
|
int __mmc_poll_for_busy(struct mmc_host *host, unsigned int period_us,
|
|
|
|
unsigned int timeout_ms,
|
2021-05-05 00:12:15 +08:00
|
|
|
int (*busy_cb)(void *cb_data, bool *busy),
|
|
|
|
void *cb_data);
|
2020-02-04 16:54:45 +08:00
|
|
|
int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
|
2021-05-05 00:12:15 +08:00
|
|
|
bool retry_crc_err, enum mmc_busy_cmd busy_cmd);
|
2015-09-15 21:19:45 +08:00
|
|
|
int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
|
mmc: core: Enable __mmc_switch() to change bus speed timing for the host
In cases when a speed mode change is requested for mmc cards, a CMD6 is
sent by calling __mmc_switch() during the card initialization. The CMD6
leads to the card entering a busy period. When that is completed, the host
must parse the CMD6 status to find out whether the change of the speed mode
succeeded.
To enable the mmc core to poll the card by using CMD13 to find out when the
busy period is completed, it's reasonable to make sure polling is done by
having the mmc host and the mmc card, being configured to operate at the
same selected bus speed timing.
Therefore, let's extend __mmc_switch() to take yet another parameter, which
allow its callers to update the bus speed timing of the mmc host. In this
way, __mmc_switch() also becomes capable of reading and validating the CMD6
status by sending a CMD13, in cases when that's desired.
If __mmc_switch() encounters a failure, we make sure to restores the old
bus speed timing for the mmc host, before propagating the error code.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
2016-11-10 00:33:36 +08:00
|
|
|
unsigned int timeout_ms, unsigned char timing,
|
2021-04-15 05:22:35 +08:00
|
|
|
bool send_status, bool retry_crc_err, unsigned int retries);
|
2017-01-13 21:14:08 +08:00
|
|
|
int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
|
|
|
|
unsigned int timeout_ms);
|
2018-12-11 00:52:40 +08:00
|
|
|
void mmc_run_bkops(struct mmc_card *card);
|
2017-03-13 20:36:37 +08:00
|
|
|
int mmc_cmdq_enable(struct mmc_card *card);
|
|
|
|
int mmc_cmdq_disable(struct mmc_card *card);
|
2021-04-02 17:24:31 +08:00
|
|
|
int mmc_sanitize(struct mmc_card *card, unsigned int timeout_ms);
|
2006-12-25 05:46:55 +08:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|