drivers/mmc/host/atmel-mci.c
Source file repositories/reference/linux-study-clean/drivers/mmc/host/atmel-mci.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/host/atmel-mci.c- Extension
.c- Size
- 74991 bytes
- Lines
- 2659
- Domain
- Driver Families
- Bucket
- drivers/mmc
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/blkdev.hlinux/clk.hlinux/debugfs.hlinux/device.hlinux/dmaengine.hlinux/dma-mapping.hlinux/err.hlinux/init.hlinux/interrupt.hlinux/io.hlinux/ioport.hlinux/module.hlinux/of.hlinux/irq.hlinux/gpio/consumer.hlinux/platform_device.hlinux/scatterlist.hlinux/seq_file.hlinux/slab.hlinux/stat.hlinux/types.hlinux/mmc/host.hlinux/mmc/sdio.hlinux/atmel_pdc.hlinux/pm.hlinux/pm_runtime.hlinux/pinctrl/consumer.hlinux/workqueue.hasm/cacheflush.hasm/io.hlinux/unaligned.hlinux/string_choices.h
Detected Declarations
struct mci_slot_pdatastruct atmel_mci_capsstruct atmel_mci_dmastruct atmel_mcistruct atmel_mci_slotenum atmel_mci_stateenum atmci_xfer_direnum atmci_pdc_buffunction atmci_req_showfunction atmci_show_status_regfunction atmci_regs_showfunction atmci_init_debugfsfunction atmci_of_initfunction for_each_child_of_node_scopedfunction atmci_get_versionfunction atmci_convert_chksizefunction atmci_timeout_timerfunction atmci_ns_to_clocksfunction atmci_set_timeoutfunction atmci_prepare_commandfunction atmci_send_commandfunction atmci_send_stop_cmdfunction atmci_pdc_set_single_buffunction atmci_pdc_set_both_buffunction atmci_pdc_cleanupfunction atmci_pdc_completefunction atmci_dma_cleanupfunction atmci_dma_completefunction atmci_prepare_datafunction atmci_prepare_data_pdcfunction atmci_prepare_data_dmafunction for_each_sgfunction atmci_submit_datafunction atmci_submit_data_pdcfunction atmci_submit_data_dmafunction atmci_stop_transferfunction errorfunction atmci_stop_transfer_dmafunction atmci_start_requestfunction atmci_queue_requestfunction atmci_requestfunction atmci_set_iosfunction atmci_get_rofunction atmci_get_cdfunction atmci_enable_sdio_irqfunction atmci_request_endfunction set_iosfunction atmci_command_complete
Annotated Snippet
struct mci_slot_pdata {
unsigned int bus_width;
struct gpio_desc *detect_pin;
struct gpio_desc *wp_pin;
bool non_removable;
};
struct atmel_mci_caps {
bool has_dma_conf_reg;
bool has_pdc;
bool has_cfg_reg;
bool has_cstor_reg;
bool has_highspeed;
bool has_rwproof;
bool has_odd_clk_div;
bool has_bad_data_ordering;
bool need_reset_after_xfer;
bool need_blksz_mul_4;
bool need_notbusy_for_read_ops;
};
struct atmel_mci_dma {
struct dma_chan *chan;
struct dma_async_tx_descriptor *data_desc;
};
/**
* struct atmel_mci - MMC controller state shared between all slots
* @lock: Spinlock protecting the queue and associated data.
* @regs: Pointer to MMIO registers.
* @sg: Scatterlist entry currently being processed by PIO or PDC code.
* @sg_len: Size of the scatterlist
* @pio_offset: Offset into the current scatterlist entry.
* @buffer: Buffer used if we don't have the r/w proof capability. We
* don't have the time to switch pdc buffers so we have to use only
* one buffer for the full transaction.
* @buf_size: size of the buffer.
* @buf_phys_addr: buffer address needed for pdc.
* @cur_slot: The slot which is currently using the controller.
* @mrq: The request currently being processed on @cur_slot,
* or NULL if the controller is idle.
* @cmd: The command currently being sent to the card, or NULL.
* @data: The data currently being transferred, or NULL if no data
* transfer is in progress.
* @data_size: just data->blocks * data->blksz.
* @dma: DMA client state.
* @data_chan: DMA channel being used for the current data transfer.
* @dma_conf: Configuration for the DMA slave
* @cmd_status: Snapshot of SR taken upon completion of the current
* command. Only valid when EVENT_CMD_COMPLETE is pending.
* @data_status: Snapshot of SR taken upon completion of the current
* data transfer. Only valid when EVENT_DATA_COMPLETE or
* EVENT_DATA_ERROR is pending.
* @stop_cmdr: Value to be loaded into CMDR when the stop command is
* to be sent.
* @bh_work: Work running the request state machine.
* @pending_events: Bitmask of events flagged by the interrupt handler
* to be processed by the work.
* @completed_events: Bitmask of events which the state machine has
* processed.
* @state: Work state.
* @queue: List of slots waiting for access to the controller.
* @need_clock_update: Update the clock rate before the next request.
* @need_reset: Reset controller before next request.
* @timer: Timer to balance the data timeout error flag which cannot rise.
* @mode_reg: Value of the MR register.
* @cfg_reg: Value of the CFG register.
* @bus_hz: The rate of @mck in Hz. This forms the basis for MMC bus
* rate and timeout calculations.
* @mapbase: Physical address of the MMIO registers.
* @mck: The peripheral bus clock hooked up to the MMC controller.
* @dev: Device associated with the MMC controller.
* @pdata: Per-slot configuration data.
* @slot: Slots sharing this MMC controller.
* @caps: MCI capabilities depending on MCI version.
* @prepare_data: function to setup MCI before data transfer which
* depends on MCI capabilities.
* @submit_data: function to start data transfer which depends on MCI
* capabilities.
* @stop_transfer: function to stop data transfer which depends on MCI
* capabilities.
*
* Locking
* =======
*
* @lock is a softirq-safe spinlock protecting @queue as well as
* @cur_slot, @mrq and @state. These must always be updated
* at the same time while holding @lock.
*
* @lock also protects mode_reg and need_clock_update since these are
Annotation
- Immediate include surface: `linux/blkdev.h`, `linux/clk.h`, `linux/debugfs.h`, `linux/device.h`, `linux/dmaengine.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/init.h`.
- Detected declarations: `struct mci_slot_pdata`, `struct atmel_mci_caps`, `struct atmel_mci_dma`, `struct atmel_mci`, `struct atmel_mci_slot`, `enum atmel_mci_state`, `enum atmci_xfer_dir`, `enum atmci_pdc_buf`, `function atmci_req_show`, `function atmci_show_status_reg`.
- Atlas domain: Driver Families / drivers/mmc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.