Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
core.h File Reference
#include <linux/interrupt.h>
#include <linux/completion.h>

Go to the source code of this file.

Data Structures

struct  mmc_command
 
struct  mmc_data
 
struct  mmc_request
 

Macros

#define MMC_RSP_PRESENT   (1 << 0)
 
#define MMC_RSP_136   (1 << 1) /* 136 bit response */
 
#define MMC_RSP_CRC   (1 << 2) /* expect valid crc */
 
#define MMC_RSP_BUSY   (1 << 3) /* card may send busy */
 
#define MMC_RSP_OPCODE   (1 << 4) /* response contains opcode */
 
#define MMC_CMD_MASK   (3 << 5) /* non-SPI command type */
 
#define MMC_CMD_AC   (0 << 5)
 
#define MMC_CMD_ADTC   (1 << 5)
 
#define MMC_CMD_BC   (2 << 5)
 
#define MMC_CMD_BCR   (3 << 5)
 
#define MMC_RSP_SPI_S1   (1 << 7) /* one status byte */
 
#define MMC_RSP_SPI_S2   (1 << 8) /* second byte */
 
#define MMC_RSP_SPI_B4   (1 << 9) /* four data bytes */
 
#define MMC_RSP_SPI_BUSY   (1 << 10) /* card may send busy */
 
#define MMC_RSP_NONE   (0)
 
#define MMC_RSP_R1   (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
 
#define MMC_RSP_R1B   (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE|MMC_RSP_BUSY)
 
#define MMC_RSP_R2   (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC)
 
#define MMC_RSP_R3   (MMC_RSP_PRESENT)
 
#define MMC_RSP_R4   (MMC_RSP_PRESENT)
 
#define MMC_RSP_R5   (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
 
#define MMC_RSP_R6   (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
 
#define MMC_RSP_R7   (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
 
#define mmc_resp_type(cmd)   ((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE))
 
#define MMC_RSP_SPI_R1   (MMC_RSP_SPI_S1)
 
#define MMC_RSP_SPI_R1B   (MMC_RSP_SPI_S1|MMC_RSP_SPI_BUSY)
 
#define MMC_RSP_SPI_R2   (MMC_RSP_SPI_S1|MMC_RSP_SPI_S2)
 
#define MMC_RSP_SPI_R3   (MMC_RSP_SPI_S1|MMC_RSP_SPI_B4)
 
#define MMC_RSP_SPI_R4   (MMC_RSP_SPI_S1|MMC_RSP_SPI_B4)
 
#define MMC_RSP_SPI_R5   (MMC_RSP_SPI_S1|MMC_RSP_SPI_S2)
 
#define MMC_RSP_SPI_R7   (MMC_RSP_SPI_S1|MMC_RSP_SPI_B4)
 
#define mmc_spi_resp_type(cmd)
 
#define mmc_cmd_type(cmd)   ((cmd)->flags & MMC_CMD_MASK)
 
#define MMC_DATA_WRITE   (1 << 8)
 
#define MMC_DATA_READ   (1 << 9)
 
#define MMC_DATA_STREAM   (1 << 10)
 
#define MMC_ERASE_ARG   0x00000000
 
#define MMC_SECURE_ERASE_ARG   0x80000000
 
#define MMC_TRIM_ARG   0x00000001
 
#define MMC_DISCARD_ARG   0x00000003
 
#define MMC_SECURE_TRIM1_ARG   0x80000001
 
#define MMC_SECURE_TRIM2_ARG   0x80008000
 
#define MMC_SECURE_ARGS   0x80000000
 
#define MMC_TRIM_ARGS   0x00008001
 

Functions

int mmc_stop_bkops (struct mmc_card *)
 
int mmc_read_bkops_status (struct mmc_card *)
 
struct mmc_async_reqmmc_start_req (struct mmc_host *, struct mmc_async_req *, int *)
 
int mmc_interrupt_hpi (struct mmc_card *)
 
void mmc_wait_for_req (struct mmc_host *, struct mmc_request *)
 
int mmc_wait_for_cmd (struct mmc_host *, struct mmc_command *, int)
 
int mmc_app_cmd (struct mmc_host *, struct mmc_card *)
 
int mmc_wait_for_app_cmd (struct mmc_host *, struct mmc_card *, struct mmc_command *, int)
 
void mmc_start_bkops (struct mmc_card *card, bool from_exception)
 
int __mmc_switch (struct mmc_card *, u8, u8, u8, unsigned int, bool)
 
int mmc_switch (struct mmc_card *, u8, u8, u8, unsigned int)
 
int mmc_erase (struct mmc_card *card, unsigned int from, unsigned int nr, unsigned int arg)
 
