Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
core.c File Reference
#include <linux/module.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/completion.h>
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/pagemap.h>
#include <linux/err.h>
#include <linux/leds.h>
#include <linux/scatterlist.h>
#include <linux/log2.h>
#include <linux/regulator/consumer.h>
#include <linux/pm_runtime.h>
#include <linux/suspend.h>
#include <linux/fault-inject.h>
#include <linux/random.h>
#include <linux/slab.h>
#include <linux/mmc/card.h>
#include <linux/mmc/host.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sd.h>
#include "core.h"
#include "bus.h"
#include "host.h"
#include "sdio_bus.h"
#include "mmc_ops.h"
#include "sd_ops.h"
#include "sdio_ops.h"

Go to the source code of this file.

Macros

#define MMC_BKOPS_MAX_TIMEOUT   (4 * 60 * 1000) /* max time to wait in ms */
 

Functions

 module_param (use_spi_crc, bool, 0)
 
 EXPORT_SYMBOL (mmc_assume_removable)
 
 module_param_named (removable, mmc_assume_removable, bool, 0644)
 
 MODULE_PARM_DESC (removable,"MMC/SD cards are removable and may be removed during suspend")
 
void mmc_request_done (struct mmc_host *host, struct mmc_request *mrq)
 
 EXPORT_SYMBOL (mmc_request_done)
 
void mmc_start_bkops (struct mmc_card *card, bool from_exception)
 
 EXPORT_SYMBOL (mmc_start_bkops)
 
struct mmc_async_reqmmc_start_req (struct mmc_host *host, struct mmc_async_req *areq, int *error)
 
 EXPORT_SYMBOL (mmc_start_req)
 
void mmc_wait_for_req (struct mmc_host *host, struct mmc_request *mrq)
 
 EXPORT_SYMBOL (mmc_wait_for_req)
 
int mmc_interrupt_hpi (struct mmc_card *card)
 
 EXPORT_SYMBOL (mmc_interrupt_hpi)
 
int mmc_wait_for_cmd (struct mmc_host *host, struct mmc_command *cmd, int retries)
 
 EXPORT_SYMBOL (mmc_wait_for_cmd)
 
int mmc_stop_bkops (struct mmc_card *card)
 
 EXPORT_SYMBOL (mmc_stop_bkops)
 
int mmc_read_bkops_status (struct mmc_card *card)
 
 EXPORT_SYMBOL (mmc_read_bkops_status)
 
void mmc_set_data_timeout (struct mmc_data *data, const struct mmc_card *card)
 
 EXPORT_SYMBOL (mmc_set_data_timeout)
 
unsigned int mmc_align_data_size (struct mmc_card *card, unsigned int sz)
 
 EXPORT_SYMBOL (mmc_align_data_size)
 
int __mmc_claim_host (struct mmc_host *host, atomic_t *abort)
 
 EXPORT_SYMBOL (__mmc_claim_host)
 
int mmc_try_claim_host (struct mmc_host *host)
 
 EXPORT_SYMBOL (mmc_try_claim_host)
 
void mmc_release_host (struct mmc_host *host)
 
 EXPORT_SYMBOL (mmc_release_host)
 
void mmc_set_chip_select (struct mmc_host *host, int mode)
 
void mmc_set_clock (struct mmc_host *host, unsigned int hz)
 
void mmc_set_ungated (struct mmc_host *host)
 
void mmc_set_bus_mode (struct mmc_host *host, unsigned int mode)
 
void mmc_set_bus_width (struct mmc_host *host, unsigned int width)
 
u32 mmc_vddrange_to_ocrmask (int vdd_min, int vdd_max)
 
 EXPORT_SYMBOL (mmc_vddrange_to_ocrmask)
 
u32 mmc_select_voltage (struct mmc_host *host, u32 ocr)
 
int mmc_set_signal_voltage (struct mmc_host *host, int signal_voltage, bool cmd11)
 
void mmc_set_timing (struct mmc_host *host, unsigned int timing)
 
void mmc_set_driver_type (struct mmc_host *host, unsigned int drv_type)
 
void mmc_power_off (struct mmc_host *host)
 
void mmc_attach_bus (struct mmc_host *host, const struct mmc_bus_ops *ops)
 
void mmc_detach_bus (struct mmc_host *host)
 
void mmc_detect_change (struct mmc_host *host, unsigned long delay)
 
 EXPORT_SYMBOL (mmc_detect_change)
 
void mmc_init_erase (struct mmc_card *card)
 
int mmc_erase (struct mmc_card *card, unsigned int from, unsigned int nr, unsigned int arg)
 
 EXPORT_SYMBOL (mmc_erase)
 
