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

Commit 253b0887 authored by Paul Mundt's avatar Paul Mundt
Browse files

sh: clkfwk: Rework legacy CPG clock handling.



This moves out the old legacy CPG clocks to their own file, and converts
over the existing users. With these clocks going away and each CPU
dealing with them on their own, CPUs can gradually move over to the new
interface.

Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 100890c5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -513,6 +513,9 @@ config SH_PCLK_FREQ
	  This is necessary for determining the reference clock value on
	  platforms lacking an RTC.

config SH_CLK_CPG_LEGACY
	def_bool y

config SH_CLK_MD
	int "CPU Mode Pin Setting"
	depends on CPU_SH2
+4 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ struct clk_lookup {
#define CLK_ENABLE_ON_INIT	(1 << 0)

/* Should be defined by processor-specific code */
void arch_init_clk_ops(struct clk_ops **, int type);
void __deprecated arch_init_clk_ops(struct clk_ops **, int type);
int __init arch_clk_init(void);

/* arch/sh/kernel/cpu/clock.c */
@@ -59,6 +59,9 @@ int clk_reparent(struct clk *child, struct clk *parent);
int clk_register(struct clk *);
void clk_unregister(struct clk *);

/* arch/sh/kernel/cpu/clock-cpg.c */
int __init __deprecated cpg_clk_init(void);

/* the exported API, in addition to clk_set_rate */
/**
 * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter
+2 −0
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ struct sh_machine_vector {

	void __iomem *(*mv_ioport_map)(unsigned long port, unsigned int size);
	void (*mv_ioport_unmap)(void __iomem *);

	int (*mv_clk_init)(void);
};

extern struct sh_machine_vector sh_mv;
+1 −0
Original line number Diff line number Diff line
@@ -17,5 +17,6 @@ obj-$(CONFIG_ARCH_SHMOBILE) += shmobile/

obj-$(CONFIG_UBC_WAKEUP)	+= ubc.o
obj-$(CONFIG_SH_ADC)		+= adc.o
obj-$(CONFIG_SH_CLK_CPG_LEGACY)	+= clock-cpg.o

obj-y	+= irq/ init.o clock.o
+60 −0
Original line number Diff line number Diff line
#include <linux/clk.h>
#include <linux/compiler.h>
#include <asm/clock.h>

static struct clk master_clk = {
	.name		= "master_clk",
	.flags		= CLK_ENABLE_ON_INIT,
	.rate		= CONFIG_SH_PCLK_FREQ,
};

static struct clk peripheral_clk = {
	.name		= "peripheral_clk",
	.parent		= &master_clk,
	.flags		= CLK_ENABLE_ON_INIT,
};

static struct clk bus_clk = {
	.name		= "bus_clk",
	.parent		= &master_clk,
	.flags		= CLK_ENABLE_ON_INIT,
};

static struct clk cpu_clk = {
	.name		= "cpu_clk",
	.parent		= &master_clk,
	.flags		= CLK_ENABLE_ON_INIT,
};

/*
 * The ordering of these clocks matters, do not change it.
 */
static struct clk *onchip_clocks[] = {
	&master_clk,
	&peripheral_clk,
	&bus_clk,
	&cpu_clk,
};

int __init __deprecated cpg_clk_init(void)
{
	int i, ret = 0;

	for (i = 0; i < ARRAY_SIZE(onchip_clocks); i++) {
		struct clk *clk = onchip_clocks[i];
		arch_init_clk_ops(&clk->ops, i);
		if (clk->ops)
			ret |= clk_register(clk);
	}

	return ret;
}

/*
 * Placeholder for compatability, until the lazy CPUs do this
 * on their own.
 */
int __init __weak arch_clk_init(void)
{
	return cpg_clk_init();
}
Loading