int mmc_can_erase (struct mmc_card *card)
 
int mmc_can_trim (struct mmc_card *card)
 
int mmc_can_discard (struct mmc_card *card)
 
int mmc_can_sanitize (struct mmc_card *card)
 
int mmc_can_secure_erase_trim (struct mmc_card *card)
 
int mmc_erase_group_aligned (struct mmc_card *card, unsigned int from, unsigned int nr)
 
unsigned int mmc_calc_max_discard (struct mmc_card *card)
 
int mmc_set_blocklen (struct mmc_card *card, unsigned int blocklen)
 
int mmc_hw_reset (struct mmc_host *host)
 
int mmc_hw_reset_check (struct mmc_host *host)
 
int mmc_can_reset (struct mmc_card *card)
 
void mmc_set_data_timeout (struct mmc_data *, const struct mmc_card *)
 
unsigned int mmc_align_data_size (struct mmc_card *, unsigned int)
 
int __mmc_claim_host (struct mmc_host *host, atomic_t *abort)
 
void mmc_release_host (struct mmc_host *host)
 
int mmc_try_claim_host (struct mmc_host *host)
 
int mmc_flush_cache (struct mmc_card *)
 
int mmc_detect_card_removed (struct mmc_host *host)
 
u32 mmc_vddrange_to_ocrmask (int vdd_min, int vdd_max)
 

Macro Definition Documentation

#define MMC_CMD_AC   (0 << 5)

Definition at line 30 of file core.h.

#define MMC_CMD_ADTC   (1 << 5)

Definition at line 31 of file core.h.

#define MMC_CMD_BC   (2 << 5)

Definition at line 32 of file core.h.

#define MMC_CMD_BCR   (3 << 5)

Definition at line 33 of file core.h.

#define MMC_CMD_MASK   (3 << 5) /* non-SPI command type */

Definition at line 29 of file core.h.

#define mmc_cmd_type (   cmd)    ((cmd)->flags & MMC_CMD_MASK)

Definition at line 76 of file core.h.

#define MMC_DATA_READ   (1 << 9)

Definition at line 110 of file core.h.

#define MMC_DATA_STREAM   (1 << 10)

Definition at line 111 of file core.h.

#define MMC_DATA_WRITE   (1 << 8)

Definition at line 109 of file core.h.

#define MMC_DISCARD_ARG   0x00000003

Definition at line 154 of file core.h.

#define MMC_ERASE_ARG   0x00000000

Definition at line 151 of file core.h.

#define mmc_resp_type (   cmd)    ((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE))

Definition at line 55 of file core.h.

#define MMC_RSP_136   (1 << 1) /* 136 bit response */

Definition at line 24 of file core.h.

#define MMC_RSP_BUSY   (1 << 3) /* card may send busy */

Definition at line 26 of file core.h.

#define MMC_RSP_CRC   (1 << 2) /* expect valid crc */

Definition at line 25 of file core.h.

#define MMC_RSP_NONE   (0)

Definition at line 45 of file core.h.

#define MMC_RSP_OPCODE   (1 << 4) /* response contains opcode */

Definition at line 27 of file core.h.

#define MMC_RSP_PRESENT   (1 << 0)

Definition at line 23 of file core.h.

#define MMC_RSP_R1   (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)

Definition at line 46 of file core.h.

Definition at line 47 of file core.h.

#define MMC_RSP_R2   (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC)

Definition at line 48 of file core.h.

#define MMC_RSP_R3   (MMC_RSP_PRESENT)

Definition at line 49 of file core.h.

#define MMC_RSP_R4   (MMC_RSP_PRESENT)

Definition at line 50 of file core.h.

#define MMC_RSP_R5   (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)

Definition at line 51 of file core.h.

#define MMC_RSP_R6   (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)

Definition at line 52 of file core.h.

#define MMC_RSP_R7   (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)

Definition at line 53 of file core.h.

#define MMC_RSP_SPI_B4   (1 << 9) /* four data bytes */

Definition at line 37 of file core.h.

#define MMC_RSP_SPI_BUSY   (1 << 10) /* card may send busy */

Definition at line 38 of file core.h.

#define MMC_RSP_SPI_R1   (MMC_RSP_SPI_S1)

Definition at line 62 of file core.h.

#define MMC_RSP_SPI_R1B   (MMC_RSP_SPI_S1|MMC_RSP_SPI_BUSY)

Definition at line 63 of file core.h.

#define MMC_RSP_SPI_R2   (MMC_RSP_SPI_S1|MMC_RSP_SPI_S2)

Definition at line 64 of file core.h.