int mmc_can_erase (struct mmc_card *card)
 
 EXPORT_SYMBOL (mmc_can_erase)
 
int mmc_can_trim (struct mmc_card *card)
 
 EXPORT_SYMBOL (mmc_can_trim)
 
int mmc_can_discard (struct mmc_card *card)
 
 EXPORT_SYMBOL (mmc_can_discard)
 
int mmc_can_sanitize (struct mmc_card *card)
 
 EXPORT_SYMBOL (mmc_can_sanitize)
 
int mmc_can_secure_erase_trim (struct mmc_card *card)
 
 EXPORT_SYMBOL (mmc_can_secure_erase_trim)
 
int mmc_erase_group_aligned (struct mmc_card *card, unsigned int from, unsigned int nr)
 
 EXPORT_SYMBOL (mmc_erase_group_aligned)
 
unsigned int mmc_calc_max_discard (struct mmc_card *card)
 
 EXPORT_SYMBOL (mmc_calc_max_discard)
 
int mmc_set_blocklen (struct mmc_card *card, unsigned int blocklen)
 
 EXPORT_SYMBOL (mmc_set_blocklen)
 
int mmc_can_reset (struct mmc_card *card)
 
 EXPORT_SYMBOL (mmc_can_reset)
 
int mmc_hw_reset (struct mmc_host *host)
 
 EXPORT_SYMBOL (mmc_hw_reset)
 
int mmc_hw_reset_check (struct mmc_host *host)
 
 EXPORT_SYMBOL (mmc_hw_reset_check)
 
int _mmc_detect_card_removed (struct mmc_host *host)
 
int mmc_detect_card_removed (struct mmc_host *host)
 
 EXPORT_SYMBOL (mmc_detect_card_removed)
 
void mmc_rescan (struct work_struct *work)
 
void mmc_start_host (struct mmc_host *host)
 
void mmc_stop_host (struct mmc_host *host)
 
int mmc_power_save_host (struct mmc_host *host)
 
 EXPORT_SYMBOL (mmc_power_save_host)
 
int mmc_power_restore_host (struct mmc_host *host)
 
 EXPORT_SYMBOL (mmc_power_restore_host)
 
int mmc_card_awake (struct mmc_host *host)
 
 EXPORT_SYMBOL (mmc_card_awake)
 
int mmc_card_sleep (struct mmc_host *host)
 
 EXPORT_SYMBOL (mmc_card_sleep)
 
int mmc_card_can_sleep (struct mmc_host *host)
 
 EXPORT_SYMBOL (mmc_card_can_sleep)
 
int mmc_flush_cache (struct mmc_card *card)
 
 EXPORT_SYMBOL (mmc_flush_cache)
 
int mmc_cache_ctrl (struct mmc_host *host, u8 enable)
 
 EXPORT_SYMBOL (mmc_cache_ctrl)
 
 subsys_initcall (mmc_init)
 
 module_exit (mmc_exit)
 
 MODULE_LICENSE ("GPL")
 

Variables

bool use_spi_crc = 1
 
bool mmc_assume_removable = 1
 

Macro Definition Documentation

#define MMC_BKOPS_MAX_TIMEOUT   (4 * 60 * 1000) /* max time to wait in ms */

Definition at line 49 of file core.c.

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_detect_card_removed ( struct mmc_host host)

Definition at line 2071 of file core.c.

EXPORT_SYMBOL ( mmc_assume_removable  )
EXPORT_SYMBOL ( mmc_request_done  )
EXPORT_SYMBOL ( mmc_start_bkops  )
EXPORT_SYMBOL ( mmc_start_req  )
EXPORT_SYMBOL ( mmc_wait_for_req  )
EXPORT_SYMBOL ( mmc_interrupt_hpi  )
EXPORT_SYMBOL ( mmc_wait_for_cmd  )
EXPORT_SYMBOL ( mmc_stop_bkops  )
EXPORT_SYMBOL ( mmc_read_bkops_status  )
EXPORT_SYMBOL ( mmc_set_data_timeout  )
EXPORT_SYMBOL ( mmc_align_data_size  )
EXPORT_SYMBOL ( __mmc_claim_host  )
EXPORT_SYMBOL ( mmc_try_claim_host  )
EXPORT_SYMBOL ( mmc_release_host  )
EXPORT_SYMBOL ( mmc_vddrange_to_ocrmask  )
EXPORT_SYMBOL ( mmc_detect_change  )
EXPORT_SYMBOL ( mmc_erase  )
EXPORT_SYMBOL ( mmc_can_erase  )
EXPORT_SYMBOL ( mmc_can_trim  )
EXPORT_SYMBOL ( mmc_can_discard  )
EXPORT_SYMBOL ( mmc_can_sanitize  )
EXPORT_SYMBOL ( mmc_can_secure_erase_trim  )
EXPORT_SYMBOL ( mmc_erase_group_aligned  )
EXPORT_SYMBOL ( mmc_calc_max_discard  )
EXPORT_SYMBOL ( mmc_set_blocklen  )
EXPORT_SYMBOL ( mmc_can_reset  )
EXPORT_SYMBOL ( mmc_hw_reset  )
EXPORT_SYMBOL ( mmc_hw_reset_check  )
EXPORT_SYMBOL ( mmc_detect_card_removed  )
EXPORT_SYMBOL ( mmc_power_save_host  )
EXPORT_SYMBOL ( mmc_power_restore_host  )
EXPORT_SYMBOL ( mmc_card_awake  )
EXPORT_SYMBOL ( mmc_card_sleep  )
EXPORT_SYMBOL ( mmc_card_can_sleep  )
EXPORT_SYMBOL ( mmc_flush_cache  )
EXPORT_SYMBOL ( mmc_cache_ctrl  )
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.

