drivers/mmc/host/renesas_sdhi_internal_dmac.c
Source file repositories/reference/linux-study-clean/drivers/mmc/host/renesas_sdhi_internal_dmac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/host/renesas_sdhi_internal_dmac.c- Extension
.c- Size
- 20254 bytes
- Lines
- 628
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/device.hlinux/dma-mapping.hlinux/io-64-nonatomic-hi-lo.hlinux/mmc/host.hlinux/mod_devicetable.hlinux/module.hlinux/of.hlinux/pagemap.hlinux/platform_data/tmio.hlinux/platform_device.hlinux/scatterlist.hlinux/sys_soc.hrenesas_sdhi.htmio_mmc.h
Detected Declarations
enum renesas_sdhi_dma_cookiefunction renesas_sdhi_internal_dmac_enable_dmafunction renesas_sdhi_internal_dmac_abort_dmafunction renesas_sdhi_internal_dmac_dma_irqfunction renesas_sdhi_internal_dmac_dataend_dmafunction renesas_sdhi_internal_dmac_mapfunction renesas_sdhi_internal_dmac_mapfunction renesas_sdhi_internal_dmac_start_dmafunction renesas_sdhi_internal_dmac_issue_work_fnfunction renesas_sdhi_internal_dmac_completefunction renesas_sdhi_internal_dmac_complete_work_fnfunction renesas_sdhi_internal_dmac_end_dmafunction renesas_sdhi_internal_dmac_post_reqfunction renesas_sdhi_internal_dmac_pre_reqfunction renesas_sdhi_internal_dmac_request_dmafunction renesas_sdhi_internal_dmac_release_dmafunction renesas_sdhi_internal_dmac_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* DMA support for Internal DMAC with SDHI SD/SDIO controller
*
* Copyright (C) 2016-19 Renesas Electronics Corporation
* Copyright (C) 2016-17 Horms Solutions, Simon Horman
* Copyright (C) 2018-19 Sang Engineering, Wolfram Sang
*/
#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/io-64-nonatomic-hi-lo.h>
#include <linux/mmc/host.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/pagemap.h>
#include <linux/platform_data/tmio.h>
#include <linux/platform_device.h>
#include <linux/scatterlist.h>
#include <linux/sys_soc.h>
#include "renesas_sdhi.h"
#include "tmio_mmc.h"
#define DM_CM_DTRAN_MODE 0x820
#define DM_CM_DTRAN_CTRL 0x828
#define DM_CM_RST 0x830
#define DM_CM_INFO1 0x840
#define DM_CM_INFO1_MASK 0x848
#define DM_CM_INFO2 0x850
#define DM_CM_INFO2_MASK 0x858
#define DM_DTRAN_ADDR 0x880
/* DM_CM_DTRAN_MODE */
#define DTRAN_MODE_CH_NUM_CH0 0 /* "downstream" = for write commands */
#define DTRAN_MODE_CH_NUM_CH1 BIT(16) /* "upstream" = for read commands */
#define DTRAN_MODE_BUS_WIDTH (BIT(5) | BIT(4))
#define DTRAN_MODE_ADDR_MODE BIT(0) /* 1 = Increment address, 0 = Fixed */
/* DM_CM_DTRAN_CTRL */
#define DTRAN_CTRL_DM_START BIT(0)
/* DM_CM_RST */
#define RST_DTRANRST1 BIT(9)
#define RST_DTRANRST0 BIT(8)
#define RST_RESERVED_BITS GENMASK_ULL(31, 0)
/* DM_CM_INFO1 and DM_CM_INFO1_MASK */
#define INFO1_MASK_CLEAR GENMASK_ULL(31, 0)
#define INFO1_DTRANEND1 BIT(20)
#define INFO1_DTRANEND1_OLD BIT(17)
#define INFO1_DTRANEND0 BIT(16)
/* DM_CM_INFO2 and DM_CM_INFO2_MASK */
#define INFO2_MASK_CLEAR GENMASK_ULL(31, 0)
#define INFO2_DTRANERR1 BIT(17)
#define INFO2_DTRANERR0 BIT(16)
enum renesas_sdhi_dma_cookie {
COOKIE_UNMAPPED,
COOKIE_PRE_MAPPED,
COOKIE_MAPPED,
};
/*
* Specification of this driver:
* - host->chan_{rx,tx} will be used as a flag of enabling/disabling the dma
* - Since this SDHI DMAC register set has 16 but 32-bit width, we
* need a custom accessor.
*/
static unsigned long global_flags;
/*
* Workaround for avoiding to use RX DMAC by multiple channels. On R-Car M3-W
* ES1.0, when multiple SDHI channels use RX DMAC simultaneously, sometimes
* hundreds of data bytes are not stored into the system memory even if the
* DMAC interrupt happened. So, this driver then uses one RX DMAC channel only.
*/
#define SDHI_INTERNAL_DMAC_RX_IN_USE 0
/* Definitions for sampling clocks */
static struct renesas_sdhi_scc rcar_gen3_scc_taps[] = {
{
.clk_rate = 0,
.tap = 0x00000300,
.tap_hs400_4tap = 0x00000100,
},
};
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/io-64-nonatomic-hi-lo.h`, `linux/mmc/host.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `enum renesas_sdhi_dma_cookie`, `function renesas_sdhi_internal_dmac_enable_dma`, `function renesas_sdhi_internal_dmac_abort_dma`, `function renesas_sdhi_internal_dmac_dma_irq`, `function renesas_sdhi_internal_dmac_dataend_dma`, `function renesas_sdhi_internal_dmac_map`, `function renesas_sdhi_internal_dmac_map`, `function renesas_sdhi_internal_dmac_start_dma`, `function renesas_sdhi_internal_dmac_issue_work_fn`, `function renesas_sdhi_internal_dmac_complete`.
- 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.