linux/drivers/mmc/core/mmc.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *  linux/drivers/mmc/core/mmc.c
 *
 *  Copyright (C) 2003-2004 Russell King, All Rights Reserved.
 *  Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved.
 *  MMCv4 support Copyright (C) 2006 Philip Langdale, All Rights Reserved.
 */

#include <linux/err.h>
#include <linux/of.h>
#include <linux/slab.h>
#include <linux/stat.h>
#include <linux/pm_runtime.h>
#include <linux/random.h>
#include <linux/sysfs.h>

#include <linux/mmc/host.h>
#include <linux/mmc/card.h>
#include <linux/mmc/mmc.h>

#include "core.h"
#include "card.h"
#include "host.h"
#include "bus.h"
#include "mmc_ops.h"
#include "quirks.h"
#include "sd_ops.h"
#include "pwrseq.h"

#define DEFAULT_CMD6_TIMEOUT_MS
#define MIN_CACHE_EN_TIMEOUT_MS
#define CACHE_FLUSH_TIMEOUT_MS

static const unsigned int tran_exp[] =;

static const unsigned char tran_mant[] =;

static const unsigned int taac_exp[] =;

static const unsigned int taac_mant[] =;

#define UNSTUFF_BITS(resp,start,size)

/*
 * Given the decoded CSD structure, decode the raw CID to our CID structure.
 */
static int mmc_decode_cid(struct mmc_card *card)
{}

static void mmc_set_erase_size(struct mmc_card *card)
{}


static void mmc_set_wp_grp_size(struct mmc_card *card)
{}

/*
 * Given a 128-bit response, decode to our card CSD structure.
 */
static int mmc_decode_csd(struct mmc_card *card)
{}

static void mmc_select_card_type(struct mmc_card *card)
{}

static void mmc_manage_enhanced_area(struct mmc_card *card, u8 *ext_csd)
{}

static void mmc_part_add(struct mmc_card *card, u64 size,
			 unsigned int part_cfg, char *name, int idx, bool ro,
			 int area_type)
{}

static void mmc_manage_gp_partitions(struct mmc_card *card, u8 *ext_csd)
{}

/* Minimum partition switch timeout in milliseconds */
#define MMC_MIN_PART_SWITCH_TIME

/*
 * Decode extended CSD.
 */
static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
{}

static int mmc_read_ext_csd(struct mmc_card *card)
{}

static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width)
{}

MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();
MMC_DEV_ATTR();

static ssize_t mmc_fwrev_show(struct device *dev,
			      struct device_attribute *attr,
			      char *buf)
{}

static DEVICE_ATTR(fwrev, S_IRUGO, mmc_fwrev_show, NULL);

static ssize_t mmc_dsr_show(struct device *dev,
			    struct device_attribute *attr,
			    char *buf)
{}

static DEVICE_ATTR(dsr, S_IRUGO, mmc_dsr_show, NULL);

static struct attribute *mmc_std_attrs[] =;
ATTRIBUTE_GROUPS();

static const struct device_type mmc_type =;

/*
 * Select the PowerClass for the current bus width
 * If power class is defined for 4/8 bit bus in the
 * extended CSD register, select it by executing the
 * mmc_switch command.
 */
static int __mmc_select_powerclass(struct mmc_card *card,
				   unsigned int bus_width)
{}

static int mmc_select_powerclass(struct mmc_card *card)
{}

/*
 * Set the bus speed for the selected speed mode.
 */
static void mmc_set_bus_speed(struct mmc_card *card)
{}

/*
 * Select the bus width amoung 4-bit and 8-bit(SDR).
 * If the bus width is changed successfully, return the selected width value.
 * Zero is returned instead of error value if the wide width is not supported.
 */
static int mmc_select_bus_width(struct mmc_card *card)
{}

/*
 * Switch to the high-speed mode
 */
static int mmc_select_hs(struct mmc_card *card)
{}

/*
 * Activate wide bus and DDR if supported.
 */
static int mmc_select_hs_ddr(struct mmc_card *card)
{}

static int mmc_select_hs400(struct mmc_card *card)
{}

int mmc_hs200_to_hs400(struct mmc_card *card)
{}

int mmc_hs400_to_hs200(struct mmc_card *card)
{}

static void mmc_select_driver_type(struct mmc_card *card)
{}

static int mmc_select_hs400es(struct mmc_card *card)
{}

/*
 * For device supporting HS200 mode, the following sequence
 * should be done before executing the tuning process.
 * 1. set the desired bus width(4-bit or 8-bit, 1-bit is not supported)
 * 2. switch to HS200 mode
 * 3. set the clock to > 52Mhz and <=200MHz
 */
static int mmc_select_hs200(struct mmc_card *card)
{}

/*
 * Activate High Speed, HS200 or HS400ES mode if supported.
 */
static int mmc_select_timing(struct mmc_card *card)
{}

/*
 * Execute tuning sequence to seek the proper bus operating
 * conditions for HS200 and HS400, which sends CMD21 to the device.
 */
static int mmc_hs200_tuning(struct mmc_card *card)
{}

/*
 * Handle the detection and initialisation of a card.
 *
 * In the case of a resume, "oldcard" will contain the card
 * we're trying to reinitialise.
 */
static int mmc_init_card(struct mmc_host *host, u32 ocr,
	struct mmc_card *oldcard)
{}

static int mmc_can_sleep(struct mmc_card *card)
{}

static int mmc_sleep_busy_cb(void *cb_data, bool *busy)
{}

static int mmc_sleep(struct mmc_host *host)
{}

static int mmc_can_poweroff_notify(const struct mmc_card *card)
{}

static int mmc_poweroff_notify(struct mmc_card *card, unsigned int notify_type)
{}

/*
 * Host is being removed. Free up the current card.
 */
static void mmc_remove(struct mmc_host *host)
{}

/*
 * Card detection - card is alive.
 */
static int mmc_alive(struct mmc_host *host)
{}

/*
 * Card detection callback from host.
 */
static void mmc_detect(struct mmc_host *host)
{}

static bool _mmc_cache_enabled(struct mmc_host *host)
{}

/*
 * Flush the internal cache of the eMMC to non-volatile storage.
 */
static int _mmc_flush_cache(struct mmc_host *host)
{}

static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
{}

/*
 * Suspend callback
 */
static int mmc_suspend(struct mmc_host *host)
{}

/*
 * This function tries to determine if the same card is still present
 * and, if so, restore all state to it.
 */
static int _mmc_resume(struct mmc_host *host)
{}

/*
 * Shutdown callback
 */
static int mmc_shutdown(struct mmc_host *host)
{}

/*
 * Callback for resume.
 */
static int mmc_resume(struct mmc_host *host)
{}

/*
 * Callback for runtime_suspend.
 */
static int mmc_runtime_suspend(struct mmc_host *host)
{}

/*
 * Callback for runtime_resume.
 */
static int mmc_runtime_resume(struct mmc_host *host)
{}

static int mmc_can_reset(struct mmc_card *card)
{}

static int _mmc_hw_reset(struct mmc_host *host)
{}

static const struct mmc_bus_ops mmc_ops =;

/*
 * Starting point for MMC card init.
 */
int mmc_attach_mmc(struct mmc_host *host)
{}