drivers/misc/cardreader/rts5260.c
Source file repositories/reference/linux-study-clean/drivers/misc/cardreader/rts5260.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/cardreader/rts5260.c- Extension
.c- Size
- 17890 bytes
- Lines
- 630
- Domain
- Driver Families
- Bucket
- drivers/misc
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/delay.hlinux/rtsx_pci.hrts5260.hrtsx_pcr.h
Detected Declarations
function Copyrightfunction rts5260_fill_drivingfunction rtsx_base_fetch_vendor_settingsfunction rtsx_base_enable_auto_blinkfunction rtsx_base_disable_auto_blinkfunction rts5260_turn_on_ledfunction rts5260_turn_off_ledfunction sd_set_sample_push_timing_sd30function rts5260_card_power_onfunction rts5260_switch_output_voltagefunction rts5260_stop_cmdfunction rts5260_card_before_power_offfunction rts5260_card_power_offfunction rts5260_init_ocpfunction rts5260_enable_ocpfunction rts5260_disable_ocpfunction rts5260_get_ocpstatfunction rts5260_get_ocpstat2function rts5260_clear_ocpstatfunction rts5260_process_ocpfunction rts5260_init_hwfunction rts5260_pwr_saving_settingfunction rts5260_init_from_cfgfunction rts5260_extra_init_hwfunction rts5260_set_l1off_cfg_sub_d0function rts5260_init_params
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/* Driver for Realtek PCI-Express card reader
*
* Copyright(c) 2016-2017 Realtek Semiconductor Corp. All rights reserved.
*
* Author:
* Steven FENG <steven_feng@realsil.com.cn>
* Rui FENG <rui_feng@realsil.com.cn>
* Wei WANG <wei_wang@realsil.com.cn>
*/
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/rtsx_pci.h>
#include "rts5260.h"
#include "rtsx_pcr.h"
static u8 rts5260_get_ic_version(struct rtsx_pcr *pcr)
{
u8 val;
rtsx_pci_read_register(pcr, DUMMY_REG_RESET_0, &val);
return val & IC_VERSION_MASK;
}
static void rts5260_fill_driving(struct rtsx_pcr *pcr, u8 voltage)
{
u8 driving_3v3[4][3] = {
{0x11, 0x11, 0x11},
{0x22, 0x22, 0x22},
{0x55, 0x55, 0x55},
{0x33, 0x33, 0x33},
};
u8 driving_1v8[4][3] = {
{0x35, 0x33, 0x33},
{0x8A, 0x88, 0x88},
{0xBD, 0xBB, 0xBB},
{0x9B, 0x99, 0x99},
};
u8 (*driving)[3], drive_sel;
if (voltage == OUTPUT_3V3) {
driving = driving_3v3;
drive_sel = pcr->sd30_drive_sel_3v3;
} else {
driving = driving_1v8;
drive_sel = pcr->sd30_drive_sel_1v8;
}
rtsx_pci_write_register(pcr, SD30_CLK_DRIVE_SEL,
0xFF, driving[drive_sel][0]);
rtsx_pci_write_register(pcr, SD30_CMD_DRIVE_SEL,
0xFF, driving[drive_sel][1]);
rtsx_pci_write_register(pcr, SD30_DAT_DRIVE_SEL,
0xFF, driving[drive_sel][2]);
}
static void rtsx_base_fetch_vendor_settings(struct rtsx_pcr *pcr)
{
struct pci_dev *pdev = pcr->pci;
u32 reg;
pci_read_config_dword(pdev, PCR_SETTING_REG1, ®);
pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
if (!rtsx_vendor_setting_valid(reg)) {
pcr_dbg(pcr, "skip fetch vendor setting\n");
return;
}
pcr->aspm_en = rtsx_reg_to_aspm(reg);
pcr->sd30_drive_sel_1v8 = rtsx_reg_to_sd30_drive_sel_1v8(reg);
pcr->card_drive_sel &= 0x3F;
pcr->card_drive_sel |= rtsx_reg_to_card_drive_sel(reg);
pci_read_config_dword(pdev, PCR_SETTING_REG2, ®);
pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
if (rtsx_check_mmc_support(reg))
pcr->extra_caps |= EXTRA_CAPS_NO_MMC;
pcr->sd30_drive_sel_3v3 = rtsx_reg_to_sd30_drive_sel_3v3(reg);
if (rtsx_reg_check_reverse_socket(reg))
pcr->flags |= PCR_REVERSE_SOCKET;
}
static int rtsx_base_enable_auto_blink(struct rtsx_pcr *pcr)
{
return rtsx_pci_write_register(pcr, OLT_LED_CTL,
Annotation
- Immediate include surface: `linux/module.h`, `linux/delay.h`, `linux/rtsx_pci.h`, `rts5260.h`, `rtsx_pcr.h`.
- Detected declarations: `function Copyright`, `function rts5260_fill_driving`, `function rtsx_base_fetch_vendor_settings`, `function rtsx_base_enable_auto_blink`, `function rtsx_base_disable_auto_blink`, `function rts5260_turn_on_led`, `function rts5260_turn_off_led`, `function sd_set_sample_push_timing_sd30`, `function rts5260_card_power_on`, `function rts5260_switch_output_voltage`.
- Atlas domain: Driver Families / drivers/misc.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.