#define MMC_RSP_SPI_R3   (MMC_RSP_SPI_S1|MMC_RSP_SPI_B4)

Definition at line 65 of file core.h.

#define MMC_RSP_SPI_R4   (MMC_RSP_SPI_S1|MMC_RSP_SPI_B4)

Definition at line 66 of file core.h.

#define MMC_RSP_SPI_R5   (MMC_RSP_SPI_S1|MMC_RSP_SPI_S2)

Definition at line 67 of file core.h.

#define MMC_RSP_SPI_R7   (MMC_RSP_SPI_S1|MMC_RSP_SPI_B4)

Definition at line 68 of file core.h.

#define MMC_RSP_SPI_S1   (1 << 7) /* one status byte */

Definition at line 35 of file core.h.

#define MMC_RSP_SPI_S2   (1 << 8) /* second byte */

Definition at line 36 of file core.h.

#define MMC_SECURE_ARGS   0x80000000

Definition at line 158 of file core.h.

#define MMC_SECURE_ERASE_ARG   0x80000000

Definition at line 152 of file core.h.

#define MMC_SECURE_TRIM1_ARG   0x80000001

Definition at line 155 of file core.h.

#define MMC_SECURE_TRIM2_ARG   0x80008000

Definition at line 156 of file core.h.

#define mmc_spi_resp_type (   cmd)
Value:

Definition at line 70 of file core.h.

#define MMC_TRIM_ARG   0x00000001

Definition at line 153 of file core.h.

#define MMC_TRIM_ARGS   0x00008001

Definition at line 159 of file core.h.

Function Documentation

int __mmc_claim_host ( struct mmc_host host,
atomic_t abort 
)

__mmc_claim_host - exclusively claim a host : mmc host to claim : whether or not the operation should be aborted

Claim a host for a set of operations. If is non null and dereference a non-zero value then this will return prematurely with that non-zero value without acquiring the lock. Returns zero with the lock held otherwise.

Definition at line 764 of file core.c.

int __mmc_switch ( struct mmc_card card,
u8  set,
u8  index,
u8  value,
unsigned int  timeout_ms,
bool  use_busy_signal 
)

__mmc_switch - modify EXT_CSD register : the MMC card associated with the data transfer : cmd set values : EXT_CSD register index : value to program into EXT_CSD register : timeout (ms) for operation performed by register write, timeout of zero implies maximum possible timeout : use the busy signal as response type

Modifies the EXT_CSD register for selected card.

Definition at line 407 of file mmc_ops.c.

unsigned int mmc_align_data_size ( struct mmc_card card,
unsigned int  sz 
)

mmc_align_data_size - pads a transfer size to a more optimal value : the MMC card associated with the data transfer : original transfer size

Pads the original data size with a number of extra bytes in order to avoid controller bugs and/or performance hits (e.g. some controllers revert to PIO for certain sizes).

Returns the improved size, which might be unmodified.

Note that this function is only relevant when issuing a single scatter gather entry.

Definition at line 741 of file core.c.

int mmc_app_cmd ( struct mmc_host ,
struct mmc_card  
)

Definition at line 25 of file sd_ops.c.

unsigned int mmc_calc_max_discard ( struct mmc_card card)

Definition at line 1901 of file core.c.

int mmc_can_discard ( struct mmc_card card)

Definition at line 1814 of file core.c.

int mmc_can_erase ( struct mmc_card card)

Definition at line 1797 of file core.c.

int mmc_can_reset ( struct mmc_card card)

Definition at line 1954 of file core.c.

int mmc_can_sanitize ( struct mmc_card card)

Definition at line 1826 of file core.c.

int mmc_can_secure_erase_trim ( struct mmc_card card)

Definition at line 1836 of file core.c.

int mmc_can_trim ( struct mmc_card card)

Definition at line 1806 of file core.c.

int mmc_detect_card_removed ( struct mmc_host host)

Definition at line 2090 of file core.c.

int mmc_erase ( struct mmc_card card,
unsigned int  from,
unsigned int  nr,
unsigned int  arg 
)

mmc_erase - erase sectors. : card to erase : first sector to erase : number of sectors to erase

  • : erase command argument (SD supports only MMC_ERASE_ARG)

Caller must claim host before calling this function.

Definition at line 1739 of file core.c.

int mmc_erase_group_aligned ( struct mmc_card card,
unsigned int  from,
unsigned int  nr 
)

Definition at line 1844 of file core.c.

int mmc_flush_cache ( struct mmc_card )

Definition at line 2335 of file core.c.

int mmc_hw_reset ( struct mmc_host host)

Definition at line 2021 of file core.c.

