drivers/memory/stm32-fmc2-ebi.c

Source file repositories/reference/linux-study-clean/drivers/memory/stm32-fmc2-ebi.c

File Facts

System
Linux kernel
Corpus path
drivers/memory/stm32-fmc2-ebi.c
Extension
.c
Size
46655 bytes
Lines
1831
Domain
Driver Families
Bucket
drivers/memory
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct stm32_fmc2_ebi_data {
	const struct stm32_fmc2_prop *child_props;
	unsigned int nb_child_props;
	u32 fmc2_enable_reg;
	u32 fmc2_enable_bit;
	int (*nwait_used_by_ctrls)(struct stm32_fmc2_ebi *ebi);
	void (*set_setup)(struct stm32_fmc2_ebi *ebi);
	int (*save_setup)(struct stm32_fmc2_ebi *ebi);
	int (*check_rif)(struct stm32_fmc2_ebi *ebi, u32 resource);
	void (*put_sems)(struct stm32_fmc2_ebi *ebi);
	void (*get_sems)(struct stm32_fmc2_ebi *ebi);
};

struct stm32_fmc2_ebi {
	struct device *dev;
	struct clk *clk;
	struct regmap *regmap;
	const struct stm32_fmc2_ebi_data *data;
	u8 bank_assigned;
	u8 sem_taken;
	bool access_granted;

	u32 bcr[FMC2_MAX_EBI_CE];
	u32 btr[FMC2_MAX_EBI_CE];
	u32 bwtr[FMC2_MAX_EBI_CE];
	u32 pcscntr;
	u32 cfgr;
};

/*
 * struct stm32_fmc2_prop - STM32 FMC2 EBI property
 * @name: the device tree binding name of the property
 * @bprop: indicate that it is a boolean property
 * @mprop: indicate that it is a mandatory property
 * @reg_type: the register that have to be modified
 * @reg_mask: the bit that have to be modified in the selected register
 *            in case of it is a boolean property
 * @reset_val: the default value that have to be set in case the property
 *             has not been defined in the device tree
 * @check: this callback ckecks that the property is compliant with the
 *         transaction type selected
 * @calculate: this callback is called to calculate for exemple a timing
 *             set in nanoseconds in the device tree in clock cycles or in
 *             clock period
 * @set: this callback applies the values in the registers
 */
struct stm32_fmc2_prop {
	const char *name;
	bool bprop;
	bool mprop;
	int reg_type;
	u32 reg_mask;
	u32 reset_val;
	int (*check)(struct stm32_fmc2_ebi *ebi,
		     const struct stm32_fmc2_prop *prop, int cs);
	u32 (*calculate)(struct stm32_fmc2_ebi *ebi, int cs, u32 setup);
	int (*set)(struct stm32_fmc2_ebi *ebi,
		   const struct stm32_fmc2_prop *prop,
		   int cs, u32 setup);
};

static int stm32_fmc2_ebi_check_mux(struct stm32_fmc2_ebi *ebi,
				    const struct stm32_fmc2_prop *prop,
				    int cs)
{
	u32 bcr;
	int ret;

	ret = regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr);
	if (ret)
		return ret;

	if (bcr & FMC2_BCR_MTYP)
		return 0;

	return -EINVAL;
}

static int stm32_fmc2_ebi_check_waitcfg(struct stm32_fmc2_ebi *ebi,
					const struct stm32_fmc2_prop *prop,
					int cs)
{
	u32 bcr, val = FIELD_PREP(FMC2_BCR_MTYP, FMC2_BCR_MTYP_NOR);
	int ret;

	ret = regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr);
	if (ret)
		return ret;

	if ((bcr & FMC2_BCR_MTYP) == val && bcr & FMC2_BCR_BURSTEN)

Annotation

Implementation Notes