#include <linux/pci.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/highmem.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/workqueue.h>
#include <linux/mmc/host.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sd.h>
#include <linux/mmc/sdio.h>
#include <linux/mmc/card.h>
#include <linux/rtsx_pci.h>
#include <asm/unaligned.h>
#include <linux/pm_runtime.h>
struct realtek_pci_sdmmc { … };
static int sdmmc_init_sd_express(struct mmc_host *mmc, struct mmc_ios *ios);
static inline struct device *sdmmc_dev(struct realtek_pci_sdmmc *host)
{ … }
static inline void sd_clear_error(struct realtek_pci_sdmmc *host)
{ … }
#ifdef DEBUG
static void dump_reg_range(struct realtek_pci_sdmmc *host, u16 start, u16 end)
{
u16 len = end - start + 1;
int i;
u8 data[8];
for (i = 0; i < len; i += 8) {
int j;
int n = min(8, len - i);
memset(&data, 0, sizeof(data));
for (j = 0; j < n; j++)
rtsx_pci_read_register(host->pcr, start + i + j,
data + j);
dev_dbg(sdmmc_dev(host), "0x%04X(%d): %8ph\n",
start + i, n, data);
}
}
static void sd_print_debug_regs(struct realtek_pci_sdmmc *host)
{
dump_reg_range(host, 0xFDA0, 0xFDB3);
dump_reg_range(host, 0xFD52, 0xFD69);
}
#else
#define sd_print_debug_regs(host) …
#endif
static inline int sd_get_cd_int(struct realtek_pci_sdmmc *host)
{ … }
static void sd_cmd_set_sd_cmd(struct rtsx_pcr *pcr, struct mmc_command *cmd)
{ … }
static void sd_cmd_set_data_len(struct rtsx_pcr *pcr, u16 blocks, u16 blksz)
{ … }
static int sd_response_type(struct mmc_command *cmd)
{ … }
static int sd_status_index(int resp_type)
{ … }
static int sd_pre_dma_transfer(struct realtek_pci_sdmmc *host,
struct mmc_data *data, bool pre)
{ … }
static void sdmmc_pre_req(struct mmc_host *mmc, struct mmc_request *mrq)
{ … }
static void sdmmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq,
int err)
{ … }
static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc *host,
struct mmc_command *cmd)
{ … }
static int sd_read_data(struct realtek_pci_sdmmc *host, struct mmc_command *cmd,
u16 byte_cnt, u8 *buf, int buf_len, int timeout)
{ … }
static int sd_write_data(struct realtek_pci_sdmmc *host,
struct mmc_command *cmd, u16 byte_cnt, u8 *buf, int buf_len,
int timeout)
{ … }
static int sd_read_long_data(struct realtek_pci_sdmmc *host,
struct mmc_request *mrq)
{ … }
static int sd_write_long_data(struct realtek_pci_sdmmc *host,
struct mmc_request *mrq)
{ … }
static inline void sd_enable_initial_mode(struct realtek_pci_sdmmc *host)
{ … }
static inline void sd_disable_initial_mode(struct realtek_pci_sdmmc *host)
{ … }
static int sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq)
{ … }
static void sd_normal_rw(struct realtek_pci_sdmmc *host,
struct mmc_request *mrq)
{ … }
static int sd_change_phase(struct realtek_pci_sdmmc *host,
u8 sample_point, bool rx)
{ … }
static inline u32 test_phase_bit(u32 phase_map, unsigned int bit)
{ … }
static int sd_get_phase_len(u32 phase_map, unsigned int start_bit)
{ … }
static u8 sd_search_final_phase(struct realtek_pci_sdmmc *host, u32 phase_map)
{ … }
static void sd_wait_data_idle(struct realtek_pci_sdmmc *host)
{ … }
static int sd_tuning_rx_cmd(struct realtek_pci_sdmmc *host,
u8 opcode, u8 sample_point)
{ … }
static int sd_tuning_phase(struct realtek_pci_sdmmc *host,
u8 opcode, u32 *phase_map)
{ … }
static int sd_tuning_rx(struct realtek_pci_sdmmc *host, u8 opcode)
{ … }
static inline int sdio_extblock_cmd(struct mmc_command *cmd,
struct mmc_data *data)
{ … }
static inline int sd_rw_cmd(struct mmc_command *cmd)
{ … }
static void sd_request(struct work_struct *work)
{ … }
static void sdmmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
{ … }
static int sd_set_bus_width(struct realtek_pci_sdmmc *host,
unsigned char bus_width)
{ … }
static int sd_power_on(struct realtek_pci_sdmmc *host, unsigned char power_mode)
{ … }
static int sd_power_off(struct realtek_pci_sdmmc *host)
{ … }
static int sd_set_power_mode(struct realtek_pci_sdmmc *host,
unsigned char power_mode)
{ … }
static int sd_set_timing(struct realtek_pci_sdmmc *host, unsigned char timing)
{ … }
static void sdmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
{ … }
static int sdmmc_get_ro(struct mmc_host *mmc)
{ … }
static int sdmmc_get_cd(struct mmc_host *mmc)
{ … }
static int sd_wait_voltage_stable_1(struct realtek_pci_sdmmc *host)
{ … }
static int sd_wait_voltage_stable_2(struct realtek_pci_sdmmc *host)
{ … }
static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
{ … }
static int sdmmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
{ … }
static int sdmmc_init_sd_express(struct mmc_host *mmc, struct mmc_ios *ios)
{ … }
static const struct mmc_host_ops realtek_pci_sdmmc_ops = …;
static void init_extra_caps(struct realtek_pci_sdmmc *host)
{ … }
static void realtek_init_host(struct realtek_pci_sdmmc *host)
{ … }
static void rtsx_pci_sdmmc_card_event(struct platform_device *pdev)
{ … }
static int rtsx_pci_sdmmc_drv_probe(struct platform_device *pdev)
{ … }
static void rtsx_pci_sdmmc_drv_remove(struct platform_device *pdev)
{ … }
static const struct platform_device_id rtsx_pci_sdmmc_ids[] = …;
MODULE_DEVICE_TABLE(platform, rtsx_pci_sdmmc_ids);
static struct platform_driver rtsx_pci_sdmmc_driver = …;
module_platform_driver(…) …;
MODULE_LICENSE(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;