drivers/clk/bcm/clk-raspberrypi.c

Source file repositories/reference/linux-study-clean/drivers/clk/bcm/clk-raspberrypi.c

File Facts

System
Linux kernel
Corpus path
drivers/clk/bcm/clk-raspberrypi.c
Extension
.c
Size
15625 bytes
Lines
586
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 raspberrypi_clk {
	struct device *dev;
	struct rpi_firmware *firmware;
	struct platform_device *cpufreq;
};

struct raspberrypi_clk_data {
	struct clk_hw hw;

	unsigned int id;
	struct raspberrypi_clk_variant *variant;

	struct raspberrypi_clk *rpi;
};

static inline
const struct raspberrypi_clk_data *clk_hw_to_data(const struct clk_hw *hw)
{
	return container_of(hw, struct raspberrypi_clk_data, hw);
}

struct raspberrypi_clk_variant {
	bool		export;
	char		*clkdev;
	unsigned long	min_rate;
	bool		minimize;
	bool		maximize;
	u32		flags;
};

static struct raspberrypi_clk_variant
raspberrypi_clk_variants[RPI_FIRMWARE_NUM_CLK_ID] = {
	[RPI_FIRMWARE_ARM_CLK_ID] = {
		.export = true,
		.clkdev = "cpu0",
		.flags = CLK_IS_CRITICAL,
	},
	[RPI_FIRMWARE_CORE_CLK_ID] = {
		.export = true,

		/*
		 * The clock is shared between the HVS and the CSI
		 * controllers, on the BCM2711 and will change depending
		 * on the pixels composited on the HVS and the capture
		 * resolution on Unicam.
		 *
		 * Since the rate can get quite large, and we need to
		 * coordinate between both driver instances, let's
		 * always use the minimum the drivers will let us.
		 */
		.minimize = true,

		/*
		 * It should never be disabled as it drives the bus for
		 * everything else.
		 */
		.flags = CLK_IS_CRITICAL,
	},
	[RPI_FIRMWARE_M2MC_CLK_ID] = {
		.export = true,

		/*
		 * If we boot without any cable connected to any of the
		 * HDMI connector, the firmware will skip the HSM
		 * initialization and leave it with a rate of 0,
		 * resulting in a bus lockup when we're accessing the
		 * registers even if it's enabled.
		 *
		 * Let's put a sensible default so that we don't end up
		 * in this situation.
		 */
		.min_rate = 120000000,

		/*
		 * The clock is shared between the two HDMI controllers
		 * on the BCM2711 and will change depending on the
		 * resolution output on each. Since the rate can get
		 * quite large, and we need to coordinate between both
		 * driver instances, let's always use the minimum the
		 * drivers will let us.
		 */
		.minimize = true,

		/*
		 * As mentioned above, this clock is disabled during boot,
		 * the firmware will skip the HSM initialization, resulting
		 * in a bus lockup. Therefore, make sure it's enabled
		 * during boot, but after it, it can be enabled/disabled
		 * by the driver.
		 */

Annotation

Implementation Notes