void mmc_attach_bus ( struct mmc_host host,
const struct mmc_bus_ops ops 
)

Definition at line 1415 of file core.c.

int mmc_cache_ctrl ( struct mmc_host host,
u8  enable 
)

Definition at line 2362 of file core.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_card_awake ( struct mmc_host host)

Definition at line 2286 of file core.c.

int mmc_card_can_sleep ( struct mmc_host host)

Definition at line 2322 of file core.c.

int mmc_card_sleep ( struct mmc_host host)

Definition at line 2304 of file core.c.

void mmc_detach_bus ( struct mmc_host host)

Definition at line 1439 of file core.c.

int mmc_detect_card_removed ( struct mmc_host host)

Definition at line 2090 of file core.c.

void mmc_detect_change ( struct mmc_host host,
unsigned long  delay 
)

mmc_detect_change - process change of state on a MMC socket : host which changed state. : optional delay to wait before detection (jiffies)

MMC drivers should call this when they detect a card has been inserted or removed. The MMC layer will confirm that any present card is still functional, and initialize any newly inserted.

Definition at line 1467 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 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.

void mmc_init_erase ( struct mmc_card card)

Definition at line 1481 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.

void mmc_power_off ( struct mmc_host host)

Definition at line 1336 of file core.c.

int mmc_power_restore_host ( struct mmc_host host)

Definition at line 2262 of file core.c.

int mmc_power_save_host ( struct mmc_host host)

Definition at line 2236 of file core.c.

int mmc_read_bkops_status ( struct mmc_card 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.

void mmc_request_done ( struct mmc_host host,
struct mmc_request mrq 
)

mmc_request_done - finish processing an MMC request : MMC host which completed request : MMC request which request

MMC drivers should call this function when they have completed their processing of a request.

Definition at line 141 of file core.c.

void mmc_rescan ( struct work_struct work)

Definition at line 2126 of file core.c.

u32 mmc_select_voltage ( struct mmc_host host,
u32  ocr 
)

Definition at line 1194 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_bus_mode ( struct mmc_host host,
unsigned int  mode 
)

Definition at line 963 of file core.c.

void mmc_set_bus_width ( struct mmc_host host,
unsigned int  width 
)

Definition at line 974 of file core.c.

void mmc_set_chip_select ( struct mmc_host host,
int  mode 
)

Definition at line 875 of file core.c.

void mmc_set_clock ( struct mmc_host host,
unsigned int  hz 
)

Definition at line 898 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_set_driver_type ( struct mmc_host host,
unsigned int  drv_type 
)

Definition at line 1268 of file core.c.

int mmc_set_signal_voltage ( struct mmc_host host,
int  signal_voltage,
bool  cmd11 
)

Definition at line 1219 of file core.c.

void mmc_set_timing ( struct mmc_host host,
unsigned int  timing 
)

Definition at line 1257 of file core.c.

void mmc_set_ungated ( struct mmc_host host)

Definition at line 955 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.

void mmc_start_host ( struct mmc_host host)

Definition at line 2192 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.

void mmc_stop_host ( struct mmc_host host)

Definition at line 2200 of file core.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_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.

module_exit ( mmc_exit  )
MODULE_LICENSE ( "GPL"  )
module_param ( use_spi_crc  ,
bool  ,
 
)
module_param_named ( removable  ,
mmc_assume_removable  ,
bool  ,
0644   
)
MODULE_PARM_DESC ( removable  ,
"MMC/SD cards are removable and may be removed during suspend  
)
subsys_initcall ( mmc_init  )

Variable Documentation

bool mmc_assume_removable = 1

Definition at line 71 of file core.c.

bool use_spi_crc = 1

Definition at line 59 of file core.c.