clk: tegra: add basic support for the DFLL clocksource
Subsystems (6)
cover clk: tegra: add basic support for the DFLL clocksource
Hello,
This patch series adds support for the open-loop mode of the Tegra DFLL root clock source. The DFLL can be used to provide an energy-efficient and reliable clock signal for the Tegra114 fast CPU cluster.
The core DFLL code requires some SoC-specific integration and characterization data to function. For the time being, this has been implemented via small shim drivers that are probed from DT data and which pass per-SoC information to the DFLL core code. Future patches will add board tuning data to the DT files.
This series isn't sufficient for the DFLL to be usable as the fast CPU clock source. Further software support is needed to switch the CPU cluster's clock from the default PLLX to the DFLL.
To test the basic functionality of the DFLL driver, something like the following can be executed:
mount -t debugfs none /debug
cd /debug/tegra_dfll_fcpu/
echo 0 > enable
cat output_rate # ensure that it is 0
echo 1 > enable
cat output_rate # ensure that it is greater than 0
Future DFLL patches are planned to include reset controller support, Tegra124 support, and closed-loop mode support.
- Paul
---
Danny Huang (1):
ARM: tegra: fuse: add functions to read speedo ID and process ID
Paul Walmsley (5):
ARM: tegra114: fuse: add DFLL FCPU minimum voltage override test function
clk: tegra: add library for the DFLL clocksource (open-loop mode)
ARM: DTS: tegra: add the DFLL IP block to the T114 SoC file
ARM: DTS: tegra: add DFLL integration to the Dalmore DTS file
clk: tegra: add Tegra114 FCPU DFLL clocksource platform driver
.../bindings/clock/nvidia,tegra114-dfll.txt | 59 + arch/arm/boot/dts/tegra114-dalmore.dts | 4 arch/arm/boot/dts/tegra114.dtsi | 10 arch/arm/mach-tegra/fuse.c | 41 + drivers/clk/Kconfig | 2 drivers/clk/tegra/Kconfig | 18 drivers/clk/tegra/Makefile | 11 drivers/clk/tegra/clk-dfll.c | 1229 ++++++++++++++++++++ drivers/clk/tegra/clk-dfll.h | 54 + drivers/clk/tegra/clk-tegra114-dfll-fcpu.c | 169 +++ include/linux/tegra-soc.h | 6 11 files changed, 1602 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt create mode 100644 drivers/clk/tegra/Kconfig create mode 100644 drivers/clk/tegra/clk-dfll.c create mode 100644 drivers/clk/tegra/clk-dfll.h create mode 100644 drivers/clk/tegra/clk-tegra114-dfll-fcpu.c
text data bss dec hex filename
8010955 394200 352064 8757219 859fe3 vmlinux.next-20131218 8014811 395096 352064 8761971 85b273 vmlinux.next-20131218-dfll
PATCH 1/6 ARM: tegra: fuse: add functions to read speedo ID and process ID
From: Danny Huang <[email protected]>
Add functions to read the speedo and process id of both the CPU and the SoC. There might be some drivers need the information as well.
[pwalmsley at nvidia.com: cleaned up the patch description; removed functions
not used by the DFLL code for now]
--- arch/arm/mach-tegra/fuse.c | 15 +++++++++++++++ include/linux/tegra-soc.h | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-)
arch/arm/mach-tegra/fuse.c +15 -0
@@ -250,3 +250,18 @@ void __init tegra_init_fuse(void) tegra_sku_id, tegra_cpu_process_id, tegra_core_process_id); } + +int tegra_get_cpu_process_id (void ) +{ +return tegra_cpu_process_id; +} +EXPORT_SYMBOL (tegra_get_cpu_process_id); + +int tegra_get_cpu_speedo_id (void ) +{ +if (tegra_chip_id ==TEGRA20 ) +return -EINVAL ; + +return tegra_cpu_speedo_id; +} +EXPORT_SYMBOL (tegra_get_cpu_speedo_id);
include/linux/tegra-soc.h +3 -1
@@ -1,5 +1,5 @@/* -* Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. +* Copyright (c) 2012-2013 NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License,
@@ -18,5 +18,7 @@#define __LINUX_TEGRA_SOC_H_u32 tegra_read_chipid (void ); +int tegra_get_cpu_process_id (void ); +int tegra_get_cpu_speedo_id (void );#endif /* __LINUX_TEGRA_SOC_H_ */
PATCH 1/6 ARM: tegra: fuse: add functions to read speedo ID and process ID
Quoted 10 lines · Paul Walmsley
From: Danny Huang <[email protected]>
Add functions to read the speedo and process id of both the CPU and the SoC. There might be some drivers need the information as well.
arch/arm/mach-tegra/fuse.c +3
-0+int tegra_get_cpu_process_id (void ) +{ +return tegra_cpu_process_id;
arch/arm/mach-tegra/fuse.c void __init tegra_init_fuse(void) · line 266
Quoted 10 lines
arch/arm/mach-tegra/fuse.c +10
-0+} +EXPORT_SYMBOL (tegra_get_cpu_process_id); + +int tegra_get_cpu_speedo_id (void ) +{ +if (tegra_chip_id ==TEGRA20 ) +return -EINVAL ; + +return tegra_cpu_speedo_id; +}
Olof specifically went through the code and removed such functions in the past. He argued that consumers of this data should just read those tegra_cpu_process_id/... variables directly instead.
PATCH 2/6 ARM: tegra114: fuse: add DFLL FCPU minimum voltage override test function
In reply to Paul WalmsleyAdd a function to test the internal Tegra114 chip fuse that indicates whether the VDD_CPU lower voltage limit for the fast CPU cluster should be overridden.
--- arch/arm/mach-tegra/fuse.c | 26 ++++++++++++++++++++++++++ include/linux/tegra-soc.h | 2 ++ 2 files changed, 28 insertions(+)
arch/arm/mach-tegra/fuse.c +26 -0
@@ -47,6 +47,15 @@#define TEGRA20_FUSE_SPARE_BIT 0x200#define TEGRA30_FUSE_SPARE_BIT 0x244 +/* +* TEGRA114_SPARE_FUSE_VDD_CPU_OVERRIDE: Spare eFuse ID that indicates +* whether the minimum VDD_CPU voltage level that the DFLL is +* characterized for should be overridden to 900mVdc. If unset, the +* voltage shouldn't be overridden - it will be whatever has been +* selected by the CPU Speedo and process IDs. +*/ +#define TEGRA114_SPARE_FUSE_VDD_CPU_OVERRIDE 61 +int tegra_sku_id;int tegra_cpu_process_id;int tegra_core_process_id;
@@ -265,3 +274,20 @@ int tegra_get_cpu_speedo_id(void)return tegra_cpu_speedo_id; }EXPORT_SYMBOL (tegra_get_cpu_speedo_id); + +/** +* tegra114_fuse_read_min_vdd_cpu_override - override DFLL VDD_CPU minimum? +* +* Returns true if the minimum VDD_CPU voltage level that the DFLL is +* characterized for is 900mVdc. If false, the minimum voltage should +* be whatever has been selected by the CPU Speedo and process IDs. +*/ +bool tegra114_fuse_read_min_vdd_cpu_override (void ) +{ +if (tegra_chip_id !=TEGRA114 ) +return -EINVAL ; + +return tegra_spare_fuse (TEGRA114_SPARE_FUSE_VDD_CPU_OVERRIDE ) ? true : + false; +} +EXPORT_SYMBOL (tegra114_fuse_read_min_vdd_cpu_override);
include/linux/tegra-soc.h +2 -0
@@ -21,4 +21,6 @@ u32 tegra_read_chipid(void);int tegra_get_cpu_process_id (void );int tegra_get_cpu_speedo_id (void ); +bool tegra114_fuse_read_min_vdd_cpu_override (void ); +#endif /* __LINUX_TEGRA_SOC_H_ */
PATCH 2/6 ARM: tegra114: fuse: add DFLL FCPU minimum voltage override test function
arch/arm/mach-tegra/fuse.c int tegra_get_cpu_speedo_id(void) · line 288
Quoted 10 lines · Paul Walmsley
Add a function to test the internal Tegra114 chip fuse that indicates whether the
VDD_CPUlower voltage limit for the fast CPU cluster should be overridden.arch/arm/mach-tegra/fuse.c +4
-0+bool tegra114_fuse_read_min_vdd_cpu_override (void ) +{ +if (tegra_chip_id !=TEGRA114 ) +return -EINVAL ;
-EINVAL doesn't translate to "bool" too well...
arch/arm/mach-tegra/fuse.c int tegra_get_cpu_speedo_id(void) · line 291
Quoted 3 lines
arch/arm/mach-tegra/fuse.c +3
-0+ +return tegra_spare_fuse (TEGRA114_SPARE_FUSE_VDD_CPU_OVERRIDE ) ? true : + false;
In the spirit of my comment on patch 1 and consistency, instead perhaps just read this fuse at boot, and assign it to a global?
BTW, why the need for "? true : false" - doesn't the compiler do the conversion correctly itself. Perhaps it's to avoid a performance warning, in which case a leading !! seems to be more popular.
PATCH 3/6 clk: tegra: add library for the DFLL clocksource (open-loop mode)
In reply to Paul WalmsleyAdd shared code to support the Tegra DFLL clocksource in open-loop mode. This root clocksource is present on the Tegra114 and Tegra124 SoCs. It's used to generate a clock for the fast CPU cluster. Future patches will add support for closed-loop mode.
This code was originally created by Aleksandr Frid <[email protected]>. It's been converted to use DT and integrated into the common clock framework, and a few minor functional changes have been implemented.
Subsequent patches will add drivers for the Tegra114 and Tegra124 fast CPU cluster DFLL devices, which rely on this code.
--- drivers/clk/Kconfig | 2 drivers/clk/tegra/Kconfig | 9 drivers/clk/tegra/Makefile | 8 drivers/clk/tegra/clk-dfll.c | 1229 ++++++++++++++++++++++++++++++++++++++++++ drivers/clk/tegra/clk-dfll.h | 54 ++ 5 files changed, 1302 insertions(+) create mode 100644 drivers/clk/tegra/Kconfig create mode 100644 drivers/clk/tegra/clk-dfll.c create mode 100644 drivers/clk/tegra/clk-dfll.h
drivers/clk/Kconfig +2 -0
@@ -117,6 +117,8 @@ config COMMON_CLK_KEYSTONE Supports clock drivers for Keystone based SOCs. These SOCs have local a power sleep control module that gate the clock to the IPs and PLLs. +source "drivers/clk/tegra/Kconfig" + endmenu source "drivers/clk/mvebu/Kconfig"
drivers/clk/tegra/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +menu "Tegra clock support" + depends on COMMON_CLK + +config CLK_TEGRA_DFLL + tristate + depends on COMMON_CLK + +endmenu +
drivers/clk/tegra/Makefile +8 -0
@@ -15,3 +15,11 @@ obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += clk-tegra20.o obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += clk-tegra30.o obj-$(CONFIG_ARCH_TEGRA_114_SOC) += clk-tegra114.o obj-$(CONFIG_ARCH_TEGRA_124_SOC) += clk-tegra124.o +obj-$(CONFIG_CLK_TEGRA_DFLL) += clk-dfll.o + +# XXX -Wno-sign-compare is only needed due to problems with +# some non-clock-related Linux header files, and can be removed +# once those headers are fixed +CFLAGS_clk-dfll.o += -Wall -Wextra -Wno-unused-parameter \ + -Wno-sign-compare +
drivers/clk/tegra/clk-dfll.c new file +1229 -0
1,229 lines not on this page · raw message
drivers/clk/tegra/clk-dfll.h new file +54 -0
54 lines not on this page · raw message
PATCH 3/6 clk: tegra: add library for the DFLL clocksource (open-loop mode)
Quoted 2 lines · Paul Walmsley
Add shared code to support the Tegra DFLL clocksource in open-loop mode. This root clocksource is present on the Tegra114 and Tegra124
"root clocksource" implies no parents, yet the clock object this driver registers lists "dfll_soc" as its parent.
Quoted 11 lines
SoCs. It's used to generate a clock for the fast CPU cluster. Future patches will add support for closed-loop mode.
This code was originally created by Aleksandr Frid <[email protected]>. It's been converted to use DT and integrated into the common clock framework, and a few minor functional changes have been implemented.
Subsequent patches will add drivers for the Tegra114 and Tegra124 fast CPU cluster DFLL devices, which rely on this code.
drivers/clk/tegra/Kconfig line 6
Quoted 4 lines
drivers/clk/tegra/Kconfig +3
-0+config CLK_TEGRA_DFLL + tristate + depends on COMMON_CLK
Is there a need to make this optional? There's nothing configurable in the rest of the Tegra clock driver, and it'd be nicer if the rest of the kernel (e.g. Tegra cpufreq driver?) could simply always assume that DFLL were available.
Quoted 1 line
+
Blank line at EOF. Same in Makefile.
drivers/clk/tegra/Makefile obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += clk-tegra20.o · line 24
Quoted 7 lines
drivers/clk/tegra/Makefile +5
-0+# XXX -Wno-sign-compare is only needed due to problems with +# some non-clock-related Linux header files, and can be removed +# once those headers are fixed +CFLAGS_clk-dfll.o += -Wall -Wextra -Wno-unused-parameter \ + -Wno-sign-compare
Aside from the no-sign-compare issue (which I assume is being fixed in parallel before this is applied?) is there really a need to second-guess the kernel's -W flags?
drivers/clk/tegra/clk-dfll.c line 2
Quoted 3 lines
drivers/clk/tegra/clk-dfll.c +2
-0+/* +* clk-dfll.c - Tegra DFLL clock source common code
It'd be best not to put filenames in comments; it's just one more thing to update if the file gets renamed.
Quoted 1 line
+struct
tegra_dfll{
...
drivers/clk/tegra/clk-dfll.c line 259
Quoted 2 lines
drivers/clk/tegra/clk-dfll.c +2
-0+u8 speedo_id; +u8 process_id;
I don't think you need a copy of these; just read the globals directly?
drivers/clk/tegra/clk-dfll.c line 316
Quoted 6 lines
drivers/clk/tegra/clk-dfll.c +6
-0+static bool dfll_is_running (struct platform_device *pdev) +{ +struct tegra_dfll *td =dev_get_drvdata (&pdev->dev); + +return (td->mode ==DFLL_DISABLED || + td->mode ==DFLL_UNINITIALIZED ) ? false : true;
Why not:
return td->mode == DFLL_OPEN_LOOP;
or at least:
return td->mode != DFLL_DISABLED && td->mode != DFLL_UNINITIALIZED;
drivers/clk/tegra/clk-dfll.c line 395
Quoted 6 lines
drivers/clk/tegra/clk-dfll.c +6
-0+static void dfll_set_tune_range (struct platform_device *pdev, +enum dfll_tune_range range) +{ +struct tegra_dfll *td =dev_get_drvdata (&pdev->dev); + + td->tune_range = range;
Do we really need a (private, single-use) function just to write a field in a structure?
Quoted 1 line
+static u64 __attribute__((pure)) dfll_calc_monitored_rate(u32
monitor_data,
Does the compiler really need to be told about pure? It seems pretty obvious from the code, and I imagine the compiler is smart enough to tell. It looks like __pure would be preferred:
include/linux/compiler-gcc.h:94:#define __pure __attribute__((pure))
Quoted 1 line
+static u64
dfll_read_monitor_rate(struct platform_device *pdev)
...
drivers/clk/tegra/clk-dfll.c line 557
Quoted 2 lines
drivers/clk/tegra/clk-dfll.c +2
-0+if (td->mode ==DFLL_DISABLED || td->mode ==DFLL_UNINITIALIZED ) +return 0 ;
if (!dfll_is_running(td))
return 0;
drivers/clk/tegra/clk-dfll.c line 723
Quoted 6 lines
drivers/clk/tegra/clk-dfll.c +5
-0+static int dfll_init(struct platform_device *pdev) + pm_runtime_enable(&pdev->dev); +pm_runtime_get_sync (&pdev->dev); + + td->ref_rate =clk_get_rate (td->ref_clk);
Doesn't clk_get_rate() work before clk_enable() (which happens in pm_runtime_get_sync()), so you could simplify the error-handling here by checking the rate a little earlier, outside the pm_runtime_get/put?
drivers/clk/tegra/clk-dfll.c line 752
Quoted 8 lines
drivers/clk/tegra/clk-dfll.c +7
-0+if (td->ref_rate ==0 ) { +dev_err (&pdev->dev,"ref_clk rate cannot be 0\n" ); + ret = -EINVAL ; + goto di_err3; + } + +pm_runtime_put_sync (&pdev->dev);
Would plain pm_runtime_put() work just as well, and avoid the put if something else enables the driver/dfll clock very soon after?
drivers/clk/tegra/clk-dfll.c line 824
Quoted 7 lines
drivers/clk/tegra/clk-dfll.c +7
-0+static const char *dfll_clk_parents[] = {"dfll_soc" }; + +static struct clk_init_data dfll_clk_init_data = { + .ops = &dfll_clk_ops, + .parent_names = dfll_clk_parents, + .num_parents =ARRAY_SIZE (dfll_clk_parents), +};
Does a root clock actually have any parents?
drivers/clk/tegra/clk-dfll.c line 878
Quoted 5 lines
drivers/clk/tegra/clk-dfll.c +5
-0+static void dfll_unregister_clk (struct platform_device *pdev) +{ +struct tegra_dfll *td =dev_get_drvdata (&pdev->dev); + +/* XXX Why doesn't clk_unregister_clkdev() exist? */
Hmm. Seems like we need a patch to the clkdev core before this series?
drivers/clk/tegra/clk-dfll.c line 895
Quoted 6 lines
drivers/clk/tegra/clk-dfll.c +6
-0+static int dfll_enable_get (void *data,u64 *val) +{ +struct platform_device *pdev = data; +struct tegra_dfll *td =dev_get_drvdata (&pdev->dev); + + *val = (td->mode ==DFLL_OPEN_LOOP );
Use dfll_is_running()? Given td->mode embodies both enable/disable and the current mode, would it make more sense to have a debugfs file that exposed the raw enum, so you could both tell is-enabled and the current mode?
drivers/clk/tegra/clk-dfll.c line 899
Quoted 4 lines
drivers/clk/tegra/clk-dfll.c +4
-0+ +return 0 ; +} +static int dfll_enable_set (void *data,u64 val)
Missing blank line.
drivers/clk/tegra/clk-dfll.c line 907
Quoted 8 lines
drivers/clk/tegra/clk-dfll.c +8
-0+{ +struct platform_device *pdev = data; +struct tegra_dfll *td =dev_get_drvdata (&pdev->dev); + +if (val && !dfll_is_running (pdev)) +clk_prepare_enable (td->dfll_clk); +else if (!val &&dfll_is_running (pdev)) +clk_disable_unprepare (td->dfll_clk);
This is going to allow unbalanced prepare_enable/disable_unprepare calls simply by writing stuff to the debugfs file. Do we want to make debugfs more friendly than that? If so, perhaps keep some state around to indicate the last requested state from debugfs, and only make the clock calls if the new requested state is different from the previous debugfs-requested state, rather than different to the current-actual state?
Quoted 1 line
+static int
dfll_register_show(struct seq_file *s, void *data)
regmap will give you this function for free. Perhaps its considered too much overhead though?
drivers/clk/tegra/clk-dfll.c line 977
Quoted 11 lines
drivers/clk/tegra/clk-dfll.c +11
-0+static ssize_t dfll_register_write (struct file *file, +const char __user *userbuf,size_t count, +loff_t *ppos) +{ +struct platform_device *pdev = file->f_path.dentry->d_inode->i_private; +struct tegra_dfll *td =dev_get_drvdata (&pdev->dev); +char buf[80 ]; +u32 offs, val; + +if (sizeof (buf) <= count) +return -EINVAL ;
Don't you need to check whether ppos==0, to detect continuation rather than initial writes?
For register twiddling, why not just use a user-space app that mmap()s /dev/mem and blasts in the values? That would remove the need to put this into the kernel. This also feels like a function that should be implemented as a common utility, not open-coded into every driver. regmap?
drivers/clk/tegra/clk-dfll.c line 1014
Quoted 7 lines
drivers/clk/tegra/clk-dfll.c +7
-0+static int dfll_debug_init (struct platform_device *pdev) +{ +struct tegra_dfll *td =dev_get_drvdata (&pdev->dev); +int ret; + +if (!td || (td->mode ==DFLL_UNINITIALIZED )) +return 0 ;
Isn't td->mode always == DFLL_UNINITIALIZED when this function is called, since the mode is only set when dfll_enable() is called, which is only called when dfll_clk_enable() is called, and the clock isn't enabled when this function is called?
drivers/clk/tegra/clk-dfll.c line 1125
Quoted 4 lines
drivers/clk/tegra/clk-dfll.c +3
-0+int tegra_dfll_register (struct platform_device *pdev, +struct tegra_dfll_soc_data *soc) + td =kzalloc (sizeof (*td),GFP_KERNEL );
devm_kzalloc would simplify error-handling.
drivers/clk/tegra/clk-dfll.c line 1129
Quoted 1 line
drivers/clk/tegra/clk-dfll.c +1
-0+ td->soc =kmemdup (soc,sizeof (struct tegra_dfll_soc_data ),GFP_KERNEL );
Why not just store the pointer?
drivers/clk/tegra/clk-dfll.c line 1142
Quoted 1 line
drivers/clk/tegra/clk-dfll.c +1
-0+ td->base =ioremap (mem->start,resource_size (mem));
devm_ioremap()
drivers/clk/tegra/clk-dfll.c
Quoted 1 line
drivers/clk/tegra/clk-dfll.c +1
-0+clk_put (td->i2c_clk);
I evidently should have mentioned devm_clk_get() somewhere too.
drivers/clk/tegra/clk-dfll.c line 1215
Quoted 3 lines
drivers/clk/tegra/clk-dfll.c +2
-0+int tegra_dfll_unregister(struct platform_device *pdev) + pm_runtime_put_sync(&pdev->dev);
What is that matching? dfll_init() does a matched get/put, as do dfll_enable/disable, which in turn should be called in a matched fashion from any client's clk_enable/disable.
drivers/clk/tegra/clk-dfll.h
Quoted 3 lines
drivers/clk/tegra/clk-dfll.h +1
-0+* clk-dfll.h - prototypes and macros for the Tegra DFLL clocksource driver
Remove filename?
PATCH 4/6 ARM: DTS: tegra: add the DFLL IP block to the T114 SoC file
In reply to Paul WalmsleyAdd basic DT bindings for the DFLL IP block for the NVIDIA Tegra114 SoC.
--- .../bindings/clock/nvidia,tegra114-dfll.txt | 43 ++++++++++++++++++++ arch/arm/boot/dts/tegra114.dtsi | 10 +++++ 2 files changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt new file +43 -0
@@ -0,0 +1,43 @@ +NVIDIA Tegra114 DFLL FCPU clocksource data in the SoC DTS file: + +Required properties: + +- compatible : "nvidia,tegra114-dfll-fcpu" + +- reg : Must contain the starting physical address and length for the + DFLL's MMIO register space, including the DFLL-to-I2C + controller interface and the DFLL's I2C controller. + +- clocks : Must contain an array of two-cell arrays, one per clock. + DFLL source clocks. At minimum this should include the + reference clock source and the IP block's main clock + source. Also it should contain the DFLL's I2C controller + clock source. The format is <&clock-provider-phandle + clock-id>. + +- clock-names : Must contain an array of strings, one per 'clocks' + two-cell array. The position in the array of these + strings must correspond to the position in the 'clocks' + array (see above). The DFLL driver currently requires + the "soc", "ref", and "i2c" clock names to be populated. + + +Optional properties: + +- status : device availability -- managed by the DT integration code, not + the DFLL driver. Should be set to "disabled" in the SoC + DTS file. + + +Example: + +dfll at 70110000 { + compatible = "nvidia,tegra114-dfll-fcpu"; + reg = <0x70110000 0x400>; + clocks = <&tegra_car TEGRA114_CLK_DFLL_SOC>, + <&tegra_car TEGRA114_CLK_DFLL_REF>, + <&tegra_car TEGRA114_CLK_I2C5>; + clock-names = "soc", "ref", "i2c"; + status = "disabled"; +}; +
arch/arm/boot/dts/tegra114.dtsi +10 -0
@@ -480,6 +480,16 @@ }; }; + dfll at 70110000 { + compatible = "nvidia,tegra114-dfll-fcpu"; + reg = <0x70110000 0x400>; + clocks = <&tegra_car TEGRA114_CLK_DFLL_SOC>, + <&tegra_car TEGRA114_CLK_DFLL_REF>, + <&tegra_car TEGRA114_CLK_I2C5>; + clock-names = "soc", "ref", "i2c"; + status = "disabled"; + }; + sdhci at 78000000 { compatible = "nvidia,tegra114-sdhci", "nvidia,tegra30-sdhci"; reg = <0x78000000 0x200>;
PATCH 4/6 ARM: DTS: tegra: add the DFLL IP block to the T114 SoC file
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt line 16
Quoted 10 lines · Paul Walmsley
Add basic DT bindings for the DFLL IP block for the NVIDIA Tegra114 SoC.
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt +6
-0+- clocks : Must contain an array of two-cell arrays, one per clock. + DFLL source clocks. At minimum this should include the + reference clock source and the IP block's main clock + source. Also it should contain the DFLL's I2C controller + clock source. The format is <&clock-provider-phandle + clock-id>.
Entries in "clocks" aren't two cells, they're a phandle plus as many cells as the node referenced by the phandle specifies.
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt line 19
Quoted 3 lines
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt +3
-0+ +- clock-names : Must contain an array of strings, one per 'clocks' + two-cell array. The position in the array of these
clock-names defines the set of entries in clocks, not the other way around.
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt line 22
Quoted 3 lines
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt +3
-0+ strings must correspond to the position in the 'clocks' + array (see above). The DFLL driver currently requires + the "soc", "ref", and "i2c" clock names to be populated.
The standard wording used by all the Tegra clock client bindings is now:
- clocks : Must contain an entry for each entry in clock-names. See clock-bindings.txt for details.
- clock-names : Must include the following entries:
- soc
- ref
- i2c
For consistency, it'd be nice to adopt the same style here.
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt line 29
Quoted 5 lines
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt +5
-0+Optional properties: + +- status : device availability -- managed by the DT integration code, not + the DFLL driver. Should be set to "disabled" in the SoC + DTS file.
That's such a core property that it's not worth documenting in every single binding.
Quoted 1 line
+
Blank line at EOF.
PATCH 4/6 ARM: DTS: tegra: add the DFLL IP block to the T114 SoC file
(Resending, and revising - the original wasn't fully baked in several regards..)
Hello Stephen,
thanks for your review.
Quoted 12 lines · Stephen Warren
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt line 16
Quoted 10 lines · Paul Walmsley
Add basic DT bindings for the DFLL IP block for the NVIDIA Tegra114 SoC.
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt +6
-0+- clocks : Must contain an array of two-cell arrays, one per clock. + DFLL source clocks. At minimum this should include the + reference clock source and the IP block's main clock + source. Also it should contain the DFLL's I2C controller + clock source. The format is <&clock-provider-phandle + clock-id>.
Quoted 2 lines
Entries in "clocks" aren't two cells, they're a phandle plus as many cells as the node referenced by the phandle specifies.
It's worth noting that the clock binding documentation itself refers to pairs:
----
clocks: List of phandle and clock specifier pairs, one pair
for each clock input to the device. Note: if the clock provider specifies '0' for #clock-cells, then only the phandle portion of the pair will appear.
----
But given the ambiguity of that documentation, I basically agree, so have changed it to:
- clocks : Must contain an array of clock specifiers, one per clock. DFLL source clocks. At minimum this should include the reference clock source and the IP block's main clock source. Also it should contain the DFLL's I2C controller clock source. The format is <&clock-provider-phandle clock-id>.
Quoted 5 lines
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt line 19
Quoted 3 lines
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt +3
-0+ +- clock-names : Must contain an array of strings, one per 'clocks' + two-cell array. The position in the array of theseclock-names defines the set of entries in clocks, not the other way around.
Hmm. Referring to the DT clock binding documentation, it lists the 'clock-names' property as optional, and the 'clocks' property as mandatory:
-----
==Clock consumers==
Required properties:
clocks: List of phandle and clock specifier pairs, one pair
for each clock input to the device. Note: if the clock provider specifies '0' for #clock-cells, then only the phandle portion of the pair will appear.
Optional properties:
clock-names: List of clock input name strings sorted in the same
order as the clocks property. Consumers drivers will use clock-names to match clock input names with clocks specifiers.
-----
Considering that of_clk_get() doesn't require names, the situation appears to be the way that the original patch described it (modulo the part about "two cells.")
Quoted 6 lines
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt line 22
Quoted 3 lines
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt +3
-0+ strings must correspond to the position in the 'clocks' + array (see above). The DFLL driver currently requires + the "soc", "ref", and "i2c" clock names to be populated.The standard wording used by all the Tegra clock client bindings is now:
Quoted 8 lines
- clocks : Must contain an entry for each entry in clock-names. See clock-bindings.txt for details.
- clock-names : Must include the following entries:
- soc
- ref
- i2cFor consistency, it'd be nice to adopt the same style here.
I've altered the 'clock-names' format along the lines of what you've suggested, but have not changed the 'clocks' format, per the above discussion:
-----
- clocks : Must contain an array of clock specifiers, one per clock. DFLL source clocks. At minimum this should include the reference clock source and the IP block's main clock source. Also it should contain the DFLL's I2C controller clock source. The format is <&clock-provider-phandle clock-id>.
- clock-names : Must contain an array of strings, one per 'clocks' cell. The position in the array of these strings must correspond to the position in the 'clocks' array (see above).
- soc
- ref
- i2c
-----
Quoted 8 lines
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt line 29
Quoted 5 lines
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt +5
-0+Optional properties: + +- status : device availability -- managed by the DT integration code, not + the DFLL driver. Should be set to "disabled" in the SoC + DTS file.That's such a core property that it's not worth documenting in every single binding.
That's fine. Removed.
Quoted 4 lines
Quoted 2 lines
+
Blank line at EOF.
Hehe. Removed.
- Paul
PATCH 4/6 ARM: DTS: tegra: add the DFLL IP block to the T114 SoC file
Quoted 1 line · Paul Walmsley
The format is <&clock-provider-phandle clock-id>.
Ah, one other change: the above string has been dropped. Pesky examples ;-)
- Paul
PATCH 4/6 ARM: DTS: tegra: add the DFLL IP block to the T114 SoC file
In reply to Paul WalmsleyQuoted 28 lines · Paul Walmsley
Quoted 12 lines · Stephen Warren
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt line 16
Quoted 10 lines · Paul Walmsley
Add basic DT bindings for the DFLL IP block for the NVIDIA Tegra114 SoC.
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt +6
-0+- clocks : Must contain an array of two-cell arrays, one per clock. + DFLL source clocks. At minimum this should include the + reference clock source and the IP block's main clock + source. Also it should contain the DFLL's I2C controller + clock source. The format is <&clock-provider-phandle + clock-id>.Quoted 2 lines
Entries in "clocks" aren't two cells, they're a phandle plus as many cells as the node referenced by the phandle specifies.
It's worth noting that the clock binding documentation itself refers to pairs:
----
clocks: List of phandle and clock specifier pairs, one pair
for each clock input to the device. Note: if the clock provider specifies '0' for #clock-cells, then only the phandle portion of the pair will appear.
Quoted 6 lines
----
But given the ambiguity of that documentation, I basically agree, so have changed it to:
Please note that there neither is an ambiguity nor a conflict here, and that you actually acknowledge what Stephen said:
Clocks get referenced by a pair which consists of a phandle for the clock provider and a clock specifier. The clock specifier is made of as many cells as the clock provider's #clock-cells property defines (including none, or any other number than 1).
This is exactly what Stephen said: A "clocks" item does not need to have two cells. The pair of phandle and clock specifier don't necessarily translate into two cells, instead the number of cells depends on the clock provider.
Also note that the phandle is specifically _not_ part of the clock specifier.
virtually yours
Gerhard Sittig
Signature · 3 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
PATCH 4/6 ARM: DTS: tegra: add the DFLL IP block to the T114 SoC file
Quoted 24 lines · Gerhard Sittig
Quoted 23 lines · Paul Walmsley
Quoted 11 lines · Stephen Warren
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt line 16
Quoted 8 lines · Paul Walmsley
Add basic DT bindings for the DFLL IP block for the NVIDIA Tegra114 SoC.
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt +6
-0+- clocks : Must contain an array of two-cell arrays, one per clock. + DFLL source clocks. At minimum this should include the + reference clock source and the IP block's main clock + source. Also it should contain the DFLL's I2C controller + clock source. The format is <&clock-provider-phandle + clock-id>.Entries in "clocks" aren't two cells, they're a phandle plus as many cells as the node referenced by the phandle specifies.
It's worth noting that the clock binding documentation itself refers to pairs:
----
clocks: List of phandle and clock specifier pairs, one pair
for each clock input to the device. Note: if the clock provider specifies '0' for #clock-cells, then only the phandle portion of the pair will appear.
Quoted 8 lines
Quoted 6 lines
----
But given the ambiguity of that documentation, I basically agree, so have changed it to:
Please note that there neither is an ambiguity nor a conflict here, and that you actually acknowledge what Stephen said:
I do not agree that the Documentation is unambiguous.
It is not correct to refer to a "pair" without a second item as a "pair."
Quoted 4 lines
This is exactly what Stephen said: A "clocks" item does not need to have two cells. The pair of phandle and clock specifier don't necessarily translate into two cells, instead the number of cells depends on the clock provider.
I do agree with this, and have updated the documentation accordingly.
- Paul
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 4/6 ARM: DTS: tegra: add the DFLL IP block to the T114 SoC file
Quoted 32 lines · Paul Walmsley
Quoted 7 lines · Stephen Warren
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt line 19
Quoted 5 lines · Paul Walmsley
Add basic DT bindings for the DFLL IP block for the NVIDIA Tegra114 SoC.
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt +2
-0+- clock-names : Must contain an array of strings, one per 'clocks' + two-cell array. The position in the array of theseclock-names defines the set of entries in clocks, not the other way around.
Hmm. If one refers to the DT clock binding documentation, it lists the 'clock-names' property as optional, and the 'clocks' property as mandatory:
-----
|==Clock consumers==
Required properties:
clocks: List of phandle and clock specifier pairs, one pair
for each clock input to the device. Note: if the clock provider specifies '0' for #clock-cells, then only the phandle portion of the pair will appear.Optional properties:
clock-names: List of clock input name strings sorted in the same
order as the clocks property. Consumers drivers will use clock-names to match clock input names with clocks specifiers.-----
|
Quoted 5 lines
Considering that
of_clk_get()doesn't require names, it certainly appears to be the way that the original patch described it (modulo the bit about 'cells'; which has been fixed.)
If the binding defines that clock must exist at certain indices in the clock property, and clock-names isn't used, then the clocks property defines which clocks must exist.
However, if the binding is defining clock names, then the clock-names property is the master that defines which clocks exist. In this case, the index of entries in the clocks property is undefined by the binding; it must simply match the clock-names property, which can be arbitrarily ordered by the user.
Since this is a new binding, we should use the clock-names style to ensure easy future backwards-compatible changes.
PATCH 5/6 ARM: DTS: tegra: add DFLL integration to the Dalmore DTS file
In reply to Paul WalmsleyExpose the DFLL device on the NVIDIA Tegra114 Dalmore board, and connect the DFLL (and FCPU cluster) voltage regulator.
--- .../bindings/clock/nvidia,tegra114-dfll.txt | 16 ++++++++++++++++ arch/arm/boot/dts/tegra114-dalmore.dts | 4 ++++ 2 files changed, 20 insertions(+)
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt +16 -0
@@ -41,3 +41,19 @@ dfll at 70110000 { status = "disabled"; }; +... + +NVIDIA Tegra114 DFLL clocksource data in the board DTS file + +Optional properties: + +- status : device availability -- managed by the DT integration code, not + the DFLL driver. Should be set to "okay" if the DFLL is to be + used on this board type. + + +Example: + +dfll at 70110000 { + status = "okay"; +};
arch/arm/boot/dts/tegra114-dalmore.dts +4 -0
@@ -1063,6 +1063,10 @@ }; }; + dfll at 70110000 { + status = "okay"; + }; + sdhci at 78000400 { cd-gpios = <&gpio TEGRA_GPIO(V, 2) GPIO_ACTIVE_LOW>; bus-width = <4>;
PATCH 5/6 ARM: DTS: tegra: add DFLL integration to the Dalmore DTS file
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt dfll at 70110000 { · line 52
Quoted 12 lines · Paul Walmsley
Expose the DFLL device on the NVIDIA Tegra114 Dalmore board, and connect the DFLL (and FCPU cluster) voltage regulator.
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt +7
-0+NVIDIA Tegra114 DFLL clocksource data in the board DTS file + +Optional properties: + +- status : device availability -- managed by the DT integration code, not + the DFLL driver. Should be set to "okay" if the DFLL is to be + used on this board type.
There's certainly no need to document the same DT property twice. The DT docs are about documenting the schema. If the DT author decides to split the properties between a .dtsi and a .dts file, that's irrelevant to the schema.
PATCH 5/6 ARM: DTS: tegra: add DFLL integration to the Dalmore DTS file
Quoted 6 lines · Stephen Warren
Quoted 4 lines · Paul Walmsley
Expose the DFLL device on the NVIDIA Tegra114 Dalmore board, and connect the DFLL (and FCPU cluster) voltage regulator.
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt +0
-0
Quoted 9 lines
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt dfll at 70110000 { · line 52
Quoted 7 lines
Documentation/devicetree/bindings/clock/nvidia,tegra114-dfll.txt +7
-0+NVIDIA Tegra114 DFLL clocksource data in the board DTS file + +Optional properties: + +- status : device availability -- managed by the DT integration code, not + the DFLL driver. Should be set to "okay" if the DFLL is to be + used on this board type.There's certainly no need to document the same DT property twice.
I've just dropped this section, per your earlier suggestion.
- Paul
PATCH 6/6 clk: tegra: add Tegra114 FCPU DFLL clocksource platform driver
In reply to Paul WalmsleyAdd basic platform driver support for the fast CPU cluster DFLL clocksource found on Tegra114 SoCs. This small driver selects the appropriate Tegra114-specific characterization data and integration code. It relies on the DFLL common code to do most of the work.
--- drivers/clk/tegra/Kconfig | 9 + drivers/clk/tegra/Makefile | 5 + drivers/clk/tegra/clk-tegra114-dfll-fcpu.c | 169 ++++++++++++++++++++++++++++ 3 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/tegra/clk-tegra114-dfll-fcpu.c
drivers/clk/tegra/Kconfig +9 -0
@@ -5,5 +5,14 @@ config CLK_TEGRA_DFLL tristate depends on COMMON_CLK +config CLK_TEGRA114_DFLL_FCPU + tristate "Clock driver for the Tegra T114 DFLL FCPU" + select CLK_TEGRA_DFLL + ---help--- + Select this if you'd like to use the DFLL root clocksource + present on NVIDIA Tegra114 chips. This DFLL clocksource can + be used to clock the fast CPU cluster. Say 'y' or 'm' here + if you're building a kernel intended for use on T114 chips. + endmenu
drivers/clk/tegra/Makefile +4 -1
@@ -16,10 +16,13 @@ obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += clk-tegra30.o obj-$(CONFIG_ARCH_TEGRA_114_SOC) += clk-tegra114.o obj-$(CONFIG_ARCH_TEGRA_124_SOC) += clk-tegra124.o obj-$(CONFIG_CLK_TEGRA_DFLL) += clk-dfll.o +obj-$(CONFIG_CLK_TEGRA114_DFLL_FCPU) += clk-tegra114-dfll-fcpu.o # XXX -Wno-sign-compare is only needed due to problems with # some non-clock-related Linux header files, and can be removed # once those headers are fixed CFLAGS_clk-dfll.o += -Wall -Wextra -Wno-unused-parameter \ -Wno-sign-compare - +CFLAGS_clk-tegra114-dfll-fcpu.o += -Wall -Wextra -Wno-unused-parameter \ + -Wno-missing-field-initializers \ + -Wno-sign-compare
drivers/clk/tegra/clk-tegra114-dfll-fcpu.c new file +169 -0
169 lines not on this page · raw message
PATCH 6/6 clk: tegra: add Tegra114 FCPU DFLL clocksource platform driver
drivers/clk/tegra/Kconfig config CLK_TEGRA_DFLL · line 9
Quoted 9 lines · Paul Walmsley
Add basic platform driver support for the fast CPU cluster DFLL clocksource found on Tegra114 SoCs. This small driver selects the appropriate Tegra114-specific characterization data and integration code. It relies on the DFLL common code to do most of the work.
drivers/clk/tegra/Kconfig +2
-0+config CLK_TEGRA114_DFLL_FCPU + tristate "Clock driver for the Tegra T114 DFLL FCPU"
depends ARCH_TEGRA_114_SOC?
drivers/clk/tegra/Kconfig
Quoted 3 lines
drivers/clk/tegra/Kconfig +3
-0+CFLAGS_clk-tegra114-dfll-fcpu.o += -Wall -Wextra -Wno-unused-parameter \ + -Wno-missing-field-initializers \ + -Wno-sign-compare
I'd drop this too.
drivers/clk/tegra/clk-tegra114-dfll-fcpu.c
Quoted 3 lines
drivers/clk/tegra/clk-tegra114-dfll-fcpu.c +1
-0+* clk-tegra114-dfll-fcpu.c - Tegra114 DFLL FCPU clock source driver
I'd drop the filename.
Quoted 1 line
+ * Copyright (C) 2012-2013 NVIDIA Corporation. All rights reserved.
This is 2012-2013 whereas the other files were only 2013?
drivers/clk/tegra/clk-tegra114-dfll-fcpu.c line 86
Quoted 3 lines
drivers/clk/tegra/clk-tegra114-dfll-fcpu.c +3
-0+#define DROOP_RATE_MIN 1000000 + +
Double blank line.
drivers/clk/tegra/clk-tegra114-dfll-fcpu.c line 103
Quoted 3 lines
drivers/clk/tegra/clk-tegra114-dfll-fcpu.c +3
-0+static int tegra114_dfll_fcpu_probe (struct platform_device *pdev) +{ +struct tegra_dfll_soc_data soc;
Since most of the data in that struct is static, why not just make it a static global, and initialize the constant fields. That would avoid the need to copy it inside tegra_dfll_register(), and avoid the need to assign the fields later in this function.
drivers/clk/tegra/clk-tegra114-dfll-fcpu.c line 110
Quoted 7 lines
drivers/clk/tegra/clk-tegra114-dfll-fcpu.c +7
-0+int r, speedo_id, process_id; + + speedo_id =tegra_get_cpu_speedo_id (); + process_id =tegra_get_cpu_process_id (); + +memset (&soc,0 ,sizeof (soc)); + soc.driver_name =DRIVER_NAME ;
Why is that needed? Shouldn't the library code be using dev_name(&pdev->dev) or similar?
drivers/clk/tegra/clk-tegra114-dfll-fcpu.c line 137
Quoted 5 lines
drivers/clk/tegra/clk-tegra114-dfll-fcpu.c +5
-0+ r =tegra_dfll_register (pdev, &soc); +if (!r) +return r; + +return 0 ;
if (!r) means if (r == 0) so this always returns 0. I assume that meant if (r), but even simpler would be:
return tegra_dfll_register(...);
Quoted 1 line
+static struct
platform_drivertegra114_dfll_fcpu_driver= {
...
drivers/clk/tegra/clk-tegra114-dfll-fcpu.c line 163
Quoted 3 lines
drivers/clk/tegra/clk-tegra114-dfll-fcpu.c +3
-0+}; + +module_platform_driver (tegra114_dfll_fcpu_driver);
The blank line before module_platform_driver() is customarily omitted.
Quoted 1 line
+MODULE_LICENSE("GPL");
"GPL v2"
Quoted 1 line
+MODULE_ALIAS("platform:"
DRIVER_NAME);
That isn't needed since we only probe using DT now.