mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-18 16:44:27 +08:00
c4e05443b6
In accordance with the way the MIPS platform is normally design there are only six clock sources which need to be available on the kernel start in order to one end up booting correctly: + CPU PLL: needed by the r4k and MIPS GIC timer drivers. The former one is initialized by the arch code, while the later one is implemented in the mips-gic-timer.c driver as the OF-declared timer. + PCIe PLL: required as a parental clock source for the APB/timer domains. + APB clock: needed in order to access all the SoC CSRs at least for the timer OF-declared drivers. + APB Timer{0-2} clocks: these are the DW APB timers which drivers dw_apb_timer_of.c are implemented as the OF-declared timers. So as long as the clocks above are available early the kernel will normally work. Let's convert the Baikal-T1 CCU drivers to the platform device drivers keeping that in mind. Generally speaking the conversion isn't that complicated since the driver infrastructure has been designed as flexible enough for that. First we need to add a new PLL/Divider clock features flag which indicates the corresponding clock source as a basic one and that clock sources will be available on the kernel early boot stages. Second the internal PLL/Divider descriptors need to be initialized with -EPROBE_DEFER value as the corresponding clock source is unavailable at the early stages. They will be allocated and initialized on the Baikal-T1 clock platform driver probe procedure. Finally the already available PLL/Divider init functions need to be split up into two ones: init procedure performed in the framework of the OF-declared clock initialization (of_clk_init()), and the probe procedure called by the platform devices bus driver. Note the later method will just continue the system clocks initialization started in the former one. Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> Link: https://lore.kernel.org/r/20220929225402.9696-9-Sergey.Semin@baikalelectronics.ru [sboyd@kernel.org: Remove module things because the Kconfig is still bool] Signed-off-by: Stephen Boyd <sboyd@kernel.org>
73 lines
1.8 KiB
C
73 lines
1.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2020 BAIKAL ELECTRONICS, JSC
|
|
*
|
|
* Baikal-T1 CCU PLL interface driver
|
|
*/
|
|
#ifndef __CLK_BT1_CCU_PLL_H__
|
|
#define __CLK_BT1_CCU_PLL_H__
|
|
|
|
#include <linux/clk-provider.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/regmap.h>
|
|
#include <linux/bits.h>
|
|
#include <linux/of.h>
|
|
|
|
/*
|
|
* CCU PLL private flags
|
|
* @CCU_PLL_BASIC: Basic PLL required by the kernel as early as possible.
|
|
*/
|
|
#define CCU_PLL_BASIC BIT(0)
|
|
|
|
/*
|
|
* struct ccu_pll_init_data - CCU PLL initialization data
|
|
* @id: Clock private identifier.
|
|
* @name: Clocks name.
|
|
* @parent_name: Clocks parent name in a fw node.
|
|
* @base: PLL registers base address with respect to the sys_regs base.
|
|
* @sys_regs: Baikal-T1 System Controller registers map.
|
|
* @np: Pointer to the node describing the CCU PLLs.
|
|
* @flags: PLL clock flags.
|
|
* @features: PLL private features.
|
|
*/
|
|
struct ccu_pll_init_data {
|
|
unsigned int id;
|
|
const char *name;
|
|
const char *parent_name;
|
|
unsigned int base;
|
|
struct regmap *sys_regs;
|
|
struct device_node *np;
|
|
unsigned long flags;
|
|
unsigned long features;
|
|
};
|
|
|
|
/*
|
|
* struct ccu_pll - CCU PLL descriptor
|
|
* @hw: clk_hw of the PLL.
|
|
* @id: Clock private identifier.
|
|
* @reg_ctl: PLL control register base.
|
|
* @reg_ctl1: PLL control1 register base.
|
|
* @sys_regs: Baikal-T1 System Controller registers map.
|
|
* @lock: PLL state change spin-lock.
|
|
*/
|
|
struct ccu_pll {
|
|
struct clk_hw hw;
|
|
unsigned int id;
|
|
unsigned int reg_ctl;
|
|
unsigned int reg_ctl1;
|
|
struct regmap *sys_regs;
|
|
spinlock_t lock;
|
|
};
|
|
#define to_ccu_pll(_hw) container_of(_hw, struct ccu_pll, hw)
|
|
|
|
static inline struct clk_hw *ccu_pll_get_clk_hw(struct ccu_pll *pll)
|
|
{
|
|
return pll ? &pll->hw : NULL;
|
|
}
|
|
|
|
struct ccu_pll *ccu_pll_hw_register(const struct ccu_pll_init_data *init);
|
|
|
|
void ccu_pll_hw_unregister(struct ccu_pll *pll);
|
|
|
|
#endif /* __CLK_BT1_CCU_PLL_H__ */
|