drivers/fsi/fsi-master-ast-cf.c

Source file repositories/reference/linux-study-clean/drivers/fsi/fsi-master-ast-cf.c

File Facts

System
Linux kernel
Corpus path
drivers/fsi/fsi-master-ast-cf.c
Extension
.c
Size
37872 bytes
Lines
1437
Domain
Driver Families
Bucket
drivers/fsi
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 fsi_master_acf {
	struct fsi_master	master;
	struct device		*dev;
	struct regmap		*scu;
	struct mutex		lock;	/* mutex for command ordering */
	struct gpio_desc	*gpio_clk;
	struct gpio_desc	*gpio_data;
	struct gpio_desc	*gpio_trans;	/* Voltage translator */
	struct gpio_desc	*gpio_enable;	/* FSI enable */
	struct gpio_desc	*gpio_mux;	/* Mux control */
	uint16_t		gpio_clk_vreg;
	uint16_t		gpio_clk_dreg;
	uint16_t       		gpio_dat_vreg;
	uint16_t       		gpio_dat_dreg;
	uint16_t       		gpio_tra_vreg;
	uint16_t       		gpio_tra_dreg;
	uint8_t			gpio_clk_bit;
	uint8_t			gpio_dat_bit;
	uint8_t			gpio_tra_bit;
	uint32_t		cf_mem_addr;
	size_t			cf_mem_size;
	void __iomem		*cf_mem;
	void __iomem		*cvic;
	struct gen_pool		*sram_pool;
	void __iomem		*sram;
	bool			is_ast2500;
	bool			external_mode;
	bool			trace_enabled;
	uint32_t		last_addr;
	uint8_t			t_send_delay;
	uint8_t			t_echo_delay;
	uint32_t		cvic_sw_irq;
};
#define to_fsi_master_acf(m) container_of(m, struct fsi_master_acf, master)

struct fsi_msg {
	uint64_t	msg;
	uint8_t		bits;
};

#define CREATE_TRACE_POINTS
#include <trace/events/fsi_master_ast_cf.h>

static void msg_push_bits(struct fsi_msg *msg, uint64_t data, int bits)
{
	msg->msg <<= bits;
	msg->msg |= data & ((1ull << bits) - 1);
	msg->bits += bits;
}

static void msg_push_crc(struct fsi_msg *msg)
{
	uint8_t crc;
	int top;

	top = msg->bits & 0x3;

	/* start bit, and any non-aligned top bits */
	crc = crc4(0, 1 << top | msg->msg >> (msg->bits - top), top + 1);

	/* aligned bits */
	crc = crc4(crc, msg->msg, msg->bits - top);

	msg_push_bits(msg, crc, 4);
}

static void msg_finish_cmd(struct fsi_msg *cmd)
{
	/* Left align message */
	cmd->msg <<= (64 - cmd->bits);
}

static bool check_same_address(struct fsi_master_acf *master, int id,
			       uint32_t addr)
{
	/* this will also handle LAST_ADDR_INVALID */
	return master->last_addr == (((id & 0x3) << 21) | (addr & ~0x3));
}

static bool check_relative_address(struct fsi_master_acf *master, int id,
				   uint32_t addr, uint32_t *rel_addrp)
{
	uint32_t last_addr = master->last_addr;
	int32_t rel_addr;

	if (last_addr == LAST_ADDR_INVALID)
		return false;

	/* We may be in 23-bit addressing mode, which uses the id as the
	 * top two address bits. So, if we're referencing a different ID,

Annotation

Implementation Notes