2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2007-02-28 14:33:10 +00:00
|
|
|
* linux/drivers/mmc/core/core.h
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Russell King, All Rights Reserved.
|
2006-12-24 21:46:55 +00:00
|
|
|
* Copyright 2007 Pierre Ossman
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
2006-12-24 21:46:55 +00:00
|
|
|
#ifndef _MMC_CORE_CORE_H
|
|
|
|
#define _MMC_CORE_CORE_H
|
2005-08-19 08:41:24 +00:00
|
|
|
|
2006-12-24 21:46:55 +00:00
|
|
|
#include <linux/delay.h>
|
|
|
|
|
|
|
|
#define MMC_CMD_RETRIES 3
|
|
|
|
|
2006-12-30 23:11:32 +00:00
|
|
|
struct mmc_bus_ops {
|
2009-09-22 23:44:34 +00:00
|
|
|
int (*awake)(struct mmc_host *);
|
|
|
|
int (*sleep)(struct mmc_host *);
|
2006-12-30 23:11:32 +00:00
|
|
|
void (*remove)(struct mmc_host *);
|
|
|
|
void (*detect)(struct mmc_host *);
|
2009-09-22 23:45:29 +00:00
|
|
|
int (*suspend)(struct mmc_host *);
|
|
|
|
int (*resume)(struct mmc_host *);
|
2010-10-02 11:54:06 +00:00
|
|
|
int (*power_save)(struct mmc_host *);
|
|
|
|
int (*power_restore)(struct mmc_host *);
|
2006-12-30 23:11:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops);
|
|
|
|
void mmc_detach_bus(struct mmc_host *host);
|
|
|
|
|
mmc: add erase, secure erase, trim and secure trim operations
SD/MMC cards tend to support an erase operation. In addition, eMMC v4.4
cards can support secure erase, trim and secure trim operations that are
all variants of the basic erase command.
SD/MMC device attributes "erase_size" and "preferred_erase_size" have been
added.
"erase_size" is the minimum size, in bytes, of an erase operation. For
MMC, "erase_size" is the erase group size reported by the card. Note that
"erase_size" does not apply to trim or secure trim operations where the
minimum size is always one 512 byte sector. For SD, "erase_size" is 512
if the card is block-addressed, 0 otherwise.
SD/MMC cards can erase an arbitrarily large area up to and
including the whole card. When erasing a large area it may
be desirable to do it in smaller chunks for three reasons:
1. A single erase command will make all other I/O on the card
wait. This is not a problem if the whole card is being erased, but
erasing one partition will make I/O for another partition on the
same card wait for the duration of the erase - which could be a
several minutes.
2. To be able to inform the user of erase progress.
3. The erase timeout becomes too large to be very useful.
Because the erase timeout contains a margin which is multiplied by
the size of the erase area, the value can end up being several
minutes for large areas.
"erase_size" is not the most efficient unit to erase (especially for SD
where it is just one sector), hence "preferred_erase_size" provides a good
chunk size for erasing large areas.
For MMC, "preferred_erase_size" is the high-capacity erase size if a card
specifies one, otherwise it is based on the capacity of the card.
For SD, "preferred_erase_size" is the allocation unit size specified by
the card.
"preferred_erase_size" is in bytes.
Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
Acked-by: Jens Axboe <axboe@kernel.dk>
Cc: Kyungmin Park <kmpark@infradead.org>
Cc: Madhusudhan Chikkature <madhu.cr@ti.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ben Gardiner <bengardiner@nanometrics.ca>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-08-11 21:17:46 +00:00
|
|
|
void mmc_init_erase(struct mmc_card *card);
|
|
|
|
|
2006-12-24 21:46:55 +00:00
|
|
|
void mmc_set_chip_select(struct mmc_host *host, int mode);
|
2006-12-30 23:11:32 +00:00
|
|
|
void mmc_set_clock(struct mmc_host *host, unsigned int hz);
|
2010-11-09 02:36:50 +00:00
|
|
|
void mmc_gate_clock(struct mmc_host *host);
|
|
|
|
void mmc_ungate_clock(struct mmc_host *host);
|
|
|
|
void mmc_set_ungated(struct mmc_host *host);
|
2006-12-30 23:11:32 +00:00
|
|
|
void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode);
|
|
|
|
void mmc_set_bus_width(struct mmc_host *host, unsigned int width);
|
2010-10-11 09:43:50 +00:00
|
|
|
void mmc_set_bus_width_ddr(struct mmc_host *host, unsigned int width,
|
|
|
|
unsigned int ddr);
|
2006-12-30 23:11:32 +00:00
|
|
|
u32 mmc_select_voltage(struct mmc_host *host, u32 ocr);
|
mmc: sd: add support for signal voltage switch procedure
Host Controller v3.00 adds another Capabilities register. Apart
from other things, this new register indicates whether the Host
Controller supports SDR50, SDR104, and DDR50 UHS-I modes. The spec
doesn't mention about explicit support for SDR12 and SDR25 UHS-I
modes, so the Host Controller v3.00 should support them by default.
Also if the controller supports SDR104 mode, it will also support
SDR50 mode as well. So depending on the host support, we set the
corresponding MMC_CAP_* flags. One more new register. Host Control2
is added in v3.00, which is used during Signal Voltage Switch
procedure described below.
Since as per v3.00 spec, UHS-I supported hosts should set S18R
to 1, we set S18R (bit 24) of OCR before sending ACMD41. We also
need to set XPC (bit 28) of OCR in case the host can supply >150mA.
This support is indicated by the Maximum Current Capabilities
register of the Host Controller.
If the response of ACMD41 has both CCS and S18A set, we start the
signal voltage switch procedure, which if successfull, will switch
the card from 3.3V signalling to 1.8V signalling. Signal voltage
switch procedure adds support for a new command CMD11 in the
Physical Layer Spec v3.01. As part of this procedure, we need to
set 1.8V Signalling Enable (bit 3) of Host Control2 register, which
if remains set after 5ms, means the switch to 1.8V signalling is
successfull. Otherwise, we clear bit 24 of OCR and retry the
initialization sequence. When we remove the card, and insert the
same or another card, we need to make sure that we start with 3.3V
signalling voltage. So we call mmc_set_signal_voltage() with
MMC_SIGNAL_VOLTAGE_330 set so that we are back to 3.3V signalling
voltage before we actually start initializing the card.
Tested by Zhangfei Gao with a Toshiba uhs card and general hs card,
on mmp2 in SDMA mode.
Signed-off-by: Arindam Nath <arindam.nath@amd.com>
Reviewed-by: Philip Rakity <prakity@marvell.com>
Tested-by: Philip Rakity <prakity@marvell.com>
Acked-by: Zhangfei Gao <zhangfei.gao@marvell.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
2011-05-05 06:48:57 +00:00
|
|
|
int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage);
|
2006-12-30 23:11:32 +00:00
|
|
|
void mmc_set_timing(struct mmc_host *host, unsigned int timing);
|
|
|
|
|
2006-12-24 21:46:55 +00:00
|
|
|
static inline void mmc_delay(unsigned int ms)
|
|
|
|
{
|
|
|
|
if (ms < 1000 / HZ) {
|
|
|
|
cond_resched();
|
|
|
|
mdelay(ms);
|
|
|
|
} else {
|
|
|
|
msleep(ms);
|
|
|
|
}
|
|
|
|
}
|
2006-10-04 09:15:41 +00:00
|
|
|
|
2007-05-19 12:06:24 +00:00
|
|
|
void mmc_rescan(struct work_struct *work);
|
|
|
|
void mmc_start_host(struct mmc_host *host);
|
|
|
|
void mmc_stop_host(struct mmc_host *host);
|
|
|
|
|
2011-01-03 18:36:56 +00:00
|
|
|
int mmc_attach_mmc(struct mmc_host *host);
|
|
|
|
int mmc_attach_sd(struct mmc_host *host);
|
|
|
|
int mmc_attach_sdio(struct mmc_host *host);
|
2008-04-13 18:15:50 +00:00
|
|
|
|
2009-12-15 02:01:29 +00:00
|
|
|
/* Module parameters */
|
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-08 16:11:32 +00:00
|
|
|
extern int use_spi_crc;
|
|
|
|
|
2008-07-24 12:18:57 +00:00
|
|
|
/* Debugfs information for hosts and cards */
|
|
|
|
void mmc_add_host_debugfs(struct mmc_host *host);
|
|
|
|
void mmc_remove_host_debugfs(struct mmc_host *host);
|
|
|
|
|
2008-07-24 12:18:58 +00:00
|
|
|
void mmc_add_card_debugfs(struct mmc_card *card);
|
|
|
|
void mmc_remove_card_debugfs(struct mmc_card *card);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
2006-12-24 21:46:55 +00:00
|
|
|
|