linux/drivers/mmc/host/via-sdmmc.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  drivers/mmc/host/via-sdmmc.c - VIA SD/MMC Card Reader driver
 *  Copyright (c) 2008, VIA Technologies Inc. All Rights Reserved.
 */

#include <linux/pci.h>
#include <linux/module.h>
#include <linux/dma-mapping.h>
#include <linux/highmem.h>
#include <linux/delay.h>
#include <linux/interrupt.h>

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

#define DRV_NAME

#define PCI_DEVICE_ID_VIA_9530

#define VIA_CRDR_SDC_OFF
#define VIA_CRDR_DDMA_OFF
#define VIA_CRDR_PCICTRL_OFF

#define VIA_CRDR_MIN_CLOCK
#define VIA_CRDR_MAX_CLOCK

/*
 * PCI registers
 */

#define VIA_CRDR_PCI_WORK_MODE
#define VIA_CRDR_PCI_DBG_MODE

/*
 * SDC MMIO Registers
 */

#define VIA_CRDR_SDCTRL
#define VIA_CRDR_SDCTRL_START
#define VIA_CRDR_SDCTRL_WRITE
#define VIA_CRDR_SDCTRL_SINGLE_WR
#define VIA_CRDR_SDCTRL_SINGLE_RD
#define VIA_CRDR_SDCTRL_MULTI_WR
#define VIA_CRDR_SDCTRL_MULTI_RD
#define VIA_CRDR_SDCTRL_STOP

#define VIA_CRDR_SDCTRL_RSP_NONE
#define VIA_CRDR_SDCTRL_RSP_R1
#define VIA_CRDR_SDCTRL_RSP_R2
#define VIA_CRDR_SDCTRL_RSP_R3
#define VIA_CRDR_SDCTRL_RSP_R1B

#define VIA_CRDR_SDCARG

#define VIA_CRDR_SDBUSMODE
#define VIA_CRDR_SDMODE_4BIT
#define VIA_CRDR_SDMODE_CLK_ON

#define VIA_CRDR_SDBLKLEN
/*
 * Bit 0 -Bit 10 : Block length. So, the maximum block length should be 2048.
 * Bit 11 - Bit 13 : Reserved.
 * GPIDET : Select GPI pin to detect card, GPI means CR_CD# in top design.
 * INTEN : Enable SD host interrupt.
 * Bit 16 - Bit 31 : Block count. So, the maximun block count should be 65536.
 */
#define VIA_CRDR_SDBLKLEN_GPIDET
#define VIA_CRDR_SDBLKLEN_INTEN
#define VIA_CRDR_MAX_BLOCK_COUNT
#define VIA_CRDR_MAX_BLOCK_LENGTH

#define VIA_CRDR_SDRESP0
#define VIA_CRDR_SDRESP1
#define VIA_CRDR_SDRESP2
#define VIA_CRDR_SDRESP3

#define VIA_CRDR_SDCURBLKCNT

#define VIA_CRDR_SDINTMASK
/*
 * MBDIE : Multiple Blocks transfer Done Interrupt Enable
 * BDDIE : Block Data transfer Done Interrupt Enable
 * CIRIE : Card Insertion or Removal Interrupt Enable
 * CRDIE : Command-Response transfer Done Interrupt Enable
 * CRTOIE : Command-Response response TimeOut Interrupt Enable
 * ASCRDIE : Auto Stop Command-Response transfer Done Interrupt Enable
 * DTIE : Data access Timeout Interrupt Enable
 * SCIE : reSponse CRC error Interrupt Enable
 * RCIE : Read data CRC error Interrupt Enable
 * WCIE : Write data CRC error Interrupt Enable
 */
#define VIA_CRDR_SDINTMASK_MBDIE
#define VIA_CRDR_SDINTMASK_BDDIE
#define VIA_CRDR_SDINTMASK_CIRIE
#define VIA_CRDR_SDINTMASK_CRDIE
#define VIA_CRDR_SDINTMASK_CRTOIE
#define VIA_CRDR_SDINTMASK_ASCRDIE
#define VIA_CRDR_SDINTMASK_DTIE
#define VIA_CRDR_SDINTMASK_SCIE
#define VIA_CRDR_SDINTMASK_RCIE
#define VIA_CRDR_SDINTMASK_WCIE