int mmc_hw_reset_check ( struct mmc_host host)

Definition at line 2027 of file core.c.

int mmc_interrupt_hpi ( struct mmc_card card)

mmc_interrupt_hpi - Issue for High priority Interrupt : the MMC card associated with the HPI transfer

Issued High Priority Interrupt, and check for card status until out-of prg-state.

Definition at line 482 of file core.c.

int mmc_read_bkops_status ( struct mmc_card )

Definition at line 600 of file core.c.

void mmc_release_host ( struct mmc_host host)

mmc_release_host - release a host : mmc host to release

Release a MMC host, allowing others to claim the host for their operations.

Definition at line 831 of file core.c.

int mmc_set_blocklen ( struct mmc_card card,
unsigned int  blocklen 
)

Definition at line 1931 of file core.c.

void mmc_set_data_timeout ( struct mmc_data data,
const struct mmc_card card 
)

mmc_set_data_timeout - set the timeout for a data command : data phase for command : the MMC card associated with the data transfer

Computes the data timeout parameters according to the correct algorithm given the card type.

Definition at line 637 of file core.c.

void mmc_start_bkops ( struct mmc_card card,
bool  from_exception 
)

mmc_start_bkops - start BKOPS for supported cards : MMC card to start BKOPS : A flag to indicate if this function was called due to an exception raised by the card

Start background operations whenever requested. When the urgent BKOPS bit is set in a R1 command response then background operations should be started immediately.

Definition at line 265 of file core.c.

struct mmc_async_req* mmc_start_req ( struct mmc_host host,
struct mmc_async_req areq,
int error 
)
read

mmc_start_req - start a non-blocking request : MMC host to start command : async request to start : out parameter returns 0 for success, otherwise non zero

Start a new MMC custom command request for a host. If there is on ongoing async request wait for completion of that request and start the new one and return. Does not wait for the new request to complete.

Returns the completed request, NULL in case of none completed.

Wait for the an ongoing request (previoulsy started) to complete and return the completed request. If there is no ongoing request, NULL is returned without waiting. NULL is not an error condition.

Definition at line 414 of file core.c.

int mmc_stop_bkops ( struct mmc_card card)

mmc_stop_bkops - stop ongoing BKOPS : MMC card to check BKOPS

Send HPI command to stop ongoing background operations to allow rapid servicing of foreground operations, e.g. read/ writes. Wait until the card comes out of the programming state to avoid errors in servicing read/write requests.

Definition at line 580 of file core.c.

int mmc_switch ( struct mmc_card ,
u8  ,
u8  ,
u8  ,
unsigned  int 
)

Definition at line 465 of file mmc_ops.c.

int mmc_try_claim_host ( struct mmc_host host)

mmc_try_claim_host - try exclusively to claim a host : mmc host to claim

Returns %1 if the host is claimed, %0 otherwise.

Definition at line 805 of file core.c.

u32 mmc_vddrange_to_ocrmask ( int  vdd_min,
int  vdd_max 
)

mmc_vddrange_to_ocrmask - Convert a voltage range to the OCR mask : minimum voltage value (mV) : maximum voltage value (mV)

This function returns the OCR mask bits according to the provided and values. If conversion is not possible the function returns 0.

Notes wrt boundary cases: This function sets the OCR bits for all boundary voltages, for example [3300:3400] range is translated to MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_34_35 mask.

Definition at line 1031 of file core.c.

int mmc_wait_for_app_cmd ( struct mmc_host host,
struct mmc_card card,
struct mmc_command cmd,
int  retries 
)

mmc_wait_for_app_cmd - start an application command and wait for completion : MMC host to start command : Card to send MMC_APP_CMD to : MMC command to start : maximum number of retries

Sends a MMC_APP_CMD, checks the card response, sends the command in the parameter and waits for it to complete. Return any error that occurred while the command was executing. Do not attempt to parse the response.

Definition at line 68 of file sd_ops.c.

int mmc_wait_for_cmd ( struct mmc_host host,
struct mmc_command cmd,
int  retries 
)

mmc_wait_for_cmd - start a command and wait for completion : MMC host to start command : MMC command to start : maximum number of retries

Start a new MMC command for a host, and wait for the command to complete. Return any error that occurred while the command was executing. Do not attempt to parse the response.

Definition at line 552 of file core.c.

void mmc_wait_for_req ( struct mmc_host host,
struct mmc_request mrq 
)

mmc_wait_for_req - start a request and wait for completion : MMC host to start command : MMC request to start

Start a new MMC custom command request for a host, and wait for the command to complete. Does not attempt to parse the response.

Definition at line 468 of file core.c.