linux/drivers/mmc/host/sunplus-mmc.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) Sunplus Inc.
 * Author: Tony Huang <[email protected]>
 * Author: Li-hao Kuo <[email protected]>
 */

#include <linux/bitfield.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <linux/iopoll.h>
#include <linux/mmc/core.h>
#include <linux/mmc/host.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sdio.h>
#include <linux/mmc/slot-gpio.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
#include <linux/reset.h>

#define SPMMC_MIN_CLK
#define SPMMC_MAX_CLK
#define SPMMC_MAX_BLK_COUNT
#define SPMMC_MAX_TUNABLE_DLY
#define SPMMC_TIMEOUT_US
#define SPMMC_POLL_DELAY_US

#define SPMMC_CARD_MEDIATYPE_SRCDST_REG
#define SPMMC_MEDIA_TYPE
#define SPMMC_DMA_SOURCE
#define SPMMC_DMA_DESTINATION
#define SPMMC_MEDIA_NONE
#define SPMMC_MEDIA_SD
#define SPMMC_MEDIA_MS

#define SPMMC_SDRAM_SECTOR_0_SIZE_REG
#define SPMMC_DMA_BASE_ADDR_REG
#define SPMMC_HW_DMA_CTRL_REG
#define SPMMC_HW_DMA_RST
#define SPMMC_DMAIDLE

#define SPMMC_MAX_DMA_MEMORY_SECTORS

#define SPMMC_SDRAM_SECTOR_1_ADDR_REG
#define SPMMC_SDRAM_SECTOR_1_LENG_REG
#define SPMMC_SDRAM_SECTOR_2_ADDR_REG
#define SPMMC_SDRAM_SECTOR_2_LENG_REG
#define SPMMC_SDRAM_SECTOR_3_ADDR_REG
#define SPMMC_SDRAM_SECTOR_3_LENG_REG
#define SPMMC_SDRAM_SECTOR_4_ADDR_REG
#define SPMMC_SDRAM_SECTOR_4_LENG_REG
#define SPMMC_SDRAM_SECTOR_5_ADDR_REG
#define SPMMC_SDRAM_SECTOR_5_LENG_REG
#define SPMMC_SDRAM_SECTOR_6_ADDR_REG
#define SPMMC_SDRAM_SECTOR_6_LENG_REG
#define SPMMC_SDRAM_SECTOR_7_ADDR_REG
#define SPMMC_SDRAM_SECTOR_7_LENG_REG

#define SPMMC_SD_INT_REG
#define SPMMC_SDINT_SDCMPEN
#define SPMMC_SDINT_SDCMP
#define SPMMC_SDINT_SDCMPCLR
#define SPMMC_SDINT_SDIOEN
#define SPMMC_SDINT_SDIO
#define SPMMC_SDINT_SDIOCLR

#define SPMMC_SD_PAGE_NUM_REG

#define SPMMC_SD_CONFIG0_REG
#define SPMMC_SD_PIO_MODE
#define SPMMC_SD_DDR_MODE
#define SPMMC_SD_LEN_MODE
#define SPMMC_SD_TRANS_MODE
#define SPMMC_SD_AUTO_RESPONSE
#define SPMMC_SD_CMD_DUMMY
#define SPMMC_SD_RSP_CHK_EN
#define SPMMC_SDIO_MODE
#define SPMMC_SD_MMC_MODE
#define SPMMC_SD_DATA_WD
#define SPMMC_RX4_EN
#define SPMMC_SD_RSP_TYPE
#define SPMMC_MMC8_EN
#define SPMMC_CLOCK_DIVISION

#define SPMMC_SDIO_CTRL_REG
#define SPMMC_INT_MULTI_TRIG

#define SPMMC_SD_RST_REG
#define SPMMC_SD_CTRL_REG
#define SPMMC_NEW_COMMAND_TRIGGER
#define SPMMC_DUMMY_CLOCK_TRIGGER

#define SPMMC_SD_STATUS_REG
#define SPMMC_SDSTATUS_DUMMY_READY
#define SPMMC_SDSTATUS_RSP_BUF_FULL
#define SPMMC_SDSTATUS_TX_DATA_BUF_EMPTY
#define SPMMC_SDSTATUS_RX_DATA_BUF_FULL
#define SPMMC_SDSTATUS_CMD_PIN_STATUS
#define SPMMC_SDSTATUS_DAT0_PIN_STATUS
#define SPMMC_SDSTATUS_RSP_TIMEOUT
#define SPMMC_SDSTATUS_CARD_CRC_CHECK_TIMEOUT
#define SPMMC_SDSTATUS_STB_TIMEOUT
#define SPMMC_SDSTATUS_RSP_CRC7_ERROR
#define SPMMC_SDSTATUS_CRC_TOKEN_CHECK_ERROR
#define SPMMC_SDSTATUS_RDATA_CRC16_ERROR
#define SPMMC_SDSTATUS_SUSPEND_STATE_READY
#define SPMMC_SDSTATUS_BUSY_CYCLE
#define SPMMC_SDSTATUS_DAT1_PIN_STATUS
#define SPMMC_SDSTATUS_SD_SENSE_STATUS
#define SPMMC_SDSTATUS_BOOT_ACK_TIMEOUT
#define SPMMC_SDSTATUS_BOOT_DATA_TIMEOUT
#define SPMMC_SDSTATUS_BOOT_ACK_ERROR

