linux/drivers/mmc/host/sdhci-pci-gli.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (C) 2019 Genesys Logic, Inc.
 *
 * Authors: Ben Chuang <[email protected]>
 *
 * Version: v0.9.0 (2019-08-08)
 */

#include <linux/bitfield.h>
#include <linux/bits.h>
#include <linux/pci.h>
#include <linux/mmc/mmc.h>
#include <linux/delay.h>
#include <linux/of.h>
#include <linux/iopoll.h>
#include "sdhci.h"
#include "sdhci-cqhci.h"
#include "sdhci-pci.h"
#include "cqhci.h"

/*  Genesys Logic extra registers */
#define SDHCI_GLI_9750_WT
#define SDHCI_GLI_9750_WT_EN
#define GLI_9750_WT_EN_ON
#define GLI_9750_WT_EN_OFF

#define SDHCI_GLI_9750_CFG2
#define SDHCI_GLI_9750_CFG2_L1DLY
#define GLI_9750_CFG2_L1DLY_VALUE

#define SDHCI_GLI_9750_DRIVING
#define SDHCI_GLI_9750_DRIVING_1
#define SDHCI_GLI_9750_DRIVING_2
#define GLI_9750_DRIVING_1_VALUE
#define GLI_9750_DRIVING_2_VALUE
#define SDHCI_GLI_9750_SEL_1
#define SDHCI_GLI_9750_SEL_2
#define SDHCI_GLI_9750_ALL_RST

#define SDHCI_GLI_9750_PLL
#define SDHCI_GLI_9750_PLL_LDIV
#define SDHCI_GLI_9750_PLL_PDIV
#define SDHCI_GLI_9750_PLL_DIR
#define SDHCI_GLI_9750_PLL_TX2_INV
#define SDHCI_GLI_9750_PLL_TX2_DLY
#define GLI_9750_PLL_TX2_INV_VALUE
#define GLI_9750_PLL_TX2_DLY_VALUE
#define SDHCI_GLI_9750_PLLSSC_STEP
#define SDHCI_GLI_9750_PLLSSC_EN

#define SDHCI_GLI_9750_PLLSSC
#define SDHCI_GLI_9750_PLLSSC_PPM

#define SDHCI_GLI_9750_SW_CTRL
#define SDHCI_GLI_9750_SW_CTRL_4
#define GLI_9750_SW_CTRL_4_VALUE

#define SDHCI_GLI_9750_MISC
#define SDHCI_GLI_9750_MISC_TX1_INV
#define SDHCI_GLI_9750_MISC_RX_INV
#define SDHCI_GLI_9750_MISC_TX1_DLY
#define GLI_9750_MISC_TX1_INV_VALUE
#define GLI_9750_MISC_RX_INV_ON
#define GLI_9750_MISC_RX_INV_OFF
#define GLI_9750_MISC_RX_INV_VALUE
#define GLI_9750_MISC_TX1_DLY_VALUE
#define SDHCI_GLI_9750_MISC_SSC_OFF

#define SDHCI_GLI_9750_TUNING_CONTROL
#define SDHCI_GLI_9750_TUNING_CONTROL_EN
#define GLI_9750_TUNING_CONTROL_EN_ON
#define GLI_9750_TUNING_CONTROL_EN_OFF
#define SDHCI_GLI_9750_TUNING_CONTROL_GLITCH_1
#define SDHCI_GLI_9750_TUNING_CONTROL_GLITCH_2
#define GLI_9750_TUNING_CONTROL_GLITCH_1_VALUE
#define GLI_9750_TUNING_CONTROL_GLITCH_2_VALUE

#define SDHCI_GLI_9750_TUNING_PARAMETERS
#define SDHCI_GLI_9750_TUNING_PARAMETERS_RX_DLY
#define GLI_9750_TUNING_PARAMETERS_RX_DLY_VALUE

#define SDHCI_GLI_9763E_CTRL_HS400

#define SDHCI_GLI_9763E_HS400_ES_REG
#define SDHCI_GLI_9763E_HS400_ES_BIT

#define PCIE_GLI_9763E_VHS
#define GLI_9763E_VHS_REV
#define GLI_9763E_VHS_REV_R
#define GLI_9763E_VHS_REV_M
#define GLI_9763E_VHS_REV_W
#define PCIE_GLI_9763E_MB
#define GLI_9763E_MB_CMDQ_OFF
#define GLI_9763E_MB_ERP_ON
#define PCIE_GLI_9763E_SCR
#define GLI_9763E_SCR_AXI_REQ

