drivers/clk/mvebu/armada-39x.c

Source file repositories/reference/linux-study-clean/drivers/clk/mvebu/armada-39x.c

File Facts

System
Linux kernel
Corpus path
drivers/clk/mvebu/armada-39x.c
Extension
.c
Size
3971 bytes
Lines
157
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

// SPDX-License-Identifier: GPL-2.0
/*
 * Marvell Armada 39x SoC clocks
 *
 * Copyright (C) 2015 Marvell
 *
 * Gregory CLEMENT <gregory.clement@free-electrons.com>
 * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
 * Andrew Lunn <andrew@lunn.ch>
 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
 *
 */

#include <linux/kernel.h>
#include <linux/clk-provider.h>
#include <linux/io.h>
#include <linux/of.h>
#include "common.h"

/*
 * SARL[14:10] : Ratios between CPU, NBCLK, HCLK and DCLK.
 *
 * SARL[15]    : TCLK frequency
 *		 0 = 250 MHz
 *		 1 = 200 MHz
 *
 * SARH[0]     : Reference clock frequency
 *               0 = 25 Mhz
 *               1 = 40 Mhz
 */

#define SARL 					0
#define  SARL_A390_TCLK_FREQ_OPT		15
#define  SARL_A390_TCLK_FREQ_OPT_MASK		0x1
#define  SARL_A390_CPU_DDR_L2_FREQ_OPT		10
#define  SARL_A390_CPU_DDR_L2_FREQ_OPT_MASK	0x1F
#define SARH					4
#define  SARH_A390_REFCLK_FREQ			BIT(0)

static const u32 armada_39x_tclk_frequencies[] __initconst = {
	250000000,
	200000000,
};

static u32 __init armada_39x_get_tclk_freq(void __iomem *sar)
{
	u8 tclk_freq_select;

	tclk_freq_select = ((readl(sar + SARL) >> SARL_A390_TCLK_FREQ_OPT) &
			    SARL_A390_TCLK_FREQ_OPT_MASK);
	return armada_39x_tclk_frequencies[tclk_freq_select];
}

static const u32 armada_39x_cpu_frequencies[] __initconst = {
	[0x0] = 666 * 1000 * 1000,
	[0x2] = 800 * 1000 * 1000,
	[0x3] = 800 * 1000 * 1000,
	[0x4] = 1066 * 1000 * 1000,
	[0x5] = 1066 * 1000 * 1000,
	[0x6] = 1200 * 1000 * 1000,
	[0x8] = 1332 * 1000 * 1000,
	[0xB] = 1600 * 1000 * 1000,
	[0xC] = 1600 * 1000 * 1000,
	[0x12] = 1800 * 1000 * 1000,
	[0x1E] = 1800 * 1000 * 1000,
};

static u32 __init armada_39x_get_cpu_freq(void __iomem *sar)
{
	u8 cpu_freq_select;

	cpu_freq_select = ((readl(sar + SARL) >> SARL_A390_CPU_DDR_L2_FREQ_OPT) &
			   SARL_A390_CPU_DDR_L2_FREQ_OPT_MASK);
	if (cpu_freq_select >= ARRAY_SIZE(armada_39x_cpu_frequencies)) {
		pr_err("Selected CPU frequency (%d) unsupported\n",
			cpu_freq_select);
		return 0;
	}

	return armada_39x_cpu_frequencies[cpu_freq_select];
}

enum { A390_CPU_TO_NBCLK, A390_CPU_TO_HCLK, A390_CPU_TO_DCLK };

static const struct coreclk_ratio armada_39x_coreclk_ratios[] __initconst = {
	{ .id = A390_CPU_TO_NBCLK, .name = "nbclk" },
	{ .id = A390_CPU_TO_HCLK, .name = "hclk" },
	{ .id = A390_CPU_TO_DCLK, .name = "dclk" },
};

Annotation

Implementation Notes