#define SPMMC_SD_STATE_REG
#define SPMMC_CRCTOKEN_CHECK_RESULT
#define SPMMC_SDSTATE_ERROR
#define SPMMC_SDSTATE_FINISH

#define SPMMC_SD_HW_STATE_REG
#define SPMMC_SD_BLOCKSIZE_REG

#define SPMMC_SD_CONFIG1_REG
#define SPMMC_TX_DUMMY_NUM
#define SPMMC_SD_HIGH_SPEED_EN

#define SPMMC_SD_TIMING_CONFIG0_REG
#define SPMMC_SD_CLOCK_DELAY
#define SPMMC_SD_WRITE_DATA_DELAY
#define SPMMC_SD_WRITE_COMMAND_DELAY
#define SPMMC_SD_READ_RESPONSE_DELAY
#define SPMMC_SD_READ_DATA_DELAY
#define SPMMC_SD_READ_CRC_DELAY

#define SPMMC_SD_PIODATATX_REG
#define SPMMC_SD_PIODATARX_REG
#define SPMMC_SD_CMDBUF0_3_REG
#define SPMMC_SD_CMDBUF4_REG
#define SPMMC_SD_RSPBUF0_3_REG
#define SPMMC_SD_RSPBUF4_5_REG

#define SPMMC_MAX_RETRIES

struct spmmc_tuning_info {};

#define SPMMC_DMA_MODE
#define SPMMC_PIO_MODE

struct spmmc_host {};

static inline int spmmc_wait_finish(struct spmmc_host *host)
{}

static inline int spmmc_wait_sdstatus(struct spmmc_host *host, unsigned int status_bit)
{}

#define spmmc_wait_rspbuf_full(host)
#define spmmc_wait_rxbuf_full(host)
#define spmmc_wait_txbuf_empty(host)

static void spmmc_get_rsp(struct spmmc_host *host, struct mmc_command *cmd)
{}

static void spmmc_set_bus_clk(struct spmmc_host *host, int clk)
{}

static void spmmc_set_bus_timing(struct spmmc_host *host, unsigned int timing)
{}

static void spmmc_set_bus_width(struct spmmc_host *host, int width)
{}

/*
 * select the working mode of controller: sd/sdio/emmc
 */
static void spmmc_set_sdmmc_mode(struct spmmc_host *host)
{}

static void spmmc_sw_reset(struct spmmc_host *host)
{}

static void spmmc_prepare_cmd(struct spmmc_host *host, struct mmc_command *cmd)
{}

static void spmmc_prepare_data(struct spmmc_host *host, struct mmc_data *data)
{}

static inline void spmmc_trigger_transaction(struct spmmc_host *host)
{}

static void spmmc_send_stop_cmd(struct spmmc_host *host)
{}

static int spmmc_check_error(struct spmmc_host *host, struct mmc_request *mrq)
{}

/*
 * the strategy is:
 * 1. if several continuous delays are acceptable, we choose a middle one;
 * 2. otherwise, we choose the first one.
 */
static inline int spmmc_find_best_delay(u8 candidate_dly)
{}

static void spmmc_xfer_data_pio(struct spmmc_host *host, struct mmc_data *data)
{}

static void spmmc_controller_init(struct spmmc_host *host)
{}

/*
 * 1. unmap scatterlist if needed;
 * 2. get response & check error conditions;
 * 3. notify mmc layer the request is done
 */
static void spmmc_finish_request(struct spmmc_host *host, struct mmc_request *mrq)
{}

/* Interrupt Service Routine */
static irqreturn_t spmmc_irq(int irq, void *dev_id)
{}

static void spmmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
{}

static void spmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
{}

/*
 * Return values for the get_cd callback should be:
 *   0 for a absent card
 *   1 for a present card
 *   -ENOSYS when not supported (equal to NULL callback)
 *   or a negative errno value when something bad happened
 */
static int spmmc_get_cd(struct mmc_host *mmc)
{}

static int spmmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
{}

static const struct mmc_host_ops spmmc_ops =;

static irqreturn_t spmmc_func_finish_req(int irq, void *dev_id)
{}

static int spmmc_drv_probe(struct platform_device *pdev)
{}

static void spmmc_drv_remove(struct platform_device *dev)
{}

static int spmmc_pm_runtime_suspend(struct device *dev)
{}

static int spmmc_pm_runtime_resume(struct device *dev)
{}

static DEFINE_RUNTIME_DEV_PM_OPS(spmmc_pm_ops, spmmc_pm_runtime_suspend,
							spmmc_pm_runtime_resume, NULL);

static const struct of_device_id spmmc_of_table[] =;
MODULE_DEVICE_TABLE(of, spmmc_of_table);

static struct platform_driver spmmc_driver =;
module_platform_driver();

MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();