#define PCIE_GLI_9763E_CFG
#define GLI_9763E_CFG_LPSN_DIS

#define PCIE_GLI_9763E_CFG2
#define GLI_9763E_CFG2_L1DLY
#define GLI_9763E_CFG2_L1DLY_MID

#define PCIE_GLI_9763E_MMC_CTRL
#define GLI_9763E_HS400_SLOW

#define PCIE_GLI_9763E_CLKRXDLY
#define GLI_9763E_HS400_RXDLY
#define GLI_9763E_HS400_RXDLY_5

#define SDHCI_GLI_9763E_CQE_BASE_ADDR
#define GLI_9763E_CQE_TRNS_MODE

#define PCI_GLI_9755_WT
#define PCI_GLI_9755_WT_EN
#define GLI_9755_WT_EN_ON
#define GLI_9755_WT_EN_OFF

#define PCI_GLI_9755_PECONF
#define PCI_GLI_9755_LFCLK
#define PCI_GLI_9755_DMACLK
#define PCI_GLI_9755_INVERT_CD
#define PCI_GLI_9755_INVERT_WP

#define PCI_GLI_9755_CFG2
#define PCI_GLI_9755_CFG2_L1DLY
#define GLI_9755_CFG2_L1DLY_VALUE

#define PCI_GLI_9755_PLL
#define PCI_GLI_9755_PLL_LDIV
#define PCI_GLI_9755_PLL_PDIV
#define PCI_GLI_9755_PLL_DIR
#define PCI_GLI_9755_PLLSSC_STEP
#define PCI_GLI_9755_PLLSSC_EN

#define PCI_GLI_9755_PLLSSC
#define PCI_GLI_9755_PLLSSC_PPM

#define PCI_GLI_9755_SerDes
#define PCI_GLI_9755_SCP_DIS

#define PCI_GLI_9755_MISC
#define PCI_GLI_9755_MISC_SSC_OFF

#define SDHCI_GLI_9767_GM_BURST_SIZE
#define SDHCI_GLI_9767_GM_BURST_SIZE_AXI_ALWAYS_SET

#define PCIE_GLI_9767_VHS
#define GLI_9767_VHS_REV
#define GLI_9767_VHS_REV_R
#define GLI_9767_VHS_REV_M
#define GLI_9767_VHS_REV_W

#define PCIE_GLI_9767_COM_MAILBOX
#define PCIE_GLI_9767_COM_MAILBOX_SSC_EN

#define PCIE_GLI_9767_CFG
#define PCIE_GLI_9767_CFG_LOW_PWR_OFF

#define PCIE_GLI_9767_COMBO_MUX_CTL
#define PCIE_GLI_9767_COMBO_MUX_CTL_RST_EN
#define PCIE_GLI_9767_COMBO_MUX_CTL_WAIT_PERST_EN

#define PCIE_GLI_9767_PWR_MACRO_CTL
#define PCIE_GLI_9767_PWR_MACRO_CTL_LOW_VOLTAGE
#define PCIE_GLI_9767_PWR_MACRO_CTL_LD0_LOW_OUTPUT_VOLTAGE
#define PCIE_GLI_9767_PWR_MACRO_CTL_LD0_LOW_OUTPUT_VOLTAGE_VALUE
#define PCIE_GLI_9767_PWR_MACRO_CTL_RCLK_AMPLITUDE_CTL
#define PCIE_GLI_9767_PWR_MACRO_CTL_RCLK_AMPLITUDE_CTL_VALUE

#define PCIE_GLI_9767_SCR
#define PCIE_GLI_9767_SCR_AUTO_AXI_W_BURST
#define PCIE_GLI_9767_SCR_AUTO_AXI_R_BURST
#define PCIE_GLI_9767_SCR_AXI_REQ
#define PCIE_GLI_9767_SCR_CARD_DET_PWR_SAVING_EN
#define PCIE_GLI_9767_SCR_SYSTEM_CLK_SELECT_MODE0
#define PCIE_GLI_9767_SCR_SYSTEM_CLK_SELECT_MODE1
#define PCIE_GLI_9767_SCR_CORE_PWR_D3_OFF
#define PCIE_GLI_9767_SCR_CFG_RST_DATA_LINK_DOWN

