#include <linux/pci.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/dma-mapping.h>
#include <linux/highmem.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/idr.h>
#include <linux/platform_device.h>
#include <linux/mfd/core.h>
#include <linux/rtsx_pci.h>
#include <linux/mmc/card.h>
#include <asm/unaligned.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
#include "rtsx_pcr.h"
#include "rts5261.h"
#include "rts5228.h"
#include "rts5264.h"
static bool msi_en = …;
module_param(msi_en, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(…) …;
static DEFINE_IDR(rtsx_pci_idr);
static DEFINE_SPINLOCK(rtsx_pci_lock);
static struct mfd_cell rtsx_pcr_cells[] = …;
static const struct pci_device_id rtsx_pci_ids[] = …;
MODULE_DEVICE_TABLE(pci, rtsx_pci_ids);
static int rtsx_comm_set_ltr_latency(struct rtsx_pcr *pcr, u32 latency)
{ … }
int rtsx_set_ltr_latency(struct rtsx_pcr *pcr, u32 latency)
{ … }
static void rtsx_comm_set_aspm(struct rtsx_pcr *pcr, bool enable)
{ … }
static void rtsx_disable_aspm(struct rtsx_pcr *pcr)
{ … }
int rtsx_set_l1off_sub(struct rtsx_pcr *pcr, u8 val)
{ … }
static void rtsx_set_l1off_sub_cfg_d0(struct rtsx_pcr *pcr, int active)
{ … }
static void rtsx_comm_pm_full_on(struct rtsx_pcr *pcr)
{ … }
static void rtsx_pm_full_on(struct rtsx_pcr *pcr)
{ … }
void rtsx_pci_start_run(struct rtsx_pcr *pcr)
{ … }
EXPORT_SYMBOL_GPL(…);
int rtsx_pci_write_register(struct rtsx_pcr *pcr, u16 addr, u8 mask, u8 data)
{ … }
EXPORT_SYMBOL_GPL(…);
int rtsx_pci_read_register(struct rtsx_pcr *pcr, u16 addr, u8 *data)
{ … }
EXPORT_SYMBOL_GPL(…);
int __rtsx_pci_write_phy_register(struct rtsx_pcr *pcr, u8 addr, u16 val)
{ … }
int rtsx_pci_write_phy_register(struct rtsx_pcr *pcr, u8 addr, u16 val)
{ … }
EXPORT_SYMBOL_GPL(…);
int __rtsx_pci_read_phy_register(struct rtsx_pcr *pcr, u8 addr, u16 *val)
{ … }
int rtsx_pci_read_phy_register(struct rtsx_pcr *pcr, u8 addr, u16 *val)
{ … }
EXPORT_SYMBOL_GPL(…);
void rtsx_pci_stop_cmd(struct rtsx_pcr *pcr)
{ … }
EXPORT_SYMBOL_GPL(…);
void rtsx_pci_add_cmd(struct rtsx_pcr *pcr,
u8 cmd_type, u16 reg_addr, u8 mask, u8 data)
{ … }
EXPORT_SYMBOL_GPL(…);
void rtsx_pci_send_cmd_no_wait(struct rtsx_pcr *pcr)
{ … }
EXPORT_SYMBOL_GPL(…);
int rtsx_pci_send_cmd(struct rtsx_pcr *pcr, int timeout)
{ … }
EXPORT_SYMBOL_GPL(…);
static void rtsx_pci_add_sg_tbl(struct rtsx_pcr *pcr,
dma_addr_t addr, unsigned int len, int end)
{ … }
int rtsx_pci_transfer_data(struct rtsx_pcr *pcr, struct scatterlist *sglist,
int num_sg, bool read, int timeout)
{ … }
EXPORT_SYMBOL_GPL(…);
int rtsx_pci_dma_map_sg(struct rtsx_pcr *pcr, struct scatterlist *sglist,
int num_sg, bool read)
{ … }
EXPORT_SYMBOL_GPL(…);
void rtsx_pci_dma_unmap_sg(struct rtsx_pcr *pcr, struct scatterlist *sglist,
int num_sg, bool read)
{ … }
EXPORT_SYMBOL_GPL(…);
int rtsx_pci_dma_transfer(struct rtsx_pcr *pcr, struct scatterlist *sglist,
int count, bool read, int timeout)
{ … }
EXPORT_SYMBOL_GPL(…);
int rtsx_pci_read_ppbuf(struct rtsx_pcr *pcr, u8 *buf, int buf_len)
{ … }
EXPORT_SYMBOL_GPL(…);
int rtsx_pci_write_ppbuf(struct rtsx_pcr *pcr, u8 *buf, int buf_len)
{ … }
EXPORT_SYMBOL_GPL(…);
static int rtsx_pci_set_pull_ctl(struct rtsx_pcr *pcr, const u32 *tbl)
{ … }
int rtsx_pci_card_pull_ctl_enable(struct rtsx_pcr *pcr, int card)
{ … }
EXPORT_SYMBOL_GPL(…);
int rtsx_pci_card_pull_ctl_disable(struct rtsx_pcr *pcr, int card)
{ … }
EXPORT_SYMBOL_GPL(…);
static void rtsx_pci_enable_bus_int(struct rtsx_pcr *pcr)
{ … }
static inline u8 double_ssc_depth(u8 depth)
{ … }
static u8 revise_ssc_depth(u8 ssc_depth, u8 div)
{ … }
int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk)
{ … }
EXPORT_SYMBOL_GPL(…);
int rtsx_pci_card_power_on(struct rtsx_pcr *pcr, int card)
{ … }
EXPORT_SYMBOL_GPL(…);
int rtsx_pci_card_power_off(struct rtsx_pcr *pcr, int card)
{ … }
EXPORT_SYMBOL_GPL(…);
int rtsx_pci_card_exclusive_check(struct rtsx_pcr *pcr, int card)
{ … }
EXPORT_SYMBOL_GPL(…);
int rtsx_pci_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
{ … }
EXPORT_SYMBOL_GPL(…);
unsigned int rtsx_pci_card_exist(struct rtsx_pcr *pcr)
{ … }
EXPORT_SYMBOL_GPL(…);
void rtsx_pci_complete_unfinished_transfer(struct rtsx_pcr *pcr)
{ … }
EXPORT_SYMBOL_GPL(…);
static void rtsx_pci_card_detect(struct work_struct *work)
{ … }
static void rtsx_pci_process_ocp(struct rtsx_pcr *pcr)
{ … }
static int rtsx_pci_process_ocp_interrupt(struct rtsx_pcr *pcr)
{ … }
static irqreturn_t rtsx_pci_isr(int irq, void *dev_id)
{ … }
static int rtsx_pci_acquire_irq(struct rtsx_pcr *pcr)
{ … }
static void rtsx_base_force_power_down(struct rtsx_pcr *pcr)
{ … }
static void __maybe_unused rtsx_pci_power_off(struct rtsx_pcr *pcr, u8 pm_state, bool runtime)
{ … }
void rtsx_pci_enable_ocp(struct rtsx_pcr *pcr)
{ … }
void rtsx_pci_disable_ocp(struct rtsx_pcr *pcr)
{ … }
void rtsx_pci_init_ocp(struct rtsx_pcr *pcr)
{ … }
int rtsx_pci_get_ocpstat(struct rtsx_pcr *pcr, u8 *val)
{ … }
void rtsx_pci_clear_ocpstat(struct rtsx_pcr *pcr)
{ … }
void rtsx_pci_enable_oobs_polling(struct rtsx_pcr *pcr)
{ … }
void rtsx_pci_disable_oobs_polling(struct rtsx_pcr *pcr)
{ … }
int rtsx_sd_power_off_card3v3(struct rtsx_pcr *pcr)
{ … }
int rtsx_ms_power_off_card3v3(struct rtsx_pcr *pcr)
{ … }
static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)
{ … }
static int rtsx_pci_init_chip(struct rtsx_pcr *pcr)
{ … }
static int rtsx_pci_probe(struct pci_dev *pcidev,
const struct pci_device_id *id)
{ … }
static void rtsx_pci_remove(struct pci_dev *pcidev)
{ … }
static int __maybe_unused rtsx_pci_suspend(struct device *dev_d)
{ … }
static int __maybe_unused rtsx_pci_resume(struct device *dev_d)
{ … }
#ifdef CONFIG_PM
static void rtsx_enable_aspm(struct rtsx_pcr *pcr)
{ … }
static void rtsx_comm_pm_power_saving(struct rtsx_pcr *pcr)
{ … }
static void rtsx_pm_power_saving(struct rtsx_pcr *pcr)
{ … }
static void rtsx_pci_shutdown(struct pci_dev *pcidev)
{ … }
static int rtsx_pci_runtime_idle(struct device *device)
{ … }
static int rtsx_pci_runtime_suspend(struct device *device)
{ … }
static int rtsx_pci_runtime_resume(struct device *device)
{ … }
#else
#define rtsx_pci_shutdown …
#define rtsx_pci_runtime_suspend …
#define rtsx_pic_runtime_resume …
#endif
static const struct dev_pm_ops rtsx_pci_pm_ops = …;
static struct pci_driver rtsx_pci_driver = …;
module_pci_driver(…) …;
MODULE_LICENSE(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;