#define VIA_CRDR_SDACTIVE_INTMASK

#define VIA_CRDR_SDSTATUS
/*
 * CECC : Reserved
 * WP : SD card Write Protect status
 * SLOTD : Reserved
 * SLOTG : SD SLOT status(Gpi pin status)
 * MBD : Multiple Blocks transfer Done interrupt status
 * BDD : Block Data transfer Done interrupt status
 * CD : Reserved
 * CIR : Card Insertion or Removal interrupt detected on GPI pin
 * IO : Reserved
 * CRD : Command-Response transfer Done interrupt status
 * CRTO : Command-Response response TimeOut interrupt status
 * ASCRDIE : Auto Stop Command-Response transfer Done interrupt status
 * DT : Data access Timeout interrupt status
 * SC : reSponse CRC error interrupt status
 * RC : Read data CRC error interrupt status
 * WC : Write data CRC error interrupt status
 */
#define VIA_CRDR_SDSTS_CECC
#define VIA_CRDR_SDSTS_WP
#define VIA_CRDR_SDSTS_SLOTD
#define VIA_CRDR_SDSTS_SLOTG
#define VIA_CRDR_SDSTS_MBD
#define VIA_CRDR_SDSTS_BDD
#define VIA_CRDR_SDSTS_CD
#define VIA_CRDR_SDSTS_CIR
#define VIA_CRDR_SDSTS_IO
#define VIA_CRDR_SDSTS_CRD
#define VIA_CRDR_SDSTS_CRTO
#define VIA_CRDR_SDSTS_ASCRDIE
#define VIA_CRDR_SDSTS_DT
#define VIA_CRDR_SDSTS_SC
#define VIA_CRDR_SDSTS_RC
#define VIA_CRDR_SDSTS_WC

#define VIA_CRDR_SDSTS_IGN_MASK
#define VIA_CRDR_SDSTS_INT_MASK
#define VIA_CRDR_SDSTS_W1C_MASK
#define VIA_CRDR_SDSTS_CMD_MASK
#define VIA_CRDR_SDSTS_DATA_MASK

#define VIA_CRDR_SDSTATUS2
/*
 * CFE : Enable SD host automatic Clock FReezing
 */
#define VIA_CRDR_SDSTS_CFE

#define VIA_CRDR_SDRSPTMO

#define VIA_CRDR_SDCLKSEL

#define VIA_CRDR_SDEXTCTRL
#define VIS_CRDR_SDEXTCTRL_AUTOSTOP_SD
#define VIS_CRDR_SDEXTCTRL_SHIFT_9
#define VIS_CRDR_SDEXTCTRL_MMC_8BIT
#define VIS_CRDR_SDEXTCTRL_RELD_BLK
#define VIS_CRDR_SDEXTCTRL_BAD_CMDA
#define VIS_CRDR_SDEXTCTRL_BAD_DATA
#define VIS_CRDR_SDEXTCTRL_AUTOSTOP_SPI
#define VIA_CRDR_SDEXTCTRL_HISPD
/* 0x38-0xFF reserved */

/*
 * Data DMA Control Registers
 */

#define VIA_CRDR_DMABASEADD
#define VIA_CRDR_DMACOUNTER

#define VIA_CRDR_DMACTRL
/*
 * DIR :Transaction Direction
 * 0 : From card to memory
 * 1 : From memory to card
 */
#define VIA_CRDR_DMACTRL_DIR
#define VIA_CRDR_DMACTRL_ENIRQ
#define VIA_CRDR_DMACTRL_SFTRST

#define VIA_CRDR_DMASTS

#define VIA_CRDR_DMASTART
/*0x14-0xFF reserved*/

/*
 * PCI Control Registers
 */

/*0x0 - 0x1 reserved*/
#define VIA_CRDR_PCICLKGATT
/*
 * SFTRST :
 * 0 : Soft reset all the controller and it will be de-asserted automatically
 * 1 : Soft reset is de-asserted
 */
#define VIA_CRDR_PCICLKGATT_SFTRST
/*
 * 3V3 : Pad power select
 * 0 : 1.8V
 * 1 : 3.3V
 * NOTE : No mater what the actual value should be, this bit always
 * read as 0. This is a hardware bug.
 */