#define PCIE_GLI_9767_SDHC_CAP
#define PCIE_GLI_9767_SDHC_CAP_SDEI_RESULT

#define PCIE_GLI_9767_SD_PLL_CTL
#define PCIE_GLI_9767_SD_PLL_CTL_PLL_LDIV
#define PCIE_GLI_9767_SD_PLL_CTL_PLL_PDIV
#define PCIE_GLI_9767_SD_PLL_CTL_PLL_DIR_EN
#define PCIE_GLI_9767_SD_PLL_CTL_SSC_EN
#define PCIE_GLI_9767_SD_PLL_CTL_SSC_STEP_SETTING

#define PCIE_GLI_9767_SD_PLL_CTL2
#define PCIE_GLI_9767_SD_PLL_CTL2_PLLSSC_PPM

#define PCIE_GLI_9767_SD_EXPRESS_CTL
#define PCIE_GLI_9767_SD_EXPRESS_CTL_SDEI_EXE
#define PCIE_GLI_9767_SD_EXPRESS_CTL_SD_EXPRESS_MODE

#define PCIE_GLI_9767_SD_DATA_MULTI_CTL
#define PCIE_GLI_9767_SD_DATA_MULTI_CTL_DISCONNECT_TIME
#define PCIE_GLI_9767_SD_DATA_MULTI_CTL_DISCONNECT_TIME_VALUE

#define PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_REG2
#define PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_REG2_SDEI_COMPLETE

#define PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_EN_REG2
#define PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_EN_REG2_SDEI_COMPLETE_STATUS_EN

#define PCIE_GLI_9767_NORMAL_ERR_INT_SIGNAL_EN_REG2
#define PCIE_GLI_9767_NORMAL_ERR_INT_SIGNAL_EN_REG2_SDEI_COMPLETE_SIGNAL_EN

#define GLI_MAX_TUNING_LOOP

/* Genesys Logic chipset */
static inline void gl9750_wt_on(struct sdhci_host *host)
{}

static inline void gl9750_wt_off(struct sdhci_host *host)
{}

static void gli_set_9750(struct sdhci_host *host)
{}

static void gli_set_9750_rx_inv(struct sdhci_host *host, bool b)
{}

static int __sdhci_execute_tuning_9750(struct sdhci_host *host, u32 opcode)
{}

static int gl9750_execute_tuning(struct sdhci_host *host, u32 opcode)
{}

static void gl9750_disable_ssc_pll(struct sdhci_host *host)
{}

static void gl9750_set_pll(struct sdhci_host *host, u8 dir, u16 ldiv, u8 pdiv)
{}

static bool gl9750_ssc_enable(struct sdhci_host *host)
{}

static void gl9750_set_ssc(struct sdhci_host *host, u8 enable, u8 step, u16 ppm)
{}

static void gl9750_set_ssc_pll_205mhz(struct sdhci_host *host)
{}

static void gl9750_set_ssc_pll_100mhz(struct sdhci_host *host)
{}

static void gl9750_set_ssc_pll_50mhz(struct sdhci_host *host)
{}

static void sdhci_gl9750_set_clock(struct sdhci_host *host, unsigned int clock)
{}

static void gl9750_hw_setting(struct sdhci_host *host)
{}

static void gli_pcie_enable_msi(struct sdhci_pci_slot *slot)
{}

static inline void gl9755_wt_on(struct pci_dev *pdev)
{}

static inline void gl9755_wt_off(struct pci_dev *pdev)
{}

static void gl9755_disable_ssc_pll(struct pci_dev *pdev)
{}

static void gl9755_set_pll(struct pci_dev *pdev, u8 dir, u16 ldiv, u8 pdiv)
{}

static bool gl9755_ssc_enable(struct pci_dev *pdev)
{}

static void gl9755_set_ssc(struct pci_dev *pdev, u8 enable, u8 step, u16 ppm)
{}

static void gl9755_set_ssc_pll_205mhz(struct pci_dev *pdev)
{}

static void gl9755_set_ssc_pll_100mhz(struct pci_dev *pdev)
{}

static void gl9755_set_ssc_pll_50mhz(struct pci_dev *pdev)
{}

