Tegra210 DFLL support
Subsystems (5)
cover Tegra210 DFLL support
This series introduces support for the DFLL as a CPU clock source on Tegra210. As Jetson TX1 uses a PWM controlled regulator IC which is driven directly by the DFLLs PWM output, we also introduce support for PWM regulators next to I2C controlled regulators. The DFLL output frequency is directly controlled by the regulator voltage. The registers for controlling the PWM are part of the DFLL IP block, so there's no separate linux regulator object involved because the regulator IC only supplies the rail powering the CPUs. It doesn't have any other controls.
The patch 1~4 are the patches of DT bindings update for DFLL clock and Tegra124 cpufreq, which add PWM and Tegra210 support for DFLL clock and remove deprecate properties for Tegra124 cpufreq bindings.
The patch 5~10 are the patches for DFLL clock driver update for PWM-mode DFLL support.
The patch 11 and 12 are the Tegra124 cpufreq driver update to make it work with Tegra210.
The patch 13~18 are the devicetree files update for Tegra210 SoC and platforms. Two platforms are updated here for different DFLL mode usage. The Tegra210-p2371-2180 (a.k.a. Jetson Tx1) uses DFLL-PWM and the Tegra210-smaug (a.k.a. Pixel C) uses DFLL-I2C. So two different modes are verified with this series.
The patch 19 is the patch for enabling the CPU regulator for Smaug board.
Joseph Lo (16):
dt-bindings: clock: tegra124-dfll: add Tegra210 support
dt-bindings: cpufreq: tegra124: remove vdd-cpu-supply from required
properties
dt-bindings: cpufreq: tegra124: remove cpu_lp clock from required
properties
clk: tegra: dfll: CVB calculation alignment with the regulator
clk: tegra: dfll: support PWM regulator control
clk: tegra: dfll: round down voltages based on alignment
clk: tegra: dfll: add CVB tables for Tegra210
cpufreq: tegra124: do not handle the CPU rail
cpufreq: tegra124: extend to support Tegra210
arm64: dts: tegra210: add DFLL clock
arm64: dts: tegra210: add CPU clocks
arm64: dts: tegra210-p2597: add pinmux for PWM-based DFLL support
arm64: dts: tegra210-p2371-2180: enable DFLL clock
arm64: dts: tegra210-smaug: add CPU power rail regulator
arm64: dts: tegra210-smaug: enable DFLL clock
arm64: defconfig: Enable MAX8973 regulator
Peter De Schrijver (3):
dt-bindings: clock: tegra124-dfll: Update DFLL binding for PWM
regulator
clk: tegra: dfll: registration for multiple SoCs
clk: tegra: dfll: build clk-dfll.c for Tegra124 and Tegra210
.../bindings/clock/nvidia,tegra124-dfll.txt | 77 ++- .../cpufreq/nvidia,tegra124-cpufreq.txt | 6 +- .../boot/dts/nvidia/tegra210-p2371-2180.dts | 20 + .../arm64/boot/dts/nvidia/tegra210-p2597.dtsi | 14 + arch/arm64/boot/dts/nvidia/tegra210-smaug.dts | 31 + arch/arm64/boot/dts/nvidia/tegra210.dtsi | 25 + arch/arm64/configs/defconfig | 1 + drivers/clk/tegra/Kconfig | 5 + drivers/clk/tegra/Makefile | 2 +- drivers/clk/tegra/clk-dfll.c | 455 ++++++++++++--- drivers/clk/tegra/clk-dfll.h | 6 +- drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 536 +++++++++++++++++- drivers/clk/tegra/cvb.c | 12 +- drivers/clk/tegra/cvb.h | 7 +- drivers/cpufreq/Kconfig.arm | 2 +- drivers/cpufreq/tegra124-cpufreq.c | 29 +- 16 files changed, 1095 insertions(+), 133 deletions(-)
Signature · 1 line
2.19.2
PATCH 1/19 dt-bindings: clock: tegra124-dfll: Update DFLL binding for PWM regulator
From: Peter De Schrijver <[email protected]>
Add new properties to configure the DFLL PWM regulator support. Also add an example and make the I2C clock only required when I2C support is used.
--- .../bindings/clock/nvidia,tegra124-dfll.txt | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +71 -2
@@ -8,7 +8,6 @@ the fast CPU cluster. It consists of a free-running voltage controlled oscillator connected to the CPU voltage rail (VDD_CPU), and a closed loop control module that will automatically adjust the VDD_CPU voltage by communicating with an off-chip PMIC either via an I2C bus or via PWM signals. -Currently only the I2C mode is supported by these bindings. Required properties: - compatible : should be "nvidia,tegra124-dfll"
@@ -45,10 +44,28 @@ Required properties for the control loop parameters: Optional properties for the control loop parameters: - nvidia,cg-scale: Boolean value, see the field DFLL_PARAMS_CG_SCALE in the TRM. +Optional properties for mode selection: +- nvidia,pwm-to-pmic: Use PWM to control regulator rather then I2C. + Required properties for I2C mode: - nvidia,i2c-fs-rate: I2C transfer rate, if using full speed mode. -Example: +Required properties for PWM mode: +- nvidia,pwm-period: period of PWM square wave in microseconds. +- nvidia,init-uv: Regulator voltage in micro volts when PWM control is disabled. +- nvidia,align-offset-uv: Regulator voltage in micro volts when PWM control is + enabled and PWM output is low. +- nvidia,align-step-uv: Voltage increase in micro volts corresponding to a + 1/33th increase in duty cycle. Eg the voltage for 2/33th + duty cycle would be: + nvidia,align-offset-uv + nvidia,align-step-uv * 2. +- pinctrl-0: I/O pad configuration when PWM control is enabled. +- pinctrl-1: I/O pad configuration when PWM control is disabled. +- pinctrl-names: must include the following entries: + - dvfs_pwm_enable: I/O pad configuration when PWM control is enabled. + - dvfs_pwm_disable: I/O pad configuration when PWM control is disabled. + +Example for I2C: clock@70110000 { compatible = "nvidia,tegra124-dfll";
@@ -76,3 +93,55 @@ clock@70110000 { nvidia,i2c-fs-rate = <400000>; }; + +Example for PWM: + +clock@70110000 { + compatible = "nvidia,tegra124-dfll"; + reg = <0 0x70110000 0 0x100>, /* DFLL control */ + <0 0x70110000 0 0x100>, /* I2C output control */ + <0 0x70110100 0 0x100>, /* Integrated I2C controller */ + <0 0x70110200 0 0x100>; /* Look-up table RAM */ + interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&tegra_car TEGRA210_CLK_DFLL_SOC>, + <&tegra_car TEGRA210_CLK_DFLL_REF>, + <&tegra_car TEGRA124_CLK_I2C5>;; + clock-names = "soc", "ref", "i2c"; + resets = <&tegra_car TEGRA124_RST_DFLL_DVCO>; + reset-names = "dvco"; + #clock-cells = <0>; + clock-output-names = "dfllCPU_out"; + nvidia,pwm-to-pmic; + nvidia,init-uv = <1000000>; + nvidia,align-step-uv = <19200>; /* 19.2mV */ + nvidia,align-offset-uv = <708000>; /* 708mV */ + nvidia,sample-rate = <25000>; + nvidia,droop-ctrl = <0x00000f00>; + nvidia,force-mode = <1>; + nvidia,cf = <6>; + nvidia,ci = <0>; + nvidia,cg = <2>; + nvidia,pwm-period = <2500>; /* 2.5us */ + pinctrl-names = "dvfs_pwm_enable", "dvfs_pwm_disable"; + pinctrl-0 = <&dvfs_pwm_active_state>; + pinctrl-1 = <&dvfs_pwm_inactive_state>; +}; + +/* pinmux nodes added for completeness. Binding doc can be found in: + * Documentation/devicetree/bindings/pinctrl/nvidia,tegra210-pinmux.txt + */ + +pinmux: pinmux@700008d4 { + dvfs_pwm_active_state: dvfs_pwm_active { + dvfs_pwm_pbb1 { + nvidia,pins = "dvfs_pwm_pbb1"; + nvidia,tristate = <TEGRA_PIN_DISABLE>; + }; + }; + dvfs_pwm_inactive_state: dvfs_pwm_inactive { + dvfs_pwm_pbb1 { + nvidia,pins = "dvfs_pwm_pbb1"; + nvidia,tristate = <TEGRA_PIN_ENABLE>; + }; + }; +};
Signature · 1 line
2.19.2
PATCH 2/19 dt-bindings: clock: tegra124-dfll: add Tegra210 support
In reply to Joseph LoAdd Tegra210 support for DFLL clock.
--- .../devicetree/bindings/clock/nvidia,tegra124-dfll.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +3 -1
@@ -10,7 +10,9 @@ control module that will automatically adjust the VDD_CPU voltage by communicating with an off-chip PMIC either via an I2C bus or via PWM signals. Required properties: -- compatible : should be "nvidia,tegra124-dfll" +- compatible : should be one of: + - "nvidia,tegra124-dfll": for Tegra124 + - "nvidia,tegra210-dfll": for Tegra210 - reg : Defines the following set of registers, in the order listed: - registers for the DFLL control logic. - registers for the I2C output logic.
Signature · 1 line
2.19.2
PATCH 3/19 dt-bindings: cpufreq: tegra124: remove vdd-cpu-supply from required properties
In reply to Joseph LoThe Tegra124 cpufreq driver works only with DFLL clock, which is a hardware-based frequency/voltage controller. The driver doesn't need to control the regulator itself. Hence remove that.
--- .../devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt | 2 -- 1 file changed, 2 deletions(-)
Documentation/devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt +0 -2
@@ -13,7 +13,6 @@ Required properties: - pll_x: Fast PLL clocksource. - pll_p: Auxiliary PLL used during fast PLL rate changes. - dfll: Fast DFLL clocksource that also automatically scales CPU voltage. -- vdd-cpu-supply: Regulator for CPU voltage Optional properties: - clock-latency: Specify the possible maximum transition latency for clock,
@@ -37,7 +36,6 @@ cpus { <&dfll>; clock-names = "cpu_g", "cpu_lp", "pll_x", "pll_p", "dfll"; clock-latency = <300000>; - vdd-cpu-supply: <&vdd_cpu>; }; <...>
Signature · 1 line
2.19.2
PATCH 4/19 dt-bindings: cpufreq: tegra124: remove cpu_lp clock from required properties
In reply to Joseph LoThe cpu_lp clock property is only needed when the CPUfreq driver supports CPU cluster switching. But it was not a design for this driver and it didn't handle that as well. So removing this property.
--- .../devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Documentation/devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt +1 -3
@@ -9,7 +9,6 @@ Required properties: See ../clocks/clock-bindings.txt for details. - clock-names: Must include the following entries: - cpu_g: Clock mux for the fast CPU cluster. - - cpu_lp: Clock mux for the low-power CPU cluster. - pll_x: Fast PLL clocksource. - pll_p: Auxiliary PLL used during fast PLL rate changes. - dfll: Fast DFLL clocksource that also automatically scales CPU voltage.
@@ -30,11 +29,10 @@ cpus { reg = <0>; clocks = <&tegra_car TEGRA124_CLK_CCLK_G>, - <&tegra_car TEGRA124_CLK_CCLK_LP>, <&tegra_car TEGRA124_CLK_PLL_X>, <&tegra_car TEGRA124_CLK_PLL_P>, <&dfll>; - clock-names = "cpu_g", "cpu_lp", "pll_x", "pll_p", "dfll"; + clock-names = "cpu_g", "pll_x", "pll_p", "dfll"; clock-latency = <300000>; };
Signature · 1 line
2.19.2
PATCH 5/19 clk: tegra: dfll: registration for multiple SoCs
In reply to Joseph LoFrom: Peter De Schrijver <[email protected]>
In a future patch, support for the DFLL in Tegra210 will be introduced. This requires support for more than 1 set of CVB and CPU max frequency tables.
--- drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 45 ++++++++++++++++------ 1 file changed, 34 insertions(+), 11 deletions(-)
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +34 -11
@@ -1,7 +1,7 @@/* * Tegra124 DFLL FCPU clock source driver * -* Copyright (C) 2012-2014 NVIDIA Corporation. All rights reserved. +* Copyright (C) 2012-2018 NVIDIA Corporation. All rights reserved. * * Aleksandr Frid <[email protected]> * Paul Walmsley <[email protected]>
@@ -21,6 +21,7 @@#include <linux/err.h> #include <linux/kernel.h> #include <linux/init.h> +#include <linux/of_device.h> #include <linux/platform_device.h> #include <soc/tegra/fuse.h>
@@ -28,8 +29,15 @@#include "clk-dfll.h" #include "cvb.h" +struct dfll_fcpu_data { +const unsigned long *cpu_max_freq_table; +unsigned int cpu_max_freq_table_size; +const struct cvb_table *cpu_cvb_tables; +unsigned int cpu_cvb_tables_size; +}; +/* Maximum CPU frequency, indexed by CPU speedo id */ -static const unsigned long cpu_max_freq_table[] = { +static const unsigned long tegra124_cpu_max_freq_table[] = { [0 ] =2014500000UL , [1 ] =2320500000UL , [2 ] =2116500000UL ,
@@ -82,16 +90,36 @@ static const struct cvb_table tegra124_cpu_cvb_tables[] = { }, }; +static const struct dfll_fcpu_data tegra124_dfll_fcpu_data = { + .cpu_max_freq_table = tegra124_cpu_max_freq_table, + .cpu_max_freq_table_size =ARRAY_SIZE (tegra124_cpu_max_freq_table), + .cpu_cvb_tables = tegra124_cpu_cvb_tables, + .cpu_cvb_tables_size =ARRAY_SIZE (tegra124_cpu_cvb_tables) +}; + +static const struct of_device_id tegra124_dfll_fcpu_of_match[] = { + { + .compatible ="nvidia,tegra124-dfll" , + .data = &tegra124_dfll_fcpu_data, + }, + { }, +}; +static int tegra124_dfll_fcpu_probe (struct platform_device *pdev) {int process_id, speedo_id, speedo_value, err;struct tegra_dfll_soc_data *soc; +const struct dfll_fcpu_data *fcpu_data; + + fcpu_data =of_device_get_match_data (&pdev->dev); +if (!fcpu_data) +return -ENODEV ; process_id = tegra_sku_info.cpu_process_id; speedo_id = tegra_sku_info.cpu_speedo_id; speedo_value = tegra_sku_info.cpu_speedo_value; -if (speedo_id >=ARRAY_SIZE (cpu_max_freq_table)) { +if (speedo_id >= fcpu_data->cpu_max_freq_table_size) {dev_err (&pdev->dev,"unknown max CPU freq for speedo_id=%d\n" , speedo_id);return -ENODEV ;
@@ -107,10 +135,10 @@ static int tegra124_dfll_fcpu_probe(struct platform_device *pdev)return -ENODEV ; } - soc->max_freq = cpu_max_freq_table[speedo_id]; + soc->max_freq = fcpu_data->cpu_max_freq_table[speedo_id]; - soc->cvb =tegra_cvb_add_opp_table (soc->dev, tegra124_cpu_cvb_tables, -ARRAY_SIZE (tegra124_cpu_cvb_tables), + soc->cvb =tegra_cvb_add_opp_table (soc->dev, fcpu_data->cpu_cvb_tables, + fcpu_data->cpu_cvb_tables_size, process_id, speedo_id, speedo_value, soc->max_freq);if (IS_ERR (soc->cvb)) {
@@ -142,11 +170,6 @@ static int tegra124_dfll_fcpu_remove(struct platform_device *pdev)return 0 ; } -static const struct of_device_id tegra124_dfll_fcpu_of_match[] = { - { .compatible ="nvidia,tegra124-dfll" , }, - { }, -}; -static const struct dev_pm_ops tegra124_dfll_pm_ops = {SET_RUNTIME_PM_OPS (tegra_dfll_runtime_suspend, tegra_dfll_runtime_resume,NULL )
Signature · 1 line
2.19.2
PATCH 6/19 clk: tegra: dfll: CVB calculation alignment with the regulator
In reply to Joseph LoThe CVB table contains calibration data for the CPU DFLL based on process charaterization. The regulator step and offset parameters depend on the regulator supplying vdd-cpu , not on the specific Tegra SKU.
When using a PWM controlled regulator, the voltage step and offset are determined by the regulator type in use. This is specified in DT. When using an I2C controlled regulator, we can retrieve them from CPU regulator or DT (if specified). Then pass this information to the CVB table calculation function.
Based on the work done of "Peter De Schrijver <[email protected]>" and "Alex Frid <[email protected]>".
--- drivers/clk/tegra/clk-dfll.h | 6 +- drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 65 ++++++++++++++++++++-- drivers/clk/tegra/cvb.c | 12 ++-- drivers/clk/tegra/cvb.h | 6 +- 4 files changed, 75 insertions(+), 14 deletions(-)
drivers/clk/tegra/clk-dfll.h +5 -1
@@ -1,6 +1,6 @@/* * clk-dfll.h - prototypes and macros for the Tegra DFLL clocksource driver -* Copyright (C) 2013 NVIDIA Corporation. All rights reserved. +* Copyright (C) 2013-2018 NVIDIA Corporation. All rights reserved. * * Aleksandr Frid <[email protected]> * Paul Walmsley <[email protected]>
@@ -22,11 +22,14 @@#include <linux/reset.h> #include <linux/types.h> +#include "cvb.h" +/** * struct tegra_dfll_soc_data - SoC-specific hooks/integration for the DFLL driver * @dev: struct device * that holds the OPP table for the DFLL * @max_freq: maximum frequency supported on this SoC * @cvb: CPU frequency table for this SoC +* @alignment: parameters of the regulator step and offset * @init_clock_trimmers: callback to initialize clock trimmers * @set_clock_trimmers_high: callback to tune clock trimmers for high voltage * @set_clock_trimmers_low: callback to tune clock trimmers for low voltage
@@ -35,6 +38,7 @@ struct tegra_dfll_soc_data {struct device *dev;unsigned long max_freq;const struct cvb_table *cvb; +struct rail_alignment alignment;void (*init_clock_trimmers)(void );void (*set_clock_trimmers_high)(void );
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +60 -5
98 lines not on this page · raw message
drivers/clk/tegra/cvb.c +7 -5
@@ -1,7 +1,7 @@/* * Utility functions for parsing Tegra CVB voltage tables * -* Copyright (C) 2012-2014 NVIDIA Corporation. All rights reserved. +* Copyright (C) 2012-2018 NVIDIA Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -62,9 +62,9 @@ static int round_voltage(int mv, const struct rail_alignment *align, int up) }static int build_opp_table (struct device *dev,const struct cvb_table *table, +struct rail_alignment *align,int speedo_value,unsigned long max_freq) { -const struct rail_alignment *align = &table->alignment;int i, ret, dfll_mv, min_mv, max_mv; min_mv =round_voltage (table->min_millivolts, align,UP );
@@ -109,8 +109,9 @@ static int build_opp_table(struct device *dev, const struct cvb_table *table,*/ const struct cvb_table *tegra_cvb_add_opp_table (struct device *dev,const struct cvb_table *tables, -size_t count,int process_id,int speedo_id, -int speedo_value,unsigned long max_freq) +size_t count,struct rail_alignment *align, +int process_id,int speedo_id,int speedo_value, +unsigned long max_freq) {size_t i;int ret;
@@ -124,7 +125,8 @@ tegra_cvb_add_opp_table(struct device *dev, const struct cvb_table *tables,if (table->process_id !=-1 && table->process_id != process_id)continue ; - ret =build_opp_table (dev, table, speedo_value, max_freq); + ret =build_opp_table (dev, table, align, speedo_value, + max_freq);return ret ?ERR_PTR (ret) : table; }
drivers/clk/tegra/cvb.h +3 -3
@@ -49,7 +49,6 @@ struct cvb_table {int min_millivolts;int max_millivolts; -struct rail_alignment alignment;int speedo_scale;int voltage_scale;
@@ -59,8 +58,9 @@ struct cvb_table {const struct cvb_table *tegra_cvb_add_opp_table (struct device *dev,const struct cvb_table *cvb_tables, -size_t count,int process_id,int speedo_id, -int speedo_value,unsigned long max_freq); +size_t count,struct rail_alignment *align, +int process_id,int speedo_id,int speedo_value, +unsigned long max_freq);void tegra_cvb_remove_opp_table (struct device *dev,const struct cvb_table *table,unsigned long max_freq);
Signature · 1 line
2.19.2
PATCH 7/19 clk: tegra: dfll: support PWM regulator control
In reply to Joseph LoThe DFLL hardware supports two modes (I2C and PWM) for voltage control when requesting a frequency. In this patch, we introduce PWM mode support.
To support that, we re-organize the LUT for unifying the table for both cases of I2C and PWM mode. And generate that based on regulator info. For the PWM-based regulator, we get this info from DT. And do the same as the case of I2C LUT, which can help to map the PMIC voltage ID and voltages that the regulator supported.
The other parts are the support code for initializing the DFLL hardware to support PWM mode. Also, the register debugfs file is slightly reworked to only show the i2c registers when I2C mode is in use.
Based on the work of Peter De Schrijver <[email protected]>.
--- drivers/clk/tegra/clk-dfll.c | 431 ++++++++++++++++++++++++++++++----- 1 file changed, 368 insertions(+), 63 deletions(-)
drivers/clk/tegra/clk-dfll.c +368 -63
@@ -1,7 +1,7 @@/* * clk-dfll.c - Tegra DFLL clock source common code * -* Copyright (C) 2012-2014 NVIDIA Corporation. All rights reserved. +* Copyright (C) 2012-2018 NVIDIA Corporation. All rights reserved. * * Aleksandr Frid <[email protected]> * Paul Walmsley <[email protected]>
@@ -47,6 +47,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/pinctrl/consumer.h> #include <linux/pm_opp.h> #include <linux/pm_runtime.h> #include <linux/regmap.h>
@@ -243,6 +244,12 @@ enum dfll_tune_range { DFLL_TUNE_LOW = 1, }; + +enum tegra_dfll_pmu_if { +TEGRA_DFLL_PMU_I2C =0 , +TEGRA_DFLL_PMU_PWM =1 , +}; +/** * struct dfll_rate_req - target DFLL rate request data * @rate: target frequency, after the postscaling
@@ -294,16 +301,25 @@ struct tegra_dfll {u32 ci;u32 cg;bool cg_scale; +u32 reg_init_uV;/* I2C interface parameters */ u32 i2c_fs_rate;u32 i2c_reg;u32 i2c_slave_addr; -/* i2c_lut array entries are regulator framework selectors */ -unsigned i2c_lut[MAX_DFLL_VOLTAGES ]; -int i2c_lut_size; -u8 lut_min, lut_max, lut_safe; +/* lut array entries are regulator framework selectors or PWM values*/ +unsigned lut[MAX_DFLL_VOLTAGES ]; +unsigned lut_uv[MAX_DFLL_VOLTAGES ]; +int lut_size; +u8 lut_bottom, lut_min, lut_max, lut_safe; + +/* PWM interface */ +enum tegra_dfll_pmu_if pmu_if; +unsigned long pwm_rate; +struct pinctrl *pwm_pin; +struct pinctrl_state *pwm_enable_state; +struct pinctrl_state *pwm_disable_state; };#define clk_hw_to_dfll (_hw) container_of(_hw, struct tegra_dfll, dfll_clk_hw)
@@ -489,6 +505,34 @@ static void dfll_set_mode(struct tegra_dfll *td,dfll_wmb (td); } +/* +* DVCO rate control +*/ + +static unsigned long get_dvco_rate_below (struct tegra_dfll *td,u8 out_min) +{ +struct dev_pm_opp *opp; +unsigned long rate, prev_rate; +int uv, min_uv; + + min_uv = td->lut_uv[out_min]; +for (rate =0 , prev_rate =0 ; ; rate++) { + opp =dev_pm_opp_find_freq_ceil (td->soc->dev, &rate); +if (IS_ERR (opp)) +break ; + + uv =dev_pm_opp_get_voltage (opp); +dev_pm_opp_put (opp); + +if (uv && uv > min_uv) +return prev_rate; + + prev_rate = rate; + } + +return prev_rate; +} +/* * DFLL-to-I2C controller interface */
@@ -518,6 +562,118 @@ static int dfll_i2c_set_output_enabled(struct tegra_dfll *td, bool enable)return 0 ; } + +/* +* DFLL-to-PWM controller interface +*/ + +/** +* dfll_pwm_set_output_enabled - enable/disable PWM voltage requests +* @td: DFLL instance +* @enable: whether to enable or disable the PWM voltage requests +* +* Set the master enable control for PWM control value updates. If disabled, +* then the PWM signal is not driven. Also configure the PWM output pad +* to the appropriate state. +*/ +static int dfll_pwm_set_output_enabled (struct tegra_dfll *td,bool enable) +{ +int ret; +u32 val, div; + +if (enable) { + ret =pinctrl_select_state (td->pwm_pin, td->pwm_enable_state); +if (ret <0 ) { +dev_err (td->dev,"setting enable state failed\n" ); +return -EINVAL ; + } + val =dfll_readl (td,DFLL_OUTPUT_CFG ); + val &= ~DFLL_OUTPUT_CFG_PWM_DIV_MASK ; + div =DIV_ROUND_UP (td->ref_rate, td->pwm_rate); + val |= (div <<DFLL_OUTPUT_CFG_PWM_DIV_SHIFT ) + &DFLL_OUTPUT_CFG_PWM_DIV_MASK ; +dfll_writel (td, val,DFLL_OUTPUT_CFG ); +dfll_wmb (td); + + val |=DFLL_OUTPUT_CFG_PWM_ENABLE ; +dfll_writel (td, val,DFLL_OUTPUT_CFG ); +dfll_wmb (td); + }else { + ret =pinctrl_select_state (td->pwm_pin, td->pwm_disable_state); +if (ret <0 ) +dev_warn (td->dev,"setting disable state failed\n" ); + + val =dfll_readl (td,DFLL_OUTPUT_CFG ); + val &= ~DFLL_OUTPUT_CFG_PWM_ENABLE ; +dfll_writel (td, val,DFLL_OUTPUT_CFG ); +dfll_wmb (td); + } + +return 0 ; +} + +/** +* dfll_set_force_output_value - set fixed value for force output +* @td: DFLL instance +* @out_val: value to force output +* +* Set the fixed value for force output, DFLL will output this value when +* force output is enabled. +*/ +static u32 dfll_set_force_output_value (struct tegra_dfll *td,u8 out_val) +{ +u32 val =dfll_readl (td,DFLL_OUTPUT_FORCE ); + + val = (val &DFLL_OUTPUT_FORCE_ENABLE ) | (out_val &OUT_MASK ); +dfll_writel (td, val,DFLL_OUTPUT_FORCE ); +dfll_wmb (td); + +return dfll_readl (td,DFLL_OUTPUT_FORCE ); +} + +/** +* dfll_set_force_output_enabled - enable/disable force output +* @td: DFLL instance +* @enable: whether to enable or disable the force output +* +* Set the enable control for fouce output with fixed value. +*/ +static void dfll_set_force_output_enabled (struct tegra_dfll *td,bool enable) +{ +u32 val =dfll_readl (td,DFLL_OUTPUT_FORCE ); + +if (enable) + val |=DFLL_OUTPUT_FORCE_ENABLE ; +else + val &= ~DFLL_OUTPUT_FORCE_ENABLE ; + +dfll_writel (td, val,DFLL_OUTPUT_FORCE ); +dfll_wmb (td); +} + +/** +* dfll_force_output - force output a fixed value +* @td: DFLL instance +* @out_sel: value to force output +* +* Set the fixed value for force output, DFLL will output this value. +*/ +static int dfll_force_output (struct tegra_dfll *td,unsigned int out_sel) +{ +u32 val; + +if (out_sel >OUT_MASK ) +return -EINVAL ; + + val =dfll_set_force_output_value (td, out_sel); +if ((td->mode <DFLL_CLOSED_LOOP ) && + !(val &DFLL_OUTPUT_FORCE_ENABLE )) { +dfll_set_force_output_enabled (td, true); + } + +return 0 ; +} +/** * dfll_load_lut - load the voltage lookup table * @td: struct tegra_dfll *
@@ -539,7 +695,7 @@ static void dfll_load_i2c_lut(struct tegra_dfll *td) lut_index = i; val =regulator_list_hardware_vsel (td->vdd_reg, - td->i2c_lut[lut_index]); + td->lut[lut_index]);__raw_writel (val, td->lut_base + i *4 ); }
@@ -594,24 +750,41 @@ static void dfll_init_out_if(struct tegra_dfll *td) {u32 val; - td->lut_min =0 ; - td->lut_max = td->i2c_lut_size -1 ; - td->lut_safe = td->lut_min +1 ; + td->lut_min = td->lut_bottom; + td->lut_max = td->lut_size -1 ; + td->lut_safe = td->lut_min + (td->lut_min < td->lut_max ?1 :0 ); + +/* clear DFLL_OUTPUT_CFG before setting new value */ +dfll_writel (td,0 ,DFLL_OUTPUT_CFG ); +dfll_wmb (td); -dfll_i2c_writel (td,0 ,DFLL_OUTPUT_CFG ); val = (td->lut_safe <<DFLL_OUTPUT_CFG_SAFE_SHIFT ) | - (td->lut_max <<DFLL_OUTPUT_CFG_MAX_SHIFT ) | - (td->lut_min <<DFLL_OUTPUT_CFG_MIN_SHIFT ); -dfll_i2c_writel (td, val,DFLL_OUTPUT_CFG ); -dfll_i2c_wmb (td); + (td->lut_max <<DFLL_OUTPUT_CFG_MAX_SHIFT ) | + (td->lut_min <<DFLL_OUTPUT_CFG_MIN_SHIFT ); +dfll_writel (td, val,DFLL_OUTPUT_CFG ); +dfll_wmb (td);dfll_writel (td,0 ,DFLL_OUTPUT_FORCE );dfll_i2c_writel (td,0 ,DFLL_INTR_EN );dfll_i2c_writel (td,DFLL_INTR_MAX_MASK |DFLL_INTR_MIN_MASK ,DFLL_INTR_STS ); -dfll_load_i2c_lut (td); -dfll_init_i2c_if (td); +if (td->pmu_if ==TEGRA_DFLL_PMU_PWM ) { +int vinit = td->reg_init_uV; +int vstep = td->soc->alignment.step_uv; +int vmin = td->lut_uv[0 ]; + +/* set initial voltage */ +if ((vinit >= vmin) && vstep) { +unsigned int vsel; + + vsel =DIV_ROUND_UP ((vinit - vmin), vstep); +dfll_force_output (td, vsel); + } + }else { +dfll_load_i2c_lut (td); +dfll_init_i2c_if (td); + } }/*
@@ -640,8 +813,8 @@ static int find_lut_index_for_rate(struct tegra_dfll *td, unsigned long rate) uv =dev_pm_opp_get_voltage (opp);dev_pm_opp_put (opp); -for (i =0 ; i < td->i2c_lut_size; i++) { -if (regulator_list_voltage (td->vdd_reg, td->i2c_lut[i]) == uv) +for (i = td->lut_bottom; i < td->lut_size; i++) { +if (regulator_list_voltage (td->vdd_reg, td->lut[i]) == uv)return i; }
@@ -863,9 +1036,14 @@ static int dfll_lock(struct tegra_dfll *td)return -EINVAL ; } -dfll_i2c_set_output_enabled (td, true); +if (td->pmu_if ==TEGRA_DFLL_PMU_PWM ) +dfll_pwm_set_output_enabled (td, true); +else +dfll_i2c_set_output_enabled (td, true); +dfll_set_mode (td,DFLL_CLOSED_LOOP );dfll_set_frequency_request (td, req); +dfll_set_force_output_enabled (td, false);return 0 ;default :
@@ -889,7 +1067,10 @@ static int dfll_unlock(struct tegra_dfll *td)case DFLL_CLOSED_LOOP :dfll_set_open_loop_config (td);dfll_set_mode (td,DFLL_OPEN_LOOP ); -dfll_i2c_set_output_enabled (td, false); +if (td->pmu_if ==TEGRA_DFLL_PMU_PWM ) +dfll_pwm_set_output_enabled (td, false); +else +dfll_i2c_set_output_enabled (td, false);return 0 ;case DFLL_OPEN_LOOP :
@@ -1171,15 +1352,17 @@ static int attr_registers_show(struct seq_file *s, void *data)seq_printf (s,"[0x%02x] = 0x%08x\n" , offs,dfll_i2c_readl (td, offs)); -seq_puts (s,"\nINTEGRATED I2C CONTROLLER REGISTERS:\n" ); - offs =DFLL_I2C_CLK_DIVISOR ; -seq_printf (s,"[0x%02x] = 0x%08x\n" , offs, -__raw_readl (td->i2c_controller_base + offs)); - -seq_puts (s,"\nLUT:\n" ); -for (offs =0 ; offs <4 *MAX_DFLL_VOLTAGES ; offs +=4 ) +if (td->pmu_if ==TEGRA_DFLL_PMU_I2C ) { +seq_puts (s,"\nINTEGRATED I2C CONTROLLER REGISTERS:\n" ); + offs =DFLL_I2C_CLK_DIVISOR ;seq_printf (s,"[0x%02x] = 0x%08x\n" , offs, -__raw_readl (td->lut_base + offs)); +__raw_readl (td->i2c_controller_base + offs)); + +seq_puts (s,"\nLUT:\n" ); +for (offs =0 ; offs <4 *MAX_DFLL_VOLTAGES ; offs +=4 ) +seq_printf (s,"[0x%02x] = 0x%08x\n" , offs, +__raw_readl (td->lut_base + offs)); + }return 0 ; }
@@ -1387,9 +1570,61 @@ static int find_vdd_map_entry_min(struct tegra_dfll *td, int uV)return -EINVAL ; } +/* +* dfll_build_pwm_lut - build the PWM regulator lookup table +* @td: DFLL instance +* @v_max: Vmax from OPP table +* +* Look-up table in h/w is ignored when PWM is used as DFLL interface to PMIC. +* In this case closed loop output is controlling duty cycle directly. The s/w +* look-up that maps PWM duty cycle to voltage is still built by this function. +*/ +static int dfll_build_pwm_lut (struct tegra_dfll *td,int v_max) +{ +int i, reg_volt; +unsigned long rate; +u8 lut_bottom =MAX_DFLL_VOLTAGES ; +int v_min = td->soc->cvb->min_millivolts *1000 ; + +for (i =0 ; i <MAX_DFLL_VOLTAGES ; i++) { + reg_volt = td->lut_uv[i]; + +/* since opp voltage is exact mv */ + reg_volt = (reg_volt /1000 ) *1000 ; +if (reg_volt > v_max) +break ; + + td->lut[i] = i; +if ((lut_bottom ==MAX_DFLL_VOLTAGES ) && (reg_volt >= v_min)) + lut_bottom = i; + } + +/* determine voltage boundaries */ + td->lut_size = i; +if ((lut_bottom ==MAX_DFLL_VOLTAGES ) || + (lut_bottom +1 >= td->lut_size)) { +dev_err (td->dev,"no voltage above DFLL minimum %d mV\n" , + td->soc->cvb->min_millivolts); +return -EINVAL ; + } + td->lut_bottom = lut_bottom; + +/* determine rate boundaries */ + rate =get_dvco_rate_below (td, td->lut_bottom); +if (!rate) { +dev_err (td->dev,"no opp below DFLL minimum voltage %d mV\n" , + td->soc->cvb->min_millivolts); +return -EINVAL ; + } + td->dvco_rate_min = rate; + +return 0 ; +} +/** * dfll_build_i2c_lut - build the I2C voltage register lookup table * @td: DFLL instance +* @v_max: Vmax from OPP table * * The DFLL hardware has 33 bytes of look-up table RAM that must be filled with * PMIC voltage register values that span the entire DFLL operating range.
@@ -1397,33 +1632,26 @@ static int find_vdd_map_entry_min(struct tegra_dfll *td, int uV)* the soc-specific platform driver (td->soc->opp_dev) and the PMIC * register-to-voltage mapping queried from the regulator framework. * -* On success, fills in td->i2c_lut and returns 0, or -err on failure. +* On success, fills in td->lut and returns 0, or -err on failure. */ -static int dfll_build_i2c_lut (struct tegra_dfll *td) +static int dfll_build_i2c_lut (struct tegra_dfll *td,int v_max) { +unsigned long rate;int ret = -EINVAL ; -int j, v, v_max, v_opp; +int j, v, v_opp;int selector; -unsigned long rate; -struct dev_pm_opp *opp;int lut; - rate =ULONG_MAX ; - opp =dev_pm_opp_find_freq_floor (td->soc->dev, &rate); -if (IS_ERR (opp)) { -dev_err (td->dev,"couldn't get vmax opp, empty opp table?\n" ); - goto out; - } - v_max =dev_pm_opp_get_voltage (opp); -dev_pm_opp_put (opp); - v = td->soc->cvb->min_millivolts *1000 ; lut =find_vdd_map_entry_exact (td, v);if (lut <0 ) goto out; - td->i2c_lut[0 ] = lut; + td->lut[0 ] = lut; + td->lut_bottom =0 ;for (j =1 , rate =0 ; ; rate++) { +struct dev_pm_opp *opp; + opp =dev_pm_opp_find_freq_ceil (td->soc->dev, &rate);if (IS_ERR (opp))break ;
@@ -1442,32 +1670,58 @@ static int dfll_build_i2c_lut(struct tegra_dfll *td) selector =find_vdd_map_entry_min (td, v);if (selector <0 ) goto out; -if (selector != td->i2c_lut[j -1 ]) - td->i2c_lut[j++] = selector; +if (selector != td->lut[j -1 ]) + td->lut[j++] = selector; } v = (j ==MAX_DFLL_VOLTAGES -1 ) ? v_max : v_opp; selector =find_vdd_map_entry_exact (td, v);if (selector <0 ) goto out; -if (selector != td->i2c_lut[j -1 ]) - td->i2c_lut[j++] = selector; +if (selector != td->lut[j -1 ]) + td->lut[j++] = selector;if (v >= v_max)break ; } - td->i2c_lut_size = j; + td->lut_size = j;if (!td->dvco_rate_min)dev_err (td->dev,"no opp above DFLL minimum voltage %d mV\n" , td->soc->cvb->min_millivolts); -else +else { ret =0 ; +for (j =0 ; j < td->lut_size; j++) + td->lut_uv[j] = +regulator_list_voltage (td->vdd_reg, + td->lut[j]); + } out:return ret; } +static int dfll_build_lut (struct tegra_dfll *td) +{ +unsigned long rate; +struct dev_pm_opp *opp; +int v_max; + + rate =ULONG_MAX ; + opp =dev_pm_opp_find_freq_floor (td->soc->dev, &rate); +if (IS_ERR (opp)) { +dev_err (td->dev,"couldn't get vmax opp, empty opp table?\n" ); +return -EINVAL ; + } + v_max =dev_pm_opp_get_voltage (opp); +dev_pm_opp_put (opp); + +if (td->pmu_if ==TEGRA_DFLL_PMU_PWM ) +return dfll_build_pwm_lut (td, v_max); +else +return dfll_build_i2c_lut (td, v_max); +} +/** * read_dt_param - helper function for reading required parameters from the DT * @td: DFLL instance
@@ -1526,11 +1780,55 @@ static int dfll_fetch_i2c_params(struct tegra_dfll *td) } td->i2c_reg = vsel_reg; - ret =dfll_build_i2c_lut (td); -if (ret) { -dev_err (td->dev,"couldn't build I2C LUT\n" ); +return 0 ; +} + +static int dfll_fetch_pwm_params (struct tegra_dfll *td) +{ +int ret, i; +u32 pwm_period; + +if (!td->soc->alignment.step_uv || !td->soc->alignment.offset_uv) { +dev_err (td->dev, +"Missing step or alignment info for PWM regulator" ); +return -EINVAL ; + } +for (i =0 ; i <MAX_DFLL_VOLTAGES ; i++) + td->lut_uv[i] = td->soc->alignment.offset_uv + + i * td->soc->alignment.step_uv; + + ret =read_dt_param (td,"nvidia,init-uv" , &td->reg_init_uV); +if (!ret) { +dev_err (td->dev,"couldn't get initialized voltage\n" ); +return ret; + } + + ret =read_dt_param (td,"nvidia,pwm-period" , &pwm_period); +if (!ret) { +dev_err (td->dev,"couldn't get PWM period\n" );return ret; } + td->pwm_rate = (NSEC_PER_SEC / pwm_period) * (MAX_DFLL_VOLTAGES -1 ); + + td->pwm_pin =devm_pinctrl_get (td->dev); +if (IS_ERR (td->pwm_pin)) { +dev_err (td->dev,"DT: missing pinctrl device\n" ); +return PTR_ERR (td->pwm_pin); + } + + td->pwm_enable_state =pinctrl_lookup_state (td->pwm_pin, +"dvfs_pwm_enable" ); +if (IS_ERR (td->pwm_enable_state)) { +dev_err (td->dev,"DT: missing pwm enabled state\n" ); +return PTR_ERR (td->pwm_enable_state); + } + + td->pwm_disable_state =pinctrl_lookup_state (td->pwm_pin, +"dvfs_pwm_disable" ); +if (IS_ERR (td->pwm_disable_state)) { +dev_err (td->dev,"DT: missing pwm disabled state\n" ); +return PTR_ERR (td->pwm_disable_state); + }return 0 ; }
@@ -1597,16 +1895,6 @@ int tegra_dfll_register(struct platform_device *pdev, td->soc = soc; - td->vdd_reg =devm_regulator_get (td->dev,"vdd-cpu" ); -if (IS_ERR (td->vdd_reg)) { - ret =PTR_ERR (td->vdd_reg); -if (ret != -EPROBE_DEFER ) -dev_err (td->dev,"couldn't get vdd_cpu regulator: %d\n" , - ret); - -return ret; - } - td->dvco_rst =devm_reset_control_get (td->dev,"dvco" );if (IS_ERR (td->dvco_rst)) {dev_err (td->dev,"couldn't get dvco reset\n" );
@@ -1619,10 +1907,27 @@ int tegra_dfll_register(struct platform_device *pdev,return ret; } - ret =dfll_fetch_i2c_params (td); +if (of_property_read_bool (td->dev->of_node,"nvidia,pwm-to-pmic" )) { + td->pmu_if =TEGRA_DFLL_PMU_PWM ; + ret =dfll_fetch_pwm_params (td); + }else { + td->vdd_reg =devm_regulator_get (td->dev,"vdd-cpu" ); +if (IS_ERR (td->vdd_reg)) { +dev_err (td->dev,"couldn't get vdd_cpu regulator\n" ); +return PTR_ERR (td->vdd_reg); + } + td->pmu_if =TEGRA_DFLL_PMU_I2C ; + ret =dfll_fetch_i2c_params (td); + }if (ret)return ret; + ret =dfll_build_lut (td); +if (ret) { +dev_err (td->dev,"couldn't build LUT\n" ); +return ret; + } + mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!mem) {dev_err (td->dev,"no control register resource\n" );
Signature · 1 line
2.19.2
PATCH 8/19 clk: tegra: dfll: round down voltages based on alignment
In reply to Joseph LoWhen generating the OPP table, the voltages are round down with the alignment from the regulator. The alignment should be applied for voltages look up as well.
Based on the work of Penny Chiu <[email protected]>.
--- drivers/clk/tegra/clk-dfll.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
drivers/clk/tegra/clk-dfll.c +15 -11
@@ -804,17 +804,17 @@ static void dfll_init_out_if(struct tegra_dfll *td)static int find_lut_index_for_rate (struct tegra_dfll *td,unsigned long rate) {struct dev_pm_opp *opp; -int i, uv; +int i, align_volt; opp =dev_pm_opp_find_freq_ceil (td->soc->dev, &rate);if (IS_ERR (opp))return PTR_ERR (opp); - uv =dev_pm_opp_get_voltage (opp); + align_volt =dev_pm_opp_get_voltage (opp) / td->soc->alignment.step_uv;dev_pm_opp_put (opp);for (i = td->lut_bottom; i < td->lut_size; i++) { -if (regulator_list_voltage (td->vdd_reg, td->lut[i]) == uv) +if ((td->lut_uv[i] / td->soc->alignment.step_uv) >= align_volt)return i; }
@@ -1532,15 +1532,17 @@ static int dfll_init(struct tegra_dfll *td)*/ static int find_vdd_map_entry_exact (struct tegra_dfll *td,int uV) { -int i, n_voltages, reg_uV; +int i, n_voltages, reg_volt, align_volt; + align_volt = uV / td->soc->alignment.step_uv; n_voltages =regulator_count_voltages (td->vdd_reg);for (i =0 ; i < n_voltages; i++) { - reg_uV =regulator_list_voltage (td->vdd_reg, i); -if (reg_uV <0 ) + reg_volt =regulator_list_voltage (td->vdd_reg, i) / + td->soc->alignment.step_uv; +if (reg_volt <0 )break ; -if (uV == reg_uV) +if (align_volt == reg_volt)return i; }
@@ -1554,15 +1556,17 @@ static int find_vdd_map_entry_exact(struct tegra_dfll *td, int uV)* */ static int find_vdd_map_entry_min (struct tegra_dfll *td,int uV) { -int i, n_voltages, reg_uV; +int i, n_voltages, reg_volt, align_volt; + align_volt = uV / td->soc->alignment.step_uv; n_voltages =regulator_count_voltages (td->vdd_reg);for (i =0 ; i < n_voltages; i++) { - reg_uV =regulator_list_voltage (td->vdd_reg, i); -if (reg_uV <0 ) + reg_volt =regulator_list_voltage (td->vdd_reg, i) / + td->soc->alignment.step_uv; +if (reg_volt <0 )break ; -if (uV <= reg_uV) +if (align_volt <= reg_volt)return i; }
Signature · 1 line
2.19.2
PATCH 9/19 clk: tegra: dfll: add CVB tables for Tegra210
In reply to Joseph LoAdd CVB tables with different chip characterization, so that we can generate the customize OPP table that suitable for different chips with different SKUs.
--- drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 426 +++++++++++++++++++++ drivers/clk/tegra/cvb.h | 1 + 2 files changed, 427 insertions(+)
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +426 -0
@@ -88,6 +88,421 @@ static const struct cvb_table tegra124_cpu_cvb_tables[] = { }, }; +static const unsigned long tegra210_cpu_max_freq_table[] = { + [0 ] =1912500000UL , + [1 ] =1912500000UL , + [2 ] =2218500000UL , + [3 ] =1785000000UL , + [4 ] =1632000000UL , + [5 ] =1912500000UL , + [6 ] =2014500000UL , + [7 ] =1734000000UL , + [8 ] =1683000000UL , + [9 ] =1555500000UL , + [10 ] =1504500000UL , +}; + +#define CPU_CVB_TABLE \ + .speedo_scale = 100, \ + .voltage_scale = 1000, \ + .entries = { \ + { 204000000UL, { 1007452, -23865, 370 } }, \ + { 306000000UL, { 1052709, -24875, 370 } }, \ + { 408000000UL, { 1099069, -25895, 370 } }, \ + { 510000000UL, { 1146534, -26905, 370 } }, \ + { 612000000UL, { 1195102, -27915, 370 } }, \ + { 714000000UL, { 1244773, -28925, 370 } }, \ + { 816000000UL, { 1295549, -29935, 370 } }, \ + { 918000000UL, { 1347428, -30955, 370 } }, \ + { 1020000000UL, { 1400411, -31965, 370 } }, \ + { 1122000000UL, { 1454497, -32975, 370 } }, \ + { 1224000000UL, { 1509687, -33985, 370 } }, \ + { 1326000000UL, { 1565981, -35005, 370 } }, \ + { 1428000000UL, { 1623379, -36015, 370 } }, \ + { 1530000000UL, { 1681880, -37025, 370 } }, \ + { 1632000000UL, { 1741485, -38035, 370 } }, \ + { 1734000000UL, { 1802194, -39055, 370 } }, \ + { 1836000000UL, { 1864006, -40065, 370 } }, \ + { 1912500000UL, { 1910780, -40815, 370 } }, \ + { 2014500000UL, { 1227000, 0, 0 } }, \ + { 2218500000UL, { 1227000, 0, 0 } }, \ + { 0UL, { 0, 0, 0 } }, \ + } + +#define CPU_CVB_TABLE_XA \ + .speedo_scale = 100, \ + .voltage_scale = 1000, \ + .entries = { \ + { 204000000UL, { 1250024, -39785, 565 } }, \ + { 306000000UL, { 1297556, -41145, 565 } }, \ + { 408000000UL, { 1346718, -42505, 565 } }, \ + { 510000000UL, { 1397511, -43855, 565 } }, \ + { 612000000UL, { 1449933, -45215, 565 } }, \ + { 714000000UL, { 1503986, -46575, 565 } }, \ + { 816000000UL, { 1559669, -47935, 565 } }, \ + { 918000000UL, { 1616982, -49295, 565 } }, \ + { 1020000000UL, { 1675926, -50645, 565 } }, \ + { 1122000000UL, { 1736500, -52005, 565 } }, \ + { 1224000000UL, { 1798704, -53365, 565 } }, \ + { 1326000000UL, { 1862538, -54725, 565 } }, \ + { 1428000000UL, { 1928003, -56085, 565 } }, \ + { 1530000000UL, { 1995097, -57435, 565 } }, \ + { 1606500000UL, { 2046149, -58445, 565 } }, \ + { 1632000000UL, { 2063822, -58795, 565 } }, \ + { 0UL, { 0, 0, 0 } }, \ + } + +#define CPU_CVB_TABLE_EUCM1 \ + .speedo_scale = 100, \ + .voltage_scale = 1000, \ + .entries = { \ + { 204000000UL, { 734429, 0, 0 } }, \ + { 306000000UL, { 768191, 0, 0 } }, \ + { 408000000UL, { 801953, 0, 0 } }, \ + { 510000000UL, { 835715, 0, 0 } }, \ + { 612000000UL, { 869477, 0, 0 } }, \ + { 714000000UL, { 903239, 0, 0 } }, \ + { 816000000UL, { 937001, 0, 0 } }, \ + { 918000000UL, { 970763, 0, 0 } }, \ + { 1020000000UL, { 1004525, 0, 0 } }, \ + { 1122000000UL, { 1038287, 0, 0 } }, \ + { 1224000000UL, { 1072049, 0, 0 } }, \ + { 1326000000UL, { 1105811, 0, 0 } }, \ + { 1428000000UL, { 1130000, 0, 0 } }, \ + { 1555500000UL, { 1130000, 0, 0 } }, \ + { 1632000000UL, { 1170000, 0, 0 } }, \ + { 1734000000UL, { 1227500, 0, 0 } }, \ + { 0UL, { 0, 0, 0 } }, \ + } + +#define CPU_CVB_TABLE_EUCM2 \ + .speedo_scale = 100, \ + .voltage_scale = 1000, \ + .entries = { \ + { 204000000UL, { 742283, 0, 0 } }, \ + { 306000000UL, { 776249, 0, 0 } }, \ + { 408000000UL, { 810215, 0, 0 } }, \ + { 510000000UL, { 844181, 0, 0 } }, \ + { 612000000UL, { 878147, 0, 0 } }, \ + { 714000000UL, { 912113, 0, 0 } }, \ + { 816000000UL, { 946079, 0, 0 } }, \ + { 918000000UL, { 980045, 0, 0 } }, \ + { 1020000000UL, { 1014011, 0, 0 } }, \ + { 1122000000UL, { 1047977, 0, 0 } }, \ + { 1224000000UL, { 1081943, 0, 0 } }, \ + { 1326000000UL, { 1090000, 0, 0 } }, \ + { 1479000000UL, { 1090000, 0, 0 } }, \ + { 1555500000UL, { 1162000, 0, 0 } }, \ + { 1683000000UL, { 1195000, 0, 0 } }, \ + { 0UL, { 0, 0, 0 } }, \ + } + +#define CPU_CVB_TABLE_EUCM2_JOINT_RAIL \ + .speedo_scale = 100, \ + .voltage_scale = 1000, \ + .entries = { \ + { 204000000UL, { 742283, 0, 0 } }, \ + { 306000000UL, { 776249, 0, 0 } }, \ + { 408000000UL, { 810215, 0, 0 } }, \ + { 510000000UL, { 844181, 0, 0 } }, \ + { 612000000UL, { 878147, 0, 0 } }, \ + { 714000000UL, { 912113, 0, 0 } }, \ + { 816000000UL, { 946079, 0, 0 } }, \ + { 918000000UL, { 980045, 0, 0 } }, \ + { 1020000000UL, { 1014011, 0, 0 } }, \ + { 1122000000UL, { 1047977, 0, 0 } }, \ + { 1224000000UL, { 1081943, 0, 0 } }, \ + { 1326000000UL, { 1090000, 0, 0 } }, \ + { 1479000000UL, { 1090000, 0, 0 } }, \ + { 1504500000UL, { 1120000, 0, 0 } }, \ + { 0UL, { 0, 0, 0 } }, \ + } + +#define CPU_CVB_TABLE_ODN \ + .speedo_scale = 100, \ + .voltage_scale = 1000, \ + .entries = { \ + { 204000000UL, { 721094, 0, 0 } }, \ + { 306000000UL, { 754040, 0, 0 } }, \ + { 408000000UL, { 786986, 0, 0 } }, \ + { 510000000UL, { 819932, 0, 0 } }, \ + { 612000000UL, { 852878, 0, 0 } }, \ + { 714000000UL, { 885824, 0, 0 } }, \ + { 816000000UL, { 918770, 0, 0 } }, \ + { 918000000UL, { 915716, 0, 0 } }, \ + { 1020000000UL, { 984662, 0, 0 } }, \ + { 1122000000UL, { 1017608, 0, 0 } }, \ + { 1224000000UL, { 1050554, 0, 0 } }, \ + { 1326000000UL, { 1083500, 0, 0 } }, \ + { 1428000000UL, { 1116446, 0, 0 } }, \ + { 1581000000UL, { 1130000, 0, 0 } }, \ + { 1683000000UL, { 1168000, 0, 0 } }, \ + { 1785000000UL, { 1227500, 0, 0 } }, \ + { 0UL, { 0, 0, 0 } }, \ + } + +struct cvb_table tegra210_cpu_cvb_tables[] = { + { + .speedo_id =10 , + .process_id =0 , + .min_millivolts =840 , + .max_millivolts =1120 , +CPU_CVB_TABLE_EUCM2_JOINT_RAIL , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =10 , + .process_id =1 , + .min_millivolts =840 , + .max_millivolts =1120 , +CPU_CVB_TABLE_EUCM2_JOINT_RAIL , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =9 , + .process_id =0 , + .min_millivolts =900 , + .max_millivolts =1162 , +CPU_CVB_TABLE_EUCM2 , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + } + }, + { + .speedo_id =9 , + .process_id =1 , + .min_millivolts =900 , + .max_millivolts =1162 , +CPU_CVB_TABLE_EUCM2 , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + } + }, + { + .speedo_id =8 , + .process_id =0 , + .min_millivolts =900 , + .max_millivolts =1195 , +CPU_CVB_TABLE_EUCM2 , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + } + }, + { + .speedo_id =8 , + .process_id =1 , + .min_millivolts =900 , + .max_millivolts =1195 , +CPU_CVB_TABLE_EUCM2 , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + } + }, + { + .speedo_id =7 , + .process_id =0 , + .min_millivolts =841 , + .max_millivolts =1227 , +CPU_CVB_TABLE_EUCM1 , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =7 , + .process_id =1 , + .min_millivolts =841 , + .max_millivolts =1227 , +CPU_CVB_TABLE_EUCM1 , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =6 , + .process_id =0 , + .min_millivolts =870 , + .max_millivolts =1150 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune1 =0x20091d9 , + } + }, + { + .speedo_id =6 , + .process_id =1 , + .min_millivolts =870 , + .max_millivolts =1150 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune1 =0x25501d0 , + } + }, + { + .speedo_id =5 , + .process_id =0 , + .min_millivolts =818 , + .max_millivolts =1227 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =5 , + .process_id =1 , + .min_millivolts =818 , + .max_millivolts =1227 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x25501d0 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =4 , + .process_id =-1 , + .min_millivolts =918 , + .max_millivolts =1113 , +CPU_CVB_TABLE_XA , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune1 =0x17711BD , + } + }, + { + .speedo_id =3 , + .process_id =0 , + .min_millivolts =825 , + .max_millivolts =1227 , +CPU_CVB_TABLE_ODN , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =3 , + .process_id =1 , + .min_millivolts =825 , + .max_millivolts =1227 , +CPU_CVB_TABLE_ODN , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x25501d0 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =2 , + .process_id =0 , + .min_millivolts =870 , + .max_millivolts =1227 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune1 =0x20091d9 , + } + }, + { + .speedo_id =2 , + .process_id =1 , + .min_millivolts =870 , + .max_millivolts =1227 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune1 =0x25501d0 , + } + }, + { + .speedo_id =1 , + .process_id =0 , + .min_millivolts =837 , + .max_millivolts =1227 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =1 , + .process_id =1 , + .min_millivolts =837 , + .max_millivolts =1227 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x25501d0 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =0 , + .process_id =0 , + .min_millivolts =850 , + .max_millivolts =1170 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =0 , + .process_id =1 , + .min_millivolts =850 , + .max_millivolts =1170 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x25501d0 , + .tune_high_min_millivolts =864 , + } + }, +}; +static const struct dfll_fcpu_data tegra124_dfll_fcpu_data = { .cpu_max_freq_table = tegra124_cpu_max_freq_table, .cpu_max_freq_table_size =ARRAY_SIZE (tegra124_cpu_max_freq_table),
@@ -95,11 +510,22 @@ static const struct dfll_fcpu_data tegra124_dfll_fcpu_data = { .cpu_cvb_tables_size = ARRAY_SIZE(tegra124_cpu_cvb_tables) }; +static const struct dfll_fcpu_data tegra210_dfll_fcpu_data = { + .cpu_max_freq_table = tegra210_cpu_max_freq_table, + .cpu_max_freq_table_size =ARRAY_SIZE (tegra210_cpu_max_freq_table), + .cpu_cvb_tables = tegra210_cpu_cvb_tables, + .cpu_cvb_tables_size =ARRAY_SIZE (tegra210_cpu_cvb_tables), +}; +static const struct of_device_id tegra124_dfll_fcpu_of_match[] = { { .compatible ="nvidia,tegra124-dfll" , .data = &tegra124_dfll_fcpu_data, }, + { + .compatible ="nvidia,tegra210-dfll" , + .data = &tegra210_dfll_fcpu_data + }, { }, };
drivers/clk/tegra/cvb.h +1 -0
@@ -41,6 +41,7 @@ struct cvb_cpu_dfll_data {u32 tune0_low;u32 tune0_high;u32 tune1; +unsigned int tune_high_min_millivolts; };struct cvb_table {
Signature · 1 line
2.19.2
PATCH 10/19 clk: tegra: dfll: build clk-dfll.c for Tegra124 and Tegra210
In reply to Joseph LoFrom: Peter De Schrijver <[email protected]>
Tegra210 has a DFLL as well and can share the majority of the code with the Tegra124 implementation. So build the same code for both platforms.
--- drivers/clk/tegra/Kconfig | 5 +++++ drivers/clk/tegra/Makefile | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/clk/tegra/Kconfig +5 -0
@@ -5,3 +5,8 @@ config TEGRA_CLK_EMC config CLK_TEGRA_BPMP def_bool y depends on TEGRA_BPMP + +config TEGRA_CLK_DFLL + depends on (ARCH_TEGRA_124_SOC || ARCH_TEGRA_210_SOC) + select PM_OPP + def_bool y
drivers/clk/tegra/Makefile +1 -1
@@ -20,7 +20,7 @@ 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_ARCH_TEGRA_124_SOC) += clk-tegra124-dfll-fcpu.o +obj-$(CONFIG_TEGRA_CLK_DFLL) += clk-tegra124-dfll-fcpu.o obj-$(CONFIG_ARCH_TEGRA_132_SOC) += clk-tegra124.o obj-y += cvb.o obj-$(CONFIG_ARCH_TEGRA_210_SOC) += clk-tegra210.o
Signature · 1 line
2.19.2
PATCH 11/19 cpufreq: tegra124: do not handle the CPU rail
In reply to Joseph LoThe Tegra124 cpufreq driver has no information to handle the Vdd-CPU rail. So the driver shouldn't handle for the CPU clock switching from DFLL to other PLL clocks. It was designed to work on DFLL clock only, which handle the frequency/voltage scaling in the background. This patch removes the driver dependency of the CPU rail.
--- drivers/cpufreq/Kconfig.arm | 2 +- drivers/cpufreq/tegra124-cpufreq.c | 26 ++------------------------ 2 files changed, 3 insertions(+), 25 deletions(-)
drivers/cpufreq/Kconfig.arm +1 -1
@@ -262,7 +262,7 @@ config ARM_TEGRA20_CPUFREQ config ARM_TEGRA124_CPUFREQ tristate "Tegra124 CPUFreq support" - depends on ARCH_TEGRA && CPUFREQ_DT && REGULATOR + depends on ARCH_TEGRA && CPUFREQ_DT default y help This adds the CPUFreq driver support for Tegra124 SOCs.
drivers/cpufreq/tegra124-cpufreq.c +2 -24
@@ -22,11 +22,9 @@#include <linux/of.h> #include <linux/platform_device.h> #include <linux/pm_opp.h> -#include <linux/regulator/consumer.h> #include <linux/types.h> struct tegra124_cpufreq_priv { -struct regulator *vdd_cpu_reg;struct clk *cpu_clk;struct clk *pllp_clk;struct clk *pllx_clk;
@@ -60,14 +58,6 @@ static int tegra124_cpu_switch_to_dfll(struct tegra124_cpufreq_priv *priv)return ret; } -static void tegra124_cpu_switch_to_pllx (struct tegra124_cpufreq_priv *priv) -{ -clk_set_parent (priv->cpu_clk, priv->pllp_clk); -clk_disable_unprepare (priv->dfll_clk); -regulator_sync_voltage (priv->vdd_cpu_reg); -clk_set_parent (priv->cpu_clk, priv->pllx_clk); -} -static int tegra124_cpufreq_probe (struct platform_device *pdev) {struct tegra124_cpufreq_priv *priv;
@@ -88,16 +78,10 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)if (!np)return -ENODEV ; - priv->vdd_cpu_reg =regulator_get (cpu_dev,"vdd-cpu" ); -if (IS_ERR (priv->vdd_cpu_reg)) { - ret =PTR_ERR (priv->vdd_cpu_reg); - goto out_put_np; - } - priv->cpu_clk =of_clk_get_by_name (np,"cpu_g" );if (IS_ERR (priv->cpu_clk)) { ret =PTR_ERR (priv->cpu_clk); - goto out_put_vdd_cpu_reg; + goto out_put_np; } priv->dfll_clk =of_clk_get_by_name (np,"dfll" );
@@ -129,15 +113,13 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)platform_device_register_full (&cpufreq_dt_devinfo);if (IS_ERR (priv->cpufreq_dt_pdev)) { ret =PTR_ERR (priv->cpufreq_dt_pdev); - goto out_switch_to_pllx; + goto out_put_pllp_clk; }platform_set_drvdata (pdev, priv);return 0 ; -out_switch_to_pllx: -tegra124_cpu_switch_to_pllx (priv); out_put_pllp_clk:clk_put (priv->pllp_clk); out_put_pllx_clk:
@@ -146,8 +128,6 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)clk_put (priv->dfll_clk); out_put_cpu_clk:clk_put (priv->cpu_clk); -out_put_vdd_cpu_reg: -regulator_put (priv->vdd_cpu_reg); out_put_np:of_node_put (np);
@@ -159,13 +139,11 @@ static int tegra124_cpufreq_remove(struct platform_device *pdev)struct tegra124_cpufreq_priv *priv =platform_get_drvdata (pdev);platform_device_unregister (priv->cpufreq_dt_pdev); -tegra124_cpu_switch_to_pllx (priv);clk_put (priv->pllp_clk);clk_put (priv->pllx_clk);clk_put (priv->dfll_clk);clk_put (priv->cpu_clk); -regulator_put (priv->vdd_cpu_reg);return 0 ; }
Signature · 1 line
2.19.2
PATCH 12/19 cpufreq: tegra124: extend to support Tegra210
In reply to Joseph LoTegra210 uses the same methodology as Tegra124 for CPUFreq controlling that based on DFLL clock. So extending this driver to support Tegra210.
--- drivers/cpufreq/tegra124-cpufreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/cpufreq/tegra124-cpufreq.c +2 -1
@@ -159,7 +159,8 @@ static int __init tegra_cpufreq_init(void)int ret;struct platform_device *pdev; -if (!of_machine_is_compatible ("nvidia,tegra124" )) +if (!(of_machine_is_compatible ("nvidia,tegra124" ) || +of_machine_is_compatible ("nvidia,tegra210" )))return -ENODEV ;/*
Signature · 1 line
2.19.2
PATCH 13/19 arm64: dts: tegra210: add DFLL clock
In reply to Joseph LoAdd essential DFLL clock properties for Tegra210.
--- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/arm64/boot/dts/nvidia/tegra210.dtsi +19 -0
@@ -4,6 +4,7 @@ #include <dt-bindings/memory/tegra210-mc.h> #include <dt-bindings/pinctrl/pinctrl-tegra.h> #include <dt-bindings/pinctrl/pinctrl-tegra-io-pad.h> +#include <dt-bindings/reset/tegra210-car.h> #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/thermal/tegra124-soctherm.h>
@@ -1131,6 +1132,24 @@ #nvidia,mipi-calibrate-cells = <1>; }; + dfll: clock@70110000 { + compatible = "nvidia,tegra210-dfll"; + reg = <0 0x70110000 0 0x100>, /* DFLL control */ + <0 0x70110000 0 0x100>, /* I2C output control */ + <0 0x70110100 0 0x100>, /* Integrated I2C controller */ + <0 0x70110200 0 0x100>; /* Look-up table RAM */ + interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&tegra_car TEGRA210_CLK_DFLL_SOC>, + <&tegra_car TEGRA210_CLK_DFLL_REF>, + <&tegra_car TEGRA210_CLK_I2C5>; + clock-names = "soc", "ref", "i2c"; + resets = <&tegra_car TEGRA210_RST_DFLL_DVCO>; + reset-names = "dvco"; + #clock-cells = <0>; + clock-output-names = "dfllCPU_out"; + status = "disabled"; + }; + aconnect@702c0000 { compatible = "nvidia,tegra210-aconnect"; clocks = <&tegra_car TEGRA210_CLK_APE>,
Signature · 1 line
2.19.2
PATCH 14/19 arm64: dts: tegra210: add CPU clocks
In reply to Joseph LoAdd CPU clocks for Tegra210.
--- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/nvidia/tegra210.dtsi +6 -0
@@ -1304,6 +1304,12 @@ device_type = "cpu"; compatible = "arm,cortex-a57"; reg = <0>; + clocks = <&tegra_car TEGRA210_CLK_CCLK_G>, + <&tegra_car TEGRA210_CLK_PLL_X>, + <&tegra_car TEGRA210_CLK_PLL_P_OUT4>, + <&dfll>; + clock-names = "cpu_g", "pll_x", "pll_p", "dfll"; + clock-latency = <300000>; }; cpu@1 {
Signature · 1 line
2.19.2
PATCH 15/19 arm64: dts: tegra210-p2597: add pinmux for PWM-based DFLL support
In reply to Joseph LoAdd pinmux for PWM-based DFLL support.
--- arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi +14 -0
@@ -1278,6 +1278,20 @@ nvidia,open-drain = <TEGRA_PIN_DISABLE>; }; }; + + dvfs_pwm_active_state: dvfs_pwm_active { + dvfs_pwm_pbb1 { + nvidia,pins = "dvfs_pwm_pbb1"; + nvidia,tristate = <TEGRA_PIN_DISABLE>; + }; + }; + + dvfs_pwm_inactive_state: dvfs_pwm_inactive { + dvfs_pwm_pbb1 { + nvidia,pins = "dvfs_pwm_pbb1"; + nvidia,tristate = <TEGRA_PIN_ENABLE>; + }; + }; }; pwm@7000a000 {
Signature · 1 line
2.19.2
PATCH 16/19 arm64: dts: tegra210-p2371-2180: enable DFLL clock
In reply to Joseph LoEnable DFLL clock for Jetson TX1 platform.
--- .../boot/dts/nvidia/tegra210-p2371-2180.dts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+)
arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts +20 -0
@@ -78,4 +78,24 @@ }; }; }; + + clock@70110000 { + status = "okay"; + nvidia,pwm-to-pmic; + nvidia,init-uv = <1000000>; + nvidia,align-offset-uv = <708000>; + nvidia,align-step-uv = <19200>; + nvidia,sample-rate = <25000>; + nvidia,droop-ctrl = <0x00000f00>; + nvidia,force-mode = <1>; + nvidia,cf = <6>; + nvidia,ci = <0>; + nvidia,cg = <2>; + nvidia,idle-override; + nvidia,one-shot-calibrate; + nvidia,pwm-period = <2500>; /* 2.5us */ + pinctrl-names = "dvfs_pwm_enable", "dvfs_pwm_disable"; + pinctrl-0 = <&dvfs_pwm_active_state>; + pinctrl-1 = <&dvfs_pwm_inactive_state>; + }; };
Signature · 1 line
2.19.2
PATCH 17/19 arm64: dts: tegra210-smaug: add CPU power rail regulator
In reply to Joseph LoAdd CPU power rail regulator for Smaug board.
--- arch/arm64/boot/dts/nvidia/tegra210-smaug.dts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/arm64/boot/dts/nvidia/tegra210-smaug.dts +19 -0
@@ -1340,6 +1340,25 @@ status = "okay"; clock-frequency = <1000000>; + max77621_cpu: max77621@1b { + compatible = "maxim,max77621"; + reg = <0x1b>; + interrupt-parent = <&gpio>; + interrupts = <TEGRA_GPIO(Y, 1) IRQ_TYPE_LEVEL_LOW>; + regulator-name = "PPVAR_CPU"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <1231250>; + regulator-ramp-delay = <12500>; + regulator-boot-on; + regulator-always-on; + maxim,dvs-default-state = <1>; + maxim,enable-active-discharge; + maxim,enable-bias-control; + maxim,enable-etr; + maxim,enable-gpio = <&max77620 5 0>; + maxim,externally-enable; + }; + max77620: max77620@3c { compatible = "maxim,max77620"; reg = <0x3c>;
Signature · 1 line
2.19.2
PATCH 18/19 arm64: dts: tegra210-smaug: enable DFLL clock
In reply to Joseph LoEnable DFLL clock for Smaug board.
--- arch/arm64/boot/dts/nvidia/tegra210-smaug.dts | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm64/boot/dts/nvidia/tegra210-smaug.dts +12 -0
@@ -1698,6 +1698,18 @@ status = "okay"; }; + clock@70110000 { + status = "okay"; + nvidia,sample-rate = <12500>; + nvidia,droop-ctrl = <0x00000f00>; + nvidia,force-mode = <1>; + nvidia,cf = <6>; + nvidia,ci = <0>; + nvidia,cg = <2>; + nvidia,i2c-fs-rate = <400000>; + vdd-cpu-supply = <&max77621_cpu>; + }; + aconnect@702c0000 { status = "okay";
Signature · 1 line
2.19.2
PATCH 19/19 arm64: defconfig: Enable MAX8973 regulator
In reply to Joseph LoThe Tegra210 Smaug board uses MAX77621 for both CPU & GPU rail. Note that max8973 and max77621 share the same driver. So enable this driver for the PMIC.
--- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
@@ -420,6 +420,7 @@ CONFIG_REGULATOR_GPIO=y CONFIG_REGULATOR_HI6421V530=y CONFIG_REGULATOR_HI655X=y CONFIG_REGULATOR_MAX77620=y +CONFIG_REGULATOR_MAX8973=y CONFIG_REGULATOR_PWM=y CONFIG_REGULATOR_QCOM_RPMH=y CONFIG_REGULATOR_QCOM_SMD_RPM=y
Signature · 1 line
2.19.2
Re: [PATCH 12/19] cpufreq: tegra124: extend to support Tegra210
In reply to Joseph LoQuoted 15 lines · Joseph Lo
Tegra210 uses the same methodology as Tegra124 for CPUFreq controlling that based on DFLL clock. So extending this driver to support Tegra210.
--- drivers/cpufreq/tegra124-cpufreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/cpufreq/tegra124-cpufreq.c +0
-0
drivers/cpufreq/tegra124-cpufreq.c static int __init tegra_cpufreq_init(void) · line 166
Quoted 9 lines
drivers/cpufreq/tegra124-cpufreq.c +2
-1@@ -159,7 +159,8 @@ static int __init tegra_cpufreq_init(void)int ret;struct platform_device *pdev; -if (!of_machine_is_compatible ("nvidia,tegra124" )) +if (!(of_machine_is_compatible ("nvidia,tegra124" ) || +of_machine_is_compatible ("nvidia,tegra210" )))return -ENODEV ;/*
Signature · 1 line
viresh
Re: [PATCH 12/19] cpufreq: tegra124: extend to support Tegra210
In reply to Joseph LoQuoted 16 lines · Joseph Lo
Tegra210 uses the same methodology as Tegra124 for CPUFreq controlling that based on DFLL clock. So extending this driver to support Tegra210.
--- drivers/cpufreq/tegra124-cpufreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/cpufreq/tegra124-cpufreq.c +0
-0
drivers/cpufreq/tegra124-cpufreq.c static int __init tegra_cpufreq_init(void) · line 166
Quoted 9 lines
drivers/cpufreq/tegra124-cpufreq.c +2
-1@@ -159,7 +159,8 @@ static int __init tegra_cpufreq_init(void)int ret;struct platform_device *pdev; -if (!of_machine_is_compatible ("nvidia,tegra124" )) +if (!(of_machine_is_compatible ("nvidia,tegra124" ) || +of_machine_is_compatible ("nvidia,tegra210" )))return -ENODEV ;/*
Seems that's not enough, you also need to blacklist "nvidia,tegra210" in the drivers/cpufreq/cpufreq-dt-platdev.c
Quoted 63 lines · Joseph Lo
This series introduces support for the DFLL as a CPU clock source on Tegra210. As Jetson TX1 uses a PWM controlled regulator IC which is driven directly by the DFLLs PWM output, we also introduce support for PWM regulators next to I2C controlled regulators. The DFLL output frequency is directly controlled by the regulator voltage. The registers for controlling the PWM are part of the DFLL IP block, so there's no separate linux regulator object involved because the regulator IC only supplies the rail powering the CPUs. It doesn't have any other controls.
The patch 1~4 are the patches of DT bindings update for DFLL clock and Tegra124 cpufreq, which add PWM and Tegra210 support for DFLL clock and remove deprecate properties for Tegra124 cpufreq bindings.
The patch 5~10 are the patches for DFLL clock driver update for PWM-mode DFLL support.
The patch 11 and 12 are the Tegra124 cpufreq driver update to make it work with Tegra210.
The patch 13~18 are the devicetree files update for Tegra210 SoC and platforms. Two platforms are updated here for different DFLL mode usage. The Tegra210-p2371-2180 (a.k.a. Jetson Tx1) uses DFLL-PWM and the Tegra210-smaug (a.k.a. Pixel C) uses DFLL-I2C. So two different modes are verified with this series.
The patch 19 is the patch for enabling the CPU regulator for Smaug board.
Joseph Lo (16):
dt-bindings: clock: tegra124-dfll: add Tegra210 support
dt-bindings: cpufreq: tegra124: remove vdd-cpu-supply from required
properties
dt-bindings: cpufreq: tegra124: removecpu_lpclock from required
properties
clk: tegra: dfll: CVB calculation alignment with the regulator
clk: tegra: dfll: support PWM regulator control
clk: tegra: dfll: round down voltages based on alignment
clk: tegra: dfll: add CVB tables for Tegra210
cpufreq: tegra124: do not handle the CPU rail
cpufreq: tegra124: extend to support Tegra210
arm64: dts: tegra210: add DFLL clock
arm64: dts: tegra210: add CPU clocks
arm64: dts: tegra210-p2597: add pinmux for PWM-based DFLL support
arm64: dts: tegra210-p2371-2180: enable DFLL clock
arm64: dts: tegra210-smaug: add CPU power rail regulator
arm64: dts: tegra210-smaug: enable DFLL clock
arm64: defconfig: Enable MAX8973 regulatorPeter De Schrijver (3):
dt-bindings: clock: tegra124-dfll: Update DFLL binding for PWM
regulator
clk: tegra: dfll: registration for multiple SoCs
clk: tegra: dfll: buildclk-dfll.cfor Tegra124 and Tegra210.../bindings/clock/nvidia,tegra124-dfll.txt | 77 ++- .../cpufreq/nvidia,tegra124-cpufreq.txt | 6 +- .../boot/dts/nvidia/tegra210-p2371-2180.dts | 20 + .../arm64/boot/dts/nvidia/tegra210-p2597.dtsi | 14 + arch/arm64/boot/dts/nvidia/tegra210-smaug.dts | 31 + arch/arm64/boot/dts/nvidia/tegra210.dtsi | 25 + arch/arm64/configs/defconfig | 1 + drivers/clk/tegra/Kconfig | 5 + drivers/clk/tegra/Makefile | 2 +-
Quoted 8 lines
drivers/clk/tegra/clk-dfll.c | 455 ++++++++++++--- drivers/clk/tegra/clk-dfll.h | 6 +- drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 536 +++++++++++++++++- drivers/clk/tegra/cvb.c | 12 +- drivers/clk/tegra/cvb.h | 7 +- drivers/cpufreq/Kconfig.arm | 2 +- drivers/cpufreq/tegra124-cpufreq.c | 29 +- 16 files changed, 1095 insertions(+), 133 deletions(-)
Hi Joseph,
can you highlight the build and runtime dependencies between the various patches? For example, can I pick up all the arch/arm64 patches into the Tegra tree without breaking anything?
Thierry
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 03/19] dt-bindings: cpufreq: tegra124: remove vdd-cpu-supply from required properties
In reply to Joseph LoQuoted 4 lines · Joseph Lo
The Tegra124 cpufreq driver works only with DFLL clock, which is a hardware-based frequency/voltage controller. The driver doesn't need to control the regulator itself. Hence remove that.
I think this is required for DFLL controlled I2C regulators because the regulator is queried for voltage selectors and I2C slave ID?
Peter.
Quoted 29 lines
Signed-off-by Joseph Lo <[email protected]>--- .../devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt | 2 -- 1 file changed, 2 deletions(-)Documentation/devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt +0
-2@@ -13,7 +13,6 @@ Required properties: - pll_x: Fast PLL clocksource. - pll_p: Auxiliary PLL used during fast PLL rate changes. - dfll: Fast DFLL clocksource that also automatically scales CPU voltage. -- vdd-cpu-supply: Regulator for CPU voltage Optional properties: - clock-latency: Specify the possible maximum transition latency for clock,@@ -37,7 +36,6 @@ cpus { <&dfll>; clock-names = "cpu_g", "cpu_lp", "pll_x", "pll_p", "dfll"; clock-latency = <300000>; - vdd-cpu-supply: <&vdd_cpu>; };Signature · 1 line
2.19.2
Re: [PATCH 04/19] dt-bindings: cpufreq: tegra124: remove cpu_lp clock from required properties
In reply to Joseph LoQuoted 4 lines · Joseph Lo
The
cpu_lpclock property is only needed when the CPUfreq driver supports CPU cluster switching. But it was not a design for this driver and it didn't handle that as well. So removing this property.
I would mark it optional. This means current DTs will still be technically compatible with this binding doc.
Peter.
Quoted 34 lines
Signed-off-by Joseph Lo <[email protected]>--- .../devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)Documentation/devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt +1
-3@@ -9,7 +9,6 @@ Required properties: See ../clocks/clock-bindings.txt for details. - clock-names: Must include the following entries: - cpu_g: Clock mux for the fast CPU cluster. - - cpu_lp: Clock mux for the low-power CPU cluster. - pll_x: Fast PLL clocksource. - pll_p: Auxiliary PLL used during fast PLL rate changes. - dfll: Fast DFLL clocksource that also automatically scales CPU voltage.@@ -30,11 +29,10 @@ cpus { reg = <0>; clocks = <&tegra_car TEGRA124_CLK_CCLK_G>, - <&tegra_car TEGRA124_CLK_CCLK_LP>, <&tegra_car TEGRA124_CLK_PLL_X>, <&tegra_car TEGRA124_CLK_PLL_P>, <&dfll>; - clock-names = "cpu_g", "cpu_lp", "pll_x", "pll_p", "dfll"; + clock-names = "cpu_g", "pll_x", "pll_p", "dfll"; clock-latency = <300000>; };Signature · 1 line
2.19.2
Re: [PATCH 08/19] clk: tegra: dfll: round down voltages based on alignment
In reply to Joseph LoQuoted 37 lines · Joseph Lo
When generating the OPP table, the voltages are round down with the alignment from the regulator. The alignment should be applied for voltages look up as well.
Based on the work of Penny Chiu <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>--- drivers/clk/tegra/clk-dfll.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)drivers/clk/tegra/clk-dfll.c +3
-3@@ -804,17 +804,17 @@ static void dfll_init_out_if(struct tegra_dfll *td)static int find_lut_index_for_rate (struct tegra_dfll *td,unsigned long rate) {struct dev_pm_opp *opp; -int i, uv; +int i, align_volt; opp =dev_pm_opp_find_freq_ceil (td->soc->dev, &rate);if (IS_ERR (opp))return PTR_ERR (opp); - uv =dev_pm_opp_get_voltage (opp); + align_volt =dev_pm_opp_get_voltage (opp) / td->soc->alignment.step_uv;dev_pm_opp_put (opp);for (i = td->lut_bottom; i < td->lut_size; i++) { -if (regulator_list_voltage (td->vdd_reg, td->lut[i]) == uv) +if ((td->lut_uv[i] / td->soc->alignment.step_uv) >= align_volt)return i; }
drivers/clk/tegra/clk-dfll.c static int dfll_init(struct tegra_dfll *td) · line 1532
Quoted 1 line
drivers/clk/tegra/clk-dfll.c +0
-0@@ -1532,15 +1532,17 @@ static int dfll_init(struct tegra_dfll *td)*/
These 2 functions are only valid for I2C mode. We should probably add a WARN_ON() in case they are called when PWM mode is used and return -EINVAL.
Quoted 45 lines
drivers/clk/tegra/clk-dfll.c +12
-8static int find_vdd_map_entry_exact (struct tegra_dfll *td,int uV) { -int i, n_voltages, reg_uV; +int i, n_voltages, reg_volt, align_volt; + align_volt = uV / td->soc->alignment.step_uv; n_voltages =regulator_count_voltages (td->vdd_reg);for (i =0 ; i < n_voltages; i++) { - reg_uV =regulator_list_voltage (td->vdd_reg, i); -if (reg_uV <0 ) + reg_volt =regulator_list_voltage (td->vdd_reg, i) / + td->soc->alignment.step_uv; +if (reg_volt <0 )break ; -if (uV == reg_uV) +if (align_volt == reg_volt)return i; }@@ -1554,15 +1556,17 @@ static int find_vdd_map_entry_exact(struct tegra_dfll *td, int uV)* */ static int find_vdd_map_entry_min (struct tegra_dfll *td,int uV) { -int i, n_voltages, reg_uV; +int i, n_voltages, reg_volt, align_volt; + align_volt = uV / td->soc->alignment.step_uv; n_voltages =regulator_count_voltages (td->vdd_reg);for (i =0 ; i < n_voltages; i++) { - reg_uV =regulator_list_voltage (td->vdd_reg, i); -if (reg_uV <0 ) + reg_volt =regulator_list_voltage (td->vdd_reg, i) / + td->soc->alignment.step_uv; +if (reg_volt <0 )break ; -if (uV <= reg_uV) +if (align_volt <= reg_volt)return i; }Signature · 1 line
2.19.2
Re: [PATCH 07/19] clk: tegra: dfll: support PWM regulator control
In reply to Joseph LoQuoted 88 lines · Joseph Lo
The DFLL hardware supports two modes (I2C and PWM) for voltage control when requesting a frequency. In this patch, we introduce PWM mode support.
To support that, we re-organize the LUT for unifying the table for both cases of I2C and PWM mode. And generate that based on regulator info. For the PWM-based regulator, we get this info from DT. And do the same as the case of I2C LUT, which can help to map the PMIC voltage ID and voltages that the regulator supported.
The other parts are the support code for initializing the DFLL hardware to support PWM mode. Also, the register debugfs file is slightly reworked to only show the i2c registers when I2C mode is in use.
Based on the work of Peter De Schrijver <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>--- drivers/clk/tegra/clk-dfll.c | 431 ++++++++++++++++++++++++++++++----- 1 file changed, 368 insertions(+), 63 deletions(-)drivers/clk/tegra/clk-dfll.c +21
-5@@ -1,7 +1,7 @@/* * clk-dfll.c - Tegra DFLL clock source common code * -* Copyright (C) 2012-2014 NVIDIA Corporation. All rights reserved. +* Copyright (C) 2012-2018 NVIDIA Corporation. All rights reserved. * * Aleksandr Frid <[email protected]> * Paul Walmsley <[email protected]> @@ -47,6 +47,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/pinctrl/consumer.h> #include <linux/pm_opp.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> @@ -243,6 +244,12 @@ enum dfll_tune_range { DFLL_TUNE_LOW = 1, }; + +enum tegra_dfll_pmu_if { +TEGRA_DFLL_PMU_I2C =0 , +TEGRA_DFLL_PMU_PWM =1 , +}; +/** * struct dfll_rate_req - target DFLL rate request data * @rate: target frequency, after the postscaling @@ -294,16 +301,25 @@ struct tegra_dfll {u32 ci;u32 cg;bool cg_scale; +u32 reg_init_uV;/* I2C interface parameters */ u32 i2c_fs_rate;u32 i2c_reg;u32 i2c_slave_addr; -/* i2c_lut array entries are regulator framework selectors */ -unsigned i2c_lut[MAX_DFLL_VOLTAGES ]; -int i2c_lut_size; -u8 lut_min, lut_max, lut_safe; +/* lut array entries are regulator framework selectors or PWM values*/ +unsigned lut[MAX_DFLL_VOLTAGES ]; +unsigned lut_uv[MAX_DFLL_VOLTAGES ]; +int lut_size; +u8 lut_bottom, lut_min, lut_max, lut_safe; + +/* PWM interface */ +enum tegra_dfll_pmu_if pmu_if; +unsigned long pwm_rate; +struct pinctrl *pwm_pin; +struct pinctrl_state *pwm_enable_state; +struct pinctrl_state *pwm_disable_state; };#define clk_hw_to_dfll (_hw) container_of(_hw, struct tegra_dfll, dfll_clk_hw)@@ -489,6 +505,34 @@ static void dfll_set_mode(struct tegra_dfll *td,dfll_wmb (td); }
...
Quoted 89 lines
drivers/clk/tegra/clk-dfll.c +52
-11+ +/** +* dfll_force_output - force output a fixed value +* @td: DFLL instance +* @out_sel: value to force output +* +* Set the fixed value for force output, DFLL will output this value. +*/ +static int dfll_force_output (struct tegra_dfll *td,unsigned int out_sel) +{ +u32 val; + +if (out_sel >OUT_MASK ) +return -EINVAL ; + + val =dfll_set_force_output_value (td, out_sel); +if ((td->mode <DFLL_CLOSED_LOOP ) && + !(val &DFLL_OUTPUT_FORCE_ENABLE )) { +dfll_set_force_output_enabled (td, true); + } + +return 0 ; +} +/** * dfll_load_lut - load the voltage lookup table * @td: struct tegra_dfll * @@ -539,7 +695,7 @@ static void dfll_load_i2c_lut(struct tegra_dfll *td) lut_index = i; val =regulator_list_hardware_vsel (td->vdd_reg, - td->i2c_lut[lut_index]); + td->lut[lut_index]);__raw_writel (val, td->lut_base + i *4 ); }@@ -594,24 +750,41 @@ static void dfll_init_out_if(struct tegra_dfll *td) {u32 val; - td->lut_min =0 ; - td->lut_max = td->i2c_lut_size -1 ; - td->lut_safe = td->lut_min +1 ; + td->lut_min = td->lut_bottom; + td->lut_max = td->lut_size -1 ; + td->lut_safe = td->lut_min + (td->lut_min < td->lut_max ?1 :0 ); + +/* clear DFLL_OUTPUT_CFG before setting new value */ +dfll_writel (td,0 ,DFLL_OUTPUT_CFG ); +dfll_wmb (td); -dfll_i2c_writel (td,0 ,DFLL_OUTPUT_CFG ); val = (td->lut_safe <<DFLL_OUTPUT_CFG_SAFE_SHIFT ) | - (td->lut_max <<DFLL_OUTPUT_CFG_MAX_SHIFT ) | - (td->lut_min <<DFLL_OUTPUT_CFG_MIN_SHIFT ); -dfll_i2c_writel (td, val,DFLL_OUTPUT_CFG ); -dfll_i2c_wmb (td); + (td->lut_max <<DFLL_OUTPUT_CFG_MAX_SHIFT ) | + (td->lut_min <<DFLL_OUTPUT_CFG_MIN_SHIFT ); +dfll_writel (td, val,DFLL_OUTPUT_CFG ); +dfll_wmb (td);dfll_writel (td,0 ,DFLL_OUTPUT_FORCE );dfll_i2c_writel (td,0 ,DFLL_INTR_EN );dfll_i2c_writel (td,DFLL_INTR_MAX_MASK |DFLL_INTR_MIN_MASK ,DFLL_INTR_STS ); -dfll_load_i2c_lut (td); -dfll_init_i2c_if (td); +if (td->pmu_if ==TEGRA_DFLL_PMU_PWM ) { +int vinit = td->reg_init_uV; +int vstep = td->soc->alignment.step_uv; +int vmin = td->lut_uv[0 ]; + +/* set initial voltage */ +if ((vinit >= vmin) && vstep) { +unsigned int vsel; + + vsel =DIV_ROUND_UP ((vinit - vmin), vstep); +dfll_force_output (td, vsel); + } + }else { +dfll_load_i2c_lut (td); +dfll_init_i2c_if (td); + } }/*
drivers/clk/tegra/clk-dfll.c static int find_lut_index_for_rate(struct tegra_dfll *td, unsigned long rate) · line 817
Quoted 7 lines
drivers/clk/tegra/clk-dfll.c +2
-2@@ -640,8 +813,8 @@ static int find_lut_index_for_rate(struct tegra_dfll *td, unsigned long rate) uv =dev_pm_opp_get_voltage (opp);dev_pm_opp_put (opp); -for (i =0 ; i < td->i2c_lut_size; i++) { -if (regulator_list_voltage (td->vdd_reg, td->i2c_lut[i]) == uv) +for (i = td->lut_bottom; i < td->lut_size; i++) { +if (regulator_list_voltage (td->vdd_reg, td->lut[i]) == uv)
Use td->lut_uv[] here, so it will also work for PWM regulators. Also change == to >= because the exact OPP voltage may not be available. In the next patch the rounding can then be fixed.
Cheers,
Peter.
Re: [PATCH 03/19] dt-bindings: cpufreq: tegra124: remove vdd-cpu-supply from required properties
In reply to Peter De SchrijverQuoted 9 lines · Peter De Schrijver
Quoted 4 lines · Joseph Lo
The Tegra124 cpufreq driver works only with DFLL clock, which is a hardware-based frequency/voltage controller. The driver doesn't need to control the regulator itself. Hence remove that.
I think this is required for DFLL controlled I2C regulators because the regulator is queried for voltage selectors and I2C slave ID?
Hi Peter,
Yes, it's required for DFLL-I2C mode and defined in DFLL node. It's not needed here in the CPU node for CPU freq driver to handle that. Hence remove that.
Thanks,
Joseph
Quoted 30 lines
Quoted 30 lines
Signed-off-by Joseph Lo <[email protected]>--- .../devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt | 2 -- 1 file changed, 2 deletions(-)Documentation/devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt +0
-2@@ -13,7 +13,6 @@ Required properties: - pll_x: Fast PLL clocksource. - pll_p: Auxiliary PLL used during fast PLL rate changes. - dfll: Fast DFLL clocksource that also automatically scales CPU voltage. -- vdd-cpu-supply: Regulator for CPU voltage Optional properties: - clock-latency: Specify the possible maximum transition latency for clock,@@ -37,7 +36,6 @@ cpus { <&dfll>; clock-names = "cpu_g", "cpu_lp", "pll_x", "pll_p", "dfll"; clock-latency = <300000>; - vdd-cpu-supply: <&vdd_cpu>; };Signature · 1 line
2.19.2
Re: [PATCH 04/19] dt-bindings: cpufreq: tegra124: remove cpu_lp clock from required properties
In reply to Peter De SchrijverQuoted 8 lines · Peter De Schrijver
Quoted 4 lines · Joseph Lo
The
cpu_lpclock property is only needed when the CPUfreq driver supports CPU cluster switching. But it was not a design for this driver and it didn't handle that as well. So removing this property.I would mark it optional. This means current DTs will still be technically compatible with this binding doc.
Hi Peter,
There is no compatible issue of this property. Because the driver doesn't use this clock at all. Removing this won't cause any backward-compatible issue.
Same as previous patch for removing vdd-cpu-supply property once we fix that in the driver. The old dt binding still works with the new driver.
Quoted 35 lines
Quoted 35 lines
Signed-off-by Joseph Lo <[email protected]>--- .../devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)Documentation/devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt +1
-3@@ -9,7 +9,6 @@ Required properties: See ../clocks/clock-bindings.txt for details. - clock-names: Must include the following entries: - cpu_g: Clock mux for the fast CPU cluster. - - cpu_lp: Clock mux for the low-power CPU cluster. - pll_x: Fast PLL clocksource. - pll_p: Auxiliary PLL used during fast PLL rate changes. - dfll: Fast DFLL clocksource that also automatically scales CPU voltage.@@ -30,11 +29,10 @@ cpus { reg = <0>; clocks = <&tegra_car TEGRA124_CLK_CCLK_G>, - <&tegra_car TEGRA124_CLK_CCLK_LP>, <&tegra_car TEGRA124_CLK_PLL_X>, <&tegra_car TEGRA124_CLK_PLL_P>, <&dfll>; - clock-names = "cpu_g", "cpu_lp", "pll_x", "pll_p", "dfll"; + clock-names = "cpu_g", "pll_x", "pll_p", "dfll"; clock-latency = <300000>; };Signature · 1 line
2.19.2
Re: [PATCH 12/19] cpufreq: tegra124: extend to support Tegra210
In reply to Dmitry OsipenkoQuoted 24 lines · Dmitry Osipenko
Quoted 23 lines · Joseph Lo
Tegra210 uses the same methodology as Tegra124 for CPUFreq controlling that based on DFLL clock. So extending this driver to support Tegra210.
--- drivers/cpufreq/tegra124-cpufreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/cpufreq/tegra124-cpufreq.c +2
-1@@ -159,7 +159,8 @@ static int __init tegra_cpufreq_init(void)int ret;struct platform_device *pdev; -if (!of_machine_is_compatible ("nvidia,tegra124" )) +if (!(of_machine_is_compatible ("nvidia,tegra124" ) || +of_machine_is_compatible ("nvidia,tegra210" )))return -ENODEV ;
Quoted 4 lines
drivers/cpufreq/tegra124-cpufreq.c static int __init tegra_cpufreq_init(void) · line 166
Quoted 2 lines
drivers/cpufreq/tegra124-cpufreq.c +0
-0/* Seems that's not enough, you also need to blacklist "nvidia,tegra210" in the
drivers/cpufreq/cpufreq-dt-platdev.c
Hi Dmitry,
Thanks for reviewing. Actually it's "just" enough, I did check that driver for creating device data for cpufreq-dt driver. It needs to have both OPP v2 property and blacklist to create device data.
Because we don't use OPP v2, it will never be true. So it will "just" work in this case.
But you are right, add that to blacklist is more clear. I can add one more patch for that in next series.
Thanks,
Joseph
Quoted 73 lines · Thierry Reding
Quoted 63 lines · Joseph Lo
This series introduces support for the DFLL as a CPU clock source on Tegra210. As Jetson TX1 uses a PWM controlled regulator IC which is driven directly by the DFLLs PWM output, we also introduce support for PWM regulators next to I2C controlled regulators. The DFLL output frequency is directly controlled by the regulator voltage. The registers for controlling the PWM are part of the DFLL IP block, so there's no separate linux regulator object involved because the regulator IC only supplies the rail powering the CPUs. It doesn't have any other controls.
The patch 1~4 are the patches of DT bindings update for DFLL clock and Tegra124 cpufreq, which add PWM and Tegra210 support for DFLL clock and remove deprecate properties for Tegra124 cpufreq bindings.
The patch 5~10 are the patches for DFLL clock driver update for PWM-mode DFLL support.
The patch 11 and 12 are the Tegra124 cpufreq driver update to make it work with Tegra210.
The patch 13~18 are the devicetree files update for Tegra210 SoC and platforms. Two platforms are updated here for different DFLL mode usage. The Tegra210-p2371-2180 (a.k.a. Jetson Tx1) uses DFLL-PWM and the Tegra210-smaug (a.k.a. Pixel C) uses DFLL-I2C. So two different modes are verified with this series.
The patch 19 is the patch for enabling the CPU regulator for Smaug board.
Joseph Lo (16):
dt-bindings: clock: tegra124-dfll: add Tegra210 support
dt-bindings: cpufreq: tegra124: remove vdd-cpu-supply from required
properties
dt-bindings: cpufreq: tegra124: removecpu_lpclock from required
properties
clk: tegra: dfll: CVB calculation alignment with the regulator
clk: tegra: dfll: support PWM regulator control
clk: tegra: dfll: round down voltages based on alignment
clk: tegra: dfll: add CVB tables for Tegra210
cpufreq: tegra124: do not handle the CPU rail
cpufreq: tegra124: extend to support Tegra210
arm64: dts: tegra210: add DFLL clock
arm64: dts: tegra210: add CPU clocks
arm64: dts: tegra210-p2597: add pinmux for PWM-based DFLL support
arm64: dts: tegra210-p2371-2180: enable DFLL clock
arm64: dts: tegra210-smaug: add CPU power rail regulator
arm64: dts: tegra210-smaug: enable DFLL clock
arm64: defconfig: Enable MAX8973 regulatorPeter De Schrijver (3):
dt-bindings: clock: tegra124-dfll: Update DFLL binding for PWM
regulator
clk: tegra: dfll: registration for multiple SoCs
clk: tegra: dfll: buildclk-dfll.cfor Tegra124 and Tegra210.../bindings/clock/nvidia,tegra124-dfll.txt | 77 ++- .../cpufreq/nvidia,tegra124-cpufreq.txt | 6 +- .../boot/dts/nvidia/tegra210-p2371-2180.dts | 20 + .../arm64/boot/dts/nvidia/tegra210-p2597.dtsi | 14 + arch/arm64/boot/dts/nvidia/tegra210-smaug.dts | 31 + arch/arm64/boot/dts/nvidia/tegra210.dtsi | 25 + arch/arm64/configs/defconfig | 1 + drivers/clk/tegra/Kconfig | 5 + drivers/clk/tegra/Makefile | 2 +-Quoted 8 lines
drivers/clk/tegra/clk-dfll.c | 455 ++++++++++++--- drivers/clk/tegra/clk-dfll.h | 6 +- drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 536 +++++++++++++++++- drivers/clk/tegra/cvb.c | 12 +- drivers/clk/tegra/cvb.h | 7 +- drivers/cpufreq/Kconfig.arm | 2 +- drivers/cpufreq/tegra124-cpufreq.c | 29 +- 16 files changed, 1095 insertions(+), 133 deletions(-)
Quoted 6 lines
Hi Joseph,
can you highlight the build and runtime dependencies between the various patches? For example, can I pick up all the
arch/arm64patches into the Tegra tree without breaking anything?
Hi Thierry,
The patches for DFLL clock and dts have build dependency, which means we need to follow the patch sequence to apply these patches (They can be applied separately.). The runtime dependency depends on two sub-series, "DFLL clock + cpufreq" patches and the dts series. We can just apply the changes for "arch/arm64" but the functionality needs to wait for another sub-series.
Thanks,
Joseph
Re: [PATCH 07/19] clk: tegra: dfll: support PWM regulator control
In reply to Peter De SchrijverQuoted 18 lines · Peter De Schrijver
Quoted 17 lines · Joseph Lo
The DFLL hardware supports two modes (I2C and PWM) for voltage control when requesting a frequency. In this patch, we introduce PWM mode support.
To support that, we re-organize the LUT for unifying the table for both cases of I2C and PWM mode. And generate that based on regulator info. For the PWM-based regulator, we get this info from DT. And do the same as the case of I2C LUT, which can help to map the PMIC voltage ID and voltages that the regulator supported.
The other parts are the support code for initializing the DFLL hardware to support PWM mode. Also, the register debugfs file is slightly reworked to only show the i2c registers when I2C mode is in use.
Based on the work of Peter De Schrijver <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>---
snip
Quoted 6 lines
Quoted 6 lines
/*
drivers/clk/tegra/clk-dfll.c +0
-0@@ -640,8 +813,8 @@ static int find_lut_index_for_rate(struct tegra_dfll *td, unsigned long rate) uv =dev_pm_opp_get_voltage (opp);dev_pm_opp_put (opp);
Quoted 9 lines
drivers/clk/tegra/clk-dfll.c static int find_lut_index_for_rate(struct tegra_dfll *td, unsigned long rate) · line 817
Quoted 4 lines
drivers/clk/tegra/clk-dfll.c +2
-2-for (i =0 ; i < td->i2c_lut_size; i++) { -if (regulator_list_voltage (td->vdd_reg, td->i2c_lut[i]) == uv) +for (i = td->lut_bottom; i < td->lut_size; i++) { +if (regulator_list_voltage (td->vdd_reg, td->lut[i]) == uv)Use td->lut_uv[] here, so it will also work for PWM regulators. Also change == to >= because the exact OPP voltage may not be available. In the next patch the rounding can then be fixed.
Okay, make sense to me. Will fix it.
Thanks,
Joseph
Re: [PATCH 08/19] clk: tegra: dfll: round down voltages based on alignment
In reply to Peter De SchrijverQuoted 37 lines · Peter De Schrijver
Quoted 36 lines · Joseph Lo
When generating the OPP table, the voltages are round down with the alignment from the regulator. The alignment should be applied for voltages look up as well.
Based on the work of Penny Chiu <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>--- drivers/clk/tegra/clk-dfll.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)drivers/clk/tegra/clk-dfll.c +3
-3@@ -804,17 +804,17 @@ static void dfll_init_out_if(struct tegra_dfll *td)static int find_lut_index_for_rate (struct tegra_dfll *td,unsigned long rate) {struct dev_pm_opp *opp; -int i, uv; +int i, align_volt; opp =dev_pm_opp_find_freq_ceil (td->soc->dev, &rate);if (IS_ERR (opp))return PTR_ERR (opp); - uv =dev_pm_opp_get_voltage (opp); + align_volt =dev_pm_opp_get_voltage (opp) / td->soc->alignment.step_uv;dev_pm_opp_put (opp);for (i = td->lut_bottom; i < td->lut_size; i++) { -if (regulator_list_voltage (td->vdd_reg, td->lut[i]) == uv) +if ((td->lut_uv[i] / td->soc->alignment.step_uv) >= align_volt)return i; }
Quoted 7 lines
drivers/clk/tegra/clk-dfll.c static int dfll_init(struct tegra_dfll *td) · line 1532
Quoted 2 lines
drivers/clk/tegra/clk-dfll.c +0
-0@@ -1532,15 +1532,17 @@ static int dfll_init(struct tegra_dfll *td)*/ These 2 functions are only valid for I2C mode. We should probably add a
WARN_ON()in case they are called when PWM mode is used and return-EINVAL.
Okay, will add that.
Thanks,
Joseph
Quoted 45 lines
Quoted 45 lines
drivers/clk/tegra/clk-dfll.c +12
-8static int find_vdd_map_entry_exact (struct tegra_dfll *td,int uV) { -int i, n_voltages, reg_uV; +int i, n_voltages, reg_volt, align_volt; + align_volt = uV / td->soc->alignment.step_uv; n_voltages =regulator_count_voltages (td->vdd_reg);for (i =0 ; i < n_voltages; i++) { - reg_uV =regulator_list_voltage (td->vdd_reg, i); -if (reg_uV <0 ) + reg_volt =regulator_list_voltage (td->vdd_reg, i) / + td->soc->alignment.step_uv; +if (reg_volt <0 )break ; -if (uV == reg_uV) +if (align_volt == reg_volt)return i; }@@ -1554,15 +1556,17 @@ static int find_vdd_map_entry_exact(struct tegra_dfll *td, int uV)* */ static int find_vdd_map_entry_min (struct tegra_dfll *td,int uV) { -int i, n_voltages, reg_uV; +int i, n_voltages, reg_volt, align_volt; + align_volt = uV / td->soc->alignment.step_uv; n_voltages =regulator_count_voltages (td->vdd_reg);for (i =0 ; i < n_voltages; i++) { - reg_uV =regulator_list_voltage (td->vdd_reg, i); -if (reg_uV <0 ) + reg_volt =regulator_list_voltage (td->vdd_reg, i) / + td->soc->alignment.step_uv; +if (reg_volt <0 )break ; -if (uV <= reg_uV) +if (align_volt <= reg_volt)return i; }Signature · 1 line
2.19.2
Re: [PATCH 08/19] clk: tegra: dfll: round down voltages based on alignment
Quoted 44 lines · Joseph Lo
Quoted 33 lines · Peter De Schrijver
Quoted 32 lines · Joseph Lo
When generating the OPP table, the voltages are round down with the alignment from the regulator. The alignment should be applied for voltages look up as well.
Based on the work of Penny Chiu <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>---
drivers/clk/tegra/clk-dfll.c| 26 +++++++++++++++-----------1 file changed, 15 insertions(+), 11 deletions(-)drivers/clk/tegra/clk-dfll.c +3
-3@@ -804,17 +804,17 @@ static void dfll_init_out_if(struct tegra_dfll *td) static int find_lut_index_for_rate(struct tegra_dfll *td, unsigned long rate) { struct dev_pm_opp *opp; - int i, uv; + int i, align_volt; opp = dev_pm_opp_find_freq_ceil(td->soc->dev, &rate); if (IS_ERR(opp)) return PTR_ERR(opp); - uv = dev_pm_opp_get_voltage(opp); + align_volt = dev_pm_opp_get_voltage(opp) / td->soc->alignment.step_uv; dev_pm_opp_put(opp); for (i = td->lut_bottom; i < td->lut_size; i++) { - if (regulator_list_voltage(td->vdd_reg, td->lut[i]) == uv) + if ((td->lut_uv[i] / td->soc->alignment.step_uv) >= align_volt)Quoted 9 lines
drivers/clk/tegra/clk-dfll.c static int dfll_init(struct tegra_dfll *td) · line 1532
Quoted 4 lines
drivers/clk/tegra/clk-dfll.c +0
-0return i; }@@ -1532,15 +1532,17 @@ static int dfll_init(struct tegra_dfll *td)*/ These 2 functions are only valid for I2C mode. We should probably add a
WARN_ON()in case they are called when PWM mode is used and return-EINVAL.
Quoted 2 lines
Okay, will add that.
Peter,
Sorry, just double check again. These 2 functions are used for generating LUT table for DFLL-I2C mode. They are only used in "dfll_build_i2c_lut" function. So I think it's fine. The WARN_ON for protection from PWM mode is not necessary.
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
drivers/clk/tegra/clk-dfll.c +11
-7static int find_vdd_map_entry_exact(struct tegra_dfll *td, int uV) { - int i, n_voltages, reg_uV; + int i, n_voltages, reg_volt, align_volt; + align_volt = uV / td->soc->alignment.step_uv; n_voltages = regulator_count_voltages(td->vdd_reg); for (i = 0; i < n_voltages; i++) { - reg_uV = regulator_list_voltage(td->vdd_reg, i); - if (reg_uV < 0) + reg_volt = regulator_list_voltage(td->vdd_reg, i) / + td->soc->alignment.step_uv; + if (reg_volt < 0) break; - if (uV == reg_uV) + if (align_volt == reg_volt) return i; }@@ -1554,15 +1556,17 @@ static int find_vdd_map_entry_exact(structtegra_dfll *td, int uV) * */ static int find_vdd_map_entry_min(struct tegra_dfll *td, int uV) { - int i, n_voltages, reg_uV; + int i, n_voltages, reg_volt, align_volt; + align_volt = uV / td->soc->alignment.step_uv; n_voltages = regulator_count_voltages(td->vdd_reg); for (i = 0; i < n_voltages; i++) { - reg_uV = regulator_list_voltage(td->vdd_reg, i); - if (reg_uV < 0) + reg_volt = regulator_list_voltage(td->vdd_reg, i) / + td->soc->alignment.step_uv; + if (reg_volt < 0)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/clk/tegra/clk-dfll.c +1
-1break; - if (uV <= reg_uV) + if (align_volt <= reg_volt) return i; }Signature · 1 line
2.19.2
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 08/19] clk: tegra: dfll: round down voltages based on alignment
Quoted 46 lines · Joseph Lo
Quoted 45 lines · Joseph Lo
Quoted 43 lines · Peter De Schrijver
Quoted 36 lines · Joseph Lo
When generating the OPP table, the voltages are round down with the alignment from the regulator. The alignment should be applied for voltages look up as well.
Based on the work of Penny Chiu <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>---
drivers/clk/tegra/clk-dfll.c| 26 +++++++++++++++-----------1 file changed, 15 insertions(+), 11 deletions(-)drivers/clk/tegra/clk-dfll.c +3
-3@@ -804,17 +804,17 @@ static void dfll_init_out_if(struct tegra_dfll *td) static int find_lut_index_for_rate(struct tegra_dfll *td,unsigned long rate) { struct dev_pm_opp *opp; - int i, uv; + int i, align_volt; opp = dev_pm_opp_find_freq_ceil(td->soc->dev, &rate); if (IS_ERR(opp)) return PTR_ERR(opp); - uv = dev_pm_opp_get_voltage(opp); + align_volt = dev_pm_opp_get_voltage(opp) / td->soc->alignment.step_uv; dev_pm_opp_put(opp); for (i = td->lut_bottom; i < td->lut_size; i++) { - if (regulator_list_voltage(td->vdd_reg, td->lut[i]) == uv) + if ((td->lut_uv[i] / td->soc->alignment.step_uv) >= align_volt) return i; }drivers/clk/tegra/clk-dfll.c static int dfll_init(struct tegra_dfll *td) · line 1532
Quoted 1 line
drivers/clk/tegra/clk-dfll.c +0
-0@@ -1532,15 +1532,17 @@ static int dfll_init(struct tegra_dfll *td)*/ These 2 functions are only valid for I2C mode. We should probably add a
WARN_ON()in case they are called when PWM mode is used and return-EINVAL.
Quoted 9 lines
Quoted 2 lines
Okay, will add that.
Peter,
Sorry, just double check again. These 2 functions are used for generating LUT table for DFLL-I2C mode. They are only used in "
dfll_build_i2c_lut" function. So I think it's fine. TheWARN_ONfor protection from PWM mode is not necessary.
They are indeed not used today, but to prevent them from being used in the future I was thinking it makes sense to add some form of protection here.
Peter.
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
drivers/clk/tegra/clk-dfll.c +12
-8static int find_vdd_map_entry_exact(struct tegra_dfll *td, int uV) { - int i, n_voltages, reg_uV; + int i, n_voltages, reg_volt, align_volt; + align_volt = uV / td->soc->alignment.step_uv; n_voltages = regulator_count_voltages(td->vdd_reg); for (i = 0; i < n_voltages; i++) { - reg_uV = regulator_list_voltage(td->vdd_reg, i); - if (reg_uV < 0) + reg_volt = regulator_list_voltage(td->vdd_reg, i) / + td->soc->alignment.step_uv; + if (reg_volt < 0) break; - if (uV == reg_uV) + if (align_volt == reg_volt) return i; }@@ -1554,15 +1556,17 @@ static intfind_vdd_map_entry_exact(struct tegra_dfll *td, int uV) * */ static int find_vdd_map_entry_min(struct tegra_dfll *td, int uV) { - int i, n_voltages, reg_uV; + int i, n_voltages, reg_volt, align_volt; + align_volt = uV / td->soc->alignment.step_uv; n_voltages = regulator_count_voltages(td->vdd_reg); for (i = 0; i < n_voltages; i++) { - reg_uV = regulator_list_voltage(td->vdd_reg, i); - if (reg_uV < 0) + reg_volt = regulator_list_voltage(td->vdd_reg, i) / + td->soc->alignment.step_uv; + if (reg_volt < 0) break; - if (uV <= reg_uV) + if (align_volt <= reg_volt) return i; }Signature · 1 line
2.19.2
Re: [PATCH 08/19] clk: tegra: dfll: round down voltages based on alignment
Quoted 57 lines · Peter De Schrijver
Quoted 46 lines · Joseph Lo
Quoted 45 lines · Joseph Lo
Quoted 43 lines · Peter De Schrijver
Quoted 36 lines · Joseph Lo
When generating the OPP table, the voltages are round down with the alignment from the regulator. The alignment should be applied for voltages look up as well.
Based on the work of Penny Chiu <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>--- drivers/clk/tegra/clk-dfll.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)drivers/clk/tegra/clk-dfll.c +3
-3@@ -804,17 +804,17 @@ static void dfll_init_out_if(struct tegra_dfll *td) static int find_lut_index_for_rate(struct tegra_dfll *td,unsigned long rate) { struct dev_pm_opp *opp; - int i, uv; + int i, align_volt; opp = dev_pm_opp_find_freq_ceil(td->soc->dev, &rate); if (IS_ERR(opp)) return PTR_ERR(opp); - uv = dev_pm_opp_get_voltage(opp); + align_volt = dev_pm_opp_get_voltage(opp) / td->soc->alignment.step_uv; dev_pm_opp_put(opp); for (i = td->lut_bottom; i < td->lut_size; i++) { - if (regulator_list_voltage(td->vdd_reg, td->lut[i]) == uv) + if ((td->lut_uv[i] / td->soc->alignment.step_uv) >= align_volt) return i; }drivers/clk/tegra/clk-dfll.c static int dfll_init(struct tegra_dfll *td) · line 1532
Quoted 1 line
drivers/clk/tegra/clk-dfll.c +0
-0@@ -1532,15 +1532,17 @@ static int dfll_init(struct tegra_dfll *td)*/ These 2 functions are only valid for I2C mode. We should probably add a
WARN_ON()in case they are called when PWM mode is used and return-EINVAL.Quoted 9 lines
Quoted 2 lines
Okay, will add that.
Peter,
Sorry, just double check again. These 2 functions are used for generating LUT table for DFLL-I2C mode. They are only used in "
dfll_build_i2c_lut" function. So I think it's fine. TheWARN_ONfor protection from PWM mode is not necessary.
Quoted 3 lines
They are indeed not used today, but to prevent them from being used in the future I was thinking it makes sense to add some form of protection here.
Okay, will add one more patch for that. Thanks.
Quoted 37 lines
Peter.
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
drivers/clk/tegra/clk-dfll.c +11
-7static int find_vdd_map_entry_exact(struct tegra_dfll *td, int uV) { - int i, n_voltages, reg_uV; + int i, n_voltages, reg_volt, align_volt; + align_volt = uV / td->soc->alignment.step_uv; n_voltages = regulator_count_voltages(td->vdd_reg); for (i = 0; i < n_voltages; i++) { - reg_uV = regulator_list_voltage(td->vdd_reg, i); - if (reg_uV < 0) + reg_volt = regulator_list_voltage(td->vdd_reg, i) / + td->soc->alignment.step_uv; + if (reg_volt < 0) break; - if (uV == reg_uV) + if (align_volt == reg_volt) return i; }@@ -1554,15 +1556,17 @@ static intfind_vdd_map_entry_exact(struct tegra_dfll *td, int uV) * */ static int find_vdd_map_entry_min(struct tegra_dfll *td, int uV) { - int i, n_voltages, reg_uV; + int i, n_voltages, reg_volt, align_volt; + align_volt = uV / td->soc->alignment.step_uv; n_voltages = regulator_count_voltages(td->vdd_reg); for (i = 0; i < n_voltages; i++) { - reg_uV = regulator_list_voltage(td->vdd_reg, i); - if (reg_uV < 0) + reg_volt = regulator_list_voltage(td->vdd_reg, i) / + td->soc->alignment.step_uv; + if (reg_volt < 0)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/clk/tegra/clk-dfll.c +1
-1break; - if (uV <= reg_uV) + if (align_volt <= reg_volt) return i; }Signature · 1 line
2.19.2
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 03/19] dt-bindings: cpufreq: tegra124: remove vdd-cpu-supply from required properties
In reply to Joseph LoQuoted 11 lines · Joseph Lo
Quoted 9 lines · Peter De Schrijver
Quoted 4 lines · Joseph Lo
The Tegra124 cpufreq driver works only with DFLL clock, which is a hardware-based frequency/voltage controller. The driver doesn't need to control the regulator itself. Hence remove that.
I think this is required for DFLL controlled I2C regulators because the regulator is queried for voltage selectors and I2C slave ID?
Quoted 6 lines
Hi Peter,
Yes, it's required for DFLL-I2C mode and defined in DFLL node. It's not needed here in the CPU node for CPU freq driver to handle that. Hence remove that.
Ah right. So yes, this is fine then.
Peter.
Quoted 32 lines
Thanks,
JosephQuoted 28 lines
Quoted 28 lines
Signed-off-by Joseph Lo <[email protected]>--- .../devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt | 2 -- 1 file changed, 2 deletions(-)Documentation/devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt +0
-2@@ -13,7 +13,6 @@ Required properties: - pll_x: Fast PLL clocksource. - pll_p: Auxiliary PLL used during fast PLL rate changes. - dfll: Fast DFLL clocksource that also automatically scales CPU voltage. -- vdd-cpu-supply: Regulator for CPU voltage Optional properties: - clock-latency: Specify the possible maximum transition latency for clock,@@ -37,7 +36,6 @@ cpus { <&dfll>; clock-names = "cpu_g", "cpu_lp", "pll_x", "pll_p", "dfll"; clock-latency = <300000>; - vdd-cpu-supply: <&vdd_cpu>; };Signature · 1 line
2.19.2
Jon Hunter
maintainerRe: [PATCH 01/19] dt-bindings: clock: tegra124-dfll: Update DFLL binding for PWM regulator
In reply to Joseph LoQuoted 29 lines · Joseph Lo
From: Peter De Schrijver <[email protected]>
Add new properties to configure the DFLL PWM regulator support. Also add an example and make the I2C clock only required when I2C support is used.
Signed-off-by Peter De Schrijver <[email protected]>Signed-off-by Joseph Lo <[email protected]>--- .../bindings/clock/nvidia,tegra124-dfll.txt | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +0
-1@@ -8,7 +8,6 @@ the fast CPU cluster. It consists of a free-running voltage controlled oscillator connected to the CPU voltage rail (VDD_CPU), and a closed loop control module that will automatically adjust the VDD_CPU voltage by communicating with an off-chip PMIC either via an I2C bus or via PWM signals. -Currently only the I2C mode is supported by these bindings. Required properties: - compatible : should be "nvidia,tegra124-dfll"@@ -45,10 +44,28 @@ Required properties for the control loop parameters: Optional properties for the control loop parameters: - nvidia,cg-scale: Boolean value, see the field DFLL_PARAMS_CG_SCALE in the TRM.
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt Required properties for the control loop parameters: · line 55
Quoted 10 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +6
-1+Optional properties for mode selection: +- nvidia,pwm-to-pmic: Use PWM to control regulator rather then I2C. + Required properties for I2C mode: - nvidia,i2c-fs-rate: I2C transfer rate, if using full speed mode. -Example: +Required properties for PWM mode: +- nvidia,pwm-period: period of PWM square wave in microseconds. +- nvidia,init-uv: Regulator voltage in micro volts when PWM control is disabled.
Maybe consider 'pwm-inactive-voltage-microvolt'.
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt Required properties for the control loop parameters: · line 57
Quoted 2 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +2
-0+- nvidia,align-offset-uv: Regulator voltage in micro volts when PWM control is + enabled and PWM output is low.
Would this be considered the minimum pwm active voltage?
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt Required properties for the control loop parameters: · line 60
Quoted 3 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +3
-0+- nvidia,align-step-uv: Voltage increase in micro volts corresponding to a + 1/33th increase in duty cycle. Eg the voltage for 2/33th + duty cycle would be:
Maybe consider 'pwm-voltage-step-microvolt'.
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt Required properties for the control loop parameters: · line 66
Quoted 6 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +6
-0+ nvidia,align-offset-uv + nvidia,align-step-uv * 2. +- pinctrl-0: I/O pad configuration when PWM control is enabled. +- pinctrl-1: I/O pad configuration when PWM control is disabled. +- pinctrl-names: must include the following entries: + - dvfs_pwm_enable: I/O pad configuration when PWM control is enabled. + - dvfs_pwm_disable: I/O pad configuration when PWM control is disabled.
Please see Rob's feedback on the above [0].
Cheers
Jon
[0] https://lore.kernel.org/patchwork/patch/885328/
Signature · 1 line
nvpublic
Re: [PATCH 02/19] dt-bindings: clock: tegra124-dfll: add Tegra210 support
In reply to Joseph LoQuoted 13 lines · Joseph Lo
Add Tegra210 support for DFLL clock.
Signed-off-by Joseph Lo <[email protected]>--- .../devicetree/bindings/clock/nvidia,tegra124-dfll.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +0
-0
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt control module that will automatically adjust the VDD_CPU voltage by · line 18
Quoted 10 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +3
-1@@ -10,7 +10,9 @@ control module that will automatically adjust the VDD_CPU voltage by communicating with an off-chip PMIC either via an I2C bus or via PWM signals. Required properties: -- compatible : should be "nvidia,tegra124-dfll" +- compatible : should be one of: + - "nvidia,tegra124-dfll": for Tegra124 + - "nvidia,tegra210-dfll": for Tegra210 - reg : Defines the following set of registers, in the order listed: - registers for the DFLL control logic. - registers for the I2C output logic.
Cheers
Jon
Signature · 1 line
nvpublic
Re: [PATCH 03/19] dt-bindings: cpufreq: tegra124: remove vdd-cpu-supply from required properties
In reply to Joseph LoQuoted 24 lines · Joseph Lo
The Tegra124 cpufreq driver works only with DFLL clock, which is a hardware-based frequency/voltage controller. The driver doesn't need to control the regulator itself. Hence remove that.
Signed-off-by Joseph Lo <[email protected]>--- .../devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt | 2 -- 1 file changed, 2 deletions(-)Documentation/devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt +0
-1@@ -13,7 +13,6 @@ Required properties: - pll_x: Fast PLL clocksource. - pll_p: Auxiliary PLL used during fast PLL rate changes. - dfll: Fast DFLL clocksource that also automatically scales CPU voltage. -- vdd-cpu-supply: Regulator for CPU voltage Optional properties: - clock-latency: Specify the possible maximum transition latency for clock,
Documentation/devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt cpus { · line 40
Quoted 7 lines
Documentation/devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt +0
-1@@ -37,7 +36,6 @@ cpus { <&dfll>; clock-names = "cpu_g", "cpu_lp", "pll_x", "pll_p", "dfll"; clock-latency = <300000>; - vdd-cpu-supply: <&vdd_cpu>; };
Cheers
Jon
Signature · 1 line
nvpublic
Re: [PATCH 04/19] dt-bindings: cpufreq: tegra124: remove cpu_lp clock from required properties
In reply to Joseph LoQuoted 26 lines · Joseph Lo
The
cpu_lpclock property is only needed when the CPUfreq driver supports CPU cluster switching. But it was not a design for this driver and it didn't handle that as well. So removing this property.Signed-off-by Joseph Lo <[email protected]>--- .../devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)Documentation/devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt +0
-1@@ -9,7 +9,6 @@ Required properties: See ../clocks/clock-bindings.txt for details. - clock-names: Must include the following entries: - cpu_g: Clock mux for the fast CPU cluster. - - cpu_lp: Clock mux for the low-power CPU cluster. - pll_x: Fast PLL clocksource. - pll_p: Auxiliary PLL used during fast PLL rate changes. - dfll: Fast DFLL clocksource that also automatically scales CPU voltage.@@ -30,11 +29,10 @@ cpus { reg = <0>;
Documentation/devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt cpus { · line 38
Quoted 10 lines
Documentation/devicetree/bindings/cpufreq/nvidia,tegra124-cpufreq.txt +1
-2clocks = <&tegra_car TEGRA124_CLK_CCLK_G>, - <&tegra_car TEGRA124_CLK_CCLK_LP>, <&tegra_car TEGRA124_CLK_PLL_X>, <&tegra_car TEGRA124_CLK_PLL_P>, <&dfll>; - clock-names = "cpu_g", "cpu_lp", "pll_x", "pll_p", "dfll"; + clock-names = "cpu_g", "pll_x", "pll_p", "dfll"; clock-latency = <300000>; };
Cheers
Jon
Signature · 1 line
nvpublic
Re: [PATCH 05/19] clk: tegra: dfll: registration for multiple SoCs
In reply to Joseph LoQuoted 105 lines · Joseph Lo
From: Peter De Schrijver <[email protected]>
In a future patch, support for the DFLL in Tegra210 will be introduced. This requires support for more than 1 set of CVB and CPU max frequency tables.
Signed-off-by Peter De Schrijver <[email protected]>Signed-off-by Joseph Lo <[email protected]>--- drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 45 ++++++++++++++++------ 1 file changed, 34 insertions(+), 11 deletions(-)drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +34
-6@@ -1,7 +1,7 @@/* * Tegra124 DFLL FCPU clock source driver * -* Copyright (C) 2012-2014 NVIDIA Corporation. All rights reserved. +* Copyright (C) 2012-2018 NVIDIA Corporation. All rights reserved. * * Aleksandr Frid <[email protected]> * Paul Walmsley <[email protected]> @@ -21,6 +21,7 @@#include <linux/err.h> #include <linux/kernel.h> #include <linux/init.h> +#include <linux/of_device.h> #include <linux/platform_device.h> #include <soc/tegra/fuse.h> @@ -28,8 +29,15 @@#include "clk-dfll.h" #include "cvb.h" +struct dfll_fcpu_data { +const unsigned long *cpu_max_freq_table; +unsigned int cpu_max_freq_table_size; +const struct cvb_table *cpu_cvb_tables; +unsigned int cpu_cvb_tables_size; +}; +/* Maximum CPU frequency, indexed by CPU speedo id */ -static const unsigned long cpu_max_freq_table[] = { +static const unsigned long tegra124_cpu_max_freq_table[] = { [0 ] =2014500000UL , [1 ] =2320500000UL , [2 ] =2116500000UL ,@@ -82,16 +90,36 @@ static const struct cvb_table tegra124_cpu_cvb_tables[] = { }, }; +static const struct dfll_fcpu_data tegra124_dfll_fcpu_data = { + .cpu_max_freq_table = tegra124_cpu_max_freq_table, + .cpu_max_freq_table_size =ARRAY_SIZE (tegra124_cpu_max_freq_table), + .cpu_cvb_tables = tegra124_cpu_cvb_tables, + .cpu_cvb_tables_size =ARRAY_SIZE (tegra124_cpu_cvb_tables) +}; + +static const struct of_device_id tegra124_dfll_fcpu_of_match[] = { + { + .compatible ="nvidia,tegra124-dfll" , + .data = &tegra124_dfll_fcpu_data, + }, + { }, +}; +static int tegra124_dfll_fcpu_probe (struct platform_device *pdev) {int process_id, speedo_id, speedo_value, err;struct tegra_dfll_soc_data *soc; +const struct dfll_fcpu_data *fcpu_data; + + fcpu_data =of_device_get_match_data (&pdev->dev); +if (!fcpu_data) +return -ENODEV ; process_id = tegra_sku_info.cpu_process_id; speedo_id = tegra_sku_info.cpu_speedo_id; speedo_value = tegra_sku_info.cpu_speedo_value; -if (speedo_id >=ARRAY_SIZE (cpu_max_freq_table)) { +if (speedo_id >= fcpu_data->cpu_max_freq_table_size) {dev_err (&pdev->dev,"unknown max CPU freq for speedo_id=%d\n" , speedo_id);return -ENODEV ;@@ -107,10 +135,10 @@ static int tegra124_dfll_fcpu_probe(struct platform_device *pdev)return -ENODEV ; } - soc->max_freq = cpu_max_freq_table[speedo_id]; + soc->max_freq = fcpu_data->cpu_max_freq_table[speedo_id]; - soc->cvb =tegra_cvb_add_opp_table (soc->dev, tegra124_cpu_cvb_tables, -ARRAY_SIZE (tegra124_cpu_cvb_tables), + soc->cvb =tegra_cvb_add_opp_table (soc->dev, fcpu_data->cpu_cvb_tables, + fcpu_data->cpu_cvb_tables_size, process_id, speedo_id, speedo_value, soc->max_freq);if (IS_ERR (soc->cvb)) {@@ -142,11 +170,6 @@ static int tegra124_dfll_fcpu_remove(struct platform_device *pdev)return 0 ;
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c static int tegra124_dfll_fcpu_remove(struct platform_device *pdev) · line 175
Quoted 10 lines
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +0
-5} -static const struct of_device_id tegra124_dfll_fcpu_of_match[] = { - { .compatible ="nvidia,tegra124-dfll" , }, - { }, -}; -static const struct dev_pm_ops tegra124_dfll_pm_ops = {SET_RUNTIME_PM_OPS (tegra_dfll_runtime_suspend, tegra_dfll_runtime_resume,NULL )
Cheers
Jon
Signature · 1 line
nvpublic
Jon Hunter
maintainerRe: [PATCH 06/19] clk: tegra: dfll: CVB calculation alignment with the regulator
In reply to Joseph LoQuoted 69 lines · Joseph Lo
The CVB table contains calibration data for the CPU DFLL based on process charaterization. The regulator step and offset parameters depend on the regulator supplying vdd-cpu , not on the specific Tegra SKU.
When using a PWM controlled regulator, the voltage step and offset are determined by the regulator type in use. This is specified in DT. When using an I2C controlled regulator, we can retrieve them from CPU regulator or DT (if specified). Then pass this information to the CVB table calculation function.
Based on the work done of "Peter De Schrijver <[email protected]>" and "Alex Frid <[email protected]>".
Signed-off-by Joseph Lo <[email protected]>--- drivers/clk/tegra/clk-dfll.h | 6 +- drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 65 ++++++++++++++++++++-- drivers/clk/tegra/cvb.c | 12 ++-- drivers/clk/tegra/cvb.h | 6 +- 4 files changed, 75 insertions(+), 14 deletions(-)drivers/clk/tegra/clk-dfll.h +5
-1@@ -1,6 +1,6 @@/* * clk-dfll.h - prototypes and macros for the Tegra DFLL clocksource driver -* Copyright (C) 2013 NVIDIA Corporation. All rights reserved. +* Copyright (C) 2013-2018 NVIDIA Corporation. All rights reserved. * * Aleksandr Frid <[email protected]> * Paul Walmsley <[email protected]> @@ -22,11 +22,14 @@#include <linux/reset.h> #include <linux/types.h> +#include "cvb.h" +/** * struct tegra_dfll_soc_data - SoC-specific hooks/integration for the DFLL driver * @dev: struct device * that holds the OPP table for the DFLL * @max_freq: maximum frequency supported on this SoC * @cvb: CPU frequency table for this SoC +* @alignment: parameters of the regulator step and offset * @init_clock_trimmers: callback to initialize clock trimmers * @set_clock_trimmers_high: callback to tune clock trimmers for high voltage * @set_clock_trimmers_low: callback to tune clock trimmers for low voltage @@ -35,6 +38,7 @@ struct tegra_dfll_soc_data {struct device *dev;unsigned long max_freq;const struct cvb_table *cvb; +struct rail_alignment alignment;void (*init_clock_trimmers)(void );void (*set_clock_trimmers_high)(void );drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +1
-0@@ -23,6 +23,7 @@#include <linux/init.h> #include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/regulator/consumer.h> #include <soc/tegra/fuse.h> #include "clk.h"
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c static const struct cvb_table tegra124_cpu_cvb_tables[] = { · line 55
Quoted 6 lines
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +0
-3@@ -50,9 +51,6 @@ static const struct cvb_table tegra124_cpu_cvb_tables[] = { .process_id = -1, .min_millivolts = 900, .max_millivolts = 1260, - .alignment = { - .step_uv = 10000, /* 10mV */ - },
What happens for tegra124-jetson-tk1 when we remove this?
Quoted 48 lines
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +32
-0.speedo_scale = 100, .voltage_scale = 1000, .entries = {@@ -105,11 +103,43 @@ static const struct of_device_id tegra124_dfll_fcpu_of_match[] = { { }, }; +static void get_alignment_from_dt (struct device *dev, +struct rail_alignment *align) +{ + align->step_uv =0 ; + align->offset_uv =0 ; + +if (of_property_read_u32 (dev->of_node,"nvidia,align-step-uv" , + &align->step_uv)) + align->step_uv =0 ; + +if (of_property_read_u32 (dev->of_node, +"nvidia,align-offset-uv" , &align->offset_uv)) + align->offset_uv =0 ; +} + +static int get_alignment_from_regulator (struct device *dev, +struct rail_alignment *align) +{ +struct regulator *reg =devm_regulator_get (dev,"vdd-cpu" ); + +if (IS_ERR (reg)) +return PTR_ERR (reg); + + align->offset_uv =regulator_list_voltage (reg,0 ); + align->step_uv =regulator_get_linear_step (reg); + +devm_regulator_put (reg); + +return 0 ; +} +static int tegra124_dfll_fcpu_probe (struct platform_device *pdev) {int process_id, speedo_id, speedo_value, err;struct tegra_dfll_soc_data *soc;const struct dfll_fcpu_data *fcpu_data; +struct rail_alignment align; fcpu_data =of_device_get_match_data (&pdev->dev);if (!fcpu_data)
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c static int tegra124_dfll_fcpu_probe(struct platform_device *pdev) · line 173
Quoted 9 lines
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +6
-0@@ -135,12 +165,37 @@ static int tegra124_dfll_fcpu_probe(struct platform_device *pdev)return -ENODEV ; } +get_alignment_from_dt (&pdev->dev, &align); +if (of_property_read_bool (pdev->dev.of_node,"nvidia,pwm-to-pmic" ) + && (!align.step_uv || !align.offset_uv)) { +dev_info (&pdev->dev,"Missing required align data in DT" ); +return -EINVAL ; + }else {
This 'else' clause is not necessary.
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c static int tegra124_dfll_fcpu_probe(struct platform_device *pdev) · line 177
Quoted 4 lines
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +4
-0+if (!align.step_uv) { +dev_info (&pdev->dev, +"no align data in DT, try from vdd-cpu\n" ); + err =get_alignment_from_regulator (&pdev->dev, &align);
dev_warn
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c static int tegra124_dfll_fcpu_probe(struct platform_device *pdev) · line 180
Quoted 3 lines
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +3
-0+if (err == -EPROBE_DEFER ) { +dev_info (&pdev->dev, +"defer probe to get vdd-cpu\n" );
This dev_info is not necessary.
Quoted 94 lines
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +14
-2+return -EPROBE_DEFER ; + } + } + } + +if (!align.step_uv) { +dev_err (&pdev->dev,"missing step uv\n" ); +return -EINVAL ; + } + soc->max_freq = fcpu_data->cpu_max_freq_table[speedo_id]; soc->cvb =tegra_cvb_add_opp_table (soc->dev, fcpu_data->cpu_cvb_tables, fcpu_data->cpu_cvb_tables_size, - process_id, speedo_id, speedo_value, - soc->max_freq); + &align, process_id, speedo_id, + speedo_value, soc->max_freq); + soc->alignment = align; +if (IS_ERR (soc->cvb)) {dev_err (&pdev->dev,"couldn't add OPP table: %ld\n" ,PTR_ERR (soc->cvb));drivers/clk/tegra/cvb.c +7
-5@@ -1,7 +1,7 @@/* * Utility functions for parsing Tegra CVB voltage tables * -* Copyright (C) 2012-2014 NVIDIA Corporation. All rights reserved. +* Copyright (C) 2012-2018 NVIDIA Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -62,9 +62,9 @@ static int round_voltage(int mv, const struct rail_alignment *align, int up) }static int build_opp_table (struct device *dev,const struct cvb_table *table, +struct rail_alignment *align,int speedo_value,unsigned long max_freq) { -const struct rail_alignment *align = &table->alignment;int i, ret, dfll_mv, min_mv, max_mv; min_mv =round_voltage (table->min_millivolts, align,UP );@@ -109,8 +109,9 @@ static int build_opp_table(struct device *dev, const struct cvb_table *table,*/ const struct cvb_table *tegra_cvb_add_opp_table (struct device *dev,const struct cvb_table *tables, -size_t count,int process_id,int speedo_id, -int speedo_value,unsigned long max_freq) +size_t count,struct rail_alignment *align, +int process_id,int speedo_id,int speedo_value, +unsigned long max_freq) {size_t i;int ret;@@ -124,7 +125,8 @@ tegra_cvb_add_opp_table(struct device *dev, const struct cvb_table *tables,if (table->process_id !=-1 && table->process_id != process_id)continue ; - ret =build_opp_table (dev, table, speedo_value, max_freq); + ret =build_opp_table (dev, table, align, speedo_value, + max_freq);return ret ?ERR_PTR (ret) : table; }drivers/clk/tegra/cvb.h +3
-3@@ -49,7 +49,6 @@ struct cvb_table {int min_millivolts;int max_millivolts; -struct rail_alignment alignment;int speedo_scale;int voltage_scale;@@ -59,8 +58,9 @@ struct cvb_table {const struct cvb_table *tegra_cvb_add_opp_table (struct device *dev,const struct cvb_table *cvb_tables, -size_t count,int process_id,int speedo_id, -int speedo_value,unsigned long max_freq); +size_t count,struct rail_alignment *align, +int process_id,int speedo_id,int speedo_value, +unsigned long max_freq);void tegra_cvb_remove_opp_table (struct device *dev,const struct cvb_table *table,unsigned long max_freq);
Signature · 1 line
nvpublic
Jon Hunter
maintainerRe: [PATCH 07/19] clk: tegra: dfll: support PWM regulator control
In reply to Joseph LoQuoted 55 lines · Joseph Lo
The DFLL hardware supports two modes (I2C and PWM) for voltage control when requesting a frequency. In this patch, we introduce PWM mode support.
To support that, we re-organize the LUT for unifying the table for both cases of I2C and PWM mode. And generate that based on regulator info. For the PWM-based regulator, we get this info from DT. And do the same as the case of I2C LUT, which can help to map the PMIC voltage ID and voltages that the regulator supported.
The other parts are the support code for initializing the DFLL hardware to support PWM mode. Also, the register debugfs file is slightly reworked to only show the i2c registers when I2C mode is in use.
Based on the work of Peter De Schrijver <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>--- drivers/clk/tegra/clk-dfll.c | 431 ++++++++++++++++++++++++++++++----- 1 file changed, 368 insertions(+), 63 deletions(-)drivers/clk/tegra/clk-dfll.c +8
-1@@ -1,7 +1,7 @@/* * clk-dfll.c - Tegra DFLL clock source common code * -* Copyright (C) 2012-2014 NVIDIA Corporation. All rights reserved. +* Copyright (C) 2012-2018 NVIDIA Corporation. All rights reserved. * * Aleksandr Frid <[email protected]> * Paul Walmsley <[email protected]> @@ -47,6 +47,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/pinctrl/consumer.h> #include <linux/pm_opp.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> @@ -243,6 +244,12 @@ enum dfll_tune_range { DFLL_TUNE_LOW = 1, }; + +enum tegra_dfll_pmu_if { +TEGRA_DFLL_PMU_I2C =0 , +TEGRA_DFLL_PMU_PWM =1 , +}; +/** * struct dfll_rate_req - target DFLL rate request data * @rate: target frequency, after the postscaling
drivers/clk/tegra/clk-dfll.c struct tegra_dfll { · line 304
Quoted 4 lines
drivers/clk/tegra/clk-dfll.c +1
-0@@ -294,16 +301,25 @@ struct tegra_dfll {u32 ci;u32 cg;bool cg_scale; +u32 reg_init_uV;
Doesn't this belong under PWM interface? Also being picky I dont' find init_uV very descriptive.
Otherwise the change looks fine to me.
Cheers
Jon
Signature · 1 line
nvpublic
Jon Hunter
maintainerRe: [PATCH 08/19] clk: tegra: dfll: round down voltages based on alignment
In reply to Joseph LoQuoted 17 lines · Joseph Lo
When generating the OPP table, the voltages are round down with the alignment from the regulator. The alignment should be applied for voltages look up as well.
Based on the work of Penny Chiu <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>--- drivers/clk/tegra/clk-dfll.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)drivers/clk/tegra/clk-dfll.c +0
-0@@ -804,17 +804,17 @@ static void dfll_init_out_if(struct tegra_dfll *td)static int find_lut_index_for_rate (struct tegra_dfll *td,unsigned long rate)
drivers/clk/tegra/clk-dfll.c static void dfll_init_out_if(struct tegra_dfll *td) · line 813
Quoted 10 lines
drivers/clk/tegra/clk-dfll.c +1
-2{struct dev_pm_opp *opp; -int i, uv; +int i, align_volt; opp =dev_pm_opp_find_freq_ceil (td->soc->dev, &rate);if (IS_ERR (opp))return PTR_ERR (opp); - uv =dev_pm_opp_get_voltage (opp);
This returns an unsigned long.
drivers/clk/tegra/clk-dfll.c static void dfll_init_out_if(struct tegra_dfll *td) · line 813
Quoted 1 line
drivers/clk/tegra/clk-dfll.c +1
-0+ align_volt =dev_pm_opp_get_voltage (opp) / td->soc->alignment.step_uv;
Nit-pick, the 'align_volt' variable does not contain an actual voltage but a step index. So maybe consider renaming this 'align_step'. And the same for other places in this change.
Cheers
Jon
Signature · 1 line
nvpublic
Jon Hunter
maintainerRe: [PATCH 09/19] clk: tegra: dfll: add CVB tables for Tegra210
In reply to Joseph LoQuoted 464 lines · Joseph Lo
Add CVB tables with different chip characterization, so that we can generate the customize OPP table that suitable for different chips with different SKUs.
Signed-off-by Joseph Lo <[email protected]>--- drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 426 +++++++++++++++++++++ drivers/clk/tegra/cvb.h | 1 + 2 files changed, 427 insertions(+)drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +426
-0@@ -88,6 +88,421 @@ static const struct cvb_table tegra124_cpu_cvb_tables[] = { }, }; +static const unsigned long tegra210_cpu_max_freq_table[] = { + [0 ] =1912500000UL , + [1 ] =1912500000UL , + [2 ] =2218500000UL , + [3 ] =1785000000UL , + [4 ] =1632000000UL , + [5 ] =1912500000UL , + [6 ] =2014500000UL , + [7 ] =1734000000UL , + [8 ] =1683000000UL , + [9 ] =1555500000UL , + [10 ] =1504500000UL , +}; + +#define CPU_CVB_TABLE \ + .speedo_scale = 100, \ + .voltage_scale = 1000, \ + .entries = { \ + { 204000000UL, { 1007452, -23865, 370 } }, \ + { 306000000UL, { 1052709, -24875, 370 } }, \ + { 408000000UL, { 1099069, -25895, 370 } }, \ + { 510000000UL, { 1146534, -26905, 370 } }, \ + { 612000000UL, { 1195102, -27915, 370 } }, \ + { 714000000UL, { 1244773, -28925, 370 } }, \ + { 816000000UL, { 1295549, -29935, 370 } }, \ + { 918000000UL, { 1347428, -30955, 370 } }, \ + { 1020000000UL, { 1400411, -31965, 370 } }, \ + { 1122000000UL, { 1454497, -32975, 370 } }, \ + { 1224000000UL, { 1509687, -33985, 370 } }, \ + { 1326000000UL, { 1565981, -35005, 370 } }, \ + { 1428000000UL, { 1623379, -36015, 370 } }, \ + { 1530000000UL, { 1681880, -37025, 370 } }, \ + { 1632000000UL, { 1741485, -38035, 370 } }, \ + { 1734000000UL, { 1802194, -39055, 370 } }, \ + { 1836000000UL, { 1864006, -40065, 370 } }, \ + { 1912500000UL, { 1910780, -40815, 370 } }, \ + { 2014500000UL, { 1227000, 0, 0 } }, \ + { 2218500000UL, { 1227000, 0, 0 } }, \ + { 0UL, { 0, 0, 0 } }, \ + } + +#define CPU_CVB_TABLE_XA \ + .speedo_scale = 100, \ + .voltage_scale = 1000, \ + .entries = { \ + { 204000000UL, { 1250024, -39785, 565 } }, \ + { 306000000UL, { 1297556, -41145, 565 } }, \ + { 408000000UL, { 1346718, -42505, 565 } }, \ + { 510000000UL, { 1397511, -43855, 565 } }, \ + { 612000000UL, { 1449933, -45215, 565 } }, \ + { 714000000UL, { 1503986, -46575, 565 } }, \ + { 816000000UL, { 1559669, -47935, 565 } }, \ + { 918000000UL, { 1616982, -49295, 565 } }, \ + { 1020000000UL, { 1675926, -50645, 565 } }, \ + { 1122000000UL, { 1736500, -52005, 565 } }, \ + { 1224000000UL, { 1798704, -53365, 565 } }, \ + { 1326000000UL, { 1862538, -54725, 565 } }, \ + { 1428000000UL, { 1928003, -56085, 565 } }, \ + { 1530000000UL, { 1995097, -57435, 565 } }, \ + { 1606500000UL, { 2046149, -58445, 565 } }, \ + { 1632000000UL, { 2063822, -58795, 565 } }, \ + { 0UL, { 0, 0, 0 } }, \ + } + +#define CPU_CVB_TABLE_EUCM1 \ + .speedo_scale = 100, \ + .voltage_scale = 1000, \ + .entries = { \ + { 204000000UL, { 734429, 0, 0 } }, \ + { 306000000UL, { 768191, 0, 0 } }, \ + { 408000000UL, { 801953, 0, 0 } }, \ + { 510000000UL, { 835715, 0, 0 } }, \ + { 612000000UL, { 869477, 0, 0 } }, \ + { 714000000UL, { 903239, 0, 0 } }, \ + { 816000000UL, { 937001, 0, 0 } }, \ + { 918000000UL, { 970763, 0, 0 } }, \ + { 1020000000UL, { 1004525, 0, 0 } }, \ + { 1122000000UL, { 1038287, 0, 0 } }, \ + { 1224000000UL, { 1072049, 0, 0 } }, \ + { 1326000000UL, { 1105811, 0, 0 } }, \ + { 1428000000UL, { 1130000, 0, 0 } }, \ + { 1555500000UL, { 1130000, 0, 0 } }, \ + { 1632000000UL, { 1170000, 0, 0 } }, \ + { 1734000000UL, { 1227500, 0, 0 } }, \ + { 0UL, { 0, 0, 0 } }, \ + } + +#define CPU_CVB_TABLE_EUCM2 \ + .speedo_scale = 100, \ + .voltage_scale = 1000, \ + .entries = { \ + { 204000000UL, { 742283, 0, 0 } }, \ + { 306000000UL, { 776249, 0, 0 } }, \ + { 408000000UL, { 810215, 0, 0 } }, \ + { 510000000UL, { 844181, 0, 0 } }, \ + { 612000000UL, { 878147, 0, 0 } }, \ + { 714000000UL, { 912113, 0, 0 } }, \ + { 816000000UL, { 946079, 0, 0 } }, \ + { 918000000UL, { 980045, 0, 0 } }, \ + { 1020000000UL, { 1014011, 0, 0 } }, \ + { 1122000000UL, { 1047977, 0, 0 } }, \ + { 1224000000UL, { 1081943, 0, 0 } }, \ + { 1326000000UL, { 1090000, 0, 0 } }, \ + { 1479000000UL, { 1090000, 0, 0 } }, \ + { 1555500000UL, { 1162000, 0, 0 } }, \ + { 1683000000UL, { 1195000, 0, 0 } }, \ + { 0UL, { 0, 0, 0 } }, \ + } + +#define CPU_CVB_TABLE_EUCM2_JOINT_RAIL \ + .speedo_scale = 100, \ + .voltage_scale = 1000, \ + .entries = { \ + { 204000000UL, { 742283, 0, 0 } }, \ + { 306000000UL, { 776249, 0, 0 } }, \ + { 408000000UL, { 810215, 0, 0 } }, \ + { 510000000UL, { 844181, 0, 0 } }, \ + { 612000000UL, { 878147, 0, 0 } }, \ + { 714000000UL, { 912113, 0, 0 } }, \ + { 816000000UL, { 946079, 0, 0 } }, \ + { 918000000UL, { 980045, 0, 0 } }, \ + { 1020000000UL, { 1014011, 0, 0 } }, \ + { 1122000000UL, { 1047977, 0, 0 } }, \ + { 1224000000UL, { 1081943, 0, 0 } }, \ + { 1326000000UL, { 1090000, 0, 0 } }, \ + { 1479000000UL, { 1090000, 0, 0 } }, \ + { 1504500000UL, { 1120000, 0, 0 } }, \ + { 0UL, { 0, 0, 0 } }, \ + } + +#define CPU_CVB_TABLE_ODN \ + .speedo_scale = 100, \ + .voltage_scale = 1000, \ + .entries = { \ + { 204000000UL, { 721094, 0, 0 } }, \ + { 306000000UL, { 754040, 0, 0 } }, \ + { 408000000UL, { 786986, 0, 0 } }, \ + { 510000000UL, { 819932, 0, 0 } }, \ + { 612000000UL, { 852878, 0, 0 } }, \ + { 714000000UL, { 885824, 0, 0 } }, \ + { 816000000UL, { 918770, 0, 0 } }, \ + { 918000000UL, { 915716, 0, 0 } }, \ + { 1020000000UL, { 984662, 0, 0 } }, \ + { 1122000000UL, { 1017608, 0, 0 } }, \ + { 1224000000UL, { 1050554, 0, 0 } }, \ + { 1326000000UL, { 1083500, 0, 0 } }, \ + { 1428000000UL, { 1116446, 0, 0 } }, \ + { 1581000000UL, { 1130000, 0, 0 } }, \ + { 1683000000UL, { 1168000, 0, 0 } }, \ + { 1785000000UL, { 1227500, 0, 0 } }, \ + { 0UL, { 0, 0, 0 } }, \ + } + +struct cvb_table tegra210_cpu_cvb_tables[] = { + { + .speedo_id =10 , + .process_id =0 , + .min_millivolts =840 , + .max_millivolts =1120 , +CPU_CVB_TABLE_EUCM2_JOINT_RAIL , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =10 , + .process_id =1 , + .min_millivolts =840 , + .max_millivolts =1120 , +CPU_CVB_TABLE_EUCM2_JOINT_RAIL , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =9 , + .process_id =0 , + .min_millivolts =900 , + .max_millivolts =1162 , +CPU_CVB_TABLE_EUCM2 , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + } + }, + { + .speedo_id =9 , + .process_id =1 , + .min_millivolts =900 , + .max_millivolts =1162 , +CPU_CVB_TABLE_EUCM2 , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + } + }, + { + .speedo_id =8 , + .process_id =0 , + .min_millivolts =900 , + .max_millivolts =1195 , +CPU_CVB_TABLE_EUCM2 , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + } + }, + { + .speedo_id =8 , + .process_id =1 , + .min_millivolts =900 , + .max_millivolts =1195 , +CPU_CVB_TABLE_EUCM2 , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + } + }, + { + .speedo_id =7 , + .process_id =0 , + .min_millivolts =841 , + .max_millivolts =1227 , +CPU_CVB_TABLE_EUCM1 , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =7 , + .process_id =1 , + .min_millivolts =841 , + .max_millivolts =1227 , +CPU_CVB_TABLE_EUCM1 , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =6 , + .process_id =0 , + .min_millivolts =870 , + .max_millivolts =1150 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune1 =0x20091d9 , + } + }, + { + .speedo_id =6 , + .process_id =1 , + .min_millivolts =870 , + .max_millivolts =1150 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune1 =0x25501d0 , + } + }, + { + .speedo_id =5 , + .process_id =0 , + .min_millivolts =818 , + .max_millivolts =1227 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =5 , + .process_id =1 , + .min_millivolts =818 , + .max_millivolts =1227 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x25501d0 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =4 , + .process_id =-1 , + .min_millivolts =918 , + .max_millivolts =1113 , +CPU_CVB_TABLE_XA , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune1 =0x17711BD , + } + }, + { + .speedo_id =3 , + .process_id =0 , + .min_millivolts =825 , + .max_millivolts =1227 , +CPU_CVB_TABLE_ODN , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =3 , + .process_id =1 , + .min_millivolts =825 , + .max_millivolts =1227 , +CPU_CVB_TABLE_ODN , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x25501d0 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =2 , + .process_id =0 , + .min_millivolts =870 , + .max_millivolts =1227 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune1 =0x20091d9 , + } + }, + { + .speedo_id =2 , + .process_id =1 , + .min_millivolts =870 , + .max_millivolts =1227 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune1 =0x25501d0 , + } + }, + { + .speedo_id =1 , + .process_id =0 , + .min_millivolts =837 , + .max_millivolts =1227 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =1 , + .process_id =1 , + .min_millivolts =837 , + .max_millivolts =1227 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x25501d0 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =0 , + .process_id =0 , + .min_millivolts =850 , + .max_millivolts =1170 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x20091d9 , + .tune_high_min_millivolts =864 , + } + }, + { + .speedo_id =0 , + .process_id =1 , + .min_millivolts =850 , + .max_millivolts =1170 , +CPU_CVB_TABLE , + .cpu_dfll_data = { + .tune0_low =0xffead0ff , + .tune0_high =0xffead0ff , + .tune1 =0x25501d0 , + .tune_high_min_millivolts =864 , + } + }, +}; +static const struct dfll_fcpu_data tegra124_dfll_fcpu_data = { .cpu_max_freq_table = tegra124_cpu_max_freq_table, .cpu_max_freq_table_size =ARRAY_SIZE (tegra124_cpu_max_freq_table),@@ -95,11 +510,22 @@ static const struct dfll_fcpu_data tegra124_dfll_fcpu_data = { .cpu_cvb_tables_size = ARRAY_SIZE(tegra124_cpu_cvb_tables) }; +static const struct dfll_fcpu_data tegra210_dfll_fcpu_data = { + .cpu_max_freq_table = tegra210_cpu_max_freq_table, + .cpu_max_freq_table_size =ARRAY_SIZE (tegra210_cpu_max_freq_table), + .cpu_cvb_tables = tegra210_cpu_cvb_tables, + .cpu_cvb_tables_size =ARRAY_SIZE (tegra210_cpu_cvb_tables), +}; +static const struct of_device_id tegra124_dfll_fcpu_of_match[] = { { .compatible ="nvidia,tegra124-dfll" , .data = &tegra124_dfll_fcpu_data, }, + { + .compatible ="nvidia,tegra210-dfll" , + .data = &tegra210_dfll_fcpu_data + }, { }, };drivers/clk/tegra/cvb.h +0
-0
drivers/clk/tegra/cvb.h struct cvb_cpu_dfll_data { · line 44
Quoted 4 lines
drivers/clk/tegra/cvb.h +1
-0@@ -41,6 +41,7 @@ struct cvb_cpu_dfll_data {u32 tune0_low;u32 tune0_high;u32 tune1; +unsigned int tune_high_min_millivolts;
Where is this actually used?
Cheers
Jon
Signature · 1 line
nvpublic
Re: [PATCH 10/19] clk: tegra: dfll: build clk-dfll.c for Tegra124 and Tegra210
In reply to Joseph LoQuoted 30 lines · Joseph Lo
From: Peter De Schrijver <[email protected]>
Tegra210 has a DFLL as well and can share the majority of the code with the Tegra124 implementation. So build the same code for both platforms.
Signed-off-by Peter De Schrijver <[email protected]>Signed-off-by Joseph Lo <[email protected]>--- drivers/clk/tegra/Kconfig | 5 +++++ drivers/clk/tegra/Makefile | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-)drivers/clk/tegra/Kconfig +5
-0@@ -5,3 +5,8 @@ config TEGRA_CLK_EMC config CLK_TEGRA_BPMP def_bool y depends on TEGRA_BPMP + +config TEGRA_CLK_DFLL + depends on (ARCH_TEGRA_124_SOC || ARCH_TEGRA_210_SOC) + select PM_OPP + def_bool ydrivers/clk/tegra/Makefile +0
-0
drivers/clk/tegra/Makefile obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += clk-tegra20.o · line 26
Quoted 8 lines
drivers/clk/tegra/Makefile +1
-1@@ -20,7 +20,7 @@ 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_ARCH_TEGRA_124_SOC) += clk-tegra124-dfll-fcpu.o +obj-$(CONFIG_TEGRA_CLK_DFLL) += clk-tegra124-dfll-fcpu.o obj-$(CONFIG_ARCH_TEGRA_132_SOC) += clk-tegra124.o obj-y += cvb.o obj-$(CONFIG_ARCH_TEGRA_210_SOC) += clk-tegra210.o
Cheers
Jon
Signature · 1 line
nvpublic
Jon Hunter
maintainerRe: [PATCH 11/19] cpufreq: tegra124: do not handle the CPU rail
In reply to Joseph LoQuoted 103 lines · Joseph Lo
The Tegra124 cpufreq driver has no information to handle the Vdd-CPU rail. So the driver shouldn't handle for the CPU clock switching from DFLL to other PLL clocks. It was designed to work on DFLL clock only, which handle the frequency/voltage scaling in the background. This patch removes the driver dependency of the CPU rail.
--- drivers/cpufreq/Kconfig.arm | 2 +- drivers/cpufreq/tegra124-cpufreq.c | 26 ++------------------------ 2 files changed, 3 insertions(+), 25 deletions(-)drivers/cpufreq/Kconfig.arm +1
-1@@ -262,7 +262,7 @@ config ARM_TEGRA20_CPUFREQ config ARM_TEGRA124_CPUFREQ tristate "Tegra124 CPUFreq support" - depends on ARCH_TEGRA && CPUFREQ_DT && REGULATOR + depends on ARCH_TEGRA && CPUFREQ_DT default y help This adds the CPUFreq driver support for Tegra124 SOCs.drivers/cpufreq/tegra124-cpufreq.c +2
-22@@ -22,11 +22,9 @@#include <linux/of.h> #include <linux/platform_device.h> #include <linux/pm_opp.h> -#include <linux/regulator/consumer.h> #include <linux/types.h> struct tegra124_cpufreq_priv { -struct regulator *vdd_cpu_reg;struct clk *cpu_clk;struct clk *pllp_clk;struct clk *pllx_clk;@@ -60,14 +58,6 @@ static int tegra124_cpu_switch_to_dfll(struct tegra124_cpufreq_priv *priv)return ret; } -static void tegra124_cpu_switch_to_pllx (struct tegra124_cpufreq_priv *priv) -{ -clk_set_parent (priv->cpu_clk, priv->pllp_clk); -clk_disable_unprepare (priv->dfll_clk); -regulator_sync_voltage (priv->vdd_cpu_reg); -clk_set_parent (priv->cpu_clk, priv->pllx_clk); -} -static int tegra124_cpufreq_probe (struct platform_device *pdev) {struct tegra124_cpufreq_priv *priv;@@ -88,16 +78,10 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)if (!np)return -ENODEV ; - priv->vdd_cpu_reg =regulator_get (cpu_dev,"vdd-cpu" ); -if (IS_ERR (priv->vdd_cpu_reg)) { - ret =PTR_ERR (priv->vdd_cpu_reg); - goto out_put_np; - } - priv->cpu_clk =of_clk_get_by_name (np,"cpu_g" );if (IS_ERR (priv->cpu_clk)) { ret =PTR_ERR (priv->cpu_clk); - goto out_put_vdd_cpu_reg; + goto out_put_np; } priv->dfll_clk =of_clk_get_by_name (np,"dfll" );@@ -129,15 +113,13 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)platform_device_register_full (&cpufreq_dt_devinfo);if (IS_ERR (priv->cpufreq_dt_pdev)) { ret =PTR_ERR (priv->cpufreq_dt_pdev); - goto out_switch_to_pllx; + goto out_put_pllp_clk; }platform_set_drvdata (pdev, priv);return 0 ; -out_switch_to_pllx: -tegra124_cpu_switch_to_pllx (priv); out_put_pllp_clk:clk_put (priv->pllp_clk); out_put_pllx_clk:@@ -146,8 +128,6 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)clk_put (priv->dfll_clk); out_put_cpu_clk:clk_put (priv->cpu_clk); -out_put_vdd_cpu_reg: -regulator_put (priv->vdd_cpu_reg); out_put_np:of_node_put (np);
drivers/cpufreq/tegra124-cpufreq.c static int tegra124_cpufreq_remove(struct platform_device *pdev) · line 168
Quoted 10 lines
drivers/cpufreq/tegra124-cpufreq.c +0
-2@@ -159,13 +139,11 @@ static int tegra124_cpufreq_remove(struct platform_device *pdev)struct tegra124_cpufreq_priv *priv =platform_get_drvdata (pdev);platform_device_unregister (priv->cpufreq_dt_pdev); -tegra124_cpu_switch_to_pllx (priv);clk_put (priv->pllp_clk);clk_put (priv->pllx_clk);clk_put (priv->dfll_clk);clk_put (priv->cpu_clk); -regulator_put (priv->vdd_cpu_reg);
I see what you are saying and while this does appear to be broken, it also does not seem right that if we load and unload this driver the CPU clock parent will remain as the DFLL clock. Can't we query the voltage of the vdd-cpu regulator before we switch and then restore it before we switch back?
I am just trying to understand if there is no way to switch back? If not then maybe we should not allow this driver to be built as a module and remove the removal function altogether.
Cheers
Jon
Signature · 1 line
nvpublic
Re: [PATCH 12/19] cpufreq: tegra124: extend to support Tegra210
In reply to Joseph LoQuoted 15 lines · Joseph Lo
Tegra210 uses the same methodology as Tegra124 for CPUFreq controlling that based on DFLL clock. So extending this driver to support Tegra210.
--- drivers/cpufreq/tegra124-cpufreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/cpufreq/tegra124-cpufreq.c +0
-0
drivers/cpufreq/tegra124-cpufreq.c static int __init tegra_cpufreq_init(void) · line 166
Quoted 9 lines
drivers/cpufreq/tegra124-cpufreq.c +2
-1@@ -159,7 +159,8 @@ static int __init tegra_cpufreq_init(void)int ret;struct platform_device *pdev; -if (!of_machine_is_compatible ("nvidia,tegra124" )) +if (!(of_machine_is_compatible ("nvidia,tegra124" ) || +of_machine_is_compatible ("nvidia,tegra210" )))return -ENODEV ;/*>
Cheers
Jon
Signature · 1 line
nvpublic
Re: [PATCH 13/19] arm64: dts: tegra210: add DFLL clock
In reply to Joseph LoQuoted 35 lines · Joseph Lo
Add essential DFLL clock properties for Tegra210.
Signed-off-by Joseph Lo <[email protected]>--- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)arch/arm64/boot/dts/nvidia/tegra210.dtsi +12
-0@@ -4,6 +4,7 @@ #include <dt-bindings/memory/tegra210-mc.h> #include <dt-bindings/pinctrl/pinctrl-tegra.h> #include <dt-bindings/pinctrl/pinctrl-tegra-io-pad.h> +#include <dt-bindings/reset/tegra210-car.h> #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/thermal/tegra124-soctherm.h>@@ -1131,6 +1132,24 @@ #nvidia,mipi-calibrate-cells = <1>; }; + dfll: clock@70110000 { + compatible = "nvidia,tegra210-dfll"; + reg = <0 0x70110000 0 0x100>, /* DFLL control */ + <0 0x70110000 0 0x100>, /* I2C output control */ + <0 0x70110100 0 0x100>, /* Integrated I2C controller */ + <0 0x70110200 0 0x100>; /* Look-up table RAM */ + interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&tegra_car TEGRA210_CLK_DFLL_SOC>, + <&tegra_car TEGRA210_CLK_DFLL_REF>, + <&tegra_car TEGRA210_CLK_I2C5>; + clock-names = "soc", "ref", "i2c";
arch/arm64/boot/dts/nvidia/tegra210.dtsi line 1155
Quoted 10 lines
arch/arm64/boot/dts/nvidia/tegra210.dtsi +7
-0+ resets = <&tegra_car TEGRA210_RST_DFLL_DVCO>; + reset-names = "dvco"; + #clock-cells = <0>; + clock-output-names = "dfllCPU_out"; + status = "disabled"; + }; + aconnect@702c0000 { compatible = "nvidia,tegra210-aconnect"; clocks = <&tegra_car TEGRA210_CLK_APE>,
Cheers
Jon
Signature · 1 line
nvpublic
Re: [PATCH 14/19] arm64: dts: tegra210: add CPU clocks
In reply to Joseph LoQuoted 15 lines · Joseph Lo
Add CPU clocks for Tegra210.
Signed-off-by Joseph Lo <[email protected]>--- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)arch/arm64/boot/dts/nvidia/tegra210.dtsi +0
-0@@ -1304,6 +1304,12 @@ device_type = "cpu"; compatible = "arm,cortex-a57";
arch/arm64/boot/dts/nvidia/tegra210.dtsi line 1315
Quoted 10 lines
arch/arm64/boot/dts/nvidia/tegra210.dtsi +6
-0reg = <0>; + clocks = <&tegra_car TEGRA210_CLK_CCLK_G>, + <&tegra_car TEGRA210_CLK_PLL_X>, + <&tegra_car TEGRA210_CLK_PLL_P_OUT4>, + <&dfll>; + clock-names = "cpu_g", "pll_x", "pll_p", "dfll"; + clock-latency = <300000>; }; cpu@1 {
Cheers
Jon
Signature · 1 line
nvpublic
Re: [PATCH 15/19] arm64: dts: tegra210-p2597: add pinmux for PWM-based DFLL support
In reply to Joseph LoQuoted 23 lines · Joseph Lo
Add pinmux for PWM-based DFLL support.
Signed-off-by Joseph Lo <[email protected]>--- arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+)arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi +7
-0@@ -1278,6 +1278,20 @@ nvidia,open-drain = <TEGRA_PIN_DISABLE>; }; }; + + dvfs_pwm_active_state: dvfs_pwm_active { + dvfs_pwm_pbb1 { + nvidia,pins = "dvfs_pwm_pbb1"; + nvidia,tristate = <TEGRA_PIN_DISABLE>; + }; + };
arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi line 1297
Quoted 10 lines
arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi +7
-0+ + dvfs_pwm_inactive_state: dvfs_pwm_inactive { + dvfs_pwm_pbb1 { + nvidia,pins = "dvfs_pwm_pbb1"; + nvidia,tristate = <TEGRA_PIN_ENABLE>; + }; + }; }; pwm@7000a000 {
Cheers
Jon
Signature · 1 line
nvpublic
Jon Hunter
maintainerRe: [PATCH 16/19] arm64: dts: tegra210-p2371-2180: enable DFLL clock
In reply to Joseph LoQuoted 20 lines · Joseph Lo
Enable DFLL clock for Jetson TX1 platform.
Signed-off-by Joseph Lo <[email protected]>--- .../boot/dts/nvidia/tegra210-p2371-2180.dts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+)arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts +5
-0@@ -78,4 +78,24 @@ }; }; }; + + clock@70110000 { + status = "okay"; + nvidia,pwm-to-pmic; + nvidia,init-uv = <1000000>;
arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts line 95
Quoted 10 lines
arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts +10
-0+ nvidia,align-offset-uv = <708000>; + nvidia,align-step-uv = <19200>; + nvidia,sample-rate = <25000>; + nvidia,droop-ctrl = <0x00000f00>; + nvidia,force-mode = <1>; + nvidia,cf = <6>; + nvidia,ci = <0>; + nvidia,cg = <2>; + nvidia,idle-override; + nvidia,one-shot-calibrate;
I don't see any Documentation for or usage of the above two properties.
Jon
Signature · 1 line
nvpublic
Re: [PATCH 17/19] arm64: dts: tegra210-smaug: add CPU power rail regulator
In reply to Joseph LoQuoted 28 lines · Joseph Lo
Add CPU power rail regulator for Smaug board.
Signed-off-by Joseph Lo <[email protected]>--- arch/arm64/boot/dts/nvidia/tegra210-smaug.dts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)arch/arm64/boot/dts/nvidia/tegra210-smaug.dts +12
-0@@ -1340,6 +1340,25 @@ status = "okay"; clock-frequency = <1000000>; + max77621_cpu: max77621@1b { + compatible = "maxim,max77621"; + reg = <0x1b>; + interrupt-parent = <&gpio>; + interrupts = <TEGRA_GPIO(Y, 1) IRQ_TYPE_LEVEL_LOW>; + regulator-name = "PPVAR_CPU"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <1231250>; + regulator-ramp-delay = <12500>; + regulator-boot-on; + regulator-always-on; + maxim,dvs-default-state = <1>;
arch/arm64/boot/dts/nvidia/tegra210-smaug.dts line 1364
Quoted 10 lines
arch/arm64/boot/dts/nvidia/tegra210-smaug.dts +7
-0+ maxim,enable-active-discharge; + maxim,enable-bias-control; + maxim,enable-etr; + maxim,enable-gpio = <&max77620 5 0>; + maxim,externally-enable; + }; + max77620: max77620@3c { compatible = "maxim,max77620"; reg = <0x3c>;
Cheers
Jon
Signature · 1 line
nvpublic
Re: [PATCH 18/19] arm64: dts: tegra210-smaug: enable DFLL clock
In reply to Joseph LoQuoted 21 lines · Joseph Lo
Enable DFLL clock for Smaug board.
Signed-off-by Joseph Lo <[email protected]>--- arch/arm64/boot/dts/nvidia/tegra210-smaug.dts | 12 ++++++++++++ 1 file changed, 12 insertions(+)arch/arm64/boot/dts/nvidia/tegra210-smaug.dts +5
-0@@ -1698,6 +1698,18 @@ status = "okay"; }; + clock@70110000 { + status = "okay"; + nvidia,sample-rate = <12500>; + nvidia,droop-ctrl = <0x00000f00>; + nvidia,force-mode = <1>;
arch/arm64/boot/dts/nvidia/tegra210-smaug.dts line 1715
Quoted 10 lines
arch/arm64/boot/dts/nvidia/tegra210-smaug.dts +7
-0+ nvidia,cf = <6>; + nvidia,ci = <0>; + nvidia,cg = <2>; + nvidia,i2c-fs-rate = <400000>; + vdd-cpu-supply = <&max77621_cpu>; + }; + aconnect@702c0000 { status = "okay";
Cheers
Jon
Signature · 1 line
nvpublic
Re: [PATCH 19/19] arm64: defconfig: Enable MAX8973 regulator
In reply to Joseph LoQuoted 15 lines · Joseph Lo
The Tegra210 Smaug board uses MAX77621 for both CPU & GPU rail. Note that max8973 and max77621 share the same driver. So enable this driver for the PMIC.
Signed-off-by Joseph Lo <[email protected]>--- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)arch/arm64/configs/defconfig +0
-0
arch/arm64/configs/defconfig CONFIG_REGULATOR_GPIO=y · line 426
Quoted 7 lines
arch/arm64/configs/defconfig +1
-0@@ -420,6 +420,7 @@ CONFIG_REGULATOR_GPIO=y CONFIG_REGULATOR_HI6421V530=y CONFIG_REGULATOR_HI655X=y CONFIG_REGULATOR_MAX77620=y +CONFIG_REGULATOR_MAX8973=y CONFIG_REGULATOR_PWM=y CONFIG_REGULATOR_QCOM_RPMH=y CONFIG_REGULATOR_QCOM_SMD_RPM=y
Cheers
Jon
Signature · 1 line
nvpublic
Jon Hunter
maintainerRe: [PATCH 07/19] clk: tegra: dfll: support PWM regulator control
In reply to Joseph LoQuoted 95 lines · Joseph Lo
The DFLL hardware supports two modes (I2C and PWM) for voltage control when requesting a frequency. In this patch, we introduce PWM mode support.
To support that, we re-organize the LUT for unifying the table for both cases of I2C and PWM mode. And generate that based on regulator info. For the PWM-based regulator, we get this info from DT. And do the same as the case of I2C LUT, which can help to map the PMIC voltage ID and voltages that the regulator supported.
The other parts are the support code for initializing the DFLL hardware to support PWM mode. Also, the register debugfs file is slightly reworked to only show the i2c registers when I2C mode is in use.
Based on the work of Peter De Schrijver <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>--- drivers/clk/tegra/clk-dfll.c | 431 ++++++++++++++++++++++++++++++----- 1 file changed, 368 insertions(+), 63 deletions(-)drivers/clk/tegra/clk-dfll.c +28
-5@@ -1,7 +1,7 @@/* * clk-dfll.c - Tegra DFLL clock source common code * -* Copyright (C) 2012-2014 NVIDIA Corporation. All rights reserved. +* Copyright (C) 2012-2018 NVIDIA Corporation. All rights reserved. * * Aleksandr Frid <[email protected]> * Paul Walmsley <[email protected]> @@ -47,6 +47,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/pinctrl/consumer.h> #include <linux/pm_opp.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> @@ -243,6 +244,12 @@ enum dfll_tune_range { DFLL_TUNE_LOW = 1, }; + +enum tegra_dfll_pmu_if { +TEGRA_DFLL_PMU_I2C =0 , +TEGRA_DFLL_PMU_PWM =1 , +}; +/** * struct dfll_rate_req - target DFLL rate request data * @rate: target frequency, after the postscaling @@ -294,16 +301,25 @@ struct tegra_dfll {u32 ci;u32 cg;bool cg_scale; +u32 reg_init_uV;/* I2C interface parameters */ u32 i2c_fs_rate;u32 i2c_reg;u32 i2c_slave_addr; -/* i2c_lut array entries are regulator framework selectors */ -unsigned i2c_lut[MAX_DFLL_VOLTAGES ]; -int i2c_lut_size; -u8 lut_min, lut_max, lut_safe; +/* lut array entries are regulator framework selectors or PWM values*/ +unsigned lut[MAX_DFLL_VOLTAGES ]; +unsigned lut_uv[MAX_DFLL_VOLTAGES ]; +int lut_size; +u8 lut_bottom, lut_min, lut_max, lut_safe; + +/* PWM interface */ +enum tegra_dfll_pmu_if pmu_if; +unsigned long pwm_rate; +struct pinctrl *pwm_pin; +struct pinctrl_state *pwm_enable_state; +struct pinctrl_state *pwm_disable_state; };#define clk_hw_to_dfll (_hw) container_of(_hw, struct tegra_dfll, dfll_clk_hw)@@ -489,6 +505,34 @@ static void dfll_set_mode(struct tegra_dfll *td,dfll_wmb (td); } +/* +* DVCO rate control +*/ + +static unsigned long get_dvco_rate_below (struct tegra_dfll *td,u8 out_min) +{ +struct dev_pm_opp *opp;
drivers/clk/tegra/clk-dfll.c static void dfll_set_mode(struct tegra_dfll *td, · line 524
Quoted 10 lines
drivers/clk/tegra/clk-dfll.c +10
-0+unsigned long rate, prev_rate; +int uv, min_uv; + + min_uv = td->lut_uv[out_min]; +for (rate =0 , prev_rate =0 ; ; rate++) { + opp =dev_pm_opp_find_freq_ceil (td->soc->dev, &rate); +if (IS_ERR (opp)) +break ; + + uv =dev_pm_opp_get_voltage (opp);
Can you fix the type of 'uv' here? It should be unsigned long.
Cheers
Jon
Signature · 1 line
nvpublic
Re: [PATCH 01/19] dt-bindings: clock: tegra124-dfll: Update DFLL binding for PWM regulator
In reply to Jon HunterHi Jon,
Thanks for reviewing this series.
Quoted 37 lines · Jon Hunter
Quoted 35 lines · Joseph Lo
From: Peter De Schrijver <[email protected]>
Add new properties to configure the DFLL PWM regulator support. Also add an example and make the I2C clock only required when I2C support is used.
Signed-off-by Peter De Schrijver <[email protected]>Signed-off-by Joseph Lo <[email protected]>--- .../bindings/clock/nvidia,tegra124-dfll.txt | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +3
-1@@ -8,7 +8,6 @@ the fast CPU cluster. It consists of a free-running voltage controlled oscillator connected to the CPU voltage rail (VDD_CPU), and a closed loop control module that will automatically adjust the VDD_CPU voltage by communicating with an off-chip PMIC either via an I2C bus or via PWM signals. -Currently only the I2C mode is supported by these bindings. Required properties: - compatible : should be "nvidia,tegra124-dfll"@@ -45,10 +44,28 @@ Required properties for the control loop parameters: Optional properties for the control loop parameters: - nvidia,cg-scale: Boolean value, see the field DFLL_PARAMS_CG_SCALE in the TRM. +Optional properties for mode selection: +- nvidia,pwm-to-pmic: Use PWM to control regulator rather then I2C. + Required properties for I2C mode: - nvidia,i2c-fs-rate: I2C transfer rate, if using full speed mode.
Quoted 6 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt Required properties for the control loop parameters: · line 55
Quoted 4 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +3
-1-Example: +Required properties for PWM mode: +- nvidia,pwm-period: period of PWM square wave in microseconds. +- nvidia,init-uv: Regulator voltage in micro volts when PWM control is disabled.Maybe consider 'pwm-inactive-voltage-microvolt'.
Ah, I think I need to refine the description here. It should be something like below.
- nvidia,pwm-init-microvolt : Regulator voltage in micro volts when
PWM control is initialized
This is the initial voltage that when we just initialize the DFLL hardware for PWM output. And before we switch the CPU clock from PLLX to DFLL, we will enable DFLL hardware in closed loop mode which will aplly the DVFS table that was calculated from CVB table.
The original description maybe make you think that it's the working voltage when it's under open-loop mode. But it's not. Sorry.
When we working on open-loop mode which will switch to low voltage range which also follows the DVFS table. Not this one.
Quoted 5 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt Required properties for the control loop parameters: · line 57
Quoted 3 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +2
-0+- nvidia,align-offset-uv: Regulator voltage in micro volts when PWM control is + enabled and PWM output is low.Would this be considered the minimum pwm active voltage?
This would be used for minimum voltage for LUT table, which is the table that PMIC can output. The real minimum voltage in PWM mode still depends on the CVB table.
So maybe change this one to 'nvidia,pwm-offset-uv'.
Quoted 6 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt Required properties for the control loop parameters: · line 60
Quoted 4 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +3
-0+- nvidia,align-step-uv: Voltage increase in micro volts corresponding to a + 1/33th increase in duty cycle. Eg the voltage for 2/33th + duty cycle would be:Maybe consider 'pwm-voltage-step-microvolt'.
Okay.
Quoted 9 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt Required properties for the control loop parameters: · line 66
Quoted 7 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +6
-0+ nvidia,align-offset-uv + nvidia,align-step-uv * 2. +- pinctrl-0: I/O pad configuration when PWM control is enabled. +- pinctrl-1: I/O pad configuration when PWM control is disabled. +- pinctrl-names: must include the following entries: + - dvfs_pwm_enable: I/O pad configuration when PWM control is enabled. + - dvfs_pwm_disable: I/O pad configuration when PWM control is disabled.Please see Rob's feedback on the above [0].
Yes, I did refer that comments in this patch. And fixed that in description but missed for bindings ...
Thanks,
Joseph
Quoted 6 lines
Cheers
Jon
Jon Hunter
maintainerRe: [PATCH 01/19] dt-bindings: clock: tegra124-dfll: Update DFLL binding for PWM regulator
Quoted 62 lines · Joseph Lo
Hi Jon,
Thanks for reviewing this series.
Quoted 39 lines · Jon Hunter
Quoted 37 lines · Joseph Lo
From: Peter De Schrijver <[email protected]>
Add new properties to configure the DFLL PWM regulator support. Also add an example and make the I2C clock only required when I2C support is used.
Signed-off-by Peter De Schrijver <[email protected]>Signed-off-by Joseph Lo <[email protected]>---
.../bindings/clock/nvidia,tegra124-dfll.txt | 73 ++++++++++++++++++-1 file changed, 71 insertions(+), 2 deletions(-)diff --git
a/Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txtb/Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txtindexdff236f524a7..8c97600d2bad100644Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +0
-0@@ -8,7 +8,6 @@ the fast CPU cluster. It consists of a free-runningvoltage controlled
oscillator connected to the CPU voltage rail (VDD_CPU), and a closed loop
control module that will automatically adjust theVDD_CPUvoltage by communicating with an off-chip PMIC either via an I2C bus or via PWM signals.
-Currently only the I2C mode is supported by these bindings. Required properties:
- compatible : should be "nvidia,tegra124-dfll"Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +0
-0@@ -45,10 +44,28 @@ Required properties for the control loop parameters:Optional properties for the control loop parameters:
- nvidia,cg-scale: Boolean value, see the fieldDFLL_PARAMS_CG_SCALEin the TRM.
+Optional properties for mode selection:
+- nvidia,pwm-to-pmic: Use PWM to control regulator rather then I2C. +
Required properties for I2C mode:Quoted 8 lines
Quoted 6 lines
- nvidia,i2c-fs-rate: I2C transfer rate, if using full speed mode. -Example:
+Required properties for PWM mode:+- nvidia,pwm-period: period of PWM square wave in microseconds. +- nvidia,init-uv: Regulator voltage in micro volts when PWM controlis disabled.
Maybe consider 'pwm-inactive-voltage-microvolt'.
Ah, I think I need to refine the description here. It should be something like below.
- nvidia,pwm-init-microvolt : Regulator voltage in micro volts when PWM control is initializedThis is the initial voltage that when we just initialize the DFLL hardware for PWM output. And before we switch the CPU clock from PLLX to DFLL, we will enable DFLL hardware in closed loop mode which will aplly the DVFS table that was calculated from CVB table.
Quoted 5 lines
The original description maybe make you think that it's the working voltage when it's under open-loop mode. But it's not. Sorry.
When we working on open-loop mode which will switch to low voltage range which also follows the DVFS table. Not this one.
OK, but I am still not sure what this voltage is. I mean that I understand it is the initial voltage, but how exactly do we define this number? Where does it come from, how is this determined?
Quoted 11 lines
Quoted 6 lines
Quoted 4 lines
+- nvidia,align-offset-uv: Regulator voltage in micro volts when PWM control is
+ enabled and PWM output is low.Would this be considered the minimum pwm active voltage?
This would be used for minimum voltage for LUT table, which is the table that PMIC can output. The real minimum voltage in PWM mode still depends on the CVB table.
So maybe change this one to 'nvidia,pwm-offset-uv'.
So is this the min supported by the PMIC? Maybe the name should reflect that because the above name does not reflect this. Furthermore, if this is a min then maybe the name should use 'min' as opposed to 'offset'. for example, 'nvidia,pwm-pmic-min-microvolts'.
Does this need to be described in DT, can it not be queried from the PMIC?
Cheers
Jon
Signature · 6 lines
nvpublic _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 01/19] dt-bindings: clock: tegra124-dfll: Update DFLL binding for PWM regulator
Quoted 67 lines · Jon Hunter
Quoted 65 lines · Joseph Lo
Hi Jon,
Thanks for reviewing this series.
Quoted 39 lines · Jon Hunter
Quoted 37 lines · Joseph Lo
From: Peter De Schrijver <[email protected]>
Add new properties to configure the DFLL PWM regulator support. Also add an example and make the I2C clock only required when I2C support is used.
Signed-off-by Peter De Schrijver <[email protected]>Signed-off-by Joseph Lo <[email protected]>--- .../bindings/clock/nvidia,tegra124-dfll.txt | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-)diff --git
a/Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txtb/Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txtindexdff236f524a7..8c97600d2bad100644Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +0
-0@@ -8,7 +8,6 @@ the fast CPU cluster. It consists of a free-runningvoltage controlled
oscillator connected to the CPU voltage rail (VDD_CPU), and a
closed loop
control module that will automatically adjust theVDD_CPUvoltage by communicating with an off-chip PMIC either via an I2C bus or via
PWM signals.Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +0
-1-Currently only the I2C mode is supported by these bindings. Required properties: - compatible : should be "nvidia,tegra124-dfll"@@ -45,10 +44,28 @@ Required properties for the control loop parameters: Optional properties for the control loop parameters: - nvidia,cg-scale: Boolean value, see the field
DFLL_PARAMS_CG_SCALEin the TRM.
+Optional properties for mode selection:
+- nvidia,pwm-to-pmic: Use PWM to control regulator rather then I2C. +
Required properties for I2C mode:Quoted 8 lines
Quoted 6 lines
- nvidia,i2c-fs-rate: I2C transfer rate, if using full speed mode. -Example:
+Required properties for PWM mode:+- nvidia,pwm-period: period of PWM square wave in microseconds. +- nvidia,init-uv: Regulator voltage in micro volts when PWM controlis disabled.
Maybe consider 'pwm-inactive-voltage-microvolt'.
Ah, I think I need to refine the description here. It should be something like below.
- nvidia,pwm-init-microvolt : Regulator voltage in micro volts when PWM
control is initializedThis is the initial voltage that when we just initialize the DFLL hardware for PWM output. And before we switch the CPU clock from PLLX to DFLL, we will enable DFLL hardware in closed loop mode which will aplly the DVFS table that was calculated from CVB table.
The original description maybe make you think that it's the working voltage when it's under open-loop mode. But it's not. Sorry.
Quoted 6 lines
Quoted 2 lines
When we working on open-loop mode which will switch to low voltage range which also follows the DVFS table. Not this one.
OK, but I am still not sure what this voltage is. I mean that I understand it is the initial voltage, but how exactly do we define this number? Where does it come from, how is this determined?
IIRC, this is the same output voltage that bootloader configured with proper PLLX rate. So before DFLL handling the CPU clock, that is the output voltage. We configure the same when DFLL HW is just initialized.
1 volt here is pretty safe when CPU clock switched from bootloader to kernel at 6.912MHz@pllx.
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines
+- nvidia,align-offset-uv: Regulator voltage in micro volts when PWM control is
+ enabled and PWM output is low.Would this be considered the minimum pwm active voltage?
This would be used for minimum voltage for LUT table, which is the table that PMIC can output. The real minimum voltage in PWM mode still depends on the CVB table.
Quoted 9 lines
Quoted 1 line
So maybe change this one to 'nvidia,pwm-offset-uv'.
So is this the min supported by the PMIC? Maybe the name should reflect that because the above name does not reflect this. Furthermore, if this is a min then maybe the name should use 'min' as opposed to 'offset'. for example, 'nvidia,pwm-pmic-min-microvolts'.
Does this need to be described in DT, can it not be queried from the PMIC?
Yes, either way needs to go with DT. The very initial patchset for DFLL-PWM support, which introduced a redundant pwm-dfll driver. And with the driver, we can describe the PWM vdd-cpu regulator in DT with the voltage table that the PMIC can output. But NAKed by reviewer.
Okay, 'nvidia,pwm-pmic-min-microvolts' looks fine. Thanks.
[1]: https://patchwork.ozlabs.org/patch/613524/
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Jon Hunter
maintainerRe: [PATCH 01/19] dt-bindings: clock: tegra124-dfll: Update DFLL binding for PWM regulator
Quoted 79 lines · Joseph Lo
Quoted 72 lines · Jon Hunter
Quoted 70 lines · Joseph Lo
Hi Jon,
Thanks for reviewing this series.
Quoted 43 lines · Jon Hunter
Quoted 41 lines · Joseph Lo
From: Peter De Schrijver <[email protected]>
Add new properties to configure the DFLL PWM regulator support. Also add an example and make the I2C clock only required when I2C support is
used.Signed-off-by Peter De Schrijver <[email protected]>Signed-off-by Joseph Lo <[email protected]>---
.../bindings/clock/nvidia,tegra124-dfll.txt | 73
++++++++++++++++++-1 file changed, 71 insertions(+), 2 deletions(-)diff --git
a/Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txtb/Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txtindexdff236f524a7..8c97600d2bad100644Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +0
-0@@ -8,7 +8,6 @@ the fast CPU cluster. It consists of a free-runningvoltage controlled
oscillator connected to the CPU voltage rail (VDD_CPU), and a closed loop
control module that will automatically adjust theVDD_CPUvoltage by
communicating with an off-chip PMIC either via an I2C bus or via PWM signals.
-Currently only the I2C mode is supported by these bindings. Required properties:
- compatible : should be "nvidia,tegra124-dfll"Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +0
-0@@ -45,10 +44,28 @@ Required properties for the control loopparameters:
Optional properties for the control loop parameters:
- nvidia,cg-scale: Boolean value, see the fieldDFLL_PARAMS_CG_SCALEin the TRM.
+Optional properties for mode selection:
+- nvidia,pwm-to-pmic: Use PWM to control regulator rather then I2C. +
Required properties for I2C mode:Quoted 8 lines
Quoted 6 lines
- nvidia,i2c-fs-rate: I2C transfer rate, if using full speed mode. -Example:
+Required properties for PWM mode:+- nvidia,pwm-period: period of PWM square wave in microseconds. +- nvidia,init-uv: Regulator voltage in micro volts when PWM controlis disabled.
Maybe consider 'pwm-inactive-voltage-microvolt'.
Ah, I think I need to refine the description here. It should be something like below.
- nvidia,pwm-init-microvolt : Regulator voltage in micro volts when PWM
control is initializedThis is the initial voltage that when we just initialize the DFLL hardware for PWM output. And before we switch the CPU clock from PLLX to DFLL, we will enable DFLL hardware in closed loop mode which will aplly the DVFS table that was calculated from CVB table.
The original description maybe make you think that it's the working voltage when it's under open-loop mode. But it's not. Sorry.
Quoted 6 lines
Quoted 2 lines
When we working on open-loop mode which will switch to low voltage range which also follows the DVFS table. Not this one.
OK, but I am still not sure what this voltage is. I mean that I understand it is the initial voltage, but how exactly do we define this number? Where does it come from, how is this determined?
Quoted 6 lines
IIRC, this is the same output voltage that bootloader configured with proper PLLX rate. So before DFLL handling the CPU clock, that is the output voltage. We configure the same when DFLL HW is just initialized.
1 volt here is pretty safe when CPU clock switched from bootloader to kernel at 6.912MHz@pllx.
OK, now I understand. Seems a little fragile, but maybe there is no better alternative here.
Please describe what this voltage is in the binding doc, so if anyone happened to modify their bootloader to run at a different speed that it is stated that this voltage should be high enough to support initial boot frequency.
Quoted 21 lines
Quoted 13 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
+- nvidia,align-offset-uv: Regulator voltage in micro volts when PWM control is
+ enabled and PWM output is low.Quoted 6 lines
Quoted 1 line
Would this be considered the minimum pwm active voltage?
This would be used for minimum voltage for LUT table, which is the table that PMIC can output. The real minimum voltage in PWM mode still depends on the CVB table.
So maybe change this one to 'nvidia,pwm-offset-uv'.
Quoted 8 lines
So is this the min supported by the PMIC? Maybe the name should reflect that because the above name does not reflect this. Furthermore, if this is a min then maybe the name should use 'min' as opposed to 'offset'. for example, 'nvidia,pwm-pmic-min-microvolts'.
Does this need to be described in DT, can it not be queried from the PMIC?
Quoted 8 lines
Yes, either way needs to go with DT. The very initial patchset for DFLL-PWM support, which introduced a redundant pwm-dfll driver. And with the driver, we can describe the PWM vdd-cpu regulator in DT with the voltage table that the PMIC can output. But NAKed by reviewer.
Okay, 'nvidia,pwm-pmic-min-microvolts' looks fine. Thanks.
Thierry, what are your thoughts here? I guess you had asked initially why we needed a phandle to the PMIC. Seems we need to comprehend the min voltage supported by the PMIC for creating the LUT.
Cheers
Jon
Signature · 6 lines
nvpublic _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 01/19] dt-bindings: clock: tegra124-dfll: Update DFLL binding for PWM regulator
Quoted 122 lines · Jon Hunter
Quoted 79 lines · Joseph Lo
Quoted 72 lines · Jon Hunter
Quoted 70 lines · Joseph Lo
Hi Jon,
Thanks for reviewing this series.
Quoted 43 lines · Jon Hunter
Quoted 41 lines · Joseph Lo
From: Peter De Schrijver <[email protected]>
Add new properties to configure the DFLL PWM regulator support. Also add an example and make the I2C clock only required when I2C support is
used.Signed-off-by Peter De Schrijver <[email protected]>Signed-off-by Joseph Lo <[email protected]>--- .../bindings/clock/nvidia,tegra124-dfll.txt | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-)diff --git
a/Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txtb/Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txtindexdff236f524a7..8c97600d2bad100644Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +0
-0@@ -8,7 +8,6 @@ the fast CPU cluster. It consists of a free-runningvoltage controlled
oscillator connected to the CPU voltage rail (VDD_CPU), and a
closed loop
control module that will automatically adjust theVDD_CPU
voltage by
communicating with an off-chip PMIC either via an I2C bus or via
PWM signals.Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +0
-1-Currently only the I2C mode is supported by these bindings. Required properties: - compatible : should be "nvidia,tegra124-dfll"@@ -45,10 +44,28 @@ Required properties for the control loopparameters:
Optional properties for the control loop parameters:
- nvidia,cg-scale: Boolean value, see the fieldDFLL_PARAMS_CG_SCALEin the TRM.
+Optional properties for mode selection:
+- nvidia,pwm-to-pmic: Use PWM to control regulator rather then I2C. +
Required properties for I2C mode:Quoted 8 lines
Quoted 6 lines
- nvidia,i2c-fs-rate: I2C transfer rate, if using full speed mode. -Example:
+Required properties for PWM mode:+- nvidia,pwm-period: period of PWM square wave in microseconds. +- nvidia,init-uv: Regulator voltage in micro volts when PWM controlis disabled.
Maybe consider 'pwm-inactive-voltage-microvolt'.
Ah, I think I need to refine the description here. It should be something like below.
- nvidia,pwm-init-microvolt : Regulator voltage in micro volts when
PWM
control is initializedThis is the initial voltage that when we just initialize the DFLL hardware for PWM output. And before we switch the CPU clock from PLLX to DFLL, we will enable DFLL hardware in closed loop mode which will aplly the DVFS table that was calculated from CVB table.
The original description maybe make you think that it's the working voltage when it's under open-loop mode. But it's not. Sorry.
Quoted 6 lines
Quoted 2 lines
When we working on open-loop mode which will switch to low voltage range which also follows the DVFS table. Not this one.
OK, but I am still not sure what this voltage is. I mean that I understand it is the initial voltage, but how exactly do we define this number? Where does it come from, how is this determined?
Quoted 6 lines
IIRC, this is the same output voltage that bootloader configured with proper PLLX rate. So before DFLL handling the CPU clock, that is the output voltage. We configure the same when DFLL HW is just initialized.
1 volt here is pretty safe when CPU clock switched from bootloader to kernel at 6.912MHz@pllx.
OK, now I understand. Seems a little fragile, but maybe there is no better alternative here.
Please describe what this voltage is in the binding doc, so if anyone happened to modify their bootloader to run at a different speed that it is stated that this voltage should be high enough to support initial boot frequency.
Quoted 26 lines
Quoted 13 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
+- nvidia,align-offset-uv: Regulator voltage in micro volts when PWM control is
+ enabled and PWM output is low.Quoted 6 lines
Quoted 1 line
Would this be considered the minimum pwm active voltage?
This would be used for minimum voltage for LUT table, which is the table that PMIC can output. The real minimum voltage in PWM mode still depends on the CVB table.
So maybe change this one to 'nvidia,pwm-offset-uv'.
Quoted 8 lines
So is this the min supported by the PMIC? Maybe the name should reflect that because the above name does not reflect this. Furthermore, if this is a min then maybe the name should use 'min' as opposed to 'offset'. for example, 'nvidia,pwm-pmic-min-microvolts'.
Does this need to be described in DT, can it not be queried from the PMIC?
Yes, either way needs to go with DT. The very initial patchset for DFLL-PWM support, which introduced a redundant pwm-dfll driver. And with the driver, we can describe the PWM vdd-cpu regulator in DT with the voltage table that the PMIC can output. But NAKed by reviewer.
Quoted 8 lines
Quoted 3 lines
Okay, 'nvidia,pwm-pmic-min-microvolts' looks fine. Thanks.
Thierry, what are your thoughts here? I guess you had asked initially why we needed a phandle to the PMIC. Seems we need to comprehend the min voltage supported by the PMIC for creating the LUT.
Jon,
Notice that this is not a real "PWM" driver it just provides an interface that makes us can provide a PWM regulator node with voltage table. Then you can get LUT from that. But the PWM driver itself is a fake pwm driver as the DFLL-PWM is hardware driven not SW.
And as you saw in [1], the DFLL control code should remain in DFLL driver, not in the PWM driver. So basically, I still prefer the way we presented in this series.
Thanks,
Joseph
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 06/19] clk: tegra: dfll: CVB calculation alignment with the regulator
In reply to Jon HunterQuoted 69 lines · Jon Hunter
Quoted 67 lines · Joseph Lo
The CVB table contains calibration data for the CPU DFLL based on process charaterization. The regulator step and offset parameters depend on the regulator supplying vdd-cpu , not on the specific Tegra SKU.
When using a PWM controlled regulator, the voltage step and offset are determined by the regulator type in use. This is specified in DT. When using an I2C controlled regulator, we can retrieve them from CPU regulator or DT (if specified). Then pass this information to the CVB table calculation function.
Based on the work done of "Peter De Schrijver <[email protected]>" and "Alex Frid <[email protected]>".
Signed-off-by Joseph Lo <[email protected]>--- drivers/clk/tegra/clk-dfll.h | 6 +- drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 65 ++++++++++++++++++++-- drivers/clk/tegra/cvb.c | 12 ++-- drivers/clk/tegra/cvb.h | 6 +- 4 files changed, 75 insertions(+), 14 deletions(-)drivers/clk/tegra/clk-dfll.h +5
-1@@ -1,6 +1,6 @@/* * clk-dfll.h - prototypes and macros for the Tegra DFLL clocksource driver -* Copyright (C) 2013 NVIDIA Corporation. All rights reserved. +* Copyright (C) 2013-2018 NVIDIA Corporation. All rights reserved. * * Aleksandr Frid <[email protected]> * Paul Walmsley <[email protected]> @@ -22,11 +22,14 @@#include <linux/reset.h> #include <linux/types.h> +#include "cvb.h" +/** * struct tegra_dfll_soc_data - SoC-specific hooks/integration for the DFLL driver * @dev: struct device * that holds the OPP table for the DFLL * @max_freq: maximum frequency supported on this SoC * @cvb: CPU frequency table for this SoC +* @alignment: parameters of the regulator step and offset * @init_clock_trimmers: callback to initialize clock trimmers * @set_clock_trimmers_high: callback to tune clock trimmers for high voltage * @set_clock_trimmers_low: callback to tune clock trimmers for low voltage @@ -35,6 +38,7 @@ struct tegra_dfll_soc_data {struct device *dev;unsigned long max_freq;const struct cvb_table *cvb; +struct rail_alignment alignment;void (*init_clock_trimmers)(void );void (*set_clock_trimmers_high)(void );drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +1
-0@@ -23,6 +23,7 @@#include <linux/init.h> #include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/regulator/consumer.h> #include <soc/tegra/fuse.h>
Quoted 10 lines
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c static const struct cvb_table tegra124_cpu_cvb_tables[] = { · line 55
Quoted 8 lines
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +0
-3#include "clk.h" @@ -50,9 +51,6 @@ static const struct cvb_table tegra124_cpu_cvb_tables[] = { .process_id = -1, .min_millivolts = 900, .max_millivolts = 1260, - .alignment = { - .step_uv = 10000, /* 10mV */ - },What happens for tegra124-jetson-tk1 when we remove this?
Same as what we what to do with this patch. This data will be queried from regulator or DT. Because Jetson TK1 works on DFLL-I2C with the I2C-based regulator, it will be queried from the regulator.
Quoted 68 lines
Quoted 49 lines
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +32
-0.speedo_scale = 100, .voltage_scale = 1000, .entries = {@@ -105,11 +103,43 @@ static const struct of_device_id tegra124_dfll_fcpu_of_match[] = { { }, }; +static void get_alignment_from_dt (struct device *dev, +struct rail_alignment *align) +{ + align->step_uv =0 ; + align->offset_uv =0 ; + +if (of_property_read_u32 (dev->of_node,"nvidia,align-step-uv" , + &align->step_uv)) + align->step_uv =0 ; + +if (of_property_read_u32 (dev->of_node, +"nvidia,align-offset-uv" , &align->offset_uv)) + align->offset_uv =0 ; +} + +static int get_alignment_from_regulator (struct device *dev, +struct rail_alignment *align) +{ +struct regulator *reg =devm_regulator_get (dev,"vdd-cpu" ); + +if (IS_ERR (reg)) +return PTR_ERR (reg); + + align->offset_uv =regulator_list_voltage (reg,0 ); + align->step_uv =regulator_get_linear_step (reg); + +devm_regulator_put (reg); + +return 0 ; +} +static int tegra124_dfll_fcpu_probe (struct platform_device *pdev) {int process_id, speedo_id, speedo_value, err;struct tegra_dfll_soc_data *soc;const struct dfll_fcpu_data *fcpu_data; +struct rail_alignment align; fcpu_data =of_device_get_match_data (&pdev->dev);if (!fcpu_data)drivers/clk/tegra/clk-tegra124-dfll-fcpu.c static int tegra124_dfll_fcpu_probe(struct platform_device *pdev) · line 173
Quoted 9 lines
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +6
-0@@ -135,12 +165,37 @@ static int tegra124_dfll_fcpu_probe(struct platform_device *pdev)return -ENODEV ; } +get_alignment_from_dt (&pdev->dev, &align); +if (of_property_read_bool (pdev->dev.of_node,"nvidia,pwm-to-pmic" ) + && (!align.step_uv || !align.offset_uv)) { +dev_info (&pdev->dev,"Missing required align data in DT" ); +return -EINVAL ; + }else {This 'else' clause is not necessary.
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c static int tegra124_dfll_fcpu_probe(struct platform_device *pdev) · line 177
Quoted 4 lines
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +4
-0+if (!align.step_uv) { +dev_info (&pdev->dev, +"no align data in DT, try from vdd-cpu\n" ); + err =get_alignment_from_regulator (&pdev->dev, &align);
dev_warn
Quoted 6 lines
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c static int tegra124_dfll_fcpu_probe(struct platform_device *pdev) · line 180
Quoted 3 lines
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +3
-0+if (err == -EPROBE_DEFER ) { +dev_info (&pdev->dev, +"defer probe to get vdd-cpu\n" );This
dev_infois not necessary.
Will fix these comments above, thanks.
Re: [PATCH 07/19] clk: tegra: dfll: support PWM regulator control
In reply to Jon HunterQuoted 56 lines · Jon Hunter
Quoted 54 lines · Joseph Lo
The DFLL hardware supports two modes (I2C and PWM) for voltage control when requesting a frequency. In this patch, we introduce PWM mode support.
To support that, we re-organize the LUT for unifying the table for both cases of I2C and PWM mode. And generate that based on regulator info. For the PWM-based regulator, we get this info from DT. And do the same as the case of I2C LUT, which can help to map the PMIC voltage ID and voltages that the regulator supported.
The other parts are the support code for initializing the DFLL hardware to support PWM mode. Also, the register debugfs file is slightly reworked to only show the i2c registers when I2C mode is in use.
Based on the work of Peter De Schrijver <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>--- drivers/clk/tegra/clk-dfll.c | 431 ++++++++++++++++++++++++++++++----- 1 file changed, 368 insertions(+), 63 deletions(-)drivers/clk/tegra/clk-dfll.c +8
-1@@ -1,7 +1,7 @@/* * clk-dfll.c - Tegra DFLL clock source common code * -* Copyright (C) 2012-2014 NVIDIA Corporation. All rights reserved. +* Copyright (C) 2012-2018 NVIDIA Corporation. All rights reserved. * * Aleksandr Frid <[email protected]> * Paul Walmsley <[email protected]> @@ -47,6 +47,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/pinctrl/consumer.h> #include <linux/pm_opp.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> @@ -243,6 +244,12 @@ enum dfll_tune_range { DFLL_TUNE_LOW = 1, }; + +enum tegra_dfll_pmu_if { +TEGRA_DFLL_PMU_I2C =0 , +TEGRA_DFLL_PMU_PWM =1 , +}; +/** * struct dfll_rate_req - target DFLL rate request data * @rate: target frequency, after the postscaling
Quoted 8 lines
drivers/clk/tegra/clk-dfll.c struct tegra_dfll { · line 304
Quoted 5 lines
drivers/clk/tegra/clk-dfll.c +1
-0@@ -294,16 +301,25 @@ struct tegra_dfll {u32 ci;u32 cg;bool cg_scale; +u32 reg_init_uV;Doesn't this belong under PWM interface? Also being picky I dont' find
init_uVvery descriptive.
Yes, will move that to PWM interface section. Thanks.
Quoted 6 lines
Otherwise the change looks fine to me.
Cheers
Jon
Re: [PATCH 07/19] clk: tegra: dfll: support PWM regulator control
In reply to Jon HunterQuoted 101 lines · Jon Hunter
Quoted 99 lines · Joseph Lo
The DFLL hardware supports two modes (I2C and PWM) for voltage control when requesting a frequency. In this patch, we introduce PWM mode support.
To support that, we re-organize the LUT for unifying the table for both cases of I2C and PWM mode. And generate that based on regulator info. For the PWM-based regulator, we get this info from DT. And do the same as the case of I2C LUT, which can help to map the PMIC voltage ID and voltages that the regulator supported.
The other parts are the support code for initializing the DFLL hardware to support PWM mode. Also, the register debugfs file is slightly reworked to only show the i2c registers when I2C mode is in use.
Based on the work of Peter De Schrijver <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>--- drivers/clk/tegra/clk-dfll.c | 431 ++++++++++++++++++++++++++++++----- 1 file changed, 368 insertions(+), 63 deletions(-)drivers/clk/tegra/clk-dfll.c +32
-5@@ -1,7 +1,7 @@/* * clk-dfll.c - Tegra DFLL clock source common code * -* Copyright (C) 2012-2014 NVIDIA Corporation. All rights reserved. +* Copyright (C) 2012-2018 NVIDIA Corporation. All rights reserved. * * Aleksandr Frid <[email protected]> * Paul Walmsley <[email protected]> @@ -47,6 +47,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/pinctrl/consumer.h> #include <linux/pm_opp.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> @@ -243,6 +244,12 @@ enum dfll_tune_range { DFLL_TUNE_LOW = 1, }; + +enum tegra_dfll_pmu_if { +TEGRA_DFLL_PMU_I2C =0 , +TEGRA_DFLL_PMU_PWM =1 , +}; +/** * struct dfll_rate_req - target DFLL rate request data * @rate: target frequency, after the postscaling @@ -294,16 +301,25 @@ struct tegra_dfll {u32 ci;u32 cg;bool cg_scale; +u32 reg_init_uV;/* I2C interface parameters */ u32 i2c_fs_rate;u32 i2c_reg;u32 i2c_slave_addr; -/* i2c_lut array entries are regulator framework selectors */ -unsigned i2c_lut[MAX_DFLL_VOLTAGES ]; -int i2c_lut_size; -u8 lut_min, lut_max, lut_safe; +/* lut array entries are regulator framework selectors or PWM values*/ +unsigned lut[MAX_DFLL_VOLTAGES ]; +unsigned lut_uv[MAX_DFLL_VOLTAGES ]; +int lut_size; +u8 lut_bottom, lut_min, lut_max, lut_safe; + +/* PWM interface */ +enum tegra_dfll_pmu_if pmu_if; +unsigned long pwm_rate; +struct pinctrl *pwm_pin; +struct pinctrl_state *pwm_enable_state; +struct pinctrl_state *pwm_disable_state; };#define clk_hw_to_dfll (_hw) container_of(_hw, struct tegra_dfll, dfll_clk_hw)@@ -489,6 +505,34 @@ static void dfll_set_mode(struct tegra_dfll *td,dfll_wmb (td); } +/* +* DVCO rate control +*/ + +static unsigned long get_dvco_rate_below (struct tegra_dfll *td,u8 out_min) +{ +struct dev_pm_opp *opp; +unsigned long rate, prev_rate; +int uv, min_uv; + + min_uv = td->lut_uv[out_min];
Quoted 8 lines
drivers/clk/tegra/clk-dfll.c static void dfll_set_mode(struct tegra_dfll *td, · line 524
Quoted 6 lines
drivers/clk/tegra/clk-dfll.c +6
-0+for (rate =0 , prev_rate =0 ; ; rate++) { + opp =dev_pm_opp_find_freq_ceil (td->soc->dev, &rate); +if (IS_ERR (opp)) +break ; + + uv =dev_pm_opp_get_voltage (opp);Can you fix the type of 'uv' here? It should be unsigned long.
Okay, will fix it. Thanks.
Re: [PATCH 09/19] clk: tegra: dfll: add CVB tables for Tegra210
In reply to Jon HunterQuoted 20 lines · Jon Hunter
Quoted 18 lines · Joseph Lo
Add CVB tables with different chip characterization, so that we can generate the customize OPP table that suitable for different chips with different SKUs.
Signed-off-by Joseph Lo <[email protected]>--- drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 426 +++++++++++++++++++++ drivers/clk/tegra/cvb.h | 1 + 2 files changed, 427 insertions(+)drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +0
-0@@ -88,6 +88,421 @@ static const struct cvb_table tegra124_cpu_cvb_tables[] = { }, };
snip.
Quoted 12 lines
drivers/clk/tegra/cvb.h struct cvb_cpu_dfll_data { · line 44
Quoted 10 lines
drivers/clk/tegra/cvb.h +1
-0@@ -41,6 +41,7 @@ struct cvb_cpu_dfll_data {u32 tune0_low;u32 tune0_high;u32 tune1; +unsigned int tune_high_min_millivolts;Where is this actually used?
It's just part of the initial CVB table. We don't have the dynamic tunning support yet that will use this tune parameter for output freq tunning. It's on my plan of the next series for DFLL enhancement.
Should I remove that from the table?
Thanks,
Joseph
Re: [PATCH 11/19] cpufreq: tegra124: do not handle the CPU rail
In reply to Jon HunterQuoted 110 lines · Jon Hunter
Quoted 108 lines · Joseph Lo
The Tegra124 cpufreq driver has no information to handle the Vdd-CPU rail. So the driver shouldn't handle for the CPU clock switching from DFLL to other PLL clocks. It was designed to work on DFLL clock only, which handle the frequency/voltage scaling in the background. This patch removes the driver dependency of the CPU rail.
--- drivers/cpufreq/Kconfig.arm | 2 +- drivers/cpufreq/tegra124-cpufreq.c | 26 ++------------------------ 2 files changed, 3 insertions(+), 25 deletions(-)drivers/cpufreq/Kconfig.arm +1
-1@@ -262,7 +262,7 @@ config ARM_TEGRA20_CPUFREQ config ARM_TEGRA124_CPUFREQ tristate "Tegra124 CPUFreq support" - depends on ARCH_TEGRA && CPUFREQ_DT && REGULATOR + depends on ARCH_TEGRA && CPUFREQ_DT default y help This adds the CPUFreq driver support for Tegra124 SOCs.drivers/cpufreq/tegra124-cpufreq.c +2
-23@@ -22,11 +22,9 @@#include <linux/of.h> #include <linux/platform_device.h> #include <linux/pm_opp.h> -#include <linux/regulator/consumer.h> #include <linux/types.h> struct tegra124_cpufreq_priv { -struct regulator *vdd_cpu_reg;struct clk *cpu_clk;struct clk *pllp_clk;struct clk *pllx_clk;@@ -60,14 +58,6 @@ static int tegra124_cpu_switch_to_dfll(struct tegra124_cpufreq_priv *priv)return ret; } -static void tegra124_cpu_switch_to_pllx (struct tegra124_cpufreq_priv *priv) -{ -clk_set_parent (priv->cpu_clk, priv->pllp_clk); -clk_disable_unprepare (priv->dfll_clk); -regulator_sync_voltage (priv->vdd_cpu_reg); -clk_set_parent (priv->cpu_clk, priv->pllx_clk); -} -static int tegra124_cpufreq_probe (struct platform_device *pdev) {struct tegra124_cpufreq_priv *priv;@@ -88,16 +78,10 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)if (!np)return -ENODEV ; - priv->vdd_cpu_reg =regulator_get (cpu_dev,"vdd-cpu" ); -if (IS_ERR (priv->vdd_cpu_reg)) { - ret =PTR_ERR (priv->vdd_cpu_reg); - goto out_put_np; - } - priv->cpu_clk =of_clk_get_by_name (np,"cpu_g" );if (IS_ERR (priv->cpu_clk)) { ret =PTR_ERR (priv->cpu_clk); - goto out_put_vdd_cpu_reg; + goto out_put_np; } priv->dfll_clk =of_clk_get_by_name (np,"dfll" );@@ -129,15 +113,13 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)platform_device_register_full (&cpufreq_dt_devinfo);if (IS_ERR (priv->cpufreq_dt_pdev)) { ret =PTR_ERR (priv->cpufreq_dt_pdev); - goto out_switch_to_pllx; + goto out_put_pllp_clk; }platform_set_drvdata (pdev, priv);return 0 ; -out_switch_to_pllx: -tegra124_cpu_switch_to_pllx (priv); out_put_pllp_clk:clk_put (priv->pllp_clk); out_put_pllx_clk:@@ -146,8 +128,6 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)clk_put (priv->dfll_clk); out_put_cpu_clk:clk_put (priv->cpu_clk); -out_put_vdd_cpu_reg: -regulator_put (priv->vdd_cpu_reg); out_put_np:of_node_put (np);@@ -159,13 +139,11 @@ static int tegra124_cpufreq_remove(struct platform_device *pdev)struct tegra124_cpufreq_priv *priv =platform_get_drvdata (pdev);platform_device_unregister (priv->cpufreq_dt_pdev); -tegra124_cpu_switch_to_pllx (priv);
Quoted 14 lines
drivers/cpufreq/tegra124-cpufreq.c static int tegra124_cpufreq_remove(struct platform_device *pdev) · line 168
Quoted 5 lines
drivers/cpufreq/tegra124-cpufreq.c +0
-1clk_put (priv->pllp_clk);clk_put (priv->pllx_clk);clk_put (priv->dfll_clk);clk_put (priv->cpu_clk); -regulator_put (priv->vdd_cpu_reg);I see what you are saying and while this does appear to be broken, it also does not seem right that if we load and unload this driver the CPU clock parent will remain as the DFLL clock. Can't we query the voltage of the vdd-cpu regulator before we switch and then restore it before we switch back? >
I am just trying to understand if there is no way to switch back? If not then maybe we should not allow this driver to be built as a module and remove the removal function altogether.
No, we shouldn't switch back to PLL clock once we switched to DFLL clock. The reason is that the PLL clock applies to different voltage/freq table. That may not match the table, we are using for DFLL clock. The cclkg is designed to work on DFLL only.The safest way here is remaining the cclkg on DFLL closed-loop mode or switching to open-loop mode. Make it always work on DFLL closed-loop mode is better.
By default the configuration is built-in now. Sounds good to me to fix the configuration option and remove the removal function.
Thanks,
Joseph
Re: [PATCH 16/19] arm64: dts: tegra210-p2371-2180: enable DFLL clock
In reply to Jon HunterQuoted 26 lines · Jon Hunter
Quoted 24 lines · Joseph Lo
Enable DFLL clock for Jetson TX1 platform.
Signed-off-by Joseph Lo <[email protected]>--- .../boot/dts/nvidia/tegra210-p2371-2180.dts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+)arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts +9
-0@@ -78,4 +78,24 @@ }; }; }; + + clock@70110000 { + status = "okay"; + nvidia,pwm-to-pmic; + nvidia,init-uv = <1000000>; + nvidia,align-offset-uv = <708000>; + nvidia,align-step-uv = <19200>; + nvidia,sample-rate = <25000>; + nvidia,droop-ctrl = <0x00000f00>;
Quoted 8 lines
arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts line 95
Quoted 6 lines
arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts +6
-0+ nvidia,force-mode = <1>; + nvidia,cf = <6>; + nvidia,ci = <0>; + nvidia,cg = <2>; + nvidia,idle-override; + nvidia,one-shot-calibrate;I don't see any Documentation for or usage of the above two properties.
Oops. Good catch. Will remove that.
Thanks.
Re: [PATCH 01/19] dt-bindings: clock: tegra124-dfll: Update DFLL binding for PWM regulator
In reply to Jon HunterQuoted 37 lines · Jon Hunter
Quoted 35 lines · Joseph Lo
From: Peter De Schrijver <[email protected]>
Add new properties to configure the DFLL PWM regulator support. Also add an example and make the I2C clock only required when I2C support is used.
Signed-off-by Peter De Schrijver <[email protected]>Signed-off-by Joseph Lo <[email protected]>--- .../bindings/clock/nvidia,tegra124-dfll.txt | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +3
-1@@ -8,7 +8,6 @@ the fast CPU cluster. It consists of a free-running voltage controlled oscillator connected to the CPU voltage rail (VDD_CPU), and a closed loop control module that will automatically adjust the VDD_CPU voltage by communicating with an off-chip PMIC either via an I2C bus or via PWM signals. -Currently only the I2C mode is supported by these bindings. Required properties: - compatible : should be "nvidia,tegra124-dfll"@@ -45,10 +44,28 @@ Required properties for the control loop parameters: Optional properties for the control loop parameters: - nvidia,cg-scale: Boolean value, see the field DFLL_PARAMS_CG_SCALE in the TRM. +Optional properties for mode selection: +- nvidia,pwm-to-pmic: Use PWM to control regulator rather then I2C. + Required properties for I2C mode: - nvidia,i2c-fs-rate: I2C transfer rate, if using full speed mode.
Quoted 7 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt Required properties for the control loop parameters: · line 55
Quoted 4 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +3
-1-Example: +Required properties for PWM mode: +- nvidia,pwm-period: period of PWM square wave in microseconds. +- nvidia,init-uv: Regulator voltage in micro volts when PWM control is disabled.Maybe consider 'pwm-inactive-voltage-microvolt'.
Inactive is not very accurate. The OVR regulator will output nvidia,align-offset-uv when the PWM input is driven low but will output nvidia,init-uv when the PWM input is in tristate mode.
Quoted 27 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt Required properties for the control loop parameters: · line 57
Quoted 2 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +2
-0+- nvidia,align-offset-uv: Regulator voltage in micro volts when PWM control is + enabled and PWM output is low.Would this be considered the minimum pwm active voltage?
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt Required properties for the control loop parameters: · line 60
Quoted 3 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +3
-0+- nvidia,align-step-uv: Voltage increase in micro volts corresponding to a + 1/33th increase in duty cycle. Eg the voltage for 2/33th + duty cycle would be:Maybe consider 'pwm-voltage-step-microvolt'.
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt Required properties for the control loop parameters: · line 66
Quoted 6 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +6
-0+ nvidia,align-offset-uv + nvidia,align-step-uv * 2. +- pinctrl-0: I/O pad configuration when PWM control is enabled. +- pinctrl-1: I/O pad configuration when PWM control is disabled. +- pinctrl-names: must include the following entries: + - dvfs_pwm_enable: I/O pad configuration when PWM control is enabled. + - dvfs_pwm_disable: I/O pad configuration when PWM control is disabled.Please see Rob's feedback on the above [0].
Cheers
Jon[0] https://lore.kernel.org/patchwork/patch/885328/
Signature · 1 line
nvpublic
Re: [PATCH 01/19] dt-bindings: clock: tegra124-dfll: Update DFLL binding for PWM regulator
In reply to Jon HunterQuoted 67 lines · Jon Hunter
Quoted 65 lines · Joseph Lo
Hi Jon,
Thanks for reviewing this series.
Quoted 39 lines · Jon Hunter
Quoted 37 lines · Joseph Lo
From: Peter De Schrijver <[email protected]>
Add new properties to configure the DFLL PWM regulator support. Also add an example and make the I2C clock only required when I2C support is used.
Signed-off-by Peter De Schrijver <[email protected]>Signed-off-by Joseph Lo <[email protected]>---
.../bindings/clock/nvidia,tegra124-dfll.txt | 73 ++++++++++++++++++-1 file changed, 71 insertions(+), 2 deletions(-)diff --git
a/Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txtb/Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txtindexdff236f524a7..8c97600d2bad100644Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +0
-0@@ -8,7 +8,6 @@ the fast CPU cluster. It consists of a free-runningvoltage controlled
oscillator connected to the CPU voltage rail (VDD_CPU), and a closed loop
control module that will automatically adjust theVDD_CPUvoltage by communicating with an off-chip PMIC either via an I2C bus or via PWM signals.
-Currently only the I2C mode is supported by these bindings. Required properties:
- compatible : should be "nvidia,tegra124-dfll"Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +0
-0@@ -45,10 +44,28 @@ Required properties for the control loop parameters:Optional properties for the control loop parameters:
- nvidia,cg-scale: Boolean value, see the fieldDFLL_PARAMS_CG_SCALEin the TRM.
+Optional properties for mode selection:
+- nvidia,pwm-to-pmic: Use PWM to control regulator rather then I2C. +
Required properties for I2C mode:Quoted 8 lines
Quoted 6 lines
- nvidia,i2c-fs-rate: I2C transfer rate, if using full speed mode. -Example:
+Required properties for PWM mode:+- nvidia,pwm-period: period of PWM square wave in microseconds. +- nvidia,init-uv: Regulator voltage in micro volts when PWM controlis disabled.
Maybe consider 'pwm-inactive-voltage-microvolt'.
Ah, I think I need to refine the description here. It should be something like below.
- nvidia,pwm-init-microvolt : Regulator voltage in micro volts when PWM control is initializedThis is the initial voltage that when we just initialize the DFLL hardware for PWM output. And before we switch the CPU clock from PLLX to DFLL, we will enable DFLL hardware in closed loop mode which will aplly the DVFS table that was calculated from CVB table.
The original description maybe make you think that it's the working voltage when it's under open-loop mode. But it's not. Sorry.
Quoted 7 lines
Quoted 2 lines
When we working on open-loop mode which will switch to low voltage range which also follows the DVFS table. Not this one.
OK, but I am still not sure what this voltage is. I mean that I understand it is the initial voltage, but how exactly do we define this number? Where does it come from, how is this determined?
It is set by a resistive divider on the board iirc.
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
+- nvidia,align-offset-uv: Regulator voltage in micro volts when PWM control is
+ enabled and PWM output is low.Would this be considered the minimum pwm active voltage?
This would be used for minimum voltage for LUT table, which is the table that PMIC can output. The real minimum voltage in PWM mode still depends on the CVB table.
Quoted 9 lines
Quoted 1 line
So maybe change this one to 'nvidia,pwm-offset-uv'.
So is this the min supported by the PMIC? Maybe the name should reflect that because the above name does not reflect this. Furthermore, if this is a min then maybe the name should use 'min' as opposed to 'offset'. for example, 'nvidia,pwm-pmic-min-microvolts'.
Does this need to be described in DT, can it not be queried from the PMIC?
There is no interface to query anything from the OVR regulator.
Peter.
Re: [PATCH 01/19] dt-bindings: clock: tegra124-dfll: Update DFLL binding for PWM regulator
Quoted 71 lines · Peter De Schrijver
Quoted 70 lines · Jon Hunter
Quoted 67 lines · Joseph Lo
Hi Jon,
Thanks for reviewing this series.
Quoted 39 lines · Jon Hunter
Quoted 37 lines · Joseph Lo
From: Peter De Schrijver <[email protected]>
Add new properties to configure the DFLL PWM regulator support. Also add an example and make the I2C clock only required when I2C support is used.
Signed-off-by Peter De Schrijver <[email protected]>Signed-off-by Joseph Lo <[email protected]>--- .../bindings/clock/nvidia,tegra124-dfll.txt | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-)diff --git
a/Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txtb/Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txtindexdff236f524a7..8c97600d2bad100644Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +0
-0@@ -8,7 +8,6 @@ the fast CPU cluster. It consists of a free-runningvoltage controlled
oscillator connected to the CPU voltage rail (VDD_CPU), and a
closed loop
control module that will automatically adjust theVDD_CPUvoltage by communicating with an off-chip PMIC either via an I2C bus or via
PWM signals.Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +0
-1-Currently only the I2C mode is supported by these bindings. Required properties: - compatible : should be "nvidia,tegra124-dfll"@@ -45,10 +44,28 @@ Required properties for the control loop parameters: Optional properties for the control loop parameters: - nvidia,cg-scale: Boolean value, see the field
DFLL_PARAMS_CG_SCALEin the TRM.
+Optional properties for mode selection:
+- nvidia,pwm-to-pmic: Use PWM to control regulator rather then I2C. +
Required properties for I2C mode:Quoted 8 lines
Quoted 6 lines
- nvidia,i2c-fs-rate: I2C transfer rate, if using full speed mode. -Example:
+Required properties for PWM mode:+- nvidia,pwm-period: period of PWM square wave in microseconds. +- nvidia,init-uv: Regulator voltage in micro volts when PWM controlis disabled.
Maybe consider 'pwm-inactive-voltage-microvolt'.
Ah, I think I need to refine the description here. It should be something like below.
- nvidia,pwm-init-microvolt : Regulator voltage in micro volts when PWM
control is initializedThis is the initial voltage that when we just initialize the DFLL hardware for PWM output. And before we switch the CPU clock from PLLX to DFLL, we will enable DFLL hardware in closed loop mode which will aplly the DVFS table that was calculated from CVB table.
The original description maybe make you think that it's the working voltage when it's under open-loop mode. But it's not. Sorry.
When we working on open-loop mode which will switch to low voltage range which also follows the DVFS table. Not this one.
Quoted 6 lines
Quoted 4 lines
OK, but I am still not sure what this voltage is. I mean that I understand it is the initial voltage, but how exactly do we define this number? Where does it come from, how is this determined?
It is set by a resistive divider on the board iirc.
Yes, correct. The previous reply I did was the case of I2C regulator. Sorry, I made the confusion here.
Quoted 18 lines
Quoted 18 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
+- nvidia,align-offset-uv: Regulator voltage in micro volts when PWM control is
+ enabled and PWM output is low.Quoted 6 lines
Quoted 1 line
Would this be considered the minimum pwm active voltage?
This would be used for minimum voltage for LUT table, which is the table that PMIC can output. The real minimum voltage in PWM mode still depends on the CVB table.
So maybe change this one to 'nvidia,pwm-offset-uv'.
So is this the min supported by the PMIC? Maybe the name should reflect that because the above name does not reflect this. Furthermore, if this is a min then maybe the name should use 'min' as opposed to 'offset'. for example, 'nvidia,pwm-pmic-min-microvolts'.
Quoted 7 lines
Quoted 2 lines
Does this need to be described in DT, can it not be queried from the PMIC?
There is no interface to query anything from the OVR regulator.
Peter.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Jon Hunter
maintainerRe: [PATCH 01/19] dt-bindings: clock: tegra124-dfll: Update DFLL binding for PWM regulator
In reply to Peter De SchrijverQuoted 46 lines · Peter De Schrijver
Quoted 37 lines · Jon Hunter
Quoted 35 lines · Joseph Lo
From: Peter De Schrijver <[email protected]>
Add new properties to configure the DFLL PWM regulator support. Also add an example and make the I2C clock only required when I2C support is used.
Signed-off-by Peter De Schrijver <[email protected]>Signed-off-by Joseph Lo <[email protected]>--- .../bindings/clock/nvidia,tegra124-dfll.txt | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +3
-1@@ -8,7 +8,6 @@ the fast CPU cluster. It consists of a free-running voltage controlled oscillator connected to the CPU voltage rail (VDD_CPU), and a closed loop control module that will automatically adjust the VDD_CPU voltage by communicating with an off-chip PMIC either via an I2C bus or via PWM signals. -Currently only the I2C mode is supported by these bindings. Required properties: - compatible : should be "nvidia,tegra124-dfll"@@ -45,10 +44,28 @@ Required properties for the control loop parameters: Optional properties for the control loop parameters: - nvidia,cg-scale: Boolean value, see the field DFLL_PARAMS_CG_SCALE in the TRM. +Optional properties for mode selection: +- nvidia,pwm-to-pmic: Use PWM to control regulator rather then I2C. + Required properties for I2C mode: - nvidia,i2c-fs-rate: I2C transfer rate, if using full speed mode.Quoted 7 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt Required properties for the control loop parameters: · line 55
Quoted 4 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +3
-1-Example: +Required properties for PWM mode: +- nvidia,pwm-period: period of PWM square wave in microseconds. +- nvidia,init-uv: Regulator voltage in micro volts when PWM control is disabled.Maybe consider 'pwm-inactive-voltage-microvolt'.
Quoted 3 lines
Inactive is not very accurate. The OVR regulator will output nvidia,align-offset-uv when the PWM input is driven low but will output nvidia,init-uv when the PWM input is in tristate mode.
Maybe but I really don't find 'nvidia,align-offset-uv' and 'nvidia,init-uv' very descriptive either. We need to make sure that the names and description make it clear what these are and where they come from to anyone reading that documentation that has never laid eyes on this before.
Sounds like the align-offset-uv is the minimum voltage when PWM is active/enabled and init-uv is the default voltage the regulator outputs when PWM control is disabled. Would the following be any better ...
- nvidia,pwm-tristate-microvolts: Regulator voltage in micro volts when PWM control is disabled and the PWM output is tristated. Note that this voltage is configured in hardware, typically via a resistor divider.
- nvidia,pwm-min-microvolts: Regulator voltage in micro volts when PWM control is enabled and PWM output is low. Hence, this is the minimum output voltage that the regulator supports when PWM control is enabled.
Jon
Signature · 1 line
nvpublic
Re: [PATCH 01/19] dt-bindings: clock: tegra124-dfll: Update DFLL binding for PWM regulator
Quoted 62 lines · Jon Hunter
Quoted 46 lines · Peter De Schrijver
Quoted 37 lines · Jon Hunter
Quoted 35 lines · Joseph Lo
From: Peter De Schrijver <[email protected]>
Add new properties to configure the DFLL PWM regulator support. Also add an example and make the I2C clock only required when I2C support is used.
Signed-off-by Peter De Schrijver <[email protected]>Signed-off-by Joseph Lo <[email protected]>--- .../bindings/clock/nvidia,tegra124-dfll.txt | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +3
-1@@ -8,7 +8,6 @@ the fast CPU cluster. It consists of a free-running voltage controlled oscillator connected to the CPU voltage rail (VDD_CPU), and a closed loop control module that will automatically adjust the VDD_CPU voltage by communicating with an off-chip PMIC either via an I2C bus or via PWM signals. -Currently only the I2C mode is supported by these bindings. Required properties: - compatible : should be "nvidia,tegra124-dfll"@@ -45,10 +44,28 @@ Required properties for the control loop parameters: Optional properties for the control loop parameters: - nvidia,cg-scale: Boolean value, see the field DFLL_PARAMS_CG_SCALE in the TRM. +Optional properties for mode selection: +- nvidia,pwm-to-pmic: Use PWM to control regulator rather then I2C. + Required properties for I2C mode: - nvidia,i2c-fs-rate: I2C transfer rate, if using full speed mode.Quoted 7 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt Required properties for the control loop parameters: · line 55
Quoted 4 lines
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt +3
-1-Example: +Required properties for PWM mode: +- nvidia,pwm-period: period of PWM square wave in microseconds. +- nvidia,init-uv: Regulator voltage in micro volts when PWM control is disabled.Maybe consider 'pwm-inactive-voltage-microvolt'.
Quoted 3 lines
Inactive is not very accurate. The OVR regulator will output nvidia,align-offset-uv when the PWM input is driven low but will output nvidia,init-uv when the PWM input is in tristate mode.
Maybe but I really don't find 'nvidia,align-offset-uv' and 'nvidia,init-uv' very descriptive either. We need to make sure that the names and description make it clear what these are and where they come from to anyone reading that documentation that has never laid eyes on this before.
Sounds like the align-offset-uv is the minimum voltage when PWM is active/enabled and init-uv is the default voltage the regulator outputs when PWM control is disabled. Would the following be any better ...
Quoted 8 lines
- nvidia,pwm-tristate-microvolts: Regulator voltage in micro volts when PWM control is disabled and the PWM output is tristated. Note that this voltage is configured in hardware, typically via a resistor divider.
- nvidia,pwm-min-microvolts: Regulator voltage in micro volts when PWM control is enabled and PWM output is low. Hence, this is the minimum output voltage that the regulator supports when PWM control is enabled.
Thanks, Jon and Peter.
That's more clear indeed. In the discussion, that also comes up with one more reason that we shouldn't handle vdd-cpu rail with regulator API in cpufreq driver that showed in other patches in this patchset. With PWM-based vdd-cpu regulator, we are not able to control the output in software.