forked from Minki/linux
916f562fb2
side. The two main highlights in the core framework are the addition of an bulk clk_get API that handles optional clks and an extra debugfs file that tells the developer about the current parent of a clk. The driver updates are dominated by i.MX in the diffstat, but that is mostly because that SoC has started converting to the clk_hw style of clk registration. The next big update is in the Amlogic meson clk driver that gained some support for audio, cpu, and temperature clks while fixing some PLL issues. Finally, the biggest thing that stands out is the conversion of a large part of the Allwinner sunxi-ng driver to the new clk parent scheme that uses less strings and more pointer comparisons to match clk parents and children up. In general, it looks like we have a lot of little fixes and tweaks here and there to clk data along with the normal addition of a handful of new drivers and a couple new core framework features. Core: - Add a 'clk_parent' file in clk debugfs - Add a clk_bulk_get_optional() API (with devm too) New Drivers: - Support gated clk controller on MIPS based BCM63XX SoCs - Support SiLabs Si5341 and Si5340 chips - Support for CPU clks on Raspberry Pi devices - Audsys clock driver for MediaTek MT8516 SoCs Updates: - Convert a large portion of the Allwinner sunxi-ng driver to new clk parent scheme - Small frequency support for SiLabs Si544 chips - Slow clk support for AT91 SAM9X60 SoCs - Remove dead code in various clk drivers (-Wunused) - Support for Marvell 98DX1135 SoCs - Get duty cycle of generic pwm clks - Improvement in mmc phase calculation and cleanup of some rate defintions - Switch i.MX6 and i.MX7 clock drivers to clk_hw based APIs - Add GPIO, SNVS and GIC clocks for i.MX8 drivers - Mark imx6sx/ul/ull/sll MMDC_P1_IPG and imx8mm DRAM_APB as critical clock - Correct imx7ulp nic1_bus_clk and imx8mm audio_pll2_clk clock setting - Add clks for new Exynos5422 Dynamic Memory Controller driver - Clock definition for Exynos4412 Mali - Add CMM (Color Management Module) clocks on Renesas R-Car H3, M3-N, E3, and D3 - Add TPU (Timer Pulse Unit / PWM) clocks on Renesas RZ/G2M - Support for 32 bit clock IDs in TI's sci-clks for J721e SoCs - TI clock probing done from DT by default instead of firmware - Fix Amlogic Meson mpll fractional part and spread sprectrum issues - Add Amlogic meson8 audio clocks - Add Amlogic g12a temperature sensors clocks - Add Amlogic g12a and g12b cpu clocks - Add TPU (Timer Pulse Unit / PWM) clocks on Renesas R-Car H3, M3-W, and M3-N - Add CMM (Color Management Module) clocks on Renesas R-Car M3-W - Add Clock Domain support on Renesas RZ/N1 -----BEGIN PGP SIGNATURE----- iQJFBAABCAAvFiEE9L57QeeUxqYDyoaDrQKIl8bklSUFAl0uBEERHHNib3lkQGtl cm5lbC5vcmcACgkQrQKIl8bklSWucw/9ELKlfvdxrc8mdIuzt+CpKdNiSG88shXY hF+vnuE6Jhv5hmlbA/DbplPTAnHT/FQF65/GPQMAYy2wYO6CjleNxQyepiVv4h8/ tWoXu5vYZXubtQyMnYTffREzjYFPBNAscLUhXNwJKRno7nT0qKCk62WgOMfaW/KN lP5dKmrL7rdJDUvxHEStrwP515Lg5Wkhj3+XzgbgFUKGuGlvHfwUOEZucT++kqhu Z1vMjPv2ksHQf3r15BsbX/6jMIONEt2Xd6jA3Lm7ebDXJl2hjX4Gq0Kkl5pmkj2w F0V7Tw4XYk6DkSl7HQaOBgQ8KV0Mw2L8Vj6eEDhUwx6wPGlQ5YTKkUCJkjs0mUyb UpO3TuPFN2W0hsTNDzwYpjqcfodDn159XJcduv1/ZpIanUvHgx0uVzQ7iwwYwW+l VR4SipY5AEn9hpief30X7TAUSKsE4do58imYeoGBrq78zdsJaEcDAMX7AcYdXVQ9 ahBS8ME/d1JEBNdRsSW7eTAfu8dZdI08uR8/T37GRG59XyZSjsyVmZ6kHCYrBygF AyLNMsXMCbW1rOoIpWkuGMD86XZy40laLg8T7WWTaq28t1VQ0BaBTGM4/eEexs3p FhZ1M7aH+PsDLrI2IGTBt/4xAMv+dhDS7HnxRlOONbWnLWVqmR+tYzF0aCkqJCmd O2zWCGffeYs= =mK0C -----END PGP SIGNATURE----- Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux Pull clk updates from Stephen Boyd: "This round of clk driver and framework updates is heavy on the driver update side. The two main highlights in the core framework are the addition of an bulk clk_get API that handles optional clks and an extra debugfs file that tells the developer about the current parent of a clk. The driver updates are dominated by i.MX in the diffstat, but that is mostly because that SoC has started converting to the clk_hw style of clk registration. The next big update is in the Amlogic meson clk driver that gained some support for audio, cpu, and temperature clks while fixing some PLL issues. Finally, the biggest thing that stands out is the conversion of a large part of the Allwinner sunxi-ng driver to the new clk parent scheme that uses less strings and more pointer comparisons to match clk parents and children up. In general, it looks like we have a lot of little fixes and tweaks here and there to clk data along with the normal addition of a handful of new drivers and a couple new core framework features. Core: - Add a 'clk_parent' file in clk debugfs - Add a clk_bulk_get_optional() API (with devm too) New Drivers: - Support gated clk controller on MIPS based BCM63XX SoCs - Support SiLabs Si5341 and Si5340 chips - Support for CPU clks on Raspberry Pi devices - Audsys clock driver for MediaTek MT8516 SoCs Updates: - Convert a large portion of the Allwinner sunxi-ng driver to new clk parent scheme - Small frequency support for SiLabs Si544 chips - Slow clk support for AT91 SAM9X60 SoCs - Remove dead code in various clk drivers (-Wunused) - Support for Marvell 98DX1135 SoCs - Get duty cycle of generic pwm clks - Improvement in mmc phase calculation and cleanup of some rate defintions - Switch i.MX6 and i.MX7 clock drivers to clk_hw based APIs - Add GPIO, SNVS and GIC clocks for i.MX8 drivers - Mark imx6sx/ul/ull/sll MMDC_P1_IPG and imx8mm DRAM_APB as critical clock - Correct imx7ulp nic1_bus_clk and imx8mm audio_pll2_clk clock setting - Add clks for new Exynos5422 Dynamic Memory Controller driver - Clock definition for Exynos4412 Mali - Add CMM (Color Management Module) clocks on Renesas R-Car H3, M3-N, E3, and D3 - Add TPU (Timer Pulse Unit / PWM) clocks on Renesas RZ/G2M - Support for 32 bit clock IDs in TI's sci-clks for J721e SoCs - TI clock probing done from DT by default instead of firmware - Fix Amlogic Meson mpll fractional part and spread sprectrum issues - Add Amlogic meson8 audio clocks - Add Amlogic g12a temperature sensors clocks - Add Amlogic g12a and g12b cpu clocks - Add TPU (Timer Pulse Unit / PWM) clocks on Renesas R-Car H3, M3-W, and M3-N - Add CMM (Color Management Module) clocks on Renesas R-Car M3-W - Add Clock Domain support on Renesas RZ/N1" * tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux: (190 commits) clk: consoldiate the __clk_get_hw() declarations clk: sprd: Add check for return value of sprd_clk_regmap_init() clk: lochnagar: Update DT binding doc to include the primary SPDIF MCLK clk: Add Si5341/Si5340 driver dt-bindings: clock: Add silabs,si5341 clk: clk-si544: Implement small frequency change support clk: add BCM63XX gated clock controller driver devicetree: document the BCM63XX gated clock bindings clk: at91: sckc: use dedicated functions to unregister clock clk: at91: sckc: improve error path for sama5d4 sck registration clk: at91: sckc: remove unnecessary line clk: at91: sckc: improve error path for sam9x5 sck register clk: at91: sckc: add support to free slow clock osclillator clk: at91: sckc: add support to free slow rc oscillator clk: at91: sckc: add support to free slow oscillator clk: rockchip: export HDMIPHY clock on rk3228 clk: rockchip: add watchdog pclk on rk3328 clk: rockchip: add clock id for hdmi_phy special clock on rk3228 clk: rockchip: add clock id for watchdog pclk on rk3328 clk: at91: sckc: add support for SAM9X60 ...
229 lines
7.2 KiB
C
229 lines
7.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* Ingenic SoC CGU driver
|
|
*
|
|
* Copyright (c) 2013-2015 Imagination Technologies
|
|
* Author: Paul Burton <paul.burton@mips.com>
|
|
*/
|
|
|
|
#ifndef __DRIVERS_CLK_INGENIC_CGU_H__
|
|
#define __DRIVERS_CLK_INGENIC_CGU_H__
|
|
|
|
#include <linux/bitops.h>
|
|
#include <linux/clk-provider.h>
|
|
#include <linux/of.h>
|
|
#include <linux/spinlock.h>
|
|
|
|
/**
|
|
* struct ingenic_cgu_pll_info - information about a PLL
|
|
* @reg: the offset of the PLL's control register within the CGU
|
|
* @m_shift: the number of bits to shift the multiplier value by (ie. the
|
|
* index of the lowest bit of the multiplier value in the PLL's
|
|
* control register)
|
|
* @m_bits: the size of the multiplier field in bits
|
|
* @m_offset: the multiplier value which encodes to 0 in the PLL's control
|
|
* register
|
|
* @n_shift: the number of bits to shift the divider value by (ie. the
|
|
* index of the lowest bit of the divider value in the PLL's
|
|
* control register)
|
|
* @n_bits: the size of the divider field in bits
|
|
* @n_offset: the divider value which encodes to 0 in the PLL's control
|
|
* register
|
|
* @od_shift: the number of bits to shift the post-VCO divider value by (ie.
|
|
* the index of the lowest bit of the post-VCO divider value in
|
|
* the PLL's control register)
|
|
* @od_bits: the size of the post-VCO divider field in bits
|
|
* @od_max: the maximum post-VCO divider value
|
|
* @od_encoding: a pointer to an array mapping post-VCO divider values to
|
|
* their encoded values in the PLL control register, or -1 for
|
|
* unsupported values
|
|
* @bypass_bit: the index of the bypass bit in the PLL control register
|
|
* @enable_bit: the index of the enable bit in the PLL control register
|
|
* @stable_bit: the index of the stable bit in the PLL control register
|
|
* @no_bypass_bit: if set, the PLL has no bypass functionality
|
|
*/
|
|
struct ingenic_cgu_pll_info {
|
|
unsigned reg;
|
|
const s8 *od_encoding;
|
|
u8 m_shift, m_bits, m_offset;
|
|
u8 n_shift, n_bits, n_offset;
|
|
u8 od_shift, od_bits, od_max;
|
|
u8 bypass_bit;
|
|
u8 enable_bit;
|
|
u8 stable_bit;
|
|
bool no_bypass_bit;
|
|
};
|
|
|
|
/**
|
|
* struct ingenic_cgu_mux_info - information about a clock mux
|
|
* @reg: offset of the mux control register within the CGU
|
|
* @shift: number of bits to shift the mux value by (ie. the index of
|
|
* the lowest bit of the mux value within its control register)
|
|
* @bits: the size of the mux value in bits
|
|
*/
|
|
struct ingenic_cgu_mux_info {
|
|
unsigned reg;
|
|
u8 shift;
|
|
u8 bits;
|
|
};
|
|
|
|
/**
|
|
* struct ingenic_cgu_div_info - information about a divider
|
|
* @reg: offset of the divider control register within the CGU
|
|
* @shift: number of bits to left shift the divide value by (ie. the index of
|
|
* the lowest bit of the divide value within its control register)
|
|
* @div: number to divide the divider value by (i.e. if the
|
|
* effective divider value is the value written to the register
|
|
* multiplied by some constant)
|
|
* @bits: the size of the divide value in bits
|
|
* @ce_bit: the index of the change enable bit within reg, or -1 if there
|
|
* isn't one
|
|
* @busy_bit: the index of the busy bit within reg, or -1 if there isn't one
|
|
* @stop_bit: the index of the stop bit within reg, or -1 if there isn't one
|
|
* @div_table: optional table to map the value read from the register to the
|
|
* actual divider value
|
|
*/
|
|
struct ingenic_cgu_div_info {
|
|
unsigned reg;
|
|
u8 shift;
|
|
u8 div;
|
|
u8 bits;
|
|
s8 ce_bit;
|
|
s8 busy_bit;
|
|
s8 stop_bit;
|
|
const u8 *div_table;
|
|
};
|
|
|
|
/**
|
|
* struct ingenic_cgu_fixdiv_info - information about a fixed divider
|
|
* @div: the divider applied to the parent clock
|
|
*/
|
|
struct ingenic_cgu_fixdiv_info {
|
|
unsigned div;
|
|
};
|
|
|
|
/**
|
|
* struct ingenic_cgu_gate_info - information about a clock gate
|
|
* @reg: offset of the gate control register within the CGU
|
|
* @bit: offset of the bit in the register that controls the gate
|
|
* @clear_to_gate: if set, the clock is gated when the bit is cleared
|
|
* @delay_us: delay in microseconds after which the clock is considered stable
|
|
*/
|
|
struct ingenic_cgu_gate_info {
|
|
unsigned reg;
|
|
u8 bit;
|
|
bool clear_to_gate;
|
|
u16 delay_us;
|
|
};
|
|
|
|
/**
|
|
* struct ingenic_cgu_custom_info - information about a custom (SoC) clock
|
|
* @clk_ops: custom clock operation callbacks
|
|
*/
|
|
struct ingenic_cgu_custom_info {
|
|
const struct clk_ops *clk_ops;
|
|
};
|
|
|
|
/**
|
|
* struct ingenic_cgu_clk_info - information about a clock
|
|
* @name: name of the clock
|
|
* @type: a bitmask formed from CGU_CLK_* values
|
|
* @parents: an array of the indices of potential parents of this clock
|
|
* within the clock_info array of the CGU, or -1 in entries
|
|
* which correspond to no valid parent
|
|
* @pll: information valid if type includes CGU_CLK_PLL
|
|
* @gate: information valid if type includes CGU_CLK_GATE
|
|
* @mux: information valid if type includes CGU_CLK_MUX
|
|
* @div: information valid if type includes CGU_CLK_DIV
|
|
* @fixdiv: information valid if type includes CGU_CLK_FIXDIV
|
|
* @custom: information valid if type includes CGU_CLK_CUSTOM
|
|
*/
|
|
struct ingenic_cgu_clk_info {
|
|
const char *name;
|
|
|
|
enum {
|
|
CGU_CLK_NONE = 0,
|
|
CGU_CLK_EXT = BIT(0),
|
|
CGU_CLK_PLL = BIT(1),
|
|
CGU_CLK_GATE = BIT(2),
|
|
CGU_CLK_MUX = BIT(3),
|
|
CGU_CLK_MUX_GLITCHFREE = BIT(4),
|
|
CGU_CLK_DIV = BIT(5),
|
|
CGU_CLK_FIXDIV = BIT(6),
|
|
CGU_CLK_CUSTOM = BIT(7),
|
|
} type;
|
|
|
|
int parents[4];
|
|
|
|
union {
|
|
struct ingenic_cgu_pll_info pll;
|
|
|
|
struct {
|
|
struct ingenic_cgu_gate_info gate;
|
|
struct ingenic_cgu_mux_info mux;
|
|
struct ingenic_cgu_div_info div;
|
|
struct ingenic_cgu_fixdiv_info fixdiv;
|
|
};
|
|
|
|
struct ingenic_cgu_custom_info custom;
|
|
};
|
|
};
|
|
|
|
/**
|
|
* struct ingenic_cgu - data about the CGU
|
|
* @np: the device tree node that caused the CGU to be probed
|
|
* @base: the ioremap'ed base address of the CGU registers
|
|
* @clock_info: an array containing information about implemented clocks
|
|
* @clocks: used to provide clocks to DT, allows lookup of struct clk*
|
|
* @lock: lock to be held whilst manipulating CGU registers
|
|
*/
|
|
struct ingenic_cgu {
|
|
struct device_node *np;
|
|
void __iomem *base;
|
|
|
|
const struct ingenic_cgu_clk_info *clock_info;
|
|
struct clk_onecell_data clocks;
|
|
|
|
spinlock_t lock;
|
|
};
|
|
|
|
/**
|
|
* struct ingenic_clk - private data for a clock
|
|
* @hw: see Documentation/driver-api/clk.rst
|
|
* @cgu: a pointer to the CGU data
|
|
* @idx: the index of this clock in cgu->clock_info
|
|
*/
|
|
struct ingenic_clk {
|
|
struct clk_hw hw;
|
|
struct ingenic_cgu *cgu;
|
|
unsigned idx;
|
|
};
|
|
|
|
#define to_ingenic_clk(_hw) container_of(_hw, struct ingenic_clk, hw)
|
|
|
|
/**
|
|
* ingenic_cgu_new() - create a new CGU instance
|
|
* @clock_info: an array of clock information structures describing the clocks
|
|
* which are implemented by the CGU
|
|
* @num_clocks: the number of entries in clock_info
|
|
* @np: the device tree node which causes this CGU to be probed
|
|
*
|
|
* Return: a pointer to the CGU instance if initialisation is successful,
|
|
* otherwise NULL.
|
|
*/
|
|
struct ingenic_cgu *
|
|
ingenic_cgu_new(const struct ingenic_cgu_clk_info *clock_info,
|
|
unsigned num_clocks, struct device_node *np);
|
|
|
|
/**
|
|
* ingenic_cgu_register_clocks() - Registers the clocks
|
|
* @cgu: pointer to cgu data
|
|
*
|
|
* Register the clocks described by the CGU with the common clock framework.
|
|
*
|
|
* Return: 0 on success or -errno if unsuccesful.
|
|
*/
|
|
int ingenic_cgu_register_clocks(struct ingenic_cgu *cgu);
|
|
|
|
#endif /* __DRIVERS_CLK_INGENIC_CGU_H__ */
|