drivers/clk/sunxi/clk-sun4i-display.c

Source file repositories/reference/linux-study-clean/drivers/clk/sunxi/clk-sun4i-display.c

File Facts

System
Linux kernel
Corpus path
drivers/clk/sunxi/clk-sun4i-display.c
Extension
.c
Size
5922 bytes
Lines
257
Domain
Driver Families
Bucket
drivers/clk
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 sun4i_a10_display_clk_data {
	bool	has_div;
	u8	num_rst;
	u8	parents;

	u8	offset_en;
	u8	offset_div;
	u8	offset_mux;
	u8	offset_rst;

	u8	width_div;
	u8	width_mux;

	u32	flags;
};

struct reset_data {
	void __iomem			*reg;
	spinlock_t			*lock;
	struct reset_controller_dev	rcdev;
	u8				offset;
};

static DEFINE_SPINLOCK(sun4i_a10_display_lock);

static inline struct reset_data *rcdev_to_reset_data(struct reset_controller_dev *rcdev)
{
	return container_of(rcdev, struct reset_data, rcdev);
};

static int sun4i_a10_display_assert(struct reset_controller_dev *rcdev,
				    unsigned long id)
{
	struct reset_data *data = rcdev_to_reset_data(rcdev);
	unsigned long flags;
	u32 reg;

	spin_lock_irqsave(data->lock, flags);

	reg = readl(data->reg);
	writel(reg & ~BIT(data->offset + id), data->reg);

	spin_unlock_irqrestore(data->lock, flags);

	return 0;
}

static int sun4i_a10_display_deassert(struct reset_controller_dev *rcdev,
				      unsigned long id)
{
	struct reset_data *data = rcdev_to_reset_data(rcdev);
	unsigned long flags;
	u32 reg;

	spin_lock_irqsave(data->lock, flags);

	reg = readl(data->reg);
	writel(reg | BIT(data->offset + id), data->reg);

	spin_unlock_irqrestore(data->lock, flags);

	return 0;
}

static int sun4i_a10_display_status(struct reset_controller_dev *rcdev,
				    unsigned long id)
{
	struct reset_data *data = rcdev_to_reset_data(rcdev);

	return !(readl(data->reg) & BIT(data->offset + id));
}

static const struct reset_control_ops sun4i_a10_display_reset_ops = {
	.assert		= sun4i_a10_display_assert,
	.deassert	= sun4i_a10_display_deassert,
	.status		= sun4i_a10_display_status,
};

static int sun4i_a10_display_reset_xlate(struct reset_controller_dev *rcdev,
					 const struct of_phandle_args *spec)
{
	/* We only have a single reset signal */
	return 0;
}

static void __init sun4i_a10_display_init(struct device_node *node,
					  const struct sun4i_a10_display_clk_data *data)
{
	const char *parents[4];
	const char *clk_name = node->name;

Annotation

Implementation Notes