drivers/mtd/spi-nor/controllers/hisi-sfc.c
Source file repositories/reference/linux-study-clean/drivers/mtd/spi-nor/controllers/hisi-sfc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/spi-nor/controllers/hisi-sfc.c- Extension
.c- Size
- 12094 bytes
- Lines
- 493
- Domain
- Driver Families
- Bucket
- drivers/mtd
- 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.
- 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/bitops.hlinux/clk.hlinux/dma-mapping.hlinux/iopoll.hlinux/module.hlinux/mtd/mtd.hlinux/mtd/spi-nor.hlinux/of.hlinux/platform_device.hlinux/slab.h
Detected Declarations
struct hifmc_privstruct hifmc_hostenum hifmc_iftypefunction hisi_spi_nor_wait_op_finishfunction hisi_spi_nor_get_if_typefunction hisi_spi_nor_initfunction hisi_spi_nor_prepfunction hisi_spi_nor_unprepfunction hisi_spi_nor_op_regfunction hisi_spi_nor_read_regfunction hisi_spi_nor_write_regfunction hisi_spi_nor_dma_transferfunction hisi_spi_nor_readfunction hisi_spi_nor_writefunction hisi_spi_nor_registerfunction hisi_spi_nor_unregister_allfunction hisi_spi_nor_register_allfunction for_each_available_child_of_node_scopedfunction hisi_spi_nor_probefunction hisi_spi_nor_remove
Annotated Snippet
struct hifmc_priv {
u32 chipselect;
u32 clkrate;
struct hifmc_host *host;
};
#define HIFMC_MAX_CHIP_NUM 2
struct hifmc_host {
struct device *dev;
struct mutex lock;
void __iomem *regbase;
void __iomem *iobase;
struct clk *clk;
void *buffer;
dma_addr_t dma_buffer;
struct spi_nor *nor[HIFMC_MAX_CHIP_NUM];
u32 num_chip;
};
static inline int hisi_spi_nor_wait_op_finish(struct hifmc_host *host)
{
u32 reg;
return readl_poll_timeout(host->regbase + FMC_INT, reg,
(reg & FMC_INT_OP_DONE), 0, FMC_WAIT_TIMEOUT);
}
static int hisi_spi_nor_get_if_type(enum spi_nor_protocol proto)
{
enum hifmc_iftype if_type;
switch (proto) {
case SNOR_PROTO_1_1_2:
if_type = IF_TYPE_DUAL;
break;
case SNOR_PROTO_1_2_2:
if_type = IF_TYPE_DIO;
break;
case SNOR_PROTO_1_1_4:
if_type = IF_TYPE_QUAD;
break;
case SNOR_PROTO_1_4_4:
if_type = IF_TYPE_QIO;
break;
case SNOR_PROTO_1_1_1:
default:
if_type = IF_TYPE_STD;
break;
}
return if_type;
}
static void hisi_spi_nor_init(struct hifmc_host *host)
{
u32 reg;
reg = TIMING_CFG_TCSH(CS_HOLD_TIME)
| TIMING_CFG_TCSS(CS_SETUP_TIME)
| TIMING_CFG_TSHSL(CS_DESELECT_TIME);
writel(reg, host->regbase + FMC_SPI_TIMING_CFG);
}
static int hisi_spi_nor_prep(struct spi_nor *nor)
{
struct hifmc_priv *priv = nor->priv;
struct hifmc_host *host = priv->host;
int ret;
mutex_lock(&host->lock);
ret = clk_set_rate(host->clk, priv->clkrate);
if (ret)
goto out;
ret = clk_prepare_enable(host->clk);
if (ret)
goto out;
return 0;
out:
mutex_unlock(&host->lock);
return ret;
}
static void hisi_spi_nor_unprep(struct spi_nor *nor)
{
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/clk.h`, `linux/dma-mapping.h`, `linux/iopoll.h`, `linux/module.h`, `linux/mtd/mtd.h`, `linux/mtd/spi-nor.h`, `linux/of.h`.
- Detected declarations: `struct hifmc_priv`, `struct hifmc_host`, `enum hifmc_iftype`, `function hisi_spi_nor_wait_op_finish`, `function hisi_spi_nor_get_if_type`, `function hisi_spi_nor_init`, `function hisi_spi_nor_prep`, `function hisi_spi_nor_unprep`, `function hisi_spi_nor_op_reg`, `function hisi_spi_nor_read_reg`.
- Atlas domain: Driver Families / drivers/mtd.
- 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.