Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33c02590 authored by Gregory CLEMENT's avatar Gregory CLEMENT Committed by Stephen Boyd
Browse files

clk: mvebu: add helper file for Armada AP and CP clocks



Clock drivers for Armada AP and Armada CP use the same function to
generate unique clock name. A third drivers is coming with the same
need, so it's time to move this function in a common file.

Signed-off-by: default avatarGregory CLEMENT <gregory.clement@bootlin.com>
Link: https://lkml.kernel.org/r/20190710134346.30239-3-gregory.clement@bootlin.com


Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent 096f4597
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -8,6 +8,9 @@ config MVEBU_CLK_CPU
config MVEBU_CLK_COREDIV
	bool

config ARMADA_AP_CP_HELPER
	bool

config ARMADA_370_CLK
	bool
	select MVEBU_CLK_COMMON
@@ -35,9 +38,11 @@ config ARMADA_XP_CLK

config ARMADA_AP806_SYSCON
	bool
	select ARMADA_AP_CP_HELPER

config ARMADA_CP110_SYSCON
	bool
	select ARMADA_AP_CP_HELPER

config DOVE_CLK
	bool
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
obj-$(CONFIG_MVEBU_CLK_COMMON)	+= common.o
obj-$(CONFIG_MVEBU_CLK_CPU) 	+= clk-cpu.o
obj-$(CONFIG_MVEBU_CLK_COREDIV)	+= clk-corediv.o
obj-$(CONFIG_ARMADA_AP_CP_HELPER) += armada_ap_cp_helper.o

obj-$(CONFIG_ARMADA_370_CLK)	+= armada-370.o
obj-$(CONFIG_ARMADA_375_CLK)	+= armada-375.o
+6 −18
Original line number Diff line number Diff line
@@ -10,11 +10,11 @@

#define pr_fmt(fmt) "ap806-system-controller: " fmt

#include "armada_ap_cp_helper.h"
#include <linux/clk-provider.h>
#include <linux/mfd/syscon.h>
#include <linux/init.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>

@@ -30,18 +30,6 @@ static struct clk_onecell_data ap806_clk_data = {
	.clk_num = AP806_CLK_NUM,
};

static char *ap806_unique_name(struct device *dev, struct device_node *np,
			       char *name)
{
	const __be32 *reg;
	u64 addr;

	reg = of_get_property(np, "reg", NULL);
	addr = of_translate_address(np, reg);
	return devm_kasprintf(dev, GFP_KERNEL, "%llx-%s",
			(unsigned long long)addr, name);
}

static int ap806_syscon_common_probe(struct platform_device *pdev,
				     struct device_node *syscon_node)
{
@@ -109,7 +97,7 @@ static int ap806_syscon_common_probe(struct platform_device *pdev,
	cpuclk_freq *= 1000 * 1000;

	/* CPU clocks depend on the Sample At Reset configuration */
	name = ap806_unique_name(dev, syscon_node, "cpu-cluster-0");
	name = ap_cp_unique_name(dev, syscon_node, "cpu-cluster-0");
	ap806_clks[0] = clk_register_fixed_rate(dev, name, NULL,
						0, cpuclk_freq);
	if (IS_ERR(ap806_clks[0])) {
@@ -117,7 +105,7 @@ static int ap806_syscon_common_probe(struct platform_device *pdev,
		goto fail0;
	}

	name = ap806_unique_name(dev, syscon_node, "cpu-cluster-1");
	name = ap_cp_unique_name(dev, syscon_node, "cpu-cluster-1");
	ap806_clks[1] = clk_register_fixed_rate(dev, name, NULL, 0,
						cpuclk_freq);
	if (IS_ERR(ap806_clks[1])) {
@@ -126,7 +114,7 @@ static int ap806_syscon_common_probe(struct platform_device *pdev,
	}

	/* Fixed clock is always 1200 Mhz */
	fixedclk_name = ap806_unique_name(dev, syscon_node, "fixed");
	fixedclk_name = ap_cp_unique_name(dev, syscon_node, "fixed");
	ap806_clks[2] = clk_register_fixed_rate(dev, fixedclk_name, NULL,
						0, 1200 * 1000 * 1000);
	if (IS_ERR(ap806_clks[2])) {
@@ -135,7 +123,7 @@ static int ap806_syscon_common_probe(struct platform_device *pdev,
	}

	/* MSS Clock is fixed clock divided by 6 */
	name = ap806_unique_name(dev, syscon_node, "mss");
	name = ap_cp_unique_name(dev, syscon_node, "mss");
	ap806_clks[3] = clk_register_fixed_factor(NULL, name, fixedclk_name,
						  0, 1, 6);
	if (IS_ERR(ap806_clks[3])) {
@@ -144,7 +132,7 @@ static int ap806_syscon_common_probe(struct platform_device *pdev,
	}

	/* SDIO(/eMMC) Clock is fixed clock divided by 3 */
	name = ap806_unique_name(dev, syscon_node, "sdio");
	name = ap_cp_unique_name(dev, syscon_node, "sdio");
	ap806_clks[4] = clk_register_fixed_factor(NULL, name,
						  fixedclk_name,
						  0, 1, 3);
+30 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0+
/*
 * Marvell Armada AP and CP110 helper
 *
 * Copyright (C) 2018 Marvell
 *
 * Gregory Clement <gregory.clement@bootlin.com>
 *
 */

#include "armada_ap_cp_helper.h"
#include <linux/device.h>
#include <linux/of.h>
#include <linux/of_address.h>

char *ap_cp_unique_name(struct device *dev, struct device_node *np,
			const char *name)
{
	const __be32 *reg;
	u64 addr;

	/* Do not create a name if there is no clock */
	if (!name)
		return NULL;

	reg = of_get_property(np, "reg", NULL);
	addr = of_translate_address(np, reg);
	return devm_kasprintf(dev, GFP_KERNEL, "%llx-%s",
			      (unsigned long long)addr, name);
}
+11 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0+ */

#ifndef __ARMADA_AP_CP_HELPER_H
#define __ARMADA_AP_CP_HELPER_H

struct device;
struct device_node;

char *ap_cp_unique_name(struct device *dev, struct device_node *np,
			const char *name);
#endif
Loading