drivers/clk/at91/dt-compat.c

Source file repositories/reference/linux-study-clean/drivers/clk/at91/dt-compat.c

File Facts

System
Linux kernel
Corpus path
drivers/clk/at91/dt-compat.c
Extension
.c
Size
27909 bytes
Lines
1068
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

if (type == PERIPHERAL_AT91RM9200) {
			hw = at91_clk_register_peripheral(regmap, name,
							  parent_name, NULL, id);
		} else {
			struct clk_range range = CLK_RANGE(0, 0);
			unsigned long flags = 0;

			of_at91_get_clk_range(periphclknp,
					      "atmel,clk-output-range",
					      &range);

			/*
			 * mpddr_clk feed DDR controller and is enabled by
			 * bootloader thus we need to keep it enabled in case
			 * there is no Linux consumer for it.
			 */
			if (!strcmp(periphclknp->name, "mpddr_clk"))
				flags = CLK_IS_CRITICAL;

			hw = at91_clk_register_sam9x5_peripheral(regmap,
								 &pmc_pcr_lock,
								 &dt_pcr_layout,
								 name,
								 parent_name,
								 NULL,
								 id, &range,
								 INT_MIN,
								 flags);
		}

		if (IS_ERR(hw))
			continue;

		of_clk_add_hw_provider(periphclknp, of_clk_hw_simple_get, hw);
	}
}

static void __init of_at91rm9200_clk_periph_setup(struct device_node *np)
{
	of_at91_clk_periph_setup(np, PERIPHERAL_AT91RM9200);
}
CLK_OF_DECLARE(at91rm9200_clk_periph, "atmel,at91rm9200-clk-peripheral",
	       of_at91rm9200_clk_periph_setup);

static void __init of_at91sam9x5_clk_periph_setup(struct device_node *np)
{
	of_at91_clk_periph_setup(np, PERIPHERAL_AT91SAM9X5);
}
CLK_OF_DECLARE(at91sam9x5_clk_periph, "atmel,at91sam9x5-clk-peripheral",
	       of_at91sam9x5_clk_periph_setup);

static struct clk_pll_characteristics * __init
of_at91_clk_pll_get_characteristics(struct device_node *np)
{
	int i;
	int offset;
	u32 tmp;
	int num_output;
	u32 num_cells;
	struct clk_range input;
	struct clk_range *output;
	u8 *out = NULL;
	u16 *icpll = NULL;
	struct clk_pll_characteristics *characteristics;

	if (of_at91_get_clk_range(np, "atmel,clk-input-range", &input))
		return NULL;

	if (of_property_read_u32(np, "#atmel,pll-clk-output-range-cells",
				 &num_cells))
		return NULL;

	if (num_cells < 2 || num_cells > 4)
		return NULL;

	num_output = of_property_count_u32_elems(np, "atmel,pll-clk-output-ranges");
	if (num_output <= 0)
		return NULL;
	num_output /= num_cells;

	characteristics = kzalloc_obj(*characteristics);
	if (!characteristics)
		return NULL;

	output = kzalloc_objs(*output, num_output);
	if (!output)
		goto out_free_characteristics;

	if (num_cells > 2) {
		out = kcalloc(num_output, sizeof(*out), GFP_KERNEL);

Annotation

Implementation Notes