drivers/staging/greybus/sdio.c
Source file repositories/reference/linux-study-clean/drivers/staging/greybus/sdio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/greybus/sdio.c- Extension
.c- Size
- 21445 bytes
- Lines
- 885
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/mmc/core.hlinux/mmc/host.hlinux/mmc/mmc.hlinux/scatterlist.hlinux/workqueue.hlinux/greybus.hgbphy.h
Detected Declarations
struct gb_sdio_hostfunction single_opfunction _gb_sdio_set_host_capsfunction _gb_sdio_get_host_ocrfunction gb_sdio_get_capsfunction _gb_queue_eventfunction _gb_sdio_process_eventsfunction gb_sdio_request_handlerfunction gb_sdio_set_iosfunction _gb_sdio_sendfunction _gb_sdio_recvfunction gb_sdio_transferfunction gb_sdio_commandfunction gb_sdio_mrq_workfunction gb_mmc_requestfunction gb_mmc_set_iosfunction gb_mmc_get_rofunction gb_mmc_get_cdfunction gb_mmc_switch_voltagefunction gb_sdio_probefunction gb_sdio_remove
Annotated Snippet
struct gb_sdio_host {
struct gb_connection *connection;
struct gbphy_device *gbphy_dev;
struct mmc_host *mmc;
struct mmc_request *mrq;
struct mutex lock; /* lock for this host */
size_t data_max;
spinlock_t xfer; /* lock to cancel ongoing transfer */
bool xfer_stop;
struct workqueue_struct *mrq_workqueue;
struct work_struct mrqwork;
u8 queued_events;
bool removed;
bool card_present;
bool read_only;
};
#define GB_SDIO_RSP_R1_R5_R6_R7 (GB_SDIO_RSP_PRESENT | GB_SDIO_RSP_CRC | \
GB_SDIO_RSP_OPCODE)
#define GB_SDIO_RSP_R3_R4 (GB_SDIO_RSP_PRESENT)
#define GB_SDIO_RSP_R2 (GB_SDIO_RSP_PRESENT | GB_SDIO_RSP_CRC | \
GB_SDIO_RSP_136)
#define GB_SDIO_RSP_R1B (GB_SDIO_RSP_PRESENT | GB_SDIO_RSP_CRC | \
GB_SDIO_RSP_OPCODE | GB_SDIO_RSP_BUSY)
/* kernel vdd starts at 0x80 and we need to translate to greybus ones 0x01 */
#define GB_SDIO_VDD_SHIFT 8
#ifndef MMC_CAP2_CORE_RUNTIME_PM
#define MMC_CAP2_CORE_RUNTIME_PM 0
#endif
static inline bool single_op(struct mmc_command *cmd)
{
u32 opcode = cmd->opcode;
return opcode == MMC_WRITE_BLOCK ||
opcode == MMC_READ_SINGLE_BLOCK;
}
static void _gb_sdio_set_host_caps(struct gb_sdio_host *host, u32 r)
{
u32 caps = 0;
u32 caps2 = 0;
caps = ((r & GB_SDIO_CAP_NONREMOVABLE) ? MMC_CAP_NONREMOVABLE : 0) |
((r & GB_SDIO_CAP_4_BIT_DATA) ? MMC_CAP_4_BIT_DATA : 0) |
((r & GB_SDIO_CAP_8_BIT_DATA) ? MMC_CAP_8_BIT_DATA : 0) |
((r & GB_SDIO_CAP_MMC_HS) ? MMC_CAP_MMC_HIGHSPEED : 0) |
((r & GB_SDIO_CAP_SD_HS) ? MMC_CAP_SD_HIGHSPEED : 0) |
((r & GB_SDIO_CAP_1_2V_DDR) ? MMC_CAP_1_2V_DDR : 0) |
((r & GB_SDIO_CAP_1_8V_DDR) ? MMC_CAP_1_8V_DDR : 0) |
((r & GB_SDIO_CAP_POWER_OFF_CARD) ? MMC_CAP_POWER_OFF_CARD : 0) |
((r & GB_SDIO_CAP_UHS_SDR12) ? MMC_CAP_UHS_SDR12 : 0) |
((r & GB_SDIO_CAP_UHS_SDR25) ? MMC_CAP_UHS_SDR25 : 0) |
((r & GB_SDIO_CAP_UHS_SDR50) ? MMC_CAP_UHS_SDR50 : 0) |
((r & GB_SDIO_CAP_UHS_SDR104) ? MMC_CAP_UHS_SDR104 : 0) |
((r & GB_SDIO_CAP_UHS_DDR50) ? MMC_CAP_UHS_DDR50 : 0) |
((r & GB_SDIO_CAP_DRIVER_TYPE_A) ? MMC_CAP_DRIVER_TYPE_A : 0) |
((r & GB_SDIO_CAP_DRIVER_TYPE_C) ? MMC_CAP_DRIVER_TYPE_C : 0) |
((r & GB_SDIO_CAP_DRIVER_TYPE_D) ? MMC_CAP_DRIVER_TYPE_D : 0);
caps2 = ((r & GB_SDIO_CAP_HS200_1_2V) ? MMC_CAP2_HS200_1_2V_SDR : 0) |
((r & GB_SDIO_CAP_HS400_1_2V) ? MMC_CAP2_HS400_1_2V : 0) |
((r & GB_SDIO_CAP_HS400_1_8V) ? MMC_CAP2_HS400_1_8V : 0) |
((r & GB_SDIO_CAP_HS200_1_8V) ? MMC_CAP2_HS200_1_8V_SDR : 0);
host->mmc->caps = caps;
host->mmc->caps2 = caps2 | MMC_CAP2_CORE_RUNTIME_PM;
if (caps & MMC_CAP_NONREMOVABLE)
host->card_present = true;
}
static u32 _gb_sdio_get_host_ocr(u32 ocr)
{
return (((ocr & GB_SDIO_VDD_165_195) ? MMC_VDD_165_195 : 0) |
((ocr & GB_SDIO_VDD_20_21) ? MMC_VDD_20_21 : 0) |
((ocr & GB_SDIO_VDD_21_22) ? MMC_VDD_21_22 : 0) |
((ocr & GB_SDIO_VDD_22_23) ? MMC_VDD_22_23 : 0) |
((ocr & GB_SDIO_VDD_23_24) ? MMC_VDD_23_24 : 0) |
((ocr & GB_SDIO_VDD_24_25) ? MMC_VDD_24_25 : 0) |
((ocr & GB_SDIO_VDD_25_26) ? MMC_VDD_25_26 : 0) |
((ocr & GB_SDIO_VDD_26_27) ? MMC_VDD_26_27 : 0) |
((ocr & GB_SDIO_VDD_27_28) ? MMC_VDD_27_28 : 0) |
((ocr & GB_SDIO_VDD_28_29) ? MMC_VDD_28_29 : 0) |
((ocr & GB_SDIO_VDD_29_30) ? MMC_VDD_29_30 : 0) |
((ocr & GB_SDIO_VDD_30_31) ? MMC_VDD_30_31 : 0) |
((ocr & GB_SDIO_VDD_31_32) ? MMC_VDD_31_32 : 0) |
((ocr & GB_SDIO_VDD_32_33) ? MMC_VDD_32_33 : 0) |
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/mmc/core.h`, `linux/mmc/host.h`, `linux/mmc/mmc.h`, `linux/scatterlist.h`, `linux/workqueue.h`, `linux/greybus.h`, `gbphy.h`.
- Detected declarations: `struct gb_sdio_host`, `function single_op`, `function _gb_sdio_set_host_caps`, `function _gb_sdio_get_host_ocr`, `function gb_sdio_get_caps`, `function _gb_queue_event`, `function _gb_sdio_process_events`, `function gb_sdio_request_handler`, `function gb_sdio_set_ios`, `function _gb_sdio_send`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.