static void sdhci_gl9755_set_clock(struct sdhci_host *host, unsigned int clock)
{}

static void gl9755_hw_setting(struct sdhci_pci_slot *slot)
{}

static inline void gl9767_vhs_read(struct pci_dev *pdev)
{}

static inline void gl9767_vhs_write(struct pci_dev *pdev)
{}

static bool gl9767_ssc_enable(struct pci_dev *pdev)
{}

static void gl9767_set_ssc(struct pci_dev *pdev, u8 enable, u8 step, u16 ppm)
{}

static void gl9767_set_pll(struct pci_dev *pdev, u8 dir, u16 ldiv, u8 pdiv)
{}

static void gl9767_set_ssc_pll_205mhz(struct pci_dev *pdev)
{}

static void gl9767_disable_ssc_pll(struct pci_dev *pdev)
{}

static void sdhci_gl9767_set_clock(struct sdhci_host *host, unsigned int clock)
{}

static void gli_set_9767(struct sdhci_host *host)
{}

static void gl9767_hw_setting(struct sdhci_pci_slot *slot)
{}

static void sdhci_gl9767_reset(struct sdhci_host *host, u8 mask)
{}

static int gl9767_init_sd_express(struct mmc_host *mmc, struct mmc_ios *ios)
{}

static int gli_probe_slot_gl9750(struct sdhci_pci_slot *slot)
{}

static int gli_probe_slot_gl9755(struct sdhci_pci_slot *slot)
{}

static int gli_probe_slot_gl9767(struct sdhci_pci_slot *slot)
{}

static void sdhci_gli_voltage_switch(struct sdhci_host *host)
{}

static void sdhci_gl9767_voltage_switch(struct sdhci_host *host)
{}

static void sdhci_gl9750_reset(struct sdhci_host *host, u8 mask)
{}

static u32 sdhci_gl9750_readl(struct sdhci_host *host, int reg)
{}

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

static void gl9763e_set_low_power_negotiation(struct sdhci_pci_slot *slot,
					      bool enable)
{}

static void sdhci_set_gl9763e_signaling(struct sdhci_host *host,
					unsigned int timing)
{}

static void sdhci_gl9763e_dumpregs(struct mmc_host *mmc)
{}

static void sdhci_gl9763e_cqe_pre_enable(struct mmc_host *mmc)
{}

static void sdhci_gl9763e_cqe_enable(struct mmc_host *mmc)
{}

static u32 sdhci_gl9763e_cqhci_irq(struct sdhci_host *host, u32 intmask)
{}

static void sdhci_gl9763e_cqe_post_disable(struct mmc_host *mmc)
{}

static const struct cqhci_host_ops sdhci_gl9763e_cqhci_ops =;

static int gl9763e_add_host(struct sdhci_pci_slot *slot)
{}

static void gli_set_gl9763e(struct sdhci_pci_slot *slot)
{}

#ifdef CONFIG_PM
static int gl9763e_runtime_suspend(struct sdhci_pci_chip *chip)
{}

static int gl9763e_runtime_resume(struct sdhci_pci_chip *chip)
{}
#endif

#ifdef CONFIG_PM_SLEEP
static int sdhci_pci_gli_resume(struct sdhci_pci_chip *chip)
{}

static int gl9763e_resume(struct sdhci_pci_chip *chip)
{}

static int gl9763e_suspend(struct sdhci_pci_chip *chip)
{}
#endif

static int gli_probe_slot_gl9763e(struct sdhci_pci_slot *slot)
{}

#define REG_OFFSET_IN_BITS(reg)

static u16 sdhci_gli_readw(struct sdhci_host *host, int reg)
{}

static u8 sdhci_gli_readb(struct sdhci_host *host, int reg)
{}

static const struct sdhci_ops sdhci_gl9755_ops =;

const struct sdhci_pci_fixes sdhci_gl9755 =;

static const struct sdhci_ops sdhci_gl9750_ops =;

const struct sdhci_pci_fixes sdhci_gl9750 =;

static const struct sdhci_ops sdhci_gl9763e_ops =;

const struct sdhci_pci_fixes sdhci_gl9763e =;

static const struct sdhci_ops sdhci_gl9767_ops =;

const struct sdhci_pci_fixes sdhci_gl9767 =;