#define VIA_CRDR_PCICLKGATT_3V3
/*
 * PAD_PWRON : Pad Power on/off select
 * 0 : Power off
 * 1 : Power on
  * NOTE : No mater what the actual value should be, this bit always
 * read as 0. This is a hardware bug.
 */
#define VIA_CRDR_PCICLKGATT_PAD_PWRON

#define VIA_CRDR_PCISDCCLK

#define VIA_CRDR_PCIDMACLK
#define VIA_CRDR_PCIDMACLK_SDC

#define VIA_CRDR_PCIINTCTRL
#define VIA_CRDR_PCIINTCTRL_SDCIRQEN

#define VIA_CRDR_PCIINTSTATUS
#define VIA_CRDR_PCIINTSTATUS_SDC

#define VIA_CRDR_PCITMOCTRL
#define VIA_CRDR_PCITMOCTRL_NO
#define VIA_CRDR_PCITMOCTRL_32US
#define VIA_CRDR_PCITMOCTRL_256US
#define VIA_CRDR_PCITMOCTRL_1024US
#define VIA_CRDR_PCITMOCTRL_256MS
#define VIA_CRDR_PCITMOCTRL_512MS
#define VIA_CRDR_PCITMOCTRL_1024MS

/*0xB-0xFF reserved*/

enum PCI_HOST_CLK_CONTROL {};

struct sdhcreg {};

struct pcictrlreg {};

struct via_crdr_mmc_host {};

/* some devices need a very long delay for power to stabilize */
#define VIA_CRDR_QUIRK_300MS_PWRDELAY

#define VIA_CMD_TIMEOUT_MS

static const struct pci_device_id via_ids[] =;

MODULE_DEVICE_TABLE(pci, via_ids);

static void via_print_sdchc(struct via_crdr_mmc_host *host)
{}

static void via_print_pcictrl(struct via_crdr_mmc_host *host)
{}

static void via_save_pcictrlreg(struct via_crdr_mmc_host *host)
{}

static void via_restore_pcictrlreg(struct via_crdr_mmc_host *host)
{}

static void via_save_sdcreg(struct via_crdr_mmc_host *host)
{}

static void via_restore_sdcreg(struct via_crdr_mmc_host *host)
{}

static void via_pwron_sleep(struct via_crdr_mmc_host *sdhost)
{}

static void via_set_ddma(struct via_crdr_mmc_host *host,
			 dma_addr_t dmaaddr, u32 count, int dir, int enirq)
{}

static void via_sdc_preparedata(struct via_crdr_mmc_host *host,
				struct mmc_data *data)
{}

static void via_sdc_get_response(struct via_crdr_mmc_host *host,
				 struct mmc_command *cmd)
{}

static void via_sdc_send_command(struct via_crdr_mmc_host *host,
				 struct mmc_command *cmd)
{}

static void via_sdc_finish_data(struct via_crdr_mmc_host *host)
{}

static void via_sdc_finish_command(struct via_crdr_mmc_host *host)
{}

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

static void via_sdc_set_power(struct via_crdr_mmc_host *host,
			      unsigned short power, unsigned int on)
{}

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

static int via_sdc_get_ro(struct mmc_host *mmc)
{}

static const struct mmc_host_ops via_sdc_ops =;

static void via_reset_pcictrl(struct via_crdr_mmc_host *host)
{}

static void via_sdc_cmd_isr(struct via_crdr_mmc_host *host, u16 intmask)
{}

static void via_sdc_data_isr(struct via_crdr_mmc_host *host, u16 intmask)
{}

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

static void via_sdc_timeout(struct timer_list *t)
{}

static void via_sdc_finish_bh_work(struct work_struct *t)
{}

static void via_sdc_card_detect(struct work_struct *work)
{}

static void via_init_mmc_host(struct via_crdr_mmc_host *host)
{}

static int via_sd_probe(struct pci_dev *pcidev,
				    const struct pci_device_id *id)
{}

static void via_sd_remove(struct pci_dev *pcidev)
{}

static void __maybe_unused via_init_sdc_pm(struct via_crdr_mmc_host *host)
{}

static int __maybe_unused via_sd_suspend(struct device *dev)
{}

static int __maybe_unused via_sd_resume(struct device *dev)
{}

static SIMPLE_DEV_PM_OPS(via_sd_pm_ops, via_sd_suspend, via_sd_resume);

static struct pci_driver via_sd_driver =;

module_pci_driver();

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