Per-user clock constraints
Subsystems (48)
v8 cover Per-user clock constraints
Hi,
in this v8 of the patchset I have rebased on top of friday's linux-next and have extended the unbalanced checks to also cover prepare/unprepare. I have dropped the changes I did to remove usage of provider-only API from kirkwood-cpufreq.c, as Mike and Andrew are taking care of it in a series [0] that will be hopefully posted soon. This iteration has been tested only on a Jetson TK1 board.
Follows the original cover letter blurb:
I'm retaking Rabin's patches [1] for splitting the clk API in two: one API for clk consumers and another for providers. The consumer API uses a clk structure that just keeps track of the consumer and has a reference to the actual clk_core struct, which is used internally.
I have kept a patch from Rabin that aims to aid in debugging nested enable/disable calls, though my personal aim is to allow more than one consumer to influence the final, effective frequency rate. For now this is limited to setting floor and ceiling constraints, with the short-term aim of allowing devfreq and thermal drivers to set floor and ceiling frequencies on the memory clock, respectively.
For those functions in the consumer clk API that were called from providers, I have added variants to clk-provider.h that are the same only that accept a clk_core instead. These functions are prefixed with clk_provider_.
Patch 1/7 just adds a bunch of defines with the goal of having all the renames in their own commit while preserving git-bisectability, with patch 3/7 containing the rename itself as generated by the Coccinelle script in [2]. Patch 2/7 is needed because sound/soc/mxs/mxs-saif.c calls both the consumer and the provider API. The actual implementation of the API split comes in patch 4/7. I will be happy to organize the refactoring differently if anybody has a better idea.
Patch 5/7 warns when there's an unbalanced usage of the enable and disable APIs, and patch 6/7 adds the API for setting floor and ceiling frequencies, per consumer. Patch 7/7 will warn when prepare/unprepare are used unbalanced, printing the code location of the last call to unprepare.
[0] https://git.linaro.org/people/mike.turquette/linux.git/shortlog/refs/heads/clk-next-tomeu-kirkwood-v2
[1] http://thread.gmane.org/gmane.linux.kernel/1402006
[2] http://cgit.collabora.com/git/user/tomeu/linux.git/log/?h=clk-refactoring-8
Thanks,
Tomeu
Tomeu Vizoso (7):
clk: Add temporary mapping to the existing API
ASoC: mxs-saif: fix mixed use of public and provider clk API
clk: Move all drivers to use internal API
clk: use struct clk only for external API
clk: per-user clock accounting for debug
clk: Add floor and ceiling constraints to clock rates
clk: Warn of unbalanced clk_prepare() calls
[detailed diffstat omitted for brevity sake]
255 files changed, 2251 insertions(+), 1726 deletions(-)
Signature · 1 line
1.9.3
PATCH v8 1/7 clk: Add temporary mapping to the existing API
To preserve git-bisectability, add aliases from the future provider API to the existing public API.
Also includes clk-provider.h and clk-dev.h in a few places so the right functions are defined.
---
v7: * Add mappings for clk_notifier_[un]register
* Add more clk-provider.h includes to clk implementations
v4: * Add more clk-provider.h includes to clk implementations
* Add mapping for clk_provider_round_rate
--- arch/arm/mach-omap2/display.c | 1 + arch/arm/mach-omap2/omap_device.c | 1 + arch/arm/mach-shmobile/clock.c | 1 + arch/arm/plat-orion/common.c | 1 + drivers/clk/berlin/bg2.c | 1 + drivers/clk/berlin/bg2q.c | 1 + drivers/clk/clk-conf.c | 1 + drivers/clk/clkdev.c | 1 + drivers/media/platform/exynos4-is/media-dev.c | 1 + include/linux/clk-provider.h | 25 +++++++++++++++++++++++++ include/linux/clk/zynq.h | 1 + 11 files changed, 35 insertions(+)
arch/arm/mach-omap2/display.c +1 -0
@@ -21,6 +21,7 @@#include <linux/platform_device.h> #include <linux/io.h> #include <linux/clk.h> +#include <linux/clk-provider.h> #include <linux/err.h> #include <linux/delay.h> #include <linux/of.h>
arch/arm/mach-omap2/omap_device.c +1 -0
@@ -32,6 +32,7 @@#include <linux/io.h> #include <linux/clk.h> #include <linux/clkdev.h> +#include <linux/clk-provider.h> #include <linux/pm_runtime.h> #include <linux/of.h> #include <linux/notifier.h>
arch/arm/mach-shmobile/clock.c +1 -0
@@ -24,6 +24,7 @@#ifdef CONFIG_COMMON_CLK #include <linux/clk.h> +#include <linux/clk-provider.h> #include <linux/clkdev.h> #include "clock.h"
arch/arm/plat-orion/common.c +1 -0
@@ -15,6 +15,7 @@#include <linux/serial_8250.h> #include <linux/ata_platform.h> #include <linux/clk.h> +#include <linux/clk-provider.h> #include <linux/clkdev.h> #include <linux/mv643xx_eth.h> #include <linux/mv643xx_i2c.h>
drivers/clk/berlin/bg2.c +1 -0
@@ -19,6 +19,7 @@#include <linux/clk.h> #include <linux/clk-provider.h> +#include <linux/clkdev.h> #include <linux/kernel.h> #include <linux/of.h> #include <linux/of_address.h>
drivers/clk/berlin/bg2q.c +1 -0
@@ -19,6 +19,7 @@#include <linux/clk.h> #include <linux/clk-provider.h> +#include <linux/clkdev.h> #include <linux/kernel.h> #include <linux/of.h> #include <linux/of_address.h>
drivers/clk/clk-conf.c +1 -0
@@ -8,6 +8,7 @@*/ #include <linux/clk.h> +#include <linux/clkdev.h> #include <linux/clk-provider.h> #include <linux/clk/clk-conf.h> #include <linux/device.h>
drivers/clk/clkdev.c +1 -0
@@ -18,6 +18,7 @@#include <linux/string.h> #include <linux/mutex.h> #include <linux/clk.h> +#include <linux/clk-provider.h> #include <linux/clkdev.h> #include <linux/of.h>
drivers/media/platform/exynos4-is/media-dev.c +1 -0
@@ -13,6 +13,7 @@#include <linux/bug.h> #include <linux/clk.h> #include <linux/clk-provider.h> +#include <linux/clkdev.h> #include <linux/device.h> #include <linux/errno.h> #include <linux/i2c.h>
include/linux/clk-provider.h +25 -0
@@ -16,6 +16,31 @@#ifdef CONFIG_COMMON_CLK +/* Temporarily map the to-be-added API to the old API, just so stuff compiles */ +#define clk_core clk + +#define __clk_create_clk + +#define clk_provider_get clk_get +#define clk_provider_get_sys clk_get_sys +#define devm_clk_provider_get devm_clk_get +#define of_clk_provider_get of_clk_get +#define of_clk_provider_get_by_name of_clk_get_by_name + +#define clk_provider_set_rate clk_set_rate +#define clk_provider_get_rate clk_get_rate +#define clk_provider_round_rate clk_round_rate +#define clk_provider_set_parent clk_set_parent +#define clk_provider_get_parent clk_get_parent +#define clk_provider_prepare clk_prepare +#define clk_provider_unprepare clk_unprepare +#define clk_provider_enable clk_enable +#define clk_provider_disable clk_disable +#define clk_provider_prepare_enable clk_prepare_enable +#define clk_provider_disable_unprepare clk_unprepare +#define clk_provider_notifier_register clk_notifier_register +#define clk_provider_notifier_unregister clk_notifier_unregister +/* * flags used across common struct clk. these flags should only affect the * top-level framework. custom flags for dealing with hardware specifics
include/linux/clk/zynq.h +1 -0
@@ -21,6 +21,7 @@#define __LINUX_CLK_ZYNQ_H_#include <linux/spinlock.h> +#include <linux/clk-provider.h> void zynq_clock_init (void );
Signature · 1 line
1.9.3
PATCH v8 2/7 ASoC: mxs-saif: fix mixed use of public and provider clk API
In reply to Tomeu VizosoIn preparation to changing the clk provider API to use struct clk_core instead of struct clk.
--- sound/soc/mxs/mxs-saif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/mxs/mxs-saif.c +2 -2
@@ -682,11 +682,11 @@ static int mxs_saif_mclk_init(struct platform_device *pdev) {struct mxs_saif *saif =platform_get_drvdata (pdev);struct device_node *np = pdev->dev.of_node; -struct clk *clk; +struct clk_core *clk;int ret; clk =clk_register_divider (&pdev->dev,"mxs_saif_mclk" , -__clk_get_name (saif->clk),0 , +clk_get_name (saif->clk),0 , saif->base +SAIF_CTRL ,BP_SAIF_CTRL_BITCLK_MULT_RATE ,3 ,0 ,NULL );
Signature · 1 line
1.9.3
PATCH v8 3/7 clk: Move all drivers to use internal API
In reply to Tomeu VizosoIn preparation to change the public API to return a per-user clk structure, remove any usage of this public API from the clock implementations.
The reason for having this in a separate commit from the one that introduces the implementation of the new functions is to separate the changes generated with Coccinelle from the rest, and keep the patches' size reasonable.
--- arch/arm/mach-dove/common.c | 10 +- arch/arm/mach-imx/clk-busy.c | 8 +- arch/arm/mach-imx/clk-fixup-div.c | 4 +- arch/arm/mach-imx/clk-fixup-mux.c | 4 +- arch/arm/mach-imx/clk-gate2.c | 4 +- arch/arm/mach-imx/clk-imx1.c | 2 +- arch/arm/mach-imx/clk-imx21.c | 2 +- arch/arm/mach-imx/clk-imx25.c | 8 +- arch/arm/mach-imx/clk-imx27.c | 4 +- arch/arm/mach-imx/clk-imx31.c | 10 +- arch/arm/mach-imx/clk-imx35.c | 22 +- arch/arm/mach-imx/clk-imx51-imx53.c | 77 +++--- arch/arm/mach-imx/clk-imx6q.c | 53 ++-- arch/arm/mach-imx/clk-imx6sl.c | 21 +- arch/arm/mach-imx/clk-imx6sx.c | 97 ++++--- arch/arm/mach-imx/clk-pfd.c | 4 +- arch/arm/mach-imx/clk-pllv1.c | 4 +- arch/arm/mach-imx/clk-pllv2.c | 4 +- arch/arm/mach-imx/clk-pllv3.c | 4 +- arch/arm/mach-imx/clk-vf610.c | 44 +-- arch/arm/mach-imx/clk.c | 10 +- arch/arm/mach-imx/clk.h | 42 +-- arch/arm/mach-msm/clock-pcom.c | 2 +- arch/arm/mach-mv78xx0/common.c | 2 +- arch/arm/mach-omap2/cclock3xxx_data.c | 370 +++++++++++++------------- arch/arm/mach-omap2/clkt2xxx_dpll.c | 4 +- arch/arm/mach-omap2/clkt2xxx_dpllcore.c | 4 +- arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c | 10 +- arch/arm/mach-omap2/clkt34xx_dpll3m2.c | 2 +- arch/arm/mach-omap2/clkt_clksel.c | 46 ++-- arch/arm/mach-omap2/clkt_dpll.c | 8 +- arch/arm/mach-omap2/clock.c | 52 ++-- arch/arm/mach-omap2/clock.h | 18 +- arch/arm/mach-omap2/clock3xxx.c | 22 +- arch/arm/mach-omap2/clock3xxx.h | 4 +- arch/arm/mach-omap2/clock_common_data.c | 2 +- arch/arm/mach-omap2/clockdomain.c | 8 +- arch/arm/mach-omap2/clockdomain.h | 4 +- arch/arm/mach-omap2/display.c | 4 +- arch/arm/mach-omap2/dpll3xxx.c | 28 +- arch/arm/mach-omap2/dpll44xx.c | 4 +- arch/arm/mach-omap2/mcbsp.c | 4 +- arch/arm/mach-omap2/omap_device.c | 8 +- arch/arm/mach-omap2/omap_hwmod.c | 42 +-- arch/arm/mach-omap2/omap_hwmod.h | 12 +- arch/arm/mach-omap2/pm24xx.c | 12 +- arch/arm/mach-orion5x/common.c | 2 +- arch/arm/mach-shmobile/clock.c | 8 +- arch/arm/mach-vexpress/spc.c | 4 +- arch/arm/plat-orion/common.c | 20 +- arch/arm/plat-orion/include/plat/common.h | 12 +- arch/powerpc/platforms/512x/clock-commonclk.c | 48 ++-- drivers/clk/at91/clk-main.c | 24 +- drivers/clk/at91/clk-master.c | 6 +- drivers/clk/at91/clk-peripheral.c | 12 +- drivers/clk/at91/clk-pll.c | 6 +- drivers/clk/at91/clk-plldiv.c | 6 +- drivers/clk/at91/clk-programmable.c | 10 +- drivers/clk/at91/clk-slow.c | 24 +- drivers/clk/at91/clk-smd.c | 6 +- drivers/clk/at91/clk-system.c | 6 +- drivers/clk/at91/clk-usb.c | 18 +- drivers/clk/at91/clk-utmi.c | 6 +- drivers/clk/bcm/clk-kona-setup.c | 6 +- drivers/clk/bcm/clk-kona.c | 12 +- drivers/clk/bcm/clk-kona.h | 2 +- drivers/clk/berlin/berlin2-avpll.c | 4 +- drivers/clk/berlin/berlin2-avpll.h | 4 +- drivers/clk/berlin/berlin2-div.c | 2 +- drivers/clk/berlin/berlin2-div.h | 2 +- drivers/clk/berlin/berlin2-pll.c | 2 +- drivers/clk/berlin/berlin2-pll.h | 2 +- drivers/clk/berlin/bg2.c | 12 +- drivers/clk/berlin/bg2q.c | 8 +- drivers/clk/clk-axi-clkgen.c | 2 +- drivers/clk/clk-axm5516.c | 4 +- drivers/clk/clk-bcm2835.c | 2 +- drivers/clk/clk-composite.c | 10 +- drivers/clk/clk-conf.c | 16 +- drivers/clk/clk-divider.c | 8 +- drivers/clk/clk-efm32gg.c | 2 +- drivers/clk/clk-fixed-factor.c | 6 +- drivers/clk/clk-fixed-rate.c | 8 +- drivers/clk/clk-fractional-divider.c | 4 +- drivers/clk/clk-gate.c | 4 +- drivers/clk/clk-highbank.c | 8 +- drivers/clk/clk-ls1x.c | 16 +- drivers/clk/clk-max77686.c | 10 +- drivers/clk/clk-moxart.c | 8 +- drivers/clk/clk-mux.c | 6 +- drivers/clk/clk-nomadik.c | 14 +- drivers/clk/clk-nspire.c | 4 +- drivers/clk/clk-ppc-corenet.c | 8 +- drivers/clk/clk-s2mps11.c | 6 +- drivers/clk/clk-si5351.c | 17 +- drivers/clk/clk-si570.c | 4 +- drivers/clk/clk-twl6040.c | 2 +- drivers/clk/clk-u300.c | 12 +- drivers/clk/clk-vt8500.c | 4 +- drivers/clk/clk-wm831x.c | 6 +- drivers/clk/clk-xgene.c | 12 +- drivers/clk/clk.h | 4 +- drivers/clk/hisilicon/clk-hi3620.c | 8 +- drivers/clk/hisilicon/clk.c | 16 +- drivers/clk/hisilicon/clk.h | 2 +- drivers/clk/hisilicon/clkgate-separated.c | 4 +- drivers/clk/keystone/gate.c | 6 +- drivers/clk/keystone/pll.c | 10 +- drivers/clk/mmp/clk-apbc.c | 4 +- drivers/clk/mmp/clk-apmu.c | 4 +- drivers/clk/mmp/clk-frac.c | 4 +- drivers/clk/mmp/clk-mmp2.c | 14 +- drivers/clk/mmp/clk-pxa168.c | 12 +- drivers/clk/mmp/clk-pxa910.c | 12 +- drivers/clk/mmp/clk.h | 8 +- drivers/clk/mvebu/clk-corediv.c | 4 +- drivers/clk/mvebu/clk-cpu.c | 8 +- drivers/clk/mvebu/common.c | 14 +- drivers/clk/mvebu/kirkwood.c | 6 +- drivers/clk/mxs/clk-div.c | 4 +- drivers/clk/mxs/clk-frac.c | 4 +- drivers/clk/mxs/clk-imx23.c | 4 +- drivers/clk/mxs/clk-imx28.c | 4 +- drivers/clk/mxs/clk-pll.c | 4 +- drivers/clk/mxs/clk-ref.c | 4 +- drivers/clk/mxs/clk.h | 16 +- drivers/clk/qcom/clk-rcg.c | 8 +- drivers/clk/qcom/clk-rcg2.c | 14 +- drivers/clk/qcom/clk-regmap.c | 2 +- drivers/clk/qcom/clk-regmap.h | 2 +- drivers/clk/qcom/common.c | 6 +- drivers/clk/qcom/gcc-msm8660.c | 2 +- drivers/clk/qcom/gcc-msm8960.c | 2 +- drivers/clk/qcom/gcc-msm8974.c | 2 +- drivers/clk/qcom/mmcc-msm8960.c | 6 +- drivers/clk/rockchip/clk-pll.c | 8 +- drivers/clk/rockchip/clk-rk3188.c | 2 +- drivers/clk/rockchip/clk-rk3288.c | 2 +- drivers/clk/rockchip/clk-rockchip.c | 2 +- drivers/clk/rockchip/clk.c | 14 +- drivers/clk/rockchip/clk.h | 4 +- drivers/clk/samsung/clk-exynos-audss.c | 16 +- drivers/clk/samsung/clk-exynos-clkout.c | 8 +- drivers/clk/samsung/clk-exynos4.c | 6 +- drivers/clk/samsung/clk-pll.c | 6 +- drivers/clk/samsung/clk-pll.h | 2 +- drivers/clk/samsung/clk-s3c2410-dclk.c | 30 +-- drivers/clk/samsung/clk.c | 22 +- drivers/clk/samsung/clk.h | 2 +- drivers/clk/shmobile/clk-div6.c | 2 +- drivers/clk/shmobile/clk-emev2.c | 4 +- drivers/clk/shmobile/clk-mstp.c | 6 +- drivers/clk/shmobile/clk-r8a7740.c | 6 +- drivers/clk/shmobile/clk-r8a7779.c | 6 +- drivers/clk/shmobile/clk-rcar-gen2.c | 10 +- drivers/clk/shmobile/clk-rz.c | 6 +- drivers/clk/sirf/clk-atlas6.c | 2 +- drivers/clk/sirf/clk-common.c | 30 +-- drivers/clk/sirf/clk-prima2.c | 2 +- drivers/clk/socfpga/clk-gate.c | 2 +- drivers/clk/socfpga/clk-periph.c | 2 +- drivers/clk/socfpga/clk-pll.c | 4 +- drivers/clk/spear/clk-aux-synth.c | 8 +- drivers/clk/spear/clk-frac-synth.c | 4 +- drivers/clk/spear/clk-gpt-synth.c | 4 +- drivers/clk/spear/clk-vco-pll.c | 8 +- drivers/clk/spear/clk.h | 14 +- drivers/clk/spear/spear1310_clock.c | 2 +- drivers/clk/spear/spear1340_clock.c | 2 +- drivers/clk/spear/spear3xx_clock.c | 16 +- drivers/clk/spear/spear6xx_clock.c | 2 +- drivers/clk/st/clk-flexgen.c | 12 +- drivers/clk/st/clkgen-fsyn.c | 22 +- drivers/clk/st/clkgen-mux.c | 32 +-- drivers/clk/st/clkgen-pll.c | 34 +-- drivers/clk/sunxi/clk-a10-hosc.c | 2 +- drivers/clk/sunxi/clk-a20-gmac.c | 2 +- drivers/clk/sunxi/clk-factors.c | 4 +- drivers/clk/sunxi/clk-sun6i-apb0-gates.c | 2 +- drivers/clk/sunxi/clk-sun6i-apb0.c | 2 +- drivers/clk/sunxi/clk-sun6i-ar100.c | 6 +- drivers/clk/sunxi/clk-sun8i-apb0.c | 2 +- drivers/clk/sunxi/clk-sunxi.c | 18 +- drivers/clk/tegra/clk-audio-sync.c | 4 +- drivers/clk/tegra/clk-divider.c | 4 +- drivers/clk/tegra/clk-periph-gate.c | 4 +- drivers/clk/tegra/clk-periph.c | 8 +- drivers/clk/tegra/clk-pll-out.c | 4 +- drivers/clk/tegra/clk-pll.c | 40 +-- drivers/clk/tegra/clk-super.c | 4 +- drivers/clk/tegra/clk-tegra-audio.c | 4 +- drivers/clk/tegra/clk-tegra-fixed.c | 8 +- drivers/clk/tegra/clk-tegra-periph.c | 12 +- drivers/clk/tegra/clk-tegra-pmc.c | 4 +- drivers/clk/tegra/clk-tegra-super-gen4.c | 8 +- drivers/clk/tegra/clk-tegra114.c | 10 +- drivers/clk/tegra/clk-tegra124.c | 6 +- drivers/clk/tegra/clk-tegra20.c | 12 +- drivers/clk/tegra/clk-tegra30.c | 8 +- drivers/clk/tegra/clk.c | 24 +- drivers/clk/tegra/clk.h | 38 +-- drivers/clk/ti/apll.c | 8 +- drivers/clk/ti/clk-2xxx.c | 8 +- drivers/clk/ti/clk-33xx.c | 18 +- drivers/clk/ti/clk-3xxx.c | 8 +- drivers/clk/ti/clk-43xx.c | 8 +- drivers/clk/ti/clk-44xx.c | 16 +- drivers/clk/ti/clk-54xx.c | 25 +- drivers/clk/ti/clk-7xx.c | 28 +- drivers/clk/ti/clk-dra7-atl.c | 6 +- drivers/clk/ti/clk.c | 2 +- drivers/clk/ti/clockdomain.c | 4 +- drivers/clk/ti/composite.c | 2 +- drivers/clk/ti/divider.c | 6 +- drivers/clk/ti/dpll.c | 8 +- drivers/clk/ti/fixed-factor.c | 2 +- drivers/clk/ti/gate.c | 2 +- drivers/clk/ti/interface.c | 2 +- drivers/clk/ti/mux.c | 6 +- drivers/clk/ux500/abx500-clk.c | 2 +- drivers/clk/ux500/clk-prcc.c | 8 +- drivers/clk/ux500/clk-prcmu.c | 16 +- drivers/clk/ux500/clk-sysctrl.c | 10 +- drivers/clk/ux500/clk.h | 22 +- drivers/clk/ux500/u8500_clk.c | 2 +- drivers/clk/ux500/u8500_of_clk.c | 12 +- drivers/clk/ux500/u8540_clk.c | 2 +- drivers/clk/versatile/clk-icst.c | 4 +- drivers/clk/versatile/clk-icst.h | 2 +- drivers/clk/versatile/clk-impd1.c | 18 +- drivers/clk/versatile/clk-realview.c | 2 +- drivers/clk/versatile/clk-sp810.c | 30 ++- drivers/clk/versatile/clk-versatile.c | 2 +- drivers/clk/versatile/clk-vexpress-osc.c | 2 +- drivers/clk/versatile/clk-vexpress.c | 6 +- drivers/clk/x86/clk-lpt.c | 2 +- drivers/clk/zynq/clkc.c | 22 +- drivers/clk/zynq/pll.c | 4 +- drivers/gpu/drm/msm/hdmi/hdmi_phy_8960.c | 2 +- drivers/media/platform/exynos4-is/media-dev.c | 16 +- drivers/media/platform/exynos4-is/media-dev.h | 6 +- drivers/staging/imx-drm/imx-tve.c | 26 +- include/asm-generic/clkdev.h | 4 +- include/linux/clk/ti.h | 10 +- include/linux/clk/zynq.h | 2 +- include/linux/platform_data/si5351.h | 4 +- 246 files changed, 1433 insertions(+), 1381 deletions(-)
arch/arm/mach-dove/common.c +5 -5
@@ -71,9 +71,9 @@ void __init dove_map_io(void)static int dove_tclk;static DEFINE_SPINLOCK (gating_lock); -static struct clk *tclk; +static struct clk_core *tclk; -static struct clk __init *dove_register_gate (const char *name, +static struct clk_core __init *dove_register_gate (const char *name,const char *parent,u8 bit_idx) { return clk_register_gate(NULL, name, parent, 0,
@@ -83,9 +83,9 @@ static struct clk __init *dove_register_gate(const char *name,static void __init dove_clk_init (void ) { -struct clk *usb0, *usb1, *sata, *pex0, *pex1, *sdio0, *sdio1; -struct clk *nand, *camera, *i2s0, *i2s1, *crypto, *ac97, *pdma; -struct clk *xor0, *xor1, *ge, *gephy; +struct clk_core *usb0, *usb1, *sata, *pex0, *pex1, *sdio0, *sdio1; +struct clk_core *nand, *camera, *i2s0, *i2s1, *crypto, *ac97, *pdma; +struct clk_core *xor0, *xor1, *ge, *gephy; tclk =clk_register_fixed_rate (NULL ,"tclk" ,NULL ,CLK_IS_ROOT , dove_tclk);
arch/arm/mach-imx/clk-busy.c +4 -4
@@ -78,12 +78,12 @@ static struct clk_ops clk_busy_divider_ops = { .set_rate = clk_busy_divider_set_rate, }; -struct clk *imx_clk_busy_divider (const char *name,const char *parent_name, +struct clk_core *imx_clk_busy_divider (const char *name,const char *parent_name,void __iomem *reg,u8 shift,u8 width,void __iomem *busy_reg,u8 busy_shift) {struct clk_busy_divider *busy; -struct clk *clk; +struct clk_core *clk;struct clk_init_data init; busy =kzalloc (sizeof (*busy),GFP_KERNEL );
@@ -152,12 +152,12 @@ static struct clk_ops clk_busy_mux_ops = { .set_parent = clk_busy_mux_set_parent, }; -struct clk *imx_clk_busy_mux (const char *name,void __iomem *reg,u8 shift, +struct clk_core *imx_clk_busy_mux (const char *name,void __iomem *reg,u8 shift,u8 width,void __iomem *busy_reg,u8 busy_shift,const char **parent_names,int num_parents) {struct clk_busy_mux *busy; -struct clk *clk; +struct clk_core *clk;struct clk_init_data init; busy =kzalloc (sizeof (*busy),GFP_KERNEL );
arch/arm/mach-imx/clk-fixup-div.c +2 -2
@@ -92,12 +92,12 @@ static const struct clk_ops clk_fixup_div_ops = { .set_rate = clk_fixup_div_set_rate, }; -struct clk *imx_clk_fixup_divider (const char *name,const char *parent, +struct clk_core *imx_clk_fixup_divider (const char *name,const char *parent,void __iomem *reg,u8 shift,u8 width,void (*fixup)(u32 *val)) {struct clk_fixup_div *fixup_div; -struct clk *clk; +struct clk_core *clk;struct clk_init_data init;if (!fixup)
arch/arm/mach-imx/clk-fixup-mux.c +2 -2
@@ -71,12 +71,12 @@ static const struct clk_ops clk_fixup_mux_ops = { .set_parent = clk_fixup_mux_set_parent, }; -struct clk *imx_clk_fixup_mux (const char *name,void __iomem *reg, +struct clk_core *imx_clk_fixup_mux (const char *name,void __iomem *reg,u8 shift,u8 width,const char **parents,int num_parents,void (*fixup)(u32 *val)) {struct clk_fixup_mux *fixup_mux; -struct clk *clk; +struct clk_core *clk;struct clk_init_data init;if (!fixup)
arch/arm/mach-imx/clk-gate2.c +2 -2
@@ -108,14 +108,14 @@ static struct clk_ops clk_gate2_ops = { .is_enabled = clk_gate2_is_enabled, }; -struct clk *clk_register_gate2 (struct device *dev,const char *name, +struct clk_core *clk_register_gate2 (struct device *dev,const char *name,const char *parent_name,unsigned long flags,void __iomem *reg,u8 bit_idx,u8 clk_gate2_flags,spinlock_t *lock,unsigned int *share_count) {struct clk_gate2 *gate; -struct clk *clk; +struct clk_core *clk;struct clk_init_data init; gate =kzalloc (sizeof (struct clk_gate2 ),GFP_KERNEL );
arch/arm/mach-imx/clk-imx1.c +1 -1
@@ -32,7 +32,7 @@ static const char *prem_sel_clks[] = { "clk32_premult", "clk16m", };static const char *clko_sel_clks[] = {"per1" ,"hclk" ,"clk48m" ,"clk16m" ,"prem" ,"fclk" , }; -static struct clk *clk[IMX1_CLK_MAX ]; +static struct clk_core *clk[IMX1_CLK_MAX ];static struct clk_onecell_data clk_data;static void __iomem *ccm__initdata ;
arch/arm/mach-imx/clk-imx21.c +1 -1
@@ -36,7 +36,7 @@ static const char *mpll_sel_clks[] = { "fpm_gate", "mpll_osc_sel", };static const char *spll_sel_clks[] = {"fpm_gate" ,"mpll_osc_sel" , };static const char *ssi_sel_clks[] = {"spll_gate" ,"mpll_gate" , }; -static struct clk *clk[IMX21_CLK_MAX ]; +static struct clk_core *clk[IMX21_CLK_MAX ];static struct clk_onecell_data clk_data;static void __init _mx21_clocks_init (unsigned long lref,unsigned long href)
arch/arm/mach-imx/clk-imx25.c +4 -4
@@ -87,7 +87,7 @@ enum mx25_clks { wdt_ipg, cko_div, cko_sel, cko, clk_max }; -static struct clk *clk[clk_max]; +static struct clk_core *clk[clk_max];static int __init __mx25_clocks_init (unsigned long osc_rate,void __iomem *ccm_base)
@@ -225,16 +225,16 @@ static int __init __mx25_clocks_init(unsigned long osc_rate,imx_check_clocks (clk,ARRAY_SIZE (clk)); -clk_prepare_enable (clk[emi_ahb]); +clk_provider_prepare_enable (clk[emi_ahb]);/* Clock source for gpt must be derived from AHB */ -clk_set_parent (clk[per5_sel], clk[ahb]); +clk_provider_set_parent (clk[per5_sel], clk[ahb]);/* * Let's initially set up CLKO parent as ipg, since this configuration * is used on some imx25 board designs to clock the audio codec. */ -clk_set_parent (clk[cko_sel], clk[ipg]); +clk_provider_set_parent (clk[cko_sel], clk[ipg]);return 0 ; }
arch/arm/mach-imx/clk-imx27.c +2 -2
@@ -39,7 +39,7 @@ static const char *clko_sel_clks[] = {static const char *ssi_sel_clks[] = {"spll_gate" ,"mpll" , }; -static struct clk *clk[IMX27_CLK_MAX ]; +static struct clk_core *clk[IMX27_CLK_MAX ];static struct clk_onecell_data clk_data;static void __init _mx27_clocks_init (unsigned long fref)
@@ -156,7 +156,7 @@ static void __init _mx27_clocks_init(unsigned long fref)clk_register_clkdev (clk[IMX27_CLK_CPU_DIV ],NULL ,"cpu0" ); -clk_prepare_enable (clk[IMX27_CLK_EMI_AHB_GATE ]); +clk_provider_prepare_enable (clk[IMX27_CLK_EMI_AHB_GATE ]);imx_print_silicon_rev ("i.MX27" ,mx27_revision ()); }
arch/arm/mach-imx/clk-imx31.c +5 -5
@@ -45,7 +45,7 @@ enum mx31_clks { gacc_gate, emi_gate, rtic_gate, firi_gate, clk_max }; -static struct clk *clk[clk_max]; +static struct clk_core *clk[clk_max];static struct clk_onecell_data clk_data;int __init mx31_clocks_init (unsigned long fref)
@@ -176,11 +176,11 @@ int __init mx31_clocks_init(unsigned long fref)clk_register_clkdev (clk[sdma_gate],NULL ,"imx31-sdma" );clk_register_clkdev (clk[iim_gate],"iim" ,NULL ); -clk_set_parent (clk[csi], clk[upll]); -clk_prepare_enable (clk[emi_gate]); -clk_prepare_enable (clk[iim_gate]); +clk_provider_set_parent (clk[csi], clk[upll]); +clk_provider_prepare_enable (clk[emi_gate]); +clk_provider_prepare_enable (clk[iim_gate]);mx31_revision (); -clk_disable_unprepare (clk[iim_gate]); +clk_provider_disable_unprepare (clk[iim_gate]);mxc_timer_init (MX31_IO_ADDRESS (MX31_GPT1_BASE_ADDR ),MX31_INT_GPT );
arch/arm/mach-imx/clk-imx35.c +11 -11
@@ -67,7 +67,7 @@ enum mx35_clks { gpu2d_gate, clk_max }; -static struct clk *clk[clk_max]; +static struct clk_core *clk[clk_max];int __init mx35_clocks_init (void ) {
@@ -99,7 +99,7 @@ int __init mx35_clocks_init(void)else clk[arm] =imx_clk_fixed_factor ("arm" ,"mpll" ,1 , aad->arm); -if (clk_get_rate (clk[arm]) >400000000 ) +if (clk_provider_get_rate (clk[arm]) >400000000 ) hsp_div = hsp_div_532;else hsp_div = hsp_div_400;
@@ -257,14 +257,14 @@ int __init mx35_clocks_init(void)clk_register_clkdev (clk[csi_gate],NULL ,"mx3-camera.0" );clk_register_clkdev (clk[admux_gate],"audmux" ,NULL ); -clk_prepare_enable (clk[spba_gate]); -clk_prepare_enable (clk[gpio1_gate]); -clk_prepare_enable (clk[gpio2_gate]); -clk_prepare_enable (clk[gpio3_gate]); -clk_prepare_enable (clk[iim_gate]); -clk_prepare_enable (clk[emi_gate]); -clk_prepare_enable (clk[max_gate]); -clk_prepare_enable (clk[iomuxc_gate]); +clk_provider_prepare_enable (clk[spba_gate]); +clk_provider_prepare_enable (clk[gpio1_gate]); +clk_provider_prepare_enable (clk[gpio2_gate]); +clk_provider_prepare_enable (clk[gpio3_gate]); +clk_provider_prepare_enable (clk[iim_gate]); +clk_provider_prepare_enable (clk[emi_gate]); +clk_provider_prepare_enable (clk[max_gate]); +clk_provider_prepare_enable (clk[iomuxc_gate]);/* * SCC is needed to boot via mmc after a watchdog reset. The clock code
@@ -272,7 +272,7 @@ int __init mx35_clocks_init(void)* handled here and not needed for mmc) and IIM (which is enabled * unconditionally above). */ -clk_prepare_enable (clk[scc_gate]); +clk_provider_prepare_enable (clk[scc_gate]);imx_print_silicon_rev ("i.MX35" ,mx35_revision ());
arch/arm/mach-imx/clk-imx51-imx53.c +40 -37
120 lines not on this page · raw message
arch/arm/mach-imx/clk-imx6q.c +34 -19
91 lines not on this page · raw message
arch/arm/mach-imx/clk-imx6sl.c +11 -10
@@ -80,7 +80,7 @@ static struct clk_div_table video_div_table[] = { { } }; -static struct clk *clks[IMX6SL_CLK_END ]; +static struct clk_core *clks[IMX6SL_CLK_END ];static struct clk_onecell_data clk_data;static void __iomem *ccm_base;static void __iomem *anatop_base;
@@ -356,7 +356,7 @@ static void __init imx6sl_clocks_init(struct device_node *ccm_node)of_clk_add_provider (np, of_clk_src_onecell_get, &clk_data);/* Ensure the AHB clk is at 132MHz. */ - ret =clk_set_rate (clks[IMX6SL_CLK_AHB ],132000000 ); + ret =clk_provider_set_rate (clks[IMX6SL_CLK_AHB ],132000000 );if (ret)pr_warn ("%s: failed to set AHB clock rate %d!\n" , __func__, ret);
@@ -366,22 +366,23 @@ static void __init imx6sl_clocks_init(struct device_node *ccm_node)* usecount and enabling/disabling of parent PLLs. */ for (i =0 ; i <ARRAY_SIZE (clks_init_on); i++) -clk_prepare_enable (clks[clks_init_on[i]]); +clk_provider_prepare_enable (clks[clks_init_on[i]]);if (IS_ENABLED (CONFIG_USB_MXS_PHY )) { -clk_prepare_enable (clks[IMX6SL_CLK_USBPHY1_GATE ]); -clk_prepare_enable (clks[IMX6SL_CLK_USBPHY2_GATE ]); +clk_provider_prepare_enable (clks[IMX6SL_CLK_USBPHY1_GATE ]); +clk_provider_prepare_enable (clks[IMX6SL_CLK_USBPHY2_GATE ]); }/* Audio-related clocks configuration */ -clk_set_parent (clks[IMX6SL_CLK_SPDIF0_SEL ], clks[IMX6SL_CLK_PLL3_PFD3 ]); +clk_provider_set_parent (clks[IMX6SL_CLK_SPDIF0_SEL ], + clks[IMX6SL_CLK_PLL3_PFD3 ]);/* set PLL5 video as lcdif pix parent clock */ -clk_set_parent (clks[IMX6SL_CLK_LCDIF_PIX_SEL ], - clks[IMX6SL_CLK_PLL5_VIDEO_DIV ]); +clk_provider_set_parent (clks[IMX6SL_CLK_LCDIF_PIX_SEL ], + clks[IMX6SL_CLK_PLL5_VIDEO_DIV ]); -clk_set_parent (clks[IMX6SL_CLK_LCDIF_AXI_SEL ], - clks[IMX6SL_CLK_PLL2_PFD2 ]); +clk_provider_set_parent (clks[IMX6SL_CLK_LCDIF_AXI_SEL ], + clks[IMX6SL_CLK_PLL2_PFD2 ]);/* Set initial power mode */ imx6q_set_lpm (WAIT_CLOCKED );
arch/arm/mach-imx/clk-imx6sx.c +57 -40
141 lines not on this page · raw message
arch/arm/mach-imx/clk-pfd.c +2 -2
@@ -128,11 +128,11 @@ static const struct clk_ops clk_pfd_ops = { .is_enabled = clk_pfd_is_enabled, }; -struct clk *imx_clk_pfd (const char *name,const char *parent_name, +struct clk_core *imx_clk_pfd (const char *name,const char *parent_name,void __iomem *reg,u8 idx) {struct clk_pfd *pfd; -struct clk *clk; +struct clk_core *clk;struct clk_init_data init; pfd =kzalloc (sizeof (*pfd),GFP_KERNEL );
arch/arm/mach-imx/clk-pllv1.c +2 -2
@@ -97,11 +97,11 @@ static struct clk_ops clk_pllv1_ops = { .recalc_rate = clk_pllv1_recalc_rate, }; -struct clk *imx_clk_pllv1 (const char *name,const char *parent, +struct clk_core *imx_clk_pllv1 (const char *name,const char *parent,void __iomem *base) {struct clk_pllv1 *pll; -struct clk *clk; +struct clk_core *clk;struct clk_init_data init; pll =kmalloc (sizeof (*pll),GFP_KERNEL );
arch/arm/mach-imx/clk-pllv2.c +2 -2
@@ -237,11 +237,11 @@ static struct clk_ops clk_pllv2_ops = { .set_rate = clk_pllv2_set_rate, }; -struct clk *imx_clk_pllv2 (const char *name,const char *parent, +struct clk_core *imx_clk_pllv2 (const char *name,const char *parent,void __iomem *base) {struct clk_pllv2 *pll; -struct clk *clk; +struct clk_core *clk;struct clk_init_data init; pll =kzalloc (sizeof (*pll),GFP_KERNEL );
arch/arm/mach-imx/clk-pllv3.c +2 -2
@@ -320,13 +320,13 @@ static const struct clk_ops clk_pllv3_enet_ops = { .recalc_rate = clk_pllv3_enet_recalc_rate, }; -struct clk *imx_clk_pllv3 (enum imx_pllv3_type type,const char *name, +struct clk_core *imx_clk_pllv3 (enum imx_pllv3_type type,const char *name,const char *parent_name,void __iomem *base,u32 div_mask) {struct clk_pllv3 *pll;const struct clk_ops *ops; -struct clk *clk; +struct clk_core *clk;struct clk_init_data init; pll =kzalloc (sizeof (*pll),GFP_KERNEL );
arch/arm/mach-imx/clk-vf610.c +28 -16
58 lines not on this page · raw message
arch/arm/mach-imx/clk.c +5 -5
@@ -7,7 +7,7 @@DEFINE_SPINLOCK (imx_ccm_lock); -void __init imx_check_clocks (struct clk *clks[],unsigned int count) +void __init imx_check_clocks (struct clk_core *clks[],unsigned int count) {unsigned i;
@@ -17,10 +17,10 @@ void __init imx_check_clocks(struct clk *clks[], unsigned int count) i, PTR_ERR(clks[i])); } -static struct clk *__init imx_obtain_fixed_clock_from_dt (const char *name) +static struct clk_core *__init imx_obtain_fixed_clock_from_dt (const char *name) {struct of_phandle_args phandle; -struct clk *clk =ERR_PTR (-ENODEV ); +struct clk_core *clk =ERR_PTR (-ENODEV );char *path; path =kasprintf (GFP_KERNEL ,"/clocks/%s" , name);
@@ -37,10 +37,10 @@ static struct clk * __init imx_obtain_fixed_clock_from_dt(const char *name)return clk; } -struct clk *__init imx_obtain_fixed_clock ( +struct clk_core *__init imx_obtain_fixed_clock (const char *name,unsigned long rate) { -struct clk *clk; +struct clk_core *clk; clk =imx_obtain_fixed_clock_from_dt (name);if (IS_ERR (clk))
arch/arm/mach-imx/clk.h +21 -21
134 lines not on this page · raw message
arch/arm/mach-msm/clock-pcom.c +1 -1
@@ -132,7 +132,7 @@ static int msm_clock_pcom_probe(struct platform_device *pdev)for (i =0 ; i < pdata->num_lookups; i++) {const struct clk_pcom_desc *desc = &pdata->lookup[i]; -struct clk *c; +struct clk_core *c;struct clk_pcom *p;struct clk_hw *hw;struct clk_init_data init;
arch/arm/mach-mv78xx0/common.c +1 -1
@@ -164,7 +164,7 @@ void __init mv78xx0_map_io(void)/***************************************************************************** * CLK tree ****************************************************************************/ -static struct clk *tclk; +static struct clk_core *tclk;static void __init clk_init (void ) {
arch/arm/mach-omap2/cclock3xxx_data.c +185 -185
1,440 lines not on this page · raw message
arch/arm/mach-omap2/clkt2xxx_dpll.c +2 -2
@@ -22,7 +22,7 @@/** * _allow_idle - enable DPLL autoidle bits -* @clk: struct clk * of the DPLL to operate on +* @clk: struct clk_core * of the DPLL to operate on * * Enable DPLL automatic idle control. The DPLL will enter low-power * stop when its downstream clocks are gated. No return value.
@@ -39,7 +39,7 @@ static void _allow_idle(struct clk_hw_omap *clk)/** * _deny_idle - prevent DPLL from automatically idling -* @clk: struct clk * of the DPLL to operate on +* @clk: struct clk_core * of the DPLL to operate on * * Disable DPLL automatic idle control. No return value. */
arch/arm/mach-omap2/clkt2xxx_dpllcore.c +2 -2
@@ -48,7 +48,7 @@ static struct clk_hw_omap *dpll_core_ck;* Returns the CORE_CLK rate. CORE_CLK can have one of three rate * sources on OMAP2xxx: the DPLL CLKOUT rate, DPLL CLKOUTX2, or 32KHz * (the latter is unusual). This currently should be called with -* struct clk *dpll_ck, which is a composite clock of dpll_ck and +* struct clk_core *dpll_ck, which is a composite clock of dpll_ck and * core_ck. */ unsigned long omap2xxx_clk_get_core_rate (void )
@@ -179,7 +179,7 @@ int omap2_reprogram_dpllcore(struct clk_hw *hw, unsigned long rate,/** * omap2xxx_clkt_dpllcore_init - clk init function for dpll_ck -* @clk: struct clk *dpll_ck +* @clk: struct clk_core *dpll_ck * * Store a local copy of @clk in dpll_core_ck so other code can query * the core rate without having to clk_get(), which can sleep. Must
arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c +5 -5
@@ -198,14 +198,14 @@ void omap2xxx_clkt_vps_check_bootloader_rates(void)*/ void omap2xxx_clkt_vps_late_init (void ) { -struct clk *c; +struct clk_core *c; - c =clk_get (NULL ,"sys_ck" ); + c =clk_provider_get (NULL ,"sys_ck" );if (IS_ERR (c)) {WARN (1 ,"could not locate sys_ck\n" ); }else { - sys_ck_rate =clk_get_rate (c); -clk_put (c); + sys_ck_rate =clk_provider_get_rate (c); +__clk_put (c); } }
@@ -230,7 +230,7 @@ void omap2xxx_clkt_vps_init(void) {struct clk_init_data init = {NULL };struct clk_hw_omap *hw =NULL ; -struct clk *clk; +struct clk_core *clk;const char *parent_name ="mpu_ck" ;struct clk_lookup *lookup =NULL ;
arch/arm/mach-omap2/clkt34xx_dpll3m2.c +1 -1
@@ -38,7 +38,7 @@/** * omap3_core_dpll_m2_set_rate - set CORE DPLL M2 divider -* @clk: struct clk * of DPLL to set +* @clk: struct clk_core * of DPLL to set * @rate: rounded target rate * * Program the DPLL M2 divider with the rounded target rate. Returns
arch/arm/mach-omap2/clkt_clksel.c +23 -23
154 lines not on this page · raw message
arch/arm/mach-omap2/clkt_dpll.c +4 -4
@@ -56,7 +56,7 @@/* * _dpll_test_fint - test whether an Fint value is valid for the DPLL -* @clk: DPLL struct clk to test +* @clk: DPLL struct clk_core to test * @n: divider value (N) to test * * Tests whether a particular divider @n will result in a valid DPLL
@@ -215,7 +215,7 @@ u8 omap2_init_dpll_parent(struct clk_hw *hw) v &= dd->enable_mask; v >>=__ffs (dd->enable_mask); -/* Reparent the struct clk in case the dpll is in bypass */ +/* Reparent the struct clk_core in case the dpll is in bypass */ if (_omap2_dpll_is_in_bypass (v))return 1 ;
@@ -224,7 +224,7 @@ u8 omap2_init_dpll_parent(struct clk_hw *hw)/** * omap2_get_dpll_rate - returns the current DPLL CLKOUT rate -* @clk: struct clk * of a DPLL +* @clk: struct clk_core * of a DPLL * * DPLLs can be locked or bypassed - basically, enabled or disabled. * When locked, the DPLL output depends on the M and N values. When
@@ -270,7 +270,7 @@ unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk)/** * omap2_dpll_round_rate - round a target rate for an OMAP DPLL -* @clk: struct clk * for a DPLL +* @clk: struct clk_core * for a DPLL * @target_rate: desired DPLL clock rate * * Given a DPLL and a desired target rate, round the target rate to a
arch/arm/mach-omap2/clock.c +26 -26
160 lines not on this page · raw message
arch/arm/mach-omap2/clock.h +9 -9
@@ -40,7 +40,7 @@ struct omap_clk {struct clockdomain ;#define DEFINE_STRUCT_CLK (_name, _parent_array_name, _clkops_name) \ - static struct clk _name = { \ + static struct clk_core _name = { \ .name = #_name, \ .hw = &_name##_hw.hw, \ .parent_names = _parent_array_name, \
@@ -50,7 +50,7 @@ struct clockdomain;#define DEFINE_STRUCT_CLK_FLAGS (_name, _parent_array_name, \ _clkops_name, _flags) \ - static struct clk _name = { \ + static struct clk_core _name = { \ .name = #_name, \ .hw = &_name##_hw.hw, \ .parent_names = _parent_array_name, \
@@ -70,7 +70,7 @@ struct clockdomain;#define DEFINE_CLK_OMAP_MUX (_name, _clkdm_name, _clksel, \ _clksel_reg, _clksel_mask, \ _parent_names, _ops) \ - static struct clk _name; \ + static struct clk_core _name; \ static struct clk_hw_omap _name##_hw = { \ .hw = { \ .clk = &_name, \
@@ -86,7 +86,7 @@ struct clockdomain; _clksel_reg, _clksel_mask, \ _enable_reg, _enable_bit, \ _hwops, _parent_names, _ops) \ -static struct clk _name; \ +static struct clk_core _name; \ static struct clk_hw_omap _name##_hw = { \ .hw = { \ .clk = &_name, \
@@ -142,14 +142,14 @@ struct clksel_rate {/** * struct clksel - available parent clocks, and a pointer to their divisors -* @parent: struct clk * to a possible parent clock +* @parent: struct clk_core * to a possible parent clock * @rates: available divisors for this parent clock * * A struct clksel is always associated with one or more struct clks * and one or more struct clksel_rates. */ struct clksel { -struct clk *parent; +struct clk_core *parent;const struct clksel_rate *rates; };
@@ -208,8 +208,8 @@ void omap2_clk_dflt_find_idlest(struct clk_hw_omap *clk,void __iomem **idlest_reg, u8 *idlest_bit, u8 *idlest_val);int omap2_clk_enable_autoidle_all (void ); -int omap2_clk_allow_idle (struct clk *clk); -int omap2_clk_deny_idle (struct clk *clk); +int omap2_clk_allow_idle (struct clk_core *clk); +int omap2_clk_deny_idle (struct clk_core *clk);int omap2_clk_switch_mpurate_at_boot (const char *mpurate_ck_name); void omap2_clk_print_new_rates(const char *hfclkin_ck_name, const char *core_ck_name,
@@ -247,7 +247,7 @@ extern const struct clksel_rate gpt_32k_rates[];extern const struct clksel_rate gpt_sys_rates[];extern const struct clksel_rate gfx_l3_rates[];extern const struct clksel_rate dsp_ick_rates[]; -extern struct clk dummy_ck; +extern struct clk_core dummy_ck;extern const struct clk_hw_omap_ops clkhwops_iclk_wait;extern const struct clk_hw_omap_ops clkhwops_wait;
arch/arm/mach-omap2/clock3xxx.c +11 -11
@@ -37,7 +37,7 @@#define DPLL5_FREQ_FOR_USBHOST 120000000/* needed by omap3_core_dpll_m2_set_rate() */ -struct clk *sdrc_ick_p, *arm_fck_p; +struct clk_core *sdrc_ick_p, *arm_fck_p;int omap3_dpll4_set_rate (struct clk_hw *hw,unsigned long rate,unsigned long parent_rate) {
@@ -56,20 +56,20 @@ int omap3_dpll4_set_rate(struct clk_hw *hw, unsigned long rate,void __init omap3_clk_lock_dpll5 (void ) { -struct clk *dpll5_clk; -struct clk *dpll5_m2_clk; +struct clk_core *dpll5_clk; +struct clk_core *dpll5_m2_clk; - dpll5_clk =clk_get (NULL ,"dpll5_ck" ); -clk_set_rate (dpll5_clk,DPLL5_FREQ_FOR_USBHOST ); -clk_prepare_enable (dpll5_clk); + dpll5_clk =clk_provider_get (NULL ,"dpll5_ck" ); +clk_provider_set_rate (dpll5_clk,DPLL5_FREQ_FOR_USBHOST ); +clk_provider_prepare_enable (dpll5_clk);/* Program dpll5_m2_clk divider for no division */ - dpll5_m2_clk =clk_get (NULL ,"dpll5_m2_ck" ); -clk_prepare_enable (dpll5_m2_clk); -clk_set_rate (dpll5_m2_clk,DPLL5_FREQ_FOR_USBHOST ); + dpll5_m2_clk =clk_provider_get (NULL ,"dpll5_m2_ck" ); +clk_provider_prepare_enable (dpll5_m2_clk); +clk_provider_set_rate (dpll5_m2_clk,DPLL5_FREQ_FOR_USBHOST ); -clk_disable_unprepare (dpll5_m2_clk); -clk_disable_unprepare (dpll5_clk); +clk_provider_disable_unprepare (dpll5_m2_clk); +clk_provider_disable_unprepare (dpll5_clk);return ; }
arch/arm/mach-omap2/clock3xxx.h +2 -2
@@ -12,8 +12,8 @@ int omap3xxx_clk_init(void);int omap3_core_dpll_m2_set_rate (struct clk_hw *clk,unsigned long rate,unsigned long parent_rate); -extern struct clk *sdrc_ick_p; -extern struct clk *arm_fck_p; +extern struct clk_core *sdrc_ick_p; +extern struct clk_core *arm_fck_p;extern const struct clkops clkops_noncore_dpll_ops;
arch/arm/mach-omap2/clock_common_data.c +1 -1
@@ -119,7 +119,7 @@ const struct clksel_rate div31_1to31_rates[] = {static struct clk_ops dummy_ck_ops = {}; -struct clk dummy_ck = { +struct clk_core dummy_ck = { .name ="dummy_clk" , .ops = &dummy_ck_ops, .flags =CLK_IS_BASIC ,
arch/arm/mach-omap2/clockdomain.c +4 -4
@@ -1141,7 +1141,7 @@ static int _clkdm_clk_hwmod_enable(struct clockdomain *clkdm)/** * clkdm_clk_enable - add an enabled downstream clock to this clkdm * @clkdm: struct clockdomain * -* @clk: struct clk * of the enabled downstream clock +* @clk: struct clk_core * of the enabled downstream clock * * Increment the usecount of the clockdomain @clkdm and ensure that it * is awake before @clk is enabled. Intended to be called by
@@ -1152,7 +1152,7 @@ static int _clkdm_clk_hwmod_enable(struct clockdomain *clkdm)* by on-chip processors. Returns -EINVAL if passed null pointers; * returns 0 upon success or if the clockdomain is in hwsup idle mode. */ -int clkdm_clk_enable (struct clockdomain *clkdm,struct clk *clk) +int clkdm_clk_enable (struct clockdomain *clkdm,struct clk_core *clk) {/* * XXX Rewrite this code to maintain a list of enabled
@@ -1168,7 +1168,7 @@ int clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk)/** * clkdm_clk_disable - remove an enabled downstream clock from this clkdm * @clkdm: struct clockdomain * -* @clk: struct clk * of the disabled downstream clock +* @clk: struct clk_core * of the disabled downstream clock * * Decrement the usecount of this clockdomain @clkdm when @clk is * disabled. Intended to be called by clk_disable() code. If the
@@ -1178,7 +1178,7 @@ int clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk)* pointers; -ERANGE if the @clkdm usecount underflows; or returns 0 * upon success or if the clockdomain is in hwsup idle mode. */ -int clkdm_clk_disable (struct clockdomain *clkdm,struct clk *clk) +int clkdm_clk_disable (struct clockdomain *clkdm,struct clk_core *clk) {if (!clkdm || !clk || !arch_clkdm || !arch_clkdm->clkdm_clk_disable)return -EINVAL ;
arch/arm/mach-omap2/clockdomain.h +2 -2
@@ -207,8 +207,8 @@ int clkdm_wakeup(struct clockdomain *clkdm);int clkdm_sleep_nolock (struct clockdomain *clkdm);int clkdm_sleep (struct clockdomain *clkdm); -int clkdm_clk_enable (struct clockdomain *clkdm,struct clk *clk); -int clkdm_clk_disable (struct clockdomain *clkdm,struct clk *clk); +int clkdm_clk_enable (struct clockdomain *clkdm,struct clk_core *clk); +int clkdm_clk_disable (struct clockdomain *clkdm,struct clk_core *clk);int clkdm_hwmod_enable (struct clockdomain *clkdm,struct omap_hwmod *oh);int clkdm_hwmod_disable (struct clockdomain *clkdm,struct omap_hwmod *oh);
arch/arm/mach-omap2/display.c +2 -2
@@ -524,7 +524,7 @@ int omap_dss_reset(struct omap_hwmod *oh)for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i >0 ; i--, oc++)if (oc->_clk) -clk_prepare_enable (oc->_clk); +clk_provider_prepare_enable (oc->_clk);dispc_disable_outputs ();
@@ -551,7 +551,7 @@ int omap_dss_reset(struct omap_hwmod *oh)for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i >0 ; i--, oc++)if (oc->_clk) -clk_disable_unprepare (oc->_clk); +clk_provider_disable_unprepare (oc->_clk); r = (c ==MAX_MODULE_SOFTRESET_WAIT ) ? -ETIMEDOUT :0 ;
arch/arm/mach-omap2/dpll3xxx.c +14 -14
@@ -288,7 +288,7 @@ static void _lookup_sddiv(struct clk_hw_omap *clk, u8 *sd_div, u16 m, u8 n)/* * _omap3_noncore_dpll_program - set non-core DPLL M,N values directly -* @clk: struct clk * of DPLL to set +* @clk: struct clk_core * of DPLL to set * @freqsel: FREQSEL value to set * * Program the DPLL with the last M, N values calculated, and wait for
@@ -410,7 +410,7 @@ int omap3_noncore_dpll_enable(struct clk_hw *hw)struct clk_hw_omap *clk =to_clk_hw_omap (hw);int r;struct dpll_data *dd; -struct clk *parent; +struct clk_core *parent; dd = clk->dpll_data;if (!dd)
@@ -461,7 +461,7 @@ void omap3_noncore_dpll_disable(struct clk_hw *hw)/** * omap3_noncore_dpll_set_rate - set non-core DPLL rate -* @clk: struct clk * of DPLL to set +* @clk: struct clk_core * of DPLL to set * @rate: rounded target rate * * Set the DPLL CLKOUT to the target rate. If the DPLL can enter
@@ -474,7 +474,7 @@ int omap3_noncore_dpll_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) {struct clk_hw_omap *clk =to_clk_hw_omap (hw); -struct clk *new_parent =NULL ; +struct clk_core *new_parent =NULL ;unsigned long rrate;u16 freqsel =0 ;struct dpll_data *dd;
@@ -493,15 +493,15 @@ int omap3_noncore_dpll_set_rate(struct clk_hw *hw, unsigned long rate, __func__, __clk_get_name(hw->clk));__clk_prepare (dd->clk_bypass); -clk_enable (dd->clk_bypass); +clk_provider_enable (dd->clk_bypass); ret =_omap3_noncore_dpll_bypass (clk);if (!ret) new_parent = dd->clk_bypass; -clk_disable (dd->clk_bypass); +clk_provider_disable (dd->clk_bypass);__clk_unprepare (dd->clk_bypass); }else {__clk_prepare (dd->clk_ref); -clk_enable (dd->clk_ref); +clk_provider_enable (dd->clk_ref);/* XXX this check is probably pointless in the CCF context */ if (dd->last_rounded_rate != rate) {
@@ -530,7 +530,7 @@ int omap3_noncore_dpll_set_rate(struct clk_hw *hw, unsigned long rate, ret =omap3_noncore_dpll_program (clk, freqsel);if (!ret)
Lines of this file are not shown. View the raw message.
arch/arm/mach-omap2/omap_hwmod.c +21 -21
42 lines not on this page · raw message
arch/arm/plat-orion/include/plat/common.h +6 -6
Lines of this file are not shown. View the raw message.
arch/powerpc/platforms/512x/clock-commonclk.c +24 -24
48 lines not on this page · raw message
drivers/clk/hisilicon/clkgate-separated.c +2 -2
Lines of this file are not shown. View the raw message.
drivers/clk/samsung/clk-exynos-clkout.c +4 -4
Lines of this file are not shown. View the raw message.
drivers/clk/samsung/clk-s3c2410-dclk.c +15 -15
Lines of this file are not shown. View the raw message.
drivers/clk/sunxi/clk-sun6i-apb0-gates.c +1 -1
Lines of this file are not shown. View the raw message.
drivers/clk/tegra/clk-tegra-super-gen4.c +4 -4
Lines of this file are not shown. View the raw message.
drivers/clk/versatile/clk-vexpress-osc.c +1 -1
Lines of this file are not shown. View the raw message.
drivers/gpu/drm/msm/hdmi/hdmi_phy_8960.c +1 -1
Lines of this file are not shown. View the raw message.
drivers/media/platform/exynos4-is/media-dev.c +8 -8
Lines of this file are not shown. View the raw message.
drivers/media/platform/exynos4-is/media-dev.h +3 -3
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 6 lines
1.9.3 _______________________________________________ Linuxppc-dev mailing list [email protected] https://lists.ozlabs.org/listinfo/linuxppc-dev
Part of the diff is not shown here. View the raw message.
Re: [PATCH v8 3/7] clk: Move all drivers to use internal API
Quoted 11 lines · Tomeu Vizoso
In preparation to change the public API to return a per-user clk structure, remove any usage of this public API from the clock implementations.
The reason for having this in a separate commit from the one that introduces the implementation of the new functions is to separate the changes generated with Coccinelle from the rest, and keep the patches' size reasonable.
Signed-off-by Tomeu Vizoso <[email protected]>Tested-by Boris Brezillon <[email protected]>Tested-by Heiko Stuebner <[email protected]>Acked-by Boris Brezillon <[email protected]>
Hi Tomeu,
Huh, what a patch. :-) Great work you are doing here!
By just looking at the ux500 changes, I realize that you now have removed the dependency to "struct clk", thus we shouldn't include the header file linux/clk.h in any file located in driver/clk/ux500/*, right!?
I suppose this comment may also applicable for others than the ux500 clk driver, but haven't checked.
Kind regards
Uffe
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v8 3/7] clk: Move all drivers to use internal API
Quoted 8 lines · Ulf Hansson
Quoted 7 lines · Tomeu Vizoso
In preparation to change the public API to return a per-user clk structure, remove any usage of this public API from the clock implementations.
The reason for having this in a separate commit from the one that introduces the implementation of the new functions is to separate the changes generated with Coccinelle from the rest, and keep the patches' size reasonable.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Tomeu Vizoso <[email protected]>Tested-by Boris Brezillon <[email protected]>Tested-by Heiko Stuebner <[email protected]>Acked-by Boris Brezillon <[email protected]>Hi Tomeu,
Huh, what a patch. :-) Great work you are doing here!
Thanks!
Quoted 7 lines
By just looking at the ux500 changes, I realize that you now have removed the dependency to "struct clk", thus we shouldn't include the header file
linux/clk.hin any file located in driver/clk/ux500/*, right!?I suppose this comment may also applicable for others than the ux500 clk driver, but haven't checked.
You are right. I have gone ahead and removed the include from all files that are fed to the coccinelle script. Everything builds fine in all configurations I have tested, so I will be adding it to v9.
Thanks for the idea,
Tomeu
Quoted 3 lines
Kind regards
Uffe
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
PATCH v8 4/7 clk: use struct clk only for external API
In reply to Tomeu VizosoIn order to provide per-user accounting, this separates the struct clk used in the common clock framework into two structures 'struct clk_core' and 'struct clk'. struct clk_core will be used for internal manipulation and struct clk will be used in the clock API implementation.
In this patch, struct clk is simply renamed to struct clk_core and a new struct clk is implemented which simply wraps it. In the next patch, the new struct clk will be used to implement per-user clock enable accounting.
Based on previous work by Rabin Vincent <[email protected]>.
NOTE: with this patch, clk_get_parent() behaves like clk_get(), i.e. it needs to be matched with a clk_put(). Otherwise, memory will leak.
---
v7: * convert clk_is_enabled to clk_core
* add clk_provider_notifier_[un]register
v4: * export clk_to_clk_core so mach-msm can use it for clk_reset
* add clk_provider_round_rate, for mach-imx
* fix build with !CONFIG_COMMON_CLK
* keep handling NULL struct clk gracefully as before
v3: * Allocate and release the per-user struct clk
* Have clk_core_to_clk return any error it's passed, so calls to it can be chained
* Add provider API for enable and disable
* Remove clk_free_clk for now
* Have clk_to_clk_core be an inline function to benefit of type-checking
* Have devres wrap the clk struct instead of clk_core
* Rename clk_core_to_clk to __clk_create_clk to make more clear that it allocates
--- arch/arm/mach-msm/clock.c | 2 +- drivers/clk/clk-devres.c | 31 ++ drivers/clk/clk.c | 669 ++++++++++++++++++++++++++----------------- drivers/clk/clk.h | 6 + drivers/clk/clkdev.c | 125 ++++++-- include/linux/clk-private.h | 38 +-- include/linux/clk-provider.h | 162 ++++++----- include/linux/clk.h | 32 ++- include/linux/clkdev.h | 24 +- 9 files changed, 703 insertions(+), 386 deletions(-)
arch/arm/mach-msm/clock.c +1 -1
@@ -21,7 +21,7 @@int clk_reset (struct clk *clk,enum clk_reset_action action) { -struct clk_hw *hw =__clk_get_hw (clk); +struct clk_hw *hw =__clk_get_hw (clk_to_clk_core (clk));struct msm_clk *m =to_msm_clk (hw);return m->reset (hw, action); }
drivers/clk/clk-devres.c +31 -0
@@ -5,10 +5,14 @@*/ #include <linux/clk.h> +#include <linux/clkdev.h> +#include <linux/clk-provider.h> #include <linux/device.h> #include <linux/export.h> #include <linux/gfp.h> +#include "clk.h" +static void devm_clk_release (struct device *dev,void *res) {clk_put (*(struct clk **)res);
@@ -34,6 +38,33 @@ struct clk *devm_clk_get(struct device *dev, const char *id) }EXPORT_SYMBOL (devm_clk_get); +#if defined(CONFIG_COMMON_CLK ) +static void devm_clk_core_release (struct device *dev,void *res) +{ +__clk_put (*(struct clk_core **)res); +} + +struct clk_core *devm_clk_provider_get (struct device *dev,const char *id) +{ +struct clk_core **ptr, *clk; + + ptr =devres_alloc (devm_clk_core_release,sizeof (*ptr),GFP_KERNEL ); +if (!ptr) +return ERR_PTR (-ENOMEM ); + + clk =clk_provider_get (dev, id); +if (!IS_ERR (clk)) { + *ptr = clk; +devres_add (dev, ptr); + }else { +devres_free (ptr); + } + +return clk; +} +EXPORT_SYMBOL (devm_clk_provider_get); +#endif +static int devm_clk_match (struct device *dev,void *res,void *data) {struct clk **c = res;
drivers/clk/clk.c +407 -262
1,367 lines not on this page · raw message
drivers/clk/clk.h +6 -0
@@ -9,9 +9,15 @@* published by the Free Software Foundation. */ +#include <linux/clk-private.h> +#if defined(CONFIG_OF ) && defined(CONFIG_COMMON_CLK )struct clk_core *of_clk_get_by_clkspec (struct of_phandle_args *clkspec);struct clk_core *__of_clk_get_from_provider (struct of_phandle_args *clkspec);void of_clk_lock (void );void of_clk_unlock (void );#endif + +#if defined(CONFIG_COMMON_CLK ) +struct clk *__clk_create_clk (struct clk_core *clk_core); +#endif
drivers/clk/clkdev.c +100 -25
248 lines not on this page · raw message
include/linux/clk-private.h +21 -17
@@ -28,20 +28,20 @@struct module ; -struct clk { +struct clk_core {const char *name;const struct clk_ops *ops;struct clk_hw *hw;struct module *owner; -struct clk *parent; +struct clk_core *parent;const char **parent_names; -struct clk **parents; +struct clk_core **parents;u8 num_parents;u8 new_parent_index;unsigned long rate;unsigned long new_rate; -struct clk *new_parent; -struct clk *new_child; +struct clk_core *new_parent; +struct clk_core *new_child;unsigned long flags;unsigned int enable_count;unsigned int prepare_count;
@@ -55,6 +55,10 @@ struct clk {struct kref ref; }; +struct clk { +struct clk_core *core; +}; +/* * DOC: Basic clock implementations common to many platforms *
@@ -66,7 +70,7 @@ struct clk {#define DEFINE_CLK (_name, _ops, _flags, _parent_names, \ _parents) \ - static struct clk _name = { \ + static struct clk_core _name = { \ .name = #_name, \ .ops = &_ops, \ .hw = &_name##_hw.hw, \
@@ -78,7 +82,7 @@ struct clk {#define DEFINE_CLK_FIXED_RATE (_name, _flags, _rate, \ _fixed_rate_flags) \ - static struct clk _name; \ + static struct clk_core _name; \ static const char *_name##_parent_names[] = {}; \ static struct clk_fixed_rate _name##_hw = { \ .hw = { \
@@ -93,11 +97,11 @@ struct clk {#define DEFINE_CLK_GATE (_name, _parent_name, _parent_ptr, \ _flags, _reg, _bit_idx, \ _gate_flags, _lock) \ - static struct clk _name; \ + static struct clk_core _name; \ static const char *_name##_parent_names[] = { \ _parent_name, \ }; \ - static struct clk *_name##_parents[] = { \ + static struct clk_core *_name##_parents[] = { \ _parent_ptr, \ }; \ static struct clk_gate _name##_hw = { \
@@ -115,11 +119,11 @@ struct clk {#define _DEFINE_CLK_DIVIDER (_name, _parent_name, _parent_ptr, \ _flags, _reg, _shift, _width, \ _divider_flags, _table, _lock) \ - static struct clk _name; \ + static struct clk_core _name; \ static const char *_name##_parent_names[] = { \ _parent_name, \ }; \ - static struct clk *_name##_parents[] = { \ + static struct clk_core *_name##_parents[] = { \ _parent_ptr, \ }; \ static struct clk_divider _name##_hw = { \
@@ -154,7 +158,7 @@ struct clk {#define DEFINE_CLK_MUX (_name, _parent_names, _parents, _flags, \ _reg, _shift, _width, \ _mux_flags, _lock) \ - static struct clk _name; \ + static struct clk_core _name; \ static struct clk_mux _name##_hw = { \ .hw = { \ .clk = &_name, \
@@ -171,11 +175,11 @@ struct clk {#define DEFINE_CLK_FIXED_FACTOR (_name, _parent_name, \ _parent_ptr, _flags, \ _mult, _div) \ - static struct clk _name; \ + static struct clk_core _name; \ static const char *_name##_parent_names[] = { \ _parent_name, \ }; \ - static struct clk *_name##_parents[] = { \ + static struct clk_core *_name##_parents[] = { \ _parent_ptr, \ }; \ static struct clk_fixed_factor _name##_hw = { \
@@ -196,7 +200,7 @@ struct clk {* Initializes the lists in struct clk, queries the hardware for the * parent and rate and sets them both. * -* Any struct clk passed into __clk_init must have the following members +* Any struct clk_core passed into __clk_init must have the following members * populated: * .name * .ops
@@ -210,9 +214,9 @@ struct clk {* * Returns 0 on success, otherwise an error code. */ -int __clk_init (struct device *dev,struct clk *clk); +int __clk_init (struct device *dev,struct clk_core *clk); -struct clk *__clk_register (struct device *dev,struct clk_hw *hw); +struct clk_core *__clk_register (struct device *dev,struct clk_hw *hw);#endif /* CONFIG_COMMON_CLK */ #endif /* CLK_PRIVATE_H */
include/linux/clk-provider.h +90 -72
306 lines not on this page · raw message
include/linux/clk.h +29 -3
@@ -22,6 +22,8 @@ struct clk;#ifdef CONFIG_COMMON_CLK +struct clk_core ; +/** * DOC: clk notifier callback types *
@@ -56,7 +58,7 @@ struct clk;* @notifier_head. */ struct clk_notifier { -struct clk *clk; +struct clk_core *clk;struct srcu_notifier_head notifier_head;struct list_head node; };
@@ -73,7 +75,7 @@ struct clk_notifier {* current rate (this was done to optimize the implementation). */ struct clk_notifier_data { -struct clk *clk; +struct clk_core *clk;unsigned long old_rate;unsigned long new_rate; };
@@ -307,6 +309,14 @@ struct clk *clk_get_parent(struct clk *clk);*/ struct clk *clk_get_sys (const char *dev_id,const char *con_id); +/** +* clk_get_name - get a clock's name +* @clk: clock source +* +* Returns the name of the provided clock. +*/ +const char *clk_get_name (struct clk *clk); +#else /* !CONFIG_HAVE_CLK */ static inline struct clk *clk_get (struct device *dev,const char *id)
@@ -398,7 +408,8 @@ struct of_phandle_args;#if defined(CONFIG_OF ) && defined(CONFIG_COMMON_CLK )struct clk *of_clk_get (struct device_node *np,int index);struct clk *of_clk_get_by_name (struct device_node *np,const char *name); -struct clk *of_clk_get_from_provider (struct of_phandle_args *clkspec); +struct clk_core *of_clk_provider_get_by_name (struct device_node *np,const char *name); +struct clk_core *of_clk_get_from_provider (struct of_phandle_args *clkspec);#else static inline struct clk *of_clk_get (struct device_node *np,int index) {
@@ -409,6 +420,21 @@ static inline struct clk *of_clk_get_by_name(struct device_node *np, {return ERR_PTR (-ENOENT ); } + +#if defined(CONFIG_COMMON_CLK ) +static inline struct clk_core *of_clk_provider_get_by_name (struct device_node *np, +const char *name) +{ +return ERR_PTR (-ENOENT ); +} +#else +static inline struct clk *of_clk_provider_get_by_name (struct device_node *np, +const char *name) +{ +return ERR_PTR (-ENOENT ); +} +#endif /* CONFIG_COMMON_CLK */ +#endif #endif
include/linux/clkdev.h +18 -6
@@ -17,11 +17,23 @@struct clk ;struct device ; +/* +* To avoid a mass-rename of all non-common clock implementations (spread out +* in arch-specific code), we let them use struct clk for both the internal and +* external view. +*/ +#ifdef CONFIG_COMMON_CLK +struct clk_core ; +#define clk_core_t struct clk_core +#else +#define clk_core_t struct clk +#endif +struct clk_lookup {struct list_head node;const char *dev_id;const char *con_id; -struct clk *clk; +clk_core_t *clk; };#define CLKDEV_INIT (d, n, c) \
@@ -31,7 +43,7 @@ struct clk_lookup { .clk = c, \ } -struct clk_lookup *clkdev_alloc (struct clk *clk,const char *con_id, +struct clk_lookup *clkdev_alloc (clk_core_t *clk,const char *con_id,const char *dev_fmt, ...);void clkdev_add (struct clk_lookup *cl);
@@ -40,12 +52,12 @@ void clkdev_drop(struct clk_lookup *cl);void clkdev_add_table (struct clk_lookup *,size_t );int clk_add_alias (const char *,const char *,char *,struct device *); -int clk_register_clkdev (struct clk *,const char *,const char *, ...); -int clk_register_clkdevs (struct clk *,struct clk_lookup *,size_t ); +int clk_register_clkdev (clk_core_t *,const char *,const char *, ...); +int clk_register_clkdevs (clk_core_t *,struct clk_lookup *,size_t );#ifdef CONFIG_COMMON_CLK -int __clk_get (struct clk *clk); -void __clk_put (struct clk *clk); +int __clk_get (struct clk_core *clk); +void __clk_put (struct clk_core *clk);#endif #endif
Signature · 1 line
1.9.3
PATCH v8 5/7 clk: per-user clock accounting for debug
When a clock has multiple users, the WARNING on imbalance of enable/disable may not show the guilty party since although they may have commited the error earlier, the warning is emitted later when some other user, presumably innocent, disables the clock.
Provide per-user clock enable/disable accounting and disabler tracking in order to help debug these problems.
Based on previous work by Rabin Vincent <[email protected]>.
--- drivers/clk/clk.c | 38 ++++++++++++++++++++++++++++++++++---- drivers/clk/clk.h | 3 ++- drivers/clk/clkdev.c | 12 ++++++++---- include/linux/clk-private.h | 5 +++++ 4 files changed, 49 insertions(+), 9 deletions(-)
drivers/clk/clk.c +34 -4
@@ -543,7 +543,8 @@ static int clk_disable_unused(void) }late_initcall_sync (clk_disable_unused); -struct clk *__clk_create_clk (struct clk_core *clk_core) +struct clk *__clk_create_clk (struct clk_core *clk_core,const char *dev, +const char *con) {struct clk *clk;
@@ -556,6 +557,8 @@ struct clk *__clk_create_clk(struct clk_core *clk_core)return ERR_PTR (-ENOMEM ); clk->core = clk_core; + clk->dev_id = dev; + clk->con_id = con;return clk; }
@@ -936,10 +939,25 @@ EXPORT_SYMBOL_GPL(clk_provider_disable);*/ void clk_disable (struct clk *clk_user) { +struct clk_core *clk; +unsigned long flags; +if (IS_ERR_OR_NULL (clk_user))return ; -clk_provider_disable (clk_to_clk_core (clk_user)); + clk =clk_to_clk_core (clk_user); + + flags =clk_enable_lock (); +if (!WARN (clk_user->enable_count ==0 , +"incorrect disable clk dev %s con %s last disabler %pF\n" , + clk_user->dev_id, clk_user->con_id, clk_user->last_disable)) { + + clk_user->last_disable =__builtin_return_address (0 ); + clk_user->enable_count--; + +__clk_disable (clk); + } +clk_enable_unlock (flags); }EXPORT_SYMBOL_GPL (clk_disable);
@@ -1000,10 +1018,22 @@ EXPORT_SYMBOL_GPL(clk_provider_enable);*/ int clk_enable (struct clk *clk_user) { +struct clk_core *clk; +unsigned long flags; +int ret; +if (!clk_user)return 0 ; -return clk_provider_enable (clk_to_clk_core (clk_user)); + clk =clk_to_clk_core (clk_user); + + flags =clk_enable_lock (); + ret =__clk_enable (clk); +if (!ret) + clk_user->enable_count++; +clk_enable_unlock (flags); + +return ret; }EXPORT_SYMBOL_GPL (clk_enable);
@@ -1698,7 +1728,7 @@ struct clk *clk_get_parent(struct clk *clk_user) clk =clk_to_clk_core (clk_user); parent =clk_provider_get_parent (clk); -return __clk_create_clk (parent); +return __clk_create_clk (parent, clk_user->dev_id, clk_user->con_id); }EXPORT_SYMBOL_GPL (clk_get_parent);
drivers/clk/clk.h +2 -1
@@ -19,5 +19,6 @@ void of_clk_unlock(void);#endif #if defined(CONFIG_COMMON_CLK ) -struct clk *__clk_create_clk (struct clk_core *clk_core); +struct clk *__clk_create_clk (struct clk_core *clk_core,const char *dev, +const char *con);#endif
drivers/clk/clkdev.c +8 -4
@@ -76,7 +76,9 @@ struct clk_core *of_clk_provider_get(struct device_node *np, int index)struct clk *of_clk_get (struct device_node *np,int index) { -return __clk_create_clk (of_clk_provider_get (np, index)); +struct clk_core *clk =of_clk_provider_get (np, index); + +return __clk_create_clk (clk, np->full_name,NULL ); }EXPORT_SYMBOL (of_clk_get);
@@ -129,7 +131,9 @@ struct clk_core *of_clk_provider_get_by_name(struct device_node *np, const char*/ struct clk *of_clk_get_by_name (struct device_node *np,const char *name) { -return __clk_create_clk (of_clk_provider_get_by_name (np, name)); +struct clk_core *clk =of_clk_provider_get_by_name (np, name); + +return __clk_create_clk (clk, np->full_name,NULL ); }EXPORT_SYMBOL (of_clk_get_by_name);#endif
@@ -201,7 +205,7 @@ struct clk *clk_get_sys(const char *dev_id, const char *con_id)#if defined(CONFIG_COMMON_CLK )struct clk_core *clk =clk_provider_get_sys (dev_id, con_id); -return __clk_create_clk (clk); +return __clk_create_clk (clk, dev_id, con_id);#else struct clk_lookup *cl;
@@ -243,7 +247,7 @@ struct clk *clk_get(struct device *dev, const char *con_id)#if defined(CONFIG_COMMON_CLK )const char *dev_id = dev ?dev_name (dev) :NULL ; -return __clk_create_clk (clk_provider_get (dev, con_id)); +return __clk_create_clk (clk_provider_get (dev, con_id), dev_id, con_id);#else const char *dev_id = dev ?dev_name (dev) :NULL ;struct clk *clk;
include/linux/clk-private.h +5 -0
@@ -57,6 +57,11 @@ struct clk_core {struct clk {struct clk_core *core; +const char *dev_id; +const char *con_id; + +unsigned int enable_count; +void *last_disable; };/*
Signature · 1 line
1.9.3
PATCH v8 6/7 clk: Add floor and ceiling constraints to clock rates
In reply to Tomeu VizosoAdds a way for clock consumers to set maximum and minimum rates. This can be used for thermal drivers to set ceiling rates, or by misc. drivers to set floor rates to assure a minimum performance level.
---
v5: * Move the storage of constraints to the per-user clk struct, as suggested
by Stephen Warren.
--- drivers/clk/clk.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/clk/clk.h | 1 + drivers/clk/clkdev.c | 2 +- include/linux/clk-private.h | 5 +++++ include/linux/clk.h | 18 ++++++++++++++++++ 5 files changed, 61 insertions(+), 1 deletion(-)
drivers/clk/clk.c +36 -0
@@ -560,6 +560,8 @@ struct clk *__clk_create_clk(struct clk_core *clk_core, const char *dev, clk->dev_id = dev; clk->con_id = con; +hlist_add_head (&clk->child_node, &clk_core->per_user_clks); +return clk; }
@@ -1625,6 +1627,7 @@ static void clk_change_rate(struct clk_core *clk)int clk_provider_set_rate (struct clk_core *clk,unsigned long rate) {struct clk_core *top, *fail_clk; +struct clk *clk_user;int ret =0 ;if (!clk)
@@ -1633,6 +1636,13 @@ int clk_provider_set_rate(struct clk_core *clk, unsigned long rate)/* prevent racing with updates to the clock topology */ clk_prepare_lock (); +hlist_for_each_entry (clk_user, &clk->per_user_clks, child_node) { + rate =max (rate, clk_user->floor_constraint); + +if (clk_user->ceiling_constraint >0 ) + rate =min (rate, clk_user->ceiling_constraint); + } +/* bail early if nothing to do */ if (rate ==clk_provider_get_rate (clk)) goto out;
@@ -1699,6 +1709,24 @@ int clk_set_rate(struct clk *clk_user, unsigned long rate) }EXPORT_SYMBOL_GPL (clk_set_rate); +int clk_set_floor_rate (struct clk *clk_user,unsigned long rate) +{ +struct clk_core *clk =clk_to_clk_core (clk_user); + + clk_user->floor_constraint = rate; +return clk_provider_set_rate (clk,clk_provider_get_rate (clk)); +} +EXPORT_SYMBOL_GPL (clk_set_floor_rate); + +int clk_set_ceiling_rate (struct clk *clk_user,unsigned long rate) +{ +struct clk_core *clk =clk_to_clk_core (clk_user); + + clk_user->ceiling_constraint = rate; +return clk_provider_set_rate (clk,clk_provider_get_rate (clk)); +} +EXPORT_SYMBOL_GPL (clk_set_ceiling_rate); +struct clk_core *clk_provider_get_parent (struct clk_core *clk) {struct clk_core *parent;
@@ -2043,6 +2071,8 @@ int __clk_init(struct device *dev, struct clk_core *clk) } } +INIT_HLIST_HEAD (&clk->per_user_clks); +/* * optional platform-specific magic *
@@ -2493,6 +2523,12 @@ int clk_notifier_unregister(struct clk *clk_user, struct notifier_block *nb) }EXPORT_SYMBOL_GPL (clk_notifier_unregister); +void __clk_free_clk (struct clk *clk_user) +{ +hlist_del (&clk_user->child_node); +kfree (clk_user); +} +#ifdef CONFIG_OF /** * struct of_clk_provider - Clock provider registration structure
drivers/clk/clk.h +1 -0
@@ -21,4 +21,5 @@ void of_clk_unlock(void);#if defined(CONFIG_COMMON_CLK )struct clk *__clk_create_clk (struct clk_core *clk_core,const char *dev,const char *con); +void __clk_free_clk (struct clk *clk_user);#endif
drivers/clk/clkdev.c +1 -1
@@ -270,7 +270,7 @@ void clk_put(struct clk *clk)#if defined(CONFIG_COMMON_CLK )clk_core_t *core =clk_to_clk_core (clk); -kfree (clk); +__clk_free_clk (clk);__clk_put (core);#else __clk_put (clk);
include/linux/clk-private.h +5 -0
@@ -48,6 +48,7 @@ struct clk_core {unsigned long accuracy;struct hlist_head children;struct hlist_node child_node; +struct hlist_head per_user_clks;unsigned int notifier_count;#ifdef CONFIG_DEBUG_FS struct dentry *dentry;
@@ -62,6 +63,10 @@ struct clk {unsigned int enable_count;void *last_disable; + +unsigned long floor_constraint; +unsigned long ceiling_constraint; +struct hlist_node child_node; };/*
include/linux/clk.h +18 -0
@@ -275,6 +275,24 @@ long clk_round_rate(struct clk *clk, unsigned long rate);int clk_set_rate (struct clk *clk,unsigned long rate);/** +* clk_set_floor_rate - set a minimum clock rate for a clock source +* @clk: clock source +* @rate: desired minimum clock rate in Hz +* +* Returns success (0) or negative errno. +*/ +int clk_set_floor_rate (struct clk *clk,unsigned long rate); + +/** +* clk_set_ceiling_rate - set a maximum clock rate for a clock source +* @clk: clock source +* @rate: desired maximum clock rate in Hz +* +* Returns success (0) or negative errno. +*/ +int clk_set_ceiling_rate (struct clk *clk,unsigned long rate); + +/** * clk_set_parent - set the parent clock source for this clock * @clk: clock source * @parent: parent clock source
Signature · 1 line
1.9.3
PATCH v8 6/7 clk: Add floor and ceiling constraints to clock rates
Quoting Tomeu Vizoso (2014-09-01 08:34:34)
drivers/clk/clk.c int clk_provider_set_rate(struct clk_core *clk, unsigned long rate) · line 1643
Quoted 9 lines
drivers/clk/clk.c +5
-0@@ -1633,6 +1636,13 @@ int clk_provider_set_rate(struct clk_core *clk, unsigned long rate)/* prevent racing with updates to the clock topology */ clk_prepare_lock (); +hlist_for_each_entry (clk_user, &clk->per_user_clks, child_node) { + rate =max (rate, clk_user->floor_constraint); + +if (clk_user->ceiling_constraint >0 ) + rate =min (rate, clk_user->ceiling_constraint);
A ceiling_constraint from consumer_A could be less than a floor_constraint from consumer_B. What should we do in this case?
In the code above the ceiling_constraint will always win. Is that by design? We should document that behavior in Documentation/clk.txt.
This is the right place to check for the aforementioned corner case, since we not only care about a single consumer having sane constraints (e.g. min < max) but also mixing constraints across consumers.
However ...
Quoted 16 lines
drivers/clk/clk.c +9
-0+ } +/* bail early if nothing to do */ if (rate ==clk_provider_get_rate (clk)) goto out;@@ -1699,6 +1709,24 @@ int clk_set_rate(struct clk *clk_user, unsigned long rate) }EXPORT_SYMBOL_GPL (clk_set_rate); +int clk_set_floor_rate (struct clk *clk_user,unsigned long rate) +{ +struct clk_core *clk =clk_to_clk_core (clk_user); + + clk_user->floor_constraint = rate; +return clk_provider_set_rate (clk,clk_provider_get_rate (clk)); +}
drivers/clk/clk.c int clk_set_rate(struct clk *clk_user, unsigned long rate) · line 1728
Quoted 10 lines
drivers/clk/clk.c +10
-0+EXPORT_SYMBOL_GPL (clk_set_floor_rate); + +int clk_set_ceiling_rate (struct clk *clk_user,unsigned long rate) +{ +struct clk_core *clk =clk_to_clk_core (clk_user); + + clk_user->ceiling_constraint = rate; +return clk_provider_set_rate (clk,clk_provider_get_rate (clk)); +} +EXPORT_SYMBOL_GPL (clk_set_ceiling_rate);
... we should probably sanity-check constraints here to make sure that ceiling_rates for a given consumer are higher than floor_constraints for that same consumer. It's a bit extra overhead but a WARN would probably be helpful in this case.
Rest of the patch looks good.
Regards,
Mike
Re: [PATCH v8 6/7] clk: Add floor and ceiling constraints to clock rates
Quoted 14 lines · Mike Turquette
Quoting Tomeu Vizoso (2014-09-01 08:34:34)
drivers/clk/clk.c int clk_provider_set_rate(struct clk_core *clk, unsigned long rate) · line 1643
Quoted 9 lines
drivers/clk/clk.c +5
-0@@ -1633,6 +1636,13 @@ int clk_provider_set_rate(struct clk_core *clk, unsigned long rate)/* prevent racing with updates to the clock topology */ clk_prepare_lock (); +hlist_for_each_entry (clk_user, &clk->per_user_clks, child_node) { + rate =max (rate, clk_user->floor_constraint); + +if (clk_user->ceiling_constraint >0 ) + rate =min (rate, clk_user->ceiling_constraint);A
ceiling_constraintfromconsumer_Acould be less than afloor_constraintfromconsumer_B. What should we do in this case?
Quoted 6 lines
In the code above the
ceiling_constraintwill always win. Is that by design? We should document that behavior inDocumentation/clk.txt.This is the right place to check for the aforementioned corner case, since we not only care about a single consumer having sane constraints (e.g. min < max) but also mixing constraints across consumers.
Yeah. I think I lean towards first applying all floors, then applying all ceilings. Because hardware damage could happen if a ceiling from thermal isn't applied because of a bug in some other driver.
This also has the advantage of being deterministic, when with the current approach the result depends on the order in which the per-user clocks are iterated.
Quoted 25 lines
However ...
Quoted 23 lines
drivers/clk/clk.c +16
-0+ } +/* bail early if nothing to do */ if (rate ==clk_provider_get_rate (clk)) goto out;@@ -1699,6 +1709,24 @@ int clk_set_rate(struct clk *clk_user, unsigned long rate) }EXPORT_SYMBOL_GPL (clk_set_rate); +int clk_set_floor_rate (struct clk *clk_user,unsigned long rate) +{ +struct clk_core *clk =clk_to_clk_core (clk_user); + + clk_user->floor_constraint = rate; +return clk_provider_set_rate (clk,clk_provider_get_rate (clk)); +} +EXPORT_SYMBOL_GPL (clk_set_floor_rate); + +int clk_set_ceiling_rate (struct clk *clk_user,unsigned long rate) +{ +struct clk_core *clk =clk_to_clk_core (clk_user); + + clk_user->ceiling_constraint = rate;
Quoted 8 lines
drivers/clk/clk.c int clk_set_rate(struct clk *clk_user, unsigned long rate) · line 1728
Quoted 3 lines
drivers/clk/clk.c +3
-0+return clk_provider_set_rate (clk,clk_provider_get_rate (clk)); +} +EXPORT_SYMBOL_GPL (clk_set_ceiling_rate);... we should probably sanity-check constraints here to make sure that
ceiling_ratesfor a given consumer are higher thanfloor_constraintsfor that same consumer. It's a bit extra overhead but a WARN would probably be helpful in this case.
Sounds like a good idea to me, will do.
Thanks,
Tomeu
Quoted 5 lines
Rest of the patch looks good.
Regards,
Mike
PATCH v8 7/7 clk: Warn of unbalanced clk_prepare() calls
In reply to Tomeu VizosoThe warning will display the clock user that is trying to unprepare the clock, and the location of the last unprepare call.
---
v8: * Patch added
--- drivers/clk/clk.c | 22 ++++++++++++++++++++-- include/linux/clk-private.h | 3 +++ 2 files changed, 23 insertions(+), 2 deletions(-)
drivers/clk/clk.c +20 -2
@@ -834,7 +834,17 @@ void clk_unprepare(struct clk *clk_user)if (IS_ERR_OR_NULL (clk_user))return ; -clk_provider_unprepare (clk_to_clk_core (clk_user)); +clk_prepare_lock (); +if (!WARN (clk_user->prepare_count ==0 , +"incorrect unprepare clk dev %s con %s last caller of unprepare %pF\n" , + clk_user->dev_id, clk_user->con_id, clk_user->last_unprepare)) { + + clk_user->last_unprepare =__builtin_return_address (0 ); + clk_user->prepare_count--; + +__clk_unprepare (clk_to_clk_core (clk_user)); + } +clk_prepare_unlock (); }EXPORT_SYMBOL_GPL (clk_unprepare);
@@ -890,10 +900,18 @@ EXPORT_SYMBOL_GPL(clk_provider_prepare);*/ int clk_prepare (struct clk *clk_user) { +int ret; +if (!clk_user)return 0 ; -return clk_provider_prepare (clk_to_clk_core (clk_user)); +clk_prepare_lock (); + ret =__clk_prepare (clk_to_clk_core (clk_user)); +if (!ret) + clk_user->prepare_count++; +clk_prepare_unlock (); + +return ret; }EXPORT_SYMBOL_GPL (clk_prepare);
include/linux/clk-private.h +3 -0
@@ -64,6 +64,9 @@ struct clk {unsigned int enable_count;void *last_disable; +unsigned int prepare_count; +void *last_unprepare; +unsigned long floor_constraint;unsigned long ceiling_constraint;struct hlist_node child_node;
Signature · 1 line
1.9.3
Re: [PATCH v8 4/7] clk: use struct clk only for external API
In reply to Tomeu VizosoQuoted 4 lines · Tomeu Vizoso
NOTE: with this patch,
clk_get_parent()behaves likeclk_get(), i.e. it needs to be matched with aclk_put(). Otherwise, memory will leak.
[...]
drivers/clk/clk.c struct clk *clk_get_parent(struct clk *clk) · line 1688
Quoted 8 lines
}
drivers/clk/clk.c +7
-0+EXPORT_SYMBOL_GPL (clk_provider_get_parent); + +/** +* clk_get_parent - return the parent of a clk +* @clk_user: the clk whose parent gets returned +* +* Simply returns clk->parent. Returns NULL if clk is NULL.
We should at least document here that clk_put() is expected to be called when it's not being used. I wonder why it's this way though. Why can't every clk_core have a private clk pointer to it's parent that's created during registration time? Then we just hand that out for clk_get_parent() and destroy it when the clk_core is freed?
Quoted 16 lines
+ */
drivers/clk/clk.c +13
-0+struct clk *clk_get_parent (struct clk *clk_user) +{ +struct clk_core *clk; +struct clk_core *parent; + +if (!clk_user) +return NULL ; + + clk =clk_to_clk_core (clk_user); + parent =clk_provider_get_parent (clk); + +return __clk_create_clk (parent); +}EXPORT_SYMBOL_GPL (clk_get_parent);
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCH v8 4/7] clk: use struct clk only for external API
Quoted 7 lines · Stephen Boyd
Quoted 4 lines · Tomeu Vizoso
NOTE: with this patch,
clk_get_parent()behaves likeclk_get(), i.e. it needs to be matched with aclk_put(). Otherwise, memory will leak.[...]
Quoted 11 lines
drivers/clk/clk.c struct clk *clk_get_parent(struct clk *clk) · line 1688
Quoted 8 lines
}
drivers/clk/clk.c +7
-0+EXPORT_SYMBOL_GPL (clk_provider_get_parent); + +/** +* clk_get_parent - return the parent of a clk +* @clk_user: the clk whose parent gets returned +* +* Simply returns clk->parent. Returns NULL if clk is NULL. We should at least document here that
clk_put()is expected to be called when it's not being used.
Good point.
Quoted 4 lines
I wonder why it's this way though. Why can't
everyclk_corehave a private clk pointer to it's parent that's created during registration time? Then we just hand that out forclk_get_parent()and destroy it when theclk_coreis freed?
Well, that wouldn't be a per-user clock any more, right? I see though how it would be desirable not to burden the caller with having to free the per-user clk.
Thanks,
Tomeu