Tegra124 CL-DVFS / DFLL clocksource + cpufreq
Subsystems (8)
v8 cover Tegra124 CL-DVFS / DFLL clocksource + cpufreq
Hi, this is v8 of the Tegra124 cpufreq series. Aside rebasing on latest -next, the following changes have been done:
clk: tegra: Add binding for the Tegra124 DFLL clocksource
- Changed dfll@ -> clock@
- Changed compatibility string to "nvidia,tegra124-dfll"
- Clarified how the vdd-cpu-supply property is used
- Marked nvidia,cg-scale as optional since it is a boolean property
- Expanded the 'FS mode' term to 'full speed mode'
- Added dvco reset control
ARM: tegra: Add the DFLL to Tegra124 device tree
- Changed dfll@ -> clock@
- Added dvco reset control
ARM: tegra: Enable the DFLL on the Jetson TK1
- Changed dfll@ -> clock@
clk: tegra: Initialize PLL_X before CCLK_G to ensure it has a parent
- Added
clk: tegra: Introduce ability for SoC-specific reset control callbacks
- Added
clk: tegra: Add DFLL DVCO reset control for Tegra124
- Changed to use SoC-specific reset control callback
clk: tegra: Add Tegra124 DFLL clocksource platform driver
- Don't set DVCO reset handlers
clk: tegra: Add library for the DFLL clock source (open-loop mode)
- Use reset control instead of function pointers
also added acks from v7.
The series is available in a git repository at
git://github.com/cyndis/linux.git cldvfs-v8
Tested by me on Jetson-TK1 (rev. D).
Original cover letter:
This series implements the DFLL/CL-DVFS clock source for the fast CPU cluster on Tegra124, and a cpufreq driver that uses the DFLL for clocking the CPU. Most of this is based on Paul Walmsley's public patch set from December 2013, which is available at
http://comments.gmane.org/gmane.linux.ports.tegra/15273
The DFLL clock hardware is a voltage-controlled oscillator plus control logic that compares the generated output clock with a 51 MHz reference clock, and can make decisions to either lower or raise the DFLL voltage to keep the output rate close to the software-requested rate. The voltage changes are done by communicating with an off-chip PMIC via either I2C or PWM. As the DFLL oscillator is powered via the CPU rail, using the DFLL as the CPU clocksource also gives us dynamic CPU voltage scaling.
This series has been tested on the Jetson TK1 (Rev C). Porting this to the Venice2 should be simple, though do note that it does not have active cooling.
Thanks,
Tuomas
Mikko Perttunen (3):
clk: tegra: Introduce ability for SoC-specific reset control callbacks
clk: tegra: Initialize PLL_X before CCLK_G to ensure it has a parent
ARM: tegra: Add CPU regulator to the Jetson TK1 device tree
Paul Walmsley (1):
clk: tegra: Add DFLL DVCO reset control for Tegra124
Tuomas Tynkkynen (14):
clk: tegra: Add binding for the Tegra124 DFLL clocksource
clk: tegra: Add library for the DFLL clock source (open-loop mode)
clk: tegra: Add closed loop support for the DFLL
clk: tegra: Add functions for parsing CVB tables
clk: tegra: Add Tegra124 DFLL clocksource platform driver
clk: tegra: Save/restore CCLKG_BURST_POLICY on suspend
clk: tegra: Add the DFLL as a possible parent of the cclk_g clock
ARM: tegra: Add the DFLL to Tegra124 device tree
ARM: tegra: Enable the DFLL on the Jetson TK1
cpufreq: tegra124: Add device tree bindings
cpufreq: tegra: Rename tegra-cpufreq to tegra20-cpufreq
cpufreq: Add cpufreq driver for Tegra124
ARM: tegra: Add entries for cpufreq on Tegra124
ARM: tegra: enable Tegra124 cpufreq driver by default
.../bindings/clock/nvidia,tegra124-dfll.txt | 79 +
.../bindings/cpufreq/tegra124-cpufreq.txt | 44 +
arch/arm/boot/dts/tegra124-jetson-tk1.dts | 15 +-
arch/arm/boot/dts/tegra124.dtsi | 34 +
arch/arm/configs/tegra_defconfig | 1 +
arch/arm/mach-tegra/Kconfig | 1 +
drivers/clk/tegra/Makefile | 3 +
drivers/clk/tegra/clk-dfll.c | 1755 ++++++++++++++++++++
drivers/clk/tegra/clk-dfll.h | 54 +
drivers/clk/tegra/clk-tegra-super-gen4.c | 50 +-
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 163 ++
drivers/clk/tegra/clk-tegra124.c | 82 +
drivers/clk/tegra/clk.c | 36 +-
drivers/clk/tegra/clk.h | 3 +
drivers/clk/tegra/cvb.c | 133 ++
drivers/clk/tegra/cvb.h | 67 +
drivers/cpufreq/Kconfig.arm | 13 +-
drivers/cpufreq/Makefile | 3 +-
drivers/cpufreq/tegra124-cpufreq.c | 217 +++
.../cpufreq/{tegra-cpufreq.c => tegra20-cpufreq.c} | 0
include/dt-bindings/reset/tegra124-car.h | 11 +
21 files changed, 2730 insertions(+), 34 deletions(-)
create mode 100644 Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt
create mode 100644 Documentation/devicetree/bindings/cpufreq/tegra124-cpufreq.txt
create mode 100644 drivers/clk/tegra/clk-dfll.c
create mode 100644 drivers/clk/tegra/clk-dfll.h
create mode 100644 drivers/clk/tegra/clk-tegra124-dfll-fcpu.c
create mode 100644 drivers/clk/tegra/cvb.c
create mode 100644 drivers/clk/tegra/cvb.h
create mode 100644 drivers/cpufreq/tegra124-cpufreq.c
rename drivers/cpufreq/{tegra-cpufreq.c => tegra20-cpufreq.c} (100%)
create mode 100644 include/dt-bindings/reset/tegra124-car.h--
2.3.0
PATCH v8 1/18 clk: tegra: Add binding for the Tegra124 DFLL clocksource
From: Tuomas Tynkkynen <[email protected]>
The DFLL is the main clocksource for the fast CPU cluster on Tegra124 and also provides automatic CPU rail voltage scaling as well. The DFLL is a separate IP block from the usual Tegra124 clock-and-reset controller, so it gets its own node in the device tree.
---
v8:
- Changed dfll@ -> clock@
- Changed compatibility string to "nvidia,tegra124-dfll"
- Clarified how the vdd-cpu-supply property is used
- Marked nvidia,cg-scale as optional since it is a boolean property
- Expanded the 'FS mode' term to 'full speed mode'
- Added dvco reset control
.../bindings/clock/nvidia,tegra124-dfll.txt | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt new file +79 -0
@@ -0,0 +1,79 @@ +NVIDIA Tegra124 DFLL FCPU clocksource + +This binding uses the common clock binding: +Documentation/devicetree/bindings/clock/clock-bindings.txt + +The DFLL IP block on Tegra is a root clocksource designed for clocking +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" +- reg : Defines the following set of registers, in the order listed: + - registers for the DFLL control logic. + - registers for the I2C output logic. + - registers for the integrated I2C master controller. + - look-up table RAM for voltage register values. +- interrupts: Should contain the DFLL block interrupt. +- clocks: Must contain an entry for each entry in clock-names. + See clock-bindings.txt for details. +- clock-names: Must include the following entries: + - soc: Clock source for the DFLL control logic. + - ref: The closed loop reference clock + - i2c: Clock source for the integrated I2C master. +- resets: Must contain an entry for each entry in reset-names. + See ../reset/reset.txt for details. +- reset-names: Must include the following entries: + - dvco: Reset control for the DFLL DVCO. +- #clock-cells: Must be 0. +- clock-output-names: Name of the clock output. +- vdd-cpu-supply: Regulator for the CPU voltage rail that the DFLL + hardware will start controlling. The regulator will be queried for + the I2C register, control values and supported voltages. + +Required properties for the control loop parameters: +- nvidia,sample-rate: Sample rate of the DFLL control loop. +- nvidia,droop-ctrl: See the register CL_DVFS_DROOP_CTRL in the TRM. +- nvidia,force-mode: See the field DFLL_PARAMS_FORCE_MODE in the TRM. +- nvidia,cf: Numeric value, see the field DFLL_PARAMS_CF_PARAM in the TRM. +- nvidia,ci: Numeric value, see the field DFLL_PARAMS_CI_PARAM in the TRM. +- nvidia,cg: Numeric value, see the field DFLL_PARAMS_CG_PARAM in the TRM. + +Optional properties for the control loop parameters: +- nvidia,cg-scale: Boolean value, see the field DFLL_PARAMS_CG_SCALE in the TRM. + +Required properties for I2C mode: +- nvidia,i2c-fs-rate: I2C transfer rate, if using full speed mode. + +Example: + +clock at 0,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 TEGRA124_CLK_DFLL_SOC>, + <&tegra_car TEGRA124_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"; + vdd-cpu-supply = <&vdd_cpu>; + status = "okay"; + + nvidia,sample-rate = <12500>; + nvidia,droop-ctrl = <0x00000f00>; + nvidia,force-mode = <1>; + nvidia,cf = <10>; + nvidia,ci = <0>; + nvidia,cg = <2>; + + nvidia,i2c-fs-rate = <400000>; +};
Signature · 1 line
2.3.0
PATCH v8 2/18 clk: tegra: Add library for the DFLL clock source (open-loop mode)
In reply to Mikko PerttunenFrom: Tuomas Tynkkynen <[email protected]>
Add shared code to support the Tegra DFLL clocksource in open-loop mode. This root clocksource is present on the Tegra124 SoCs. The DFLL is the intended primary clock source for the fast CPU cluster.
This code is very closely based on a patch by Paul Walmsley from December (http://comments.gmane.org/gmane.linux.ports.tegra/15273),
which in turn comes from the internal driver by originally created by Aleksandr Frid <[email protected]>.
Subsequent patches will add support for closed loop mode and drivers for the Tegra124 fast CPU cluster DFLL devices, which rely on this code.
---
v8:
- Use DVCO reset control instead of non-standard handlers
drivers/clk/tegra/Makefile | 1 + drivers/clk/tegra/clk-dfll.c | 1095 ++++++++++++++++++++++++++++++++++++++++++ drivers/clk/tegra/clk-dfll.h | 54 +++ 3 files changed, 1150 insertions(+) create mode 100644 drivers/clk/tegra/clk-dfll.c create mode 100644 drivers/clk/tegra/clk-dfll.h
drivers/clk/tegra/Makefile +1 -0
@@ -1,5 +1,6 @@ obj-y += clk.o obj-y += clk-audio-sync.o +obj-y += clk-dfll.o obj-y += clk-divider.o obj-y += clk-periph.o obj-y += clk-periph-gate.o
drivers/clk/tegra/clk-dfll.c new file +1095 -0
1,095 lines not on this page · raw message
drivers/clk/tegra/clk-dfll.h new file +54 -0
54 lines not on this page · raw message
Signature · 1 line
2.3.0
PATCH v8 3/18 clk: tegra: Add closed loop support for the DFLL
In reply to Mikko PerttunenFrom: Tuomas Tynkkynen <[email protected]>
With closed loop support, the clock rate of the DFLL can be adjusted.
The oscillator itself in the DFLL is a free-running oscillator whose rate is directly determined the supply voltage. However, the DFLL module contains logic to compare the DFLL output rate to a fixed reference clock (51 MHz) and make a decision to either lower or raise the DFLL supply voltage. The DFLL module can then autonomously change the supply voltage by communicating with an off-chip PMIC via either I2C or PWM signals. This driver currently supports only I2C.
--- drivers/clk/tegra/clk-dfll.c | 666 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 663 insertions(+), 3 deletions(-)
drivers/clk/tegra/clk-dfll.c +663 -3
@@ -206,12 +206,16 @@*/ #define REF_CLOCK_RATE 51000000UL +#define DVCO_RATE_TO_MULT (rate, ref_rate) ((rate) / ((ref_rate) / 2)) +#define MULT_TO_DVCO_RATE (mult, ref_rate) ((mult) * ((ref_rate) / 2))/** * enum dfll_ctrl_mode - DFLL hardware operating mode * @DFLL_UNINITIALIZED: (uninitialized state - not in hardware bitfield) * @DFLL_DISABLED: DFLL not generating an output clock * @DFLL_OPEN_LOOP: DVCO running, but DFLL not adjusting voltage +* @DFLL_CLOSED_LOOP: DVCO running, and DFLL adjusting voltage to match +* the requested rate * * The integer corresponding to the last two states, minus one, is * written to the DFLL hardware to change operating modes.
@@ -220,6 +224,7 @@ enum dfll_ctrl_mode {DFLL_UNINITIALIZED =0 ,DFLL_DISABLED =1 ,DFLL_OPEN_LOOP =2 , + DFLL_CLOSED_LOOP = 3, };/**
@@ -237,6 +242,22 @@ enum dfll_tune_range { DFLL_TUNE_LOW = 1, }; +/** +* struct dfll_rate_req - target DFLL rate request data +* @rate: target frequency, after the postscaling +* @dvco_target_rate: target frequency, after the postscaling +* @lut_index: LUT index at which voltage the dvco_target_rate will be reached +* @mult_bits: value to program to the MULT bits of the DFLL_FREQ_REQ register +* @scale_bits: value to program to the SCALE bits of the DFLL_FREQ_REQ register +*/ +struct dfll_rate_req { +unsigned long rate; +unsigned long dvco_target_rate; +int lut_index; +u8 mult_bits; +u8 scale_bits; +}; +struct tegra_dfll {struct device *dev;struct tegra_dfll_soc_data *soc;
@@ -261,9 +282,27 @@ struct tegra_dfll {struct dentry *debugfs_dir;struct clk_hw dfll_clk_hw;const char *output_clock_name; +struct dfll_rate_req last_req; +unsigned long last_unrounded_rate;/* Parameters from DT */ u32 droop_ctrl; +u32 sample_rate; +u32 force_mode; +u32 cf; +u32 ci; +u32 cg; +bool cg_scale; + +/* 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; };#define clk_hw_to_dfll (_hw) container_of(_hw, struct tegra_dfll, dfll_clk_hw)
@@ -273,6 +312,7 @@ static const char * const mode_name[] = { [DFLL_UNINITIALIZED] = "uninitialized", [DFLL_DISABLED] = "disabled", [DFLL_OPEN_LOOP] = "open_loop", + [DFLL_CLOSED_LOOP] = "closed_loop", };/*
@@ -499,6 +539,283 @@ static void dfll_set_mode(struct tegra_dfll *td, }/* +* DFLL-to-I2C controller interface +*/ + +/** +* dfll_i2c_set_output_enabled - enable/disable I2C PMIC voltage requests +* @td: DFLL instance +* @enable: whether to enable or disable the I2C voltage requests +* +* Set the master enable control for I2C control value updates. If disabled, +* then I2C control messages are inhibited, regardless of the DFLL mode. +*/ +static int dfll_i2c_set_output_enabled (struct tegra_dfll *td,bool enable) +{ +u32 val; + + val =dfll_i2c_readl (td,DFLL_OUTPUT_CFG ); + +if (enable) + val |=DFLL_OUTPUT_CFG_I2C_ENABLE ; +else + val &= ~DFLL_OUTPUT_CFG_I2C_ENABLE ; + +dfll_i2c_writel (td, val,DFLL_OUTPUT_CFG ); +dfll_i2c_wmb (td); + +return 0 ; +} + +/** +* dfll_load_lut - load the voltage lookup table +* @td: struct tegra_dfll * +* +* Load the voltage-to-PMIC register value lookup table into the DFLL +* IP block memory. Look-up tables can be loaded at any time. +*/ +static void dfll_load_i2c_lut (struct tegra_dfll *td) +{ +int i, lut_index; +u32 val; + +for (i =0 ; i <MAX_DFLL_VOLTAGES ; i++) { +if (i < td->lut_min) + lut_index = td->lut_min; +else if (i > td->lut_max) + lut_index = td->lut_max; +else + lut_index = i; + + val =regulator_list_hardware_vsel (td->vdd_reg, + td->i2c_lut[lut_index]); +__raw_writel (val, td->lut_base + i *4 ); + } + +dfll_i2c_wmb (td); +} + +/** +* dfll_init_i2c_if - set up the DFLL's DFLL-I2C interface +* @td: DFLL instance +* +* During DFLL driver initialization, program the DFLL-I2C interface +* with the PMU slave address, vdd register offset, and transfer mode. +* This data is used by the DFLL to automatically construct I2C +* voltage-set commands, which are then passed to the DFLL's internal +* I2C controller. +*/ +static void dfll_init_i2c_if (struct tegra_dfll *td) +{ +u32 val; + +if (td->i2c_slave_addr >0x7f ) { + val = td->i2c_slave_addr <<DFLL_I2C_CFG_SLAVE_ADDR_SHIFT_10BIT ; + val |=DFLL_I2C_CFG_SLAVE_ADDR_10 ; + }else { + val = td->i2c_slave_addr <<DFLL_I2C_CFG_SLAVE_ADDR_SHIFT_7BIT ; + } + val |=DFLL_I2C_CFG_SIZE_MASK ; + val |=DFLL_I2C_CFG_ARB_ENABLE ; +dfll_i2c_writel (td, val,DFLL_I2C_CFG ); + +dfll_i2c_writel (td, td->i2c_reg,DFLL_I2C_VDD_REG_ADDR ); + + val =DIV_ROUND_UP (td->i2c_clk_rate, td->i2c_fs_rate *8 ); +BUG_ON (!val || (val >DFLL_I2C_CLK_DIVISOR_MASK )); + val = (val -1 ) <<DFLL_I2C_CLK_DIVISOR_FS_SHIFT ; + +/* default hs divisor just in case */ + val |=1 <<DFLL_I2C_CLK_DIVISOR_HS_SHIFT ; +__raw_writel (val, td->i2c_controller_base +DFLL_I2C_CLK_DIVISOR ); +dfll_i2c_wmb (td); +} + +/** +* dfll_init_out_if - prepare DFLL-to-PMIC interface +* @td: DFLL instance +* +* During DFLL driver initialization or resume from context loss, +* disable the I2C command output to the PMIC, set safe voltage and +* output limits, and disable and clear limit interrupts. +*/ +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 ; + +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); + +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); +} + +/* +* Set/get the DFLL's targeted output clock rate +*/ + +/** +* find_lut_index_for_rate - determine I2C LUT index for given DFLL rate +* @td: DFLL instance +* @rate: clock rate +* +* Determines the index of a I2C LUT entry for a voltage that approximately +* produces the given DFLL clock rate. This is used when forcing a value +* to the integrator during rate changes. Returns -ENOENT if a suitable +* LUT index is not found. +*/ +static int find_lut_index_for_rate (struct tegra_dfll *td,unsigned long rate) +{ +struct dev_pm_opp *opp; +int i, uv; + + opp =dev_pm_opp_find_freq_ceil (td->soc->opp_dev, &rate); +if (IS_ERR (opp)) +return PTR_ERR (opp); + uv =dev_pm_opp_get_voltage (opp); + +for (i =0 ; i < td->i2c_lut_size; i++) { +if (regulator_list_voltage (td->vdd_reg, td->i2c_lut[i]) == uv) +return i; + } + +return -ENOENT ; +} + +/** +* dfll_calculate_rate_request - calculate DFLL parameters for a given rate +* @td: DFLL instance +* @req: DFLL-rate-request structure +* @rate: the desired DFLL rate +* +* Populate the DFLL-rate-request record @req fields with the scale_bits +* and mult_bits fields, based on the target input rate. Returns 0 upon +* success, or -EINVAL if the requested rate in req->rate is too high +* or low for the DFLL to generate. +*/ +static int dfll_calculate_rate_request (struct tegra_dfll *td, +struct dfll_rate_req *req, +unsigned long rate) +{ +u32 val; + +/* +* If requested rate is below the minimum DVCO rate, active the scaler. +* In the future the DVCO minimum voltage should be selected based on +* chip temperature and the actual minimum rate should be calibrated +* at runtime. +*/ + req->scale_bits =DFLL_FREQ_REQ_SCALE_MAX -1 ; +if (rate < td->dvco_rate_min) { +int scale; + + scale =DIV_ROUND_CLOSEST (rate /1000 *DFLL_FREQ_REQ_SCALE_MAX , + td->dvco_rate_min /1000 ); +if (!scale) { +dev_err (td->dev,"%s: Rate %lu is too low\n" , + __func__, rate); +return -EINVAL ; + } + req->scale_bits = scale -1 ; + rate = td->dvco_rate_min; + } + +/* Convert requested rate into frequency request and scale settings */ + val =DVCO_RATE_TO_MULT (rate, td->ref_rate); +if (val >FREQ_MAX ) { +dev_err (td->dev,"%s: Rate %lu is above dfll range\n" , + __func__, rate); +return -EINVAL ; + } + req->mult_bits = val; + req->dvco_target_rate =MULT_TO_DVCO_RATE (req->mult_bits, td->ref_rate); + req->rate =dfll_scale_dvco_rate (req->scale_bits, + req->dvco_target_rate); + req->lut_index =find_lut_index_for_rate (td, req->dvco_target_rate); +if (req->lut_index <0 ) +return req->lut_index; + +return 0 ; +} + +/** +* dfll_set_frequency_request - start the frequency change operation +* @td: DFLL instance +* @req: rate request structure +* +* Tell the DFLL to try to change its output frequency to the +* frequency represented by @req. DFLL must be in closed-loop mode. +*/ +static void dfll_set_frequency_request (struct tegra_dfll *td, +struct dfll_rate_req *req) +{ +u32 val =0 ; +int force_val; +int coef =128 ;/* FIXME: td->cg_scale? */ ; + + force_val = (req->lut_index - td->lut_safe) * coef / td->cg; + force_val =clamp (force_val,FORCE_MIN ,FORCE_MAX ); + + val |= req->mult_bits <<DFLL_FREQ_REQ_MULT_SHIFT ; + val |= req->scale_bits <<DFLL_FREQ_REQ_SCALE_SHIFT ; + val |= ((u32 )force_val <<DFLL_FREQ_REQ_FORCE_SHIFT ) & +DFLL_FREQ_REQ_FORCE_MASK ; + val |=DFLL_FREQ_REQ_FREQ_VALID |DFLL_FREQ_REQ_FORCE_ENABLE ; + +dfll_writel (td, val,DFLL_FREQ_REQ ); +dfll_wmb (td); +} + +/** +* tegra_dfll_request_rate - set the next rate for the DFLL to tune to +* @td: DFLL instance +* @rate: clock rate to target +* +* Convert the requested clock rate @rate into the DFLL control logic +* settings. In closed-loop mode, update new settings immediately to +* adjust DFLL output rate accordingly. Otherwise, just save them +* until the next switch to closed loop. Returns 0 upon success, +* -EPERM if the DFLL driver has not yet been initialized, or -EINVAL +* if @rate is outside the DFLL's tunable range. +*/ +static int dfll_request_rate (struct tegra_dfll *td,unsigned long rate) +{ +int ret; +struct dfll_rate_req req; + +if (td->mode ==DFLL_UNINITIALIZED ) { +dev_err (td->dev,"%s: Cannot set DFLL rate in %s mode\n" , + __func__, mode_name[td->mode]); +return -EPERM ; + } + + ret =dfll_calculate_rate_request (td, &req, rate); +if (ret) +return ret; + + td->last_unrounded_rate = rate; + td->last_req = req; + +if (td->mode ==DFLL_CLOSED_LOOP ) +dfll_set_frequency_request (td, &td->last_req); + +return 0 ; +} + +/* * DFLL enable/disable & open-loop <-> closed-loop transitions */
@@ -570,8 +887,76 @@ static void dfll_set_open_loop_config(struct tegra_dfll *td)dfll_wmb (td); } +/** +* tegra_dfll_lock - switch from open-loop to closed-loop mode +* @td: DFLL instance +* +* Switch from OPEN_LOOP state to CLOSED_LOOP state. Returns 0 upon success, +* -EINVAL if the DFLL's target rate hasn't been set yet, or -EPERM if the +* DFLL is not currently in open-loop mode. +*/ +static int dfll_lock (struct tegra_dfll *td) +{ +struct dfll_rate_req *req = &td->last_req; + +switch (td->mode) { +case DFLL_CLOSED_LOOP : +return 0 ; + +case DFLL_OPEN_LOOP : +if (req->rate ==0 ) { +dev_err (td->dev,"%s: Cannot lock DFLL at rate 0\n" , + __func__); +return -EINVAL ; + } + +dfll_i2c_set_output_enabled (td, true); +dfll_set_mode (td,DFLL_CLOSED_LOOP ); +dfll_set_frequency_request (td, req); +return 0 ; + +default : +BUG_ON (td->mode >DFLL_CLOSED_LOOP ); +dev_err (td->dev,"%s: Cannot lock DFLL in %s mode\n" , + __func__, mode_name[td->mode]); +return -EPERM ; + } +} + +/** +* tegra_dfll_unlock - switch from closed-loop to open-loop mode +* @td: DFLL instance +* +* Switch from CLOSED_LOOP state to OPEN_LOOP state. Returns 0 upon success, +* or -EPERM if the DFLL is not currently in open-loop mode. +*/ +static int dfll_unlock (struct tegra_dfll *td) +{ +switch (td->mode) { +case DFLL_CLOSED_LOOP : +dfll_set_open_loop_config (td); +dfll_set_mode (td,DFLL_OPEN_LOOP ); +dfll_i2c_set_output_enabled (td, false); +return 0 ; + +case DFLL_OPEN_LOOP : +return 0 ; + +default : +BUG_ON (td->mode >DFLL_CLOSED_LOOP ); +dev_err (td->dev,"%s: Cannot unlock DFLL in %s mode\n" , + __func__, mode_name[td->mode]); +return -EPERM ; + } +} +/* * Clock framework integration +* +* When the DFLL is being controlled by the CCF, always enter closed loop +* mode when the clk is enabled. This requires that a DFLL rate request +* has been set beforehand, which implies that a clk_set_rate() call is +* always required before a clk_enable(). */ static int dfll_clk_is_enabled (struct clk_hw *hw)
@@ -584,21 +969,72 @@ static int dfll_clk_is_enabled(struct clk_hw *hw)static int dfll_clk_enable (struct clk_hw *hw) {struct tegra_dfll *td =clk_hw_to_dfll (hw); +int ret; + + ret =dfll_enable (td); +if (ret) +return ret; + + ret =dfll_lock (td); +if (ret) +dfll_disable (td); -return dfll_enable (td); +return ret; }static void dfll_clk_disable (struct clk_hw *hw) {struct tegra_dfll *td =clk_hw_to_dfll (hw); +int ret; + + ret =dfll_unlock (td); +if (!ret) +dfll_disable (td); +} + +static unsigned long dfll_clk_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +struct tegra_dfll *td =clk_hw_to_dfll (hw); -dfll_disable (td); +return td->last_unrounded_rate; +} + +static long dfll_clk_round_rate (struct clk_hw *hw, +unsigned long rate, +unsigned long *parent_rate) +{ +struct tegra_dfll *td =clk_hw_to_dfll (hw); +struct dfll_rate_req req; +int ret; + + ret =dfll_calculate_rate_request (td, &req, rate); +if (ret) +return ret; + +/* +* Don't return the rounded rate, since it doesn't really matter as +* the output rate will be voltage controlled anyway, and cpufreq +* freaks out if any rounding happens. +*/ +return rate; +} + +static int dfll_clk_set_rate (struct clk_hw *hw,unsigned long rate, +unsigned long parent_rate) +{ +struct tegra_dfll *td =clk_hw_to_dfll (hw); + +return dfll_request_rate (td, rate); }static const struct clk_ops dfll_clk_ops = { .is_enabled = dfll_clk_is_enabled, .enable = dfll_clk_enable, .disable = dfll_clk_disable, + .recalc_rate = dfll_clk_recalc_rate, + .round_rate = dfll_clk_round_rate, + .set_rate = dfll_clk_set_rate, };static struct clk_init_data dfll_clk_init_data = {
@@ -677,6 +1113,23 @@ static int attr_enable_set(void *data, u64 val)DEFINE_SIMPLE_ATTRIBUTE (enable_fops, attr_enable_get, attr_enable_set,"%llu\n" ); +static int attr_lock_get (void *data,u64 *val) +{ +struct tegra_dfll *td = data; + + *val = (td->mode ==DFLL_CLOSED_LOOP ); + +return 0 ; +} +static int attr_lock_set (void *data,u64 val) +{ +struct tegra_dfll *td = data; + +return val ?dfll_lock (td) :dfll_unlock (td); +} +DEFINE_SIMPLE_ATTRIBUTE (lock_fops, attr_lock_get, attr_lock_set, +"%llu\n" ); +static int attr_rate_get (void *data,u64 *val) {struct tegra_dfll *td = data;
@@ -685,7 +1138,14 @@ static int attr_rate_get(void *data, u64 *val)return 0 ; } -DEFINE_SIMPLE_ATTRIBUTE (rate_fops, attr_rate_get,NULL ,"%llu\n" ); + +static int attr_rate_set (void *data,u64 val) +{ +struct tegra_dfll *td = data; + +return dfll_request_rate (td, val); +} +DEFINE_SIMPLE_ATTRIBUTE (rate_fops, attr_rate_get, attr_rate_set,"%llu\n" );static int attr_registers_show (struct seq_file *s,void *data) {
@@ -751,6 +1211,10 @@ static int dfll_debug_init(struct tegra_dfll *td) td->debugfs_dir, td, &enable_fops)) goto err_out; +if (!debugfs_create_file ("lock" ,S_IRUGO , + td->debugfs_dir, td, &lock_fops)) + goto err_out; +if (!debugfs_create_file ("rate" ,S_IRUGO , td->debugfs_dir, td, &rate_fops)) goto err_out;
@@ -782,6 +1246,19 @@ err_out:*/ static void dfll_set_default_params (struct tegra_dfll *td) { +u32 val; + + val =DIV_ROUND_UP (td->ref_rate, td->sample_rate *32 ); +BUG_ON (val >DFLL_CONFIG_DIV_MASK ); +dfll_writel (td, val,DFLL_CONFIG ); + + val = (td->force_mode <<DFLL_PARAMS_FORCE_MODE_SHIFT ) | + (td->cf <<DFLL_PARAMS_CF_PARAM_SHIFT ) | + (td->ci <<DFLL_PARAMS_CI_PARAM_SHIFT ) | + (td->cg <<DFLL_PARAMS_CG_PARAM_SHIFT ) | + (td->cg_scale ?DFLL_PARAMS_CG_SCALE :0 ); +dfll_writel (td, val,DFLL_PARAMS ); +dfll_tune_low (td);dfll_writel (td, td->droop_ctrl,DFLL_DROOP_CTRL );dfll_writel (td,DFLL_MONITOR_CTRL_FREQ ,DFLL_MONITOR_CTRL );
@@ -859,6 +1336,8 @@ static int dfll_init(struct tegra_dfll *td) goto di_err2; } + td->last_unrounded_rate =0 ; +pm_runtime_enable (td->dev);pm_runtime_get_sync (td->dev);
@@ -870,6 +1349,8 @@ static int dfll_init(struct tegra_dfll *td)dfll_set_open_loop_config (td); +dfll_init_out_if (td); +pm_runtime_put_sync (td->dev);return 0 ;
@@ -888,6 +1369,130 @@ di_err1:* DT data fetch */ +/* +* Find a PMIC voltage register-to-voltage mapping for the given voltage. +* An exact voltage match is required. +*/ +static int find_vdd_map_entry_exact (struct tegra_dfll *td,int uV) +{ +int i, n_voltages, reg_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 ) +break ; + +if (uV == reg_uV) +return i; + } + +dev_err (td->dev,"no voltage map entry for %d uV\n" , uV); +return -EINVAL ; +} + +/* +* Find a PMIC voltage register-to-voltage mapping for the given voltage, +* rounding up to the closest supported voltage. +* */ +static int find_vdd_map_entry_min (struct tegra_dfll *td,int uV) +{ +int i, n_voltages, reg_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 ) +break ; + +if (uV <= reg_uV) +return i; + } + +dev_err (td->dev,"no voltage map entry rounding to %d uV\n" , uV); +return -EINVAL ; +} + +/** +* dfll_build_i2c_lut - build the I2C voltage register lookup table +* @td: DFLL instance +* +* 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. +* This function builds the look-up table based on the OPP table provided by +* 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. +*/ +static int dfll_build_i2c_lut (struct tegra_dfll *td) +{ +int ret = -EINVAL ; +int j, v, v_max, v_opp; +int selector; +unsigned long rate; +struct dev_pm_opp *opp; + +rcu_read_lock (); + + rate =ULONG_MAX ; + opp =dev_pm_opp_find_freq_floor (td->soc->opp_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); + + v = td->soc->min_millivolts *1000 ; + td->i2c_lut[0 ] =find_vdd_map_entry_exact (td, v); +if (td->i2c_lut[0 ] <0 ) + goto out; + +for (j =1 , rate =0 ; ; rate++) { + opp =dev_pm_opp_find_freq_ceil (td->soc->opp_dev, &rate); +if (IS_ERR (opp)) +break ; + v_opp =dev_pm_opp_get_voltage (opp); + +if (v_opp <= td->soc->min_millivolts *1000 ) + td->dvco_rate_min =dev_pm_opp_get_freq (opp); + +for (;;) { + v +=max (1 , (v_max - v) / (MAX_DFLL_VOLTAGES - j)); +if (v >= v_opp) +break ; + + 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; + } + + 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 (v >= v_max) +break ; + } + td->i2c_lut_size = j; + +if (!td->dvco_rate_min) +dev_err (td->dev,"no opp above DFLL minimum voltage %d mV\n" , + td->soc->min_millivolts); +else + ret =0 ; + +out: +rcu_read_unlock (); + +return ret; +} +/** * read_dt_param - helper function for reading required parameters from the DT * @td: DFLL instance
@@ -912,6 +1517,50 @@ static bool read_dt_param(struct tegra_dfll *td, const char *param, u32 *dest) }/** +* dfll_fetch_i2c_params - query PMIC I2C params from DT & regulator subsystem +* @td: DFLL instance +* +* Read all the parameters required for operation in I2C mode. The parameters +* can originate from the device tree or the regulator subsystem. +* Returns 0 on success or -err on failure. +*/ +static int dfll_fetch_i2c_params (struct tegra_dfll *td) +{ +struct regmap *regmap; +struct device *i2c_dev; +struct i2c_client *i2c_client; +int vsel_reg, vsel_mask; +int ret; + +if (!read_dt_param (td,"nvidia,i2c-fs-rate" , &td->i2c_fs_rate)) +return -EINVAL ; + + regmap =regulator_get_regmap (td->vdd_reg); + i2c_dev =regmap_get_device (regmap); + i2c_client =to_i2c_client (i2c_dev); + + td->i2c_slave_addr = i2c_client->addr; + + ret =regulator_get_hardware_vsel_register (td->vdd_reg, + &vsel_reg, + &vsel_mask); +if (ret <0 ) { +dev_err (td->dev, +"regulator unsuitable for DFLL I2C operation\n" ); +return -EINVAL ; + } + td->i2c_reg = vsel_reg; + + ret =dfll_build_i2c_lut (td); +if (ret) { +dev_err (td->dev,"couldn't build I2C LUT\n" ); +return ret; + } + +return 0 ; +} + +/** * dfll_fetch_common_params - read DFLL parameters from the device tree * @td: DFLL instance *
@@ -923,6 +1572,13 @@ static int dfll_fetch_common_params(struct tegra_dfll *td)bool ok = true; ok &=read_dt_param (td,"nvidia,droop-ctrl" , &td->droop_ctrl); + ok &=read_dt_param (td,"nvidia,sample-rate" , &td->sample_rate); + ok &=read_dt_param (td,"nvidia,force-mode" , &td->force_mode); + ok &=read_dt_param (td,"nvidia,cf" , &td->cf); + ok &=read_dt_param (td,"nvidia,ci" , &td->ci); + ok &=read_dt_param (td,"nvidia,cg" , &td->cg); + td->cg_scale =of_property_read_bool (td->dev->of_node, +"nvidia,cg-scale" );if (of_property_read_string (td->dev->of_node,"clock-output-names" , &td->output_clock_name)) {
@@ -984,6 +1640,10 @@ int tegra_dfll_register(struct platform_device *pdev,return ret; } + ret =dfll_fetch_i2c_params (td); +if (ret) +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.3.0
PATCH v8 4/18 clk: tegra: Add functions for parsing CVB tables
In reply to Mikko PerttunenFrom: Tuomas Tynkkynen <[email protected]>
Tegra CVB tables encode the relationship between operating voltage and optimal frequency as a function of the so-called speedo value. The speedo value is written to the on-chip fuses at the factory, which allows the voltage-frequency operating points to be calculated on an per-chip basis.
Add utility functions to parse the Tegra-specific tables and export the voltage-frequency pairs to the generic OPP framework for other drivers to use.
--- arch/arm/mach-tegra/Kconfig | 1 + drivers/clk/tegra/cvb.c | 133 ++++++++++++++++++++++++++++++++++++++++++++ drivers/clk/tegra/cvb.h | 67 ++++++++++++++++++++++ 3 files changed, 201 insertions(+) create mode 100644 drivers/clk/tegra/cvb.c create mode 100644 drivers/clk/tegra/cvb.h
arch/arm/mach-tegra/Kconfig +1 -0
@@ -8,6 +8,7 @@ menuconfig ARCH_TEGRA select HAVE_ARM_SCU if SMP select HAVE_ARM_TWD if SMP select PINCTRL + select PM_OPP select ARCH_HAS_RESET_CONTROLLER select RESET_CONTROLLER select SOC_BUS
drivers/clk/tegra/cvb.c new file +133 -0
133 lines not on this page · raw message
drivers/clk/tegra/cvb.h new file +67 -0
67 lines not on this page · raw message
Signature · 1 line
2.3.0
PATCH v8 5/18 clk: tegra: Introduce ability for SoC-specific reset control callbacks
In reply to Mikko PerttunenThis patch allows SoC-specific CAR initialization routines to register their own reset_assert and reset_deassert callbacks with the common Tegra CAR code. If defined, the common code will call these callbacks when a reset control with number >= 0x40000000 is attempted to be asserted or deasserted respectively. The callback should return -EINVAL if the number of the reset control is invalid. Numbers greater than or equal to 0x40000000 are used to avoid clashes with low numbers that are automatically mapped to standard CAR reset lines. Furthermore, numbers with the most significant bit set should not be used, as some functions interpret these as negative error codes.
Each SoC with these special resets should specify the defined reset control numbers in a device tree header file.
---
v8:
- Added
drivers/clk/tegra/clk.c | 36 ++++++++++++++++++++++++++++-------- drivers/clk/tegra/clk.h | 3 +++ 2 files changed, 31 insertions(+), 8 deletions(-)
drivers/clk/tegra/clk.c +28 -8
@@ -46,7 +46,6 @@#define RST_DEVICES_L 0x004#define RST_DEVICES_H 0x008#define RST_DEVICES_U 0x00C -#define RST_DFLL_DVCO 0x2F4#define RST_DEVICES_V 0x358#define RST_DEVICES_W 0x35C#define RST_DEVICES_X 0x28C
@@ -73,6 +72,10 @@ static struct clk **clks;static int clk_num;static struct clk_onecell_data clk_data; +/* Handlers for SoC-specific reset lines */ +static int (*reset_assert)(unsigned long ); +static int (*reset_deassert)(unsigned long ); +static struct tegra_clk_periph_regs periph_regs[] = { [0 ] = { .enb_reg =CLK_OUT_ENB_L ,
@@ -138,19 +141,29 @@ static int tegra_clk_rst_assert(struct reset_controller_dev *rcdev,*/ tegra_read_chipid (); -writel_relaxed (BIT (id %32 ), - clk_base + periph_regs[id /32 ].rst_set_reg); +if (id >=0x40000000 && reset_assert) { +return reset_assert (id); + }else if (id < clk_num *32 ) { +writel_relaxed (BIT (id %32 ), + clk_base + periph_regs[id /32 ].rst_set_reg); +return 0 ; + } -return 0 ; +return -EINVAL ; }static int tegra_clk_rst_deassert (struct reset_controller_dev *rcdev,unsigned long id) { -writel_relaxed (BIT (id %32 ), - clk_base + periph_regs[id /32 ].rst_clr_reg); +if (id >=0x40000000 && reset_deassert) { +return reset_deassert (id); + }else if (id < clk_num *32 ) { +writel_relaxed (BIT (id %32 ), + clk_base + periph_regs[id /32 ].rst_clr_reg); +return 0 ; + } -return 0 ; +return -EINVAL ; }struct tegra_clk_periph_regs *get_reg_bank (int clkid)
@@ -272,10 +285,17 @@ void __init tegra_add_of_provider(struct device_node *np)of_clk_add_provider (np, of_clk_src_onecell_get, &clk_data); rst_ctlr.of_node = np; - rst_ctlr.nr_resets = clk_num *32 ; + rst_ctlr.nr_resets =0x80000000 ;reset_controller_register (&rst_ctlr); } +void __init tegra_init_special_resets (int (*assert)(unsigned long ), +int (*deassert)(unsigned long )) +{ + reset_assert = assert; + reset_deassert = deassert; +} +void __init tegra_register_devclks (struct tegra_devclk *dev_clks,int num) {int i;
drivers/clk/tegra/clk.h +3 -0
@@ -591,6 +591,9 @@ struct tegra_devclk {char *con_id; }; +void tegra_init_special_resets (int (*assert)(unsigned long ), +int (*deassert)(unsigned long )); +void tegra_init_from_table (struct tegra_clk_init_table *tbl,struct clk *clks[],int clk_max);
Signature · 1 line
2.3.0
PATCH v8 6/18 clk: tegra: Add DFLL DVCO reset control for Tegra124
In reply to Mikko PerttunenFrom: Paul Walmsley <[email protected]>
The DVCO present in the DFLL IP block has a separate reset line, exposed via the CAR IP block. This reset line is asserted upon SoC reset. Unless something (such as the DFLL driver) deasserts this line, the DVCO will not oscillate, although reads and writes to the DFLL IP block will complete.
Thanks to Aleksandr Frid <[email protected]> for identifying this and saving hours of debugging time.
---
v8:
- Changed to use SoC-specific reset system
drivers/clk/tegra/clk-tegra124.c | 68 ++++++++++++++++++++++++++++++++ include/dt-bindings/reset/tegra124-car.h | 11 ++++++ 2 files changed, 79 insertions(+) create mode 100644 include/dt-bindings/reset/tegra124-car.h
drivers/clk/tegra/clk-tegra124.c +68 -0
@@ -24,6 +24,7 @@#include <linux/export.h> #include <linux/clk/tegra.h> #include <dt-bindings/clock/tegra124-car.h> +#include <dt-bindings/reset/tegra124-car.h> #include "clk.h" #include "clk-id.h"
@@ -39,6 +40,9 @@#define CLK_SOURCE_CSITE 0x1d4#define CLK_SOURCE_EMC 0x19c +#define RST_DFLL_DVCO 0x2f4 +#define DVFS_DFLL_RESET_SHIFT 0 +#define PLLC_BASE 0x80#define PLLC_OUT 0x84#define PLLC_MISC2 0x88
@@ -1421,6 +1425,68 @@ static void __init tegra124_clock_apply_init_table(void) }/** +* tegra124_car_barrier - wait for pending writes to the CAR to complete +* +* Wait for any outstanding writes to the CAR MMIO space from this CPU +* to complete before continuing execution. No return value. +*/ +static void tegra124_car_barrier (void ) +{ +readl_relaxed (clk_base +RST_DFLL_DVCO ); +} + +/** +* tegra124_clock_assert_dfll_dvco_reset - assert the DFLL's DVCO reset +* +* Assert the reset line of the DFLL's DVCO. No return value. +*/ +void tegra124_clock_assert_dfll_dvco_reset (void ) +{ +u32 v; + + v =readl_relaxed (clk_base +RST_DFLL_DVCO ); + v |= (1 <<DVFS_DFLL_RESET_SHIFT ); +writel_relaxed (v, clk_base +RST_DFLL_DVCO ); +tegra124_car_barrier (); +} + +/** +* tegra124_clock_deassert_dfll_dvco_reset - deassert the DFLL's DVCO reset +* +* Deassert the reset line of the DFLL's DVCO, allowing the DVCO to +* operate. No return value. +*/ +void tegra124_clock_deassert_dfll_dvco_reset (void ) +{ +u32 v; + + v =readl_relaxed (clk_base +RST_DFLL_DVCO ); + v &= ~(1 <<DVFS_DFLL_RESET_SHIFT ); +writel_relaxed (v, clk_base +RST_DFLL_DVCO ); +tegra124_car_barrier (); +} + +int tegra124_reset_assert (unsigned long id) +{ +if (id ==TEGRA124_RST_DFLL_DVCO ) +tegra124_clock_assert_dfll_dvco_reset (); +else +return -EINVAL ; + +return 0 ; +} + +int tegra124_reset_deassert (unsigned long id) +{ +if (id ==TEGRA124_RST_DFLL_DVCO ) +tegra124_clock_deassert_dfll_dvco_reset (); +else +return -EINVAL ; + +return 0 ; +} + +/** * tegra132_clock_apply_init_table - initialize clocks on Tegra132 SoCs * * Program an initial clock rate and enable or disable clocks needed
@@ -1504,6 +1570,8 @@ static void __init tegra124_132_clock_init_post(struct device_node *np) {tegra_super_clk_gen4_init (clk_base, pmc_base, tegra124_clks, &pll_x_params); +tegra_init_special_resets (tegra124_reset_assert, + tegra124_reset_deassert);tegra_add_of_provider (np);tegra_register_devclks (devclks,ARRAY_SIZE (devclks));
include/dt-bindings/reset/tegra124-car.h new file +11 -0
@@ -0,0 +1,11 @@ +/* +* This header provides Tegra124-specific constants for binding +* nvidia,tegra124-car. +*/ + +#ifndef _DT_BINDINGS_RESET_TEGRA124_CAR_H +#define _DT_BINDINGS_RESET_TEGRA124_CAR_H + +#define TEGRA124_RST_DFLL_DVCO 0x40000000 + +#endif /* _DT_BINDINGS_RESET_TEGRA124_CAR_H */
Signature · 1 line
2.3.0
PATCH v8 7/18 clk: tegra: Add Tegra124 DFLL clocksource platform driver
In reply to Mikko PerttunenFrom: Tuomas Tynkkynen <[email protected]>
Add basic platform driver support for the fast CPU cluster DFLL clocksource found on Tegra124 SoCs. This small driver selects the appropriate Tegra124-specific characterization data and integration code. It relies on the DFLL common code to do most of the work.
---
v8:
- Removed non-standard dvco reset handlers
drivers/clk/tegra/Makefile | 2 + drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 163 +++++++++++++++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 drivers/clk/tegra/clk-tegra124-dfll-fcpu.c
drivers/clk/tegra/Makefile +2 -0
@@ -16,4 +16,6 @@ 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_ARCH_TEGRA_132_SOC) += clk-tegra124.o +obj-y += cvb.o
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c new file +163 -0
163 lines not on this page · raw message
Signature · 1 line
2.3.0
PATCH v8 8/18 clk: tegra: Save/restore CCLKG_BURST_POLICY on suspend
In reply to Mikko PerttunenFrom: Tuomas Tynkkynen <[email protected]>
Save and restore this register since the LP1 restore assembly routines fiddle with it. Otherwise the CPU would keep running on PLLX after resume from suspend even when DFLL was the original clocksource.
--- drivers/clk/tegra/clk-tegra124.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/clk/tegra/clk-tegra124.c +14 -0
@@ -98,6 +98,8 @@#define PMC_PLLM_WB0_OVERRIDE 0x1dc#define PMC_PLLM_WB0_OVERRIDE_2 0x2b0 +#define CCLKG_BURST_POLICY 0x368 +#define UTMIP_PLL_CFG2 0x488#define UTMIP_PLL_CFG2_STABLE_COUNT (x) (((x) & 0xffff) << 6)#define UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT (x) (((x) & 0x3f) << 18)
@@ -130,6 +132,8 @@#ifdef CONFIG_PM_SLEEP static struct cpu_clk_suspend_context {u32 clk_csite_src; +u32 cclkg_burst; +u32 cclkg_divider; } tegra124_cpu_clk_sctx;#endif
@@ -1330,12 +1334,22 @@ static void tegra124_cpu_clock_suspend(void) tegra124_cpu_clk_sctx.clk_csite_src =readl (clk_base +CLK_SOURCE_CSITE );writel (3 <<30 , clk_base +CLK_SOURCE_CSITE ); + + tegra124_cpu_clk_sctx.cclkg_burst = +readl (clk_base +CCLKG_BURST_POLICY ); + tegra124_cpu_clk_sctx.cclkg_divider = + readl(clk_base + CCLKG_BURST_POLICY + 4); }static void tegra124_cpu_clock_resume (void ) {writel (tegra124_cpu_clk_sctx.clk_csite_src, clk_base +CLK_SOURCE_CSITE ); + +writel (tegra124_cpu_clk_sctx.cclkg_burst, + clk_base +CCLKG_BURST_POLICY ); +writel (tegra124_cpu_clk_sctx.cclkg_divider, + clk_base +CCLKG_BURST_POLICY +4 ); }#endif
Signature · 1 line
2.3.0
PATCH v8 9/18 clk: tegra: Add the DFLL as a possible parent of the cclk_g clock
In reply to Mikko PerttunenFrom: Tuomas Tynkkynen <[email protected]>
The DFLL clocksource was missing from the list of possible parents for the fast CPU cluster. Add it to the list.
--- drivers/clk/tegra/clk-tegra-super-gen4.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/tegra/clk-tegra-super-gen4.c +3 -1
@@ -44,7 +44,9 @@ static const char *sclk_parents[] = { "clk_m", "pll_c_out1", "pll_p_out4",static const char *cclk_g_parents[] = {"clk_m" ,"pll_c" ,"clk_32k" ,"pll_m" ,"pll_p" ,"pll_p_out4" ,"unused" , -"unused" ,"pll_x" }; +"unused" ,"pll_x" ,"unused" ,"unused" , +"unused" ,"unused" ,"unused" ,"unused" , +"dfllCPU_out" };static const char *cclk_lp_parents[] = {"clk_m" ,"pll_c" ,"clk_32k" ,"pll_m" ,"pll_p" ,"pll_p_out4" ,"unused" ,
Signature · 1 line
2.3.0
PATCH v8 10/18 clk: tegra: Initialize PLL_X before CCLK_G to ensure it has a parent
In reply to Mikko PerttunenThis patch moves the initialization of PLL_X to be slightly before that of CCLK_G. This ensures that at boot, CCLK_G will immediately have a parent and the common clock framework can determine its clock rate correctly.
Without this patch, calling clk_put on CCLK_G could cause the CCF to set its rate to zero, hanging the system.
---
v8:
- Added
drivers/clk/tegra/clk-tegra-super-gen4.c | 46 ++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 20 deletions(-)
drivers/clk/tegra/clk-tegra-super-gen4.c +26 -20
@@ -104,6 +104,32 @@ void __init tegra_super_clk_gen4_init(void __iomem *clk_base,struct clk *clk;struct clk **dt_clk; +/* +* Register PLL_X first so that CCLK_G has a parent at registration +* time. This ensures that the common clock framework knows CCLK_G's +* rate. +*/ + +#if defined(CONFIG_ARCH_TEGRA_114_SOC ) || defined(CONFIG_ARCH_TEGRA_124_SOC ) +/* PLLX */ + dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x, tegra_clks); +if (!dt_clk) +return ; + + clk =tegra_clk_register_pllxc ("pll_x" ,"pll_ref" , clk_base, + pmc_base,CLK_IGNORE_UNUSED , params,NULL ); + *dt_clk = clk; + +/* PLLX_OUT0 */ + + dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x_out0, tegra_clks); +if (!dt_clk) +return ; + clk =clk_register_fixed_factor (NULL ,"pll_x_out0" ,"pll_x" , +CLK_SET_RATE_PARENT ,1 ,2 ); + *dt_clk = clk; +#endif +/* CCLKG */ dt_clk =tegra_lookup_dt_id (tegra_clk_cclk_g, tegra_clks);if (dt_clk) {
@@ -127,25 +153,5 @@ void __init tegra_super_clk_gen4_init(void __iomem *clk_base, }tegra_sclk_init (clk_base, tegra_clks); - -#if defined(CONFIG_ARCH_TEGRA_114_SOC ) || defined(CONFIG_ARCH_TEGRA_124_SOC ) -/* PLLX */ - dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x, tegra_clks); -if (!dt_clk) -return ; - - clk =tegra_clk_register_pllxc ("pll_x" ,"pll_ref" , clk_base, - pmc_base,CLK_IGNORE_UNUSED , params,NULL ); - *dt_clk = clk; - -/* PLLX_OUT0 */ - - dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x_out0, tegra_clks); -if (!dt_clk) -return ; - clk =clk_register_fixed_factor (NULL ,"pll_x_out0" ,"pll_x" , -CLK_SET_RATE_PARENT ,1 ,2 ); - *dt_clk = clk; -#endif }
Signature · 1 line
2.3.0
Re: [PATCH v8 10/18] clk: tegra: Initialize PLL_X before CCLK_G to ensure it has a parent
Quoting Mikko Perttunen (2015-03-01 04:44:33)
Quoted 7 lines
This patch moves the initialization of
PLL_Xto be slightly before that ofCCLK_G. This ensures that at boot,CCLK_Gwill immediately have a parent and the common clock framework can determine its clock rate correctly.Without this patch, calling
clk_putonCCLK_Gcould cause the CCF to set its rate to zero, hanging the system.
Hi Mikko,
Patch looks fine to me but I wanted to get more info on the behavior you mentioned above about clk_put. Is there some special circumstance that causes this for you? Why does calling clk_put adjust the rate of your clock?
Thanks,
Mike
Quoted 75 lines
Signed-off-by Mikko Perttunen <[email protected]>---
v8:
- Addeddrivers/clk/tegra/clk-tegra-super-gen4.c | 46 ++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 20 deletions(-)drivers/clk/tegra/clk-tegra-super-gen4.c +26
-20@@ -104,6 +104,32 @@ void __init tegra_super_clk_gen4_init(void __iomem *clk_base,struct clk *clk;struct clk **dt_clk; +/* +* Register PLL_X first so that CCLK_G has a parent at registration +* time. This ensures that the common clock framework knows CCLK_G's +* rate. +*/ + +#if defined(CONFIG_ARCH_TEGRA_114_SOC ) || defined(CONFIG_ARCH_TEGRA_124_SOC ) +/* PLLX */ + dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x, tegra_clks); +if (!dt_clk) +return ; + + clk =tegra_clk_register_pllxc ("pll_x" ,"pll_ref" , clk_base, + pmc_base,CLK_IGNORE_UNUSED , params,NULL ); + *dt_clk = clk; + +/* PLLX_OUT0 */ + + dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x_out0, tegra_clks); +if (!dt_clk) +return ; + clk =clk_register_fixed_factor (NULL ,"pll_x_out0" ,"pll_x" , +CLK_SET_RATE_PARENT ,1 ,2 ); + *dt_clk = clk; +#endif +/* CCLKG */ dt_clk =tegra_lookup_dt_id (tegra_clk_cclk_g, tegra_clks);if (dt_clk) {@@ -127,25 +153,5 @@ void __init tegra_super_clk_gen4_init(void __iomem *clk_base, }tegra_sclk_init (clk_base, tegra_clks); - -#if defined(CONFIG_ARCH_TEGRA_114_SOC ) || defined(CONFIG_ARCH_TEGRA_124_SOC ) -/* PLLX */ - dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x, tegra_clks); -if (!dt_clk) -return ; - - clk =tegra_clk_register_pllxc ("pll_x" ,"pll_ref" , clk_base, - pmc_base,CLK_IGNORE_UNUSED , params,NULL ); - *dt_clk = clk; - -/* PLLX_OUT0 */ - - dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x_out0, tegra_clks); -if (!dt_clk) -return ; - clk =clk_register_fixed_factor (NULL ,"pll_x_out0" ,"pll_x" , -CLK_SET_RATE_PARENT ,1 ,2 ); - *dt_clk = clk; -#endif }Signature · 1 line
2.3.0
Re: [PATCH v8 10/18] clk: tegra: Initialize PLL_X before CCLK_G to ensure it has a parent
Quoted 11 lines · Michael Turquette
Quoting Mikko Perttunen (2015-03-01 04:44:33)
Quoted 7 lines
This patch moves the initialization of
PLL_Xto be slightly before that ofCCLK_G. This ensures that at boot,CCLK_Gwill immediately have a parent and the common clock framework can determine its clock rate correctly.Without this patch, calling
clk_putonCCLK_Gcould cause the CCF to set its rate to zero, hanging the system.Hi Mikko,
Quoted 7 lines
Patch looks fine to me but I wanted to get more info on the behavior you mentioned above about
clk_put. Is there some special circumstance that causes this for you? Why does callingclk_putadjust the rate of your clock?Thanks,
Mike
Hi Mike,
this is the chain of events:
- CCLK_G is registered. CCF stores its current rate, but since it doesn't have a parent at this point, the rate is assumed zero.
- tegra cpufreq driver tries to probe, and clk_gets CCLK_G
- tegra dfll driver tries to probe, but fails
- tegra cpufreq driver's probe fails, and during unwinding clk_puts CCLK_G
- CCF attempts to restore CCLK_G's rate to what it was prior to the clk_get (to revert possible changes due to clock constraints)
- the stored rate was zero, so CCLK_G is set to zero.
We did discuss it a bit on IRC with Tomeu and Peter and agreed that some fix in CCF should be done, but we didn't get much further than that.
Mikko
Quoted 76 lines
Quoted 76 lines
Signed-off-by Mikko Perttunen <[email protected]>---
v8:
- Addeddrivers/clk/tegra/clk-tegra-super-gen4.c | 46 ++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 20 deletions(-)drivers/clk/tegra/clk-tegra-super-gen4.c +26
-21@@ -104,6 +104,32 @@ void __init tegra_super_clk_gen4_init(void __iomem *clk_base,struct clk *clk;struct clk **dt_clk; +/* +* Register PLL_X first so that CCLK_G has a parent at registration +* time. This ensures that the common clock framework knows CCLK_G's +* rate. +*/ + +#if defined(CONFIG_ARCH_TEGRA_114_SOC ) || defined(CONFIG_ARCH_TEGRA_124_SOC ) +/* PLLX */ + dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x, tegra_clks); +if (!dt_clk) +return ; + + clk =tegra_clk_register_pllxc ("pll_x" ,"pll_ref" , clk_base, + pmc_base,CLK_IGNORE_UNUSED , params,NULL ); + *dt_clk = clk; + +/* PLLX_OUT0 */ + + dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x_out0, tegra_clks); +if (!dt_clk) +return ; + clk =clk_register_fixed_factor (NULL ,"pll_x_out0" ,"pll_x" , +CLK_SET_RATE_PARENT ,1 ,2 ); + *dt_clk = clk; +#endif +/* CCLKG */ dt_clk =tegra_lookup_dt_id (tegra_clk_cclk_g, tegra_clks);if (dt_clk) {@@ -127,25 +153,5 @@ void __init tegra_super_clk_gen4_init(void __iomem *clk_base, }tegra_sclk_init (clk_base, tegra_clks); - -#if defined(CONFIG_ARCH_TEGRA_114_SOC ) || defined(CONFIG_ARCH_TEGRA_124_SOC ) -/* PLLX */ - dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x, tegra_clks); -if (!dt_clk) -return ; - - clk =tegra_clk_register_pllxc ("pll_x" ,"pll_ref" , clk_base, - pmc_base,CLK_IGNORE_UNUSED , params,NULL ); - *dt_clk = clk; - -/* PLLX_OUT0 */ - - dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x_out0, tegra_clks); -if (!dt_clk) -return ; - clk =clk_register_fixed_factor (NULL ,"pll_x_out0" ,"pll_x" , -CLK_SET_RATE_PARENT ,1 ,2 ); - *dt_clk = clk; -#endif } --2.3.0
Re: [PATCH v8 10/18] clk: tegra: Initialize PLL_X before CCLK_G to ensure it has a parent
Quoted 26 lines · Mikko Perttunen
Quoted 14 lines · Michael Turquette
Quoting Mikko Perttunen (2015-03-01 04:44:33)
Quoted 8 lines
This patch moves the initialization of
PLL_Xto be slightly before that ofCCLK_G. This ensures that at boot,CCLK_Gwill immediately have a parent and the common clock framework can determine its clock rate correctly.Without this patch, calling
clk_putonCCLK_Gcould cause the CCF to set its rate to zero, hanging the system.Hi Mikko,
Quoted 7 lines
Patch looks fine to me but I wanted to get more info on the behavior you mentioned above about
clk_put. Is there some special circumstance that causes this for you? Why does callingclk_putadjust the rate of your clock?Thanks,
MikeHi Mike,
Quoted 8 lines
this is the chain of events:
-CCLK_Gis registered. CCF stores its current rate, but since it doesn't have a parent at this point, the rate is assumed zero.
- tegra cpufreq driver tries to probe, andclk_getsCCLK_G
- tegra dfll driver tries to probe, but fails
- tegra cpufreq driver's probe fails, and during unwindingclk_putsCCLK_G
- CCF attempts to restore CCLK_G's rate to what it was prior to theclk_get(to revert possible changes due to clock constraints)
The CCF will currently only do so if any constraints were set in the per-user clk that was destroyed, so this particular problem shouldn't happen any more: ec02ace clk: Only recalculate the rate if needed
Quoted 4 lines
- the stored rate was zero, so
CCLK_Gis set to zero.We did discuss it a bit on IRC with Tomeu and Peter and agreed that some fix in CCF should be done, but we didn't get much further than that.
Wonder if we could somehow make sure that the rate in the CCF matches the current state of the HW.
Regards,
Tomeu
Quoted 93 lines
Mikko
Quoted 81 lines
Quoted 81 lines
Signed-off-by Mikko Perttunen <[email protected]>---
v8:
- Addeddrivers/clk/tegra/clk-tegra-super-gen4.c | 46 ++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 20 deletions(-)drivers/clk/tegra/clk-tegra-super-gen4.c +2
-0@@ -104,6 +104,32 @@ void __init tegra_super_clk_gen4_init(void __iomem *clk_base, struct clk *clk;struct clk **dt_clk; +/* +* Register PLL_X first so that CCLK_G has a parent at registration
+ * time. This ensures that the common clock framework knows
CCLK_G'sdrivers/clk/tegra/clk-tegra-super-gen4.c +4
-0+* rate. +*/ + +#if defined(CONFIG_ARCH_TEGRA_114_SOC) ||
defined(CONFIG_ARCH_TEGRA_124_SOC)drivers/clk/tegra/clk-tegra-super-gen4.c +19
-20+/* PLLX */ + dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x, tegra_clks); +if (!dt_clk) +return ; + + clk =tegra_clk_register_pllxc ("pll_x" ,"pll_ref" , clk_base, + pmc_base,CLK_IGNORE_UNUSED , params,NULL ); + *dt_clk = clk; + +/* PLLX_OUT0 */ + + dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x_out0, tegra_clks); +if (!dt_clk) +return ; + clk =clk_register_fixed_factor (NULL ,"pll_x_out0" ,"pll_x" , +CLK_SET_RATE_PARENT ,1 ,2 ); + *dt_clk = clk; +#endif +/* CCLKG */ dt_clk =tegra_lookup_dt_id (tegra_clk_cclk_g, tegra_clks);if (dt_clk) {@@ -127,25 +153,5 @@ void __init tegra_super_clk_gen4_init(void __iomem *clk_base, }tegra_sclk_init (clk_base, tegra_clks); - -#if defined(CONFIG_ARCH_TEGRA_114_SOC ) ||defined (CONFIG_ARCH_TEGRA_124_SOC ) -/* PLLX */ - dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x, tegra_clks); -if (!dt_clk) -return ; - - clk =tegra_clk_register_pllxc ("pll_x" ,"pll_ref" , clk_base, - pmc_base,CLK_IGNORE_UNUSED , params,NULL ); - *dt_clk = clk; - -/* PLLX_OUT0 */ - - dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x_out0, tegra_clks); -if (!dt_clk) -return ; - clk =clk_register_fixed_factor (NULL ,"pll_x_out0" ,"pll_x" , -CLK_SET_RATE_PARENT ,1 ,2 ); - *dt_clk = clk; -#endif }Quoted 3 lines
Quoted 3 lines
--
2.3.0--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v8 10/18] clk: tegra: Initialize PLL_X before CCLK_G to ensure it has a parent
Quoting Tomeu Vizoso (2015-04-13 05:17:01)
Quoted 36 lines · Mikko Perttunen
Quoted 26 lines · Michael Turquette
Quoted 14 lines
Quoting Mikko Perttunen (2015-03-01 04:44:33)
Quoted 8 lines
This patch moves the initialization of
PLL_Xto be slightly before that ofCCLK_G. This ensures that at boot,CCLK_Gwill immediately have a parent and the common clock framework can determine its clock rate correctly.Without this patch, calling
clk_putonCCLK_Gcould cause the CCF to set its rate to zero, hanging the system.Hi Mikko,
Quoted 7 lines
Patch looks fine to me but I wanted to get more info on the behavior you mentioned above about
clk_put. Is there some special circumstance that causes this for you? Why does callingclk_putadjust the rate of your clock?Thanks,
MikeHi Mike,
Quoted 8 lines
this is the chain of events:
-CCLK_Gis registered. CCF stores its current rate, but since it doesn't have a parent at this point, the rate is assumed zero.
- tegra cpufreq driver tries to probe, andclk_getsCCLK_G
- tegra dfll driver tries to probe, but fails
- tegra cpufreq driver's probe fails, and during unwindingclk_putsCCLK_G
- CCF attempts to restore CCLK_G's rate to what it was prior to theclk_get(to revert possible changes due to clock constraints)
Quoted 3 lines
The CCF will currently only do so if any constraints were set in the per-user clk that was destroyed, so this particular problem shouldn't happen any more: ec02ace clk: Only recalculate the rate if needed
Precisely. clk_put shouldn't be setting rates unless we're releasing a constraint. Can this re-ordering patch be dropped?
Quoted 8 lines
Quoted 5 lines
- the stored rate was zero, so
CCLK_Gis set to zero.We did discuss it a bit on IRC with Tomeu and Peter and agreed that some fix in CCF should be done, but we didn't get much further than that.
Wonder if we could somehow make sure that the rate in the CCF matches the current state of the HW.
If there is no constraint expressed by Linux software then we should not care.
Probably we need to track a few more things in the framework. Stephen and I were discussing struct clk.hw_en which tracks the enable/disable state of the hardware independently of the enable_count (e.g. gate clock is enabled by bootloader but not enabled by Linux ccf).
Tracking something like "is_clk_initialized" would be helpful. It is an abstract concept but knowing that clock has been successfully hooked up to its parent and that its rate has been properly calculated would be very helpful for some corner cases.
Regards,
Mike
Quoted 98 lines
Regards,
Tomeu
Quoted 93 lines
Mikko
Quoted 81 lines
Quoted 81 lines
Signed-off-by Mikko Perttunen <[email protected]>---
v8:
- Addeddrivers/clk/tegra/clk-tegra-super-gen4.c | 46 ++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 20 deletions(-)drivers/clk/tegra/clk-tegra-super-gen4.c +2
-0@@ -104,6 +104,32 @@ void __init tegra_super_clk_gen4_init(void __iomem *clk_base, struct clk *clk;struct clk **dt_clk; +/* +* Register PLL_X first so that CCLK_G has a parent at registration
+ * time. This ensures that the common clock framework knows
CCLK_G'sdrivers/clk/tegra/clk-tegra-super-gen4.c +4
-0+* rate. +*/ + +#if defined(CONFIG_ARCH_TEGRA_114_SOC) ||
defined(CONFIG_ARCH_TEGRA_124_SOC)drivers/clk/tegra/clk-tegra-super-gen4.c +19
-20+/* PLLX */ + dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x, tegra_clks); +if (!dt_clk) +return ; + + clk =tegra_clk_register_pllxc ("pll_x" ,"pll_ref" , clk_base, + pmc_base,CLK_IGNORE_UNUSED , params,NULL ); + *dt_clk = clk; + +/* PLLX_OUT0 */ + + dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x_out0, tegra_clks); +if (!dt_clk) +return ; + clk =clk_register_fixed_factor (NULL ,"pll_x_out0" ,"pll_x" , +CLK_SET_RATE_PARENT ,1 ,2 ); + *dt_clk = clk; +#endif +/* CCLKG */ dt_clk =tegra_lookup_dt_id (tegra_clk_cclk_g, tegra_clks);if (dt_clk) {@@ -127,25 +153,5 @@ void __init tegra_super_clk_gen4_init(void __iomem *clk_base, }tegra_sclk_init (clk_base, tegra_clks); - -#if defined(CONFIG_ARCH_TEGRA_114_SOC ) ||defined (CONFIG_ARCH_TEGRA_124_SOC ) -/* PLLX */ - dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x, tegra_clks); -if (!dt_clk) -return ; - - clk =tegra_clk_register_pllxc ("pll_x" ,"pll_ref" , clk_base, - pmc_base,CLK_IGNORE_UNUSED , params,NULL ); - *dt_clk = clk; - -/* PLLX_OUT0 */ - - dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x_out0, tegra_clks); -if (!dt_clk) -return ; - clk =clk_register_fixed_factor (NULL ,"pll_x_out0" ,"pll_x" , -CLK_SET_RATE_PARENT ,1 ,2 ); - *dt_clk = clk; -#endif }Quoted 3 lines
Quoted 3 lines
--
2.3.0--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v8 10/18] clk: tegra: Initialize PLL_X before CCLK_G to ensure it has a parent
Quoted 37 lines · Michael Turquette
Quoting Tomeu Vizoso (2015-04-13 05:17:01)
Quoted 36 lines · Mikko Perttunen
Quoted 34 lines · Michael Turquette
Quoted 14 lines
Quoting Mikko Perttunen (2015-03-01 04:44:33)
Quoted 8 lines
This patch moves the initialization of
PLL_Xto be slightly before that ofCCLK_G. This ensures that at boot,CCLK_Gwill immediately have a parent and the common clock framework can determine its clock rate correctly.Without this patch, calling
clk_putonCCLK_Gcould cause the CCF to set its rate to zero, hanging the system.Hi Mikko,
Quoted 7 lines
Patch looks fine to me but I wanted to get more info on the behavior you mentioned above about
clk_put. Is there some special circumstance that causes this for you? Why does callingclk_putadjust the rate of your clock?Thanks,
MikeHi Mike,
this is the chain of events:
-CCLK_Gis registered. CCF stores its current rate, but since it doesn't have a parent at this point, the rate is assumed zero.
- tegra cpufreq driver tries to probe, andclk_getsCCLK_G
- tegra dfll driver tries to probe, but fails
- tegra cpufreq driver's probe fails, and during unwindingclk_putsCCLK_G
- CCF attempts to restore CCLK_G's rate to what it was prior to theclk_get(to revert possible changes due to clock constraints)
Quoted 6 lines
Quoted 3 lines
The CCF will currently only do so if any constraints were set in the per-user clk that was destroyed, so this particular problem shouldn't happen any more: ec02ace clk: Only recalculate the rate if needed
Precisely.
clk_putshouldn't be setting rates unless we're releasing a constraint. Can this re-ordering patch be dropped?
Yes.
I'll try to post a (hopefully) final version of the series tomorrow.
Thanks, Mikko.
Quoted 124 lines
Quoted 9 lines
Quoted 6 lines
- the stored rate was zero, so
CCLK_Gis set to zero.We did discuss it a bit on IRC with Tomeu and Peter and agreed that some fix in CCF should be done, but we didn't get much further than that.
Wonder if we could somehow make sure that the rate in the CCF matches the current state of the HW.
If there is no constraint expressed by Linux software then we should not care.
Probably we need to track a few more things in the framework. Stephen and I were discussing struct clk.hw_en which tracks the enable/disable state of the hardware independently of the
enable_count(e.g. gate clock is enabled by bootloader but not enabled by Linux ccf).Tracking something like "
is_clk_initialized" would be helpful. It is an abstract concept but knowing that clock has been successfully hooked up to its parent and that its rate has been properly calculated would be very helpful for some corner cases.Regards,
MikeQuoted 98 lines
Regards,
Tomeu
Quoted 93 lines
Mikko
Quoted 81 lines
Quoted 81 lines
Signed-off-by Mikko Perttunen <[email protected]>---
v8:
- Addeddrivers/clk/tegra/clk-tegra-super-gen4.c | 46 ++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 20 deletions(-)drivers/clk/tegra/clk-tegra-super-gen4.c +2
-0@@ -104,6 +104,32 @@ void __init tegra_super_clk_gen4_init(void __iomem *clk_base, struct clk *clk;struct clk **dt_clk; +/* +* Register PLL_X first so that CCLK_G has a parent at registration
+ * time. This ensures that the common clock framework knows
CCLK_G'sdrivers/clk/tegra/clk-tegra-super-gen4.c +4
-0+* rate. +*/ + +#if defined(CONFIG_ARCH_TEGRA_114_SOC) ||
defined(CONFIG_ARCH_TEGRA_124_SOC)drivers/clk/tegra/clk-tegra-super-gen4.c +19
-20+/* PLLX */ + dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x, tegra_clks); +if (!dt_clk) +return ; + + clk =tegra_clk_register_pllxc ("pll_x" ,"pll_ref" , clk_base, + pmc_base,CLK_IGNORE_UNUSED , params,NULL ); + *dt_clk = clk; + +/* PLLX_OUT0 */ + + dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x_out0, tegra_clks); +if (!dt_clk) +return ; + clk =clk_register_fixed_factor (NULL ,"pll_x_out0" ,"pll_x" , +CLK_SET_RATE_PARENT ,1 ,2 ); + *dt_clk = clk; +#endif +/* CCLKG */ dt_clk =tegra_lookup_dt_id (tegra_clk_cclk_g, tegra_clks);if (dt_clk) {@@ -127,25 +153,5 @@ void __init tegra_super_clk_gen4_init(void __iomem *clk_base, }tegra_sclk_init (clk_base, tegra_clks); - -#if defined(CONFIG_ARCH_TEGRA_114_SOC ) ||defined (CONFIG_ARCH_TEGRA_124_SOC ) -/* PLLX */ - dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x, tegra_clks); -if (!dt_clk) -return ; - - clk =tegra_clk_register_pllxc ("pll_x" ,"pll_ref" , clk_base, - pmc_base,CLK_IGNORE_UNUSED , params,NULL ); - *dt_clk = clk; - -/* PLLX_OUT0 */ - - dt_clk =tegra_lookup_dt_id (tegra_clk_pll_x_out0, tegra_clks); -if (!dt_clk) -return ; - clk =clk_register_fixed_factor (NULL ,"pll_x_out0" ,"pll_x" , -CLK_SET_RATE_PARENT ,1 ,2 ); - *dt_clk = clk; -#endif }Quoted 3 lines
Quoted 3 lines
--
2.3.0--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
PATCH v8 11/18 ARM: tegra: Add the DFLL to Tegra124 device tree
In reply to Mikko PerttunenFrom: Tuomas Tynkkynen <[email protected]>
The DFLL clocksource is a separate IP block from the usual clock-and-reset controller, so it gets its own device tree node.
---
v8:
- Changed dfll@ -> clock@
- Added dvco reset control
arch/arm/boot/dts/tegra124.dtsi | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
arch/arm/boot/dts/tegra124.dtsi +25 -0
@@ -4,6 +4,7 @@ #include <dt-bindings/pinctrl/pinctrl-tegra.h> #include <dt-bindings/pinctrl/pinctrl-tegra-xusb.h> #include <dt-bindings/interrupt-controller/arm-gic.h> +#include <dt-bindings/reset/tegra124-car.h> #include <dt-bindings/thermal/tegra124-soctherm.h> #include "skeleton.dtsi"
@@ -670,6 +671,30 @@ #thermal-sensor-cells = <1>; }; + dfll: clock at 0,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 TEGRA124_CLK_DFLL_SOC>, + <&tegra_car TEGRA124_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,sample-rate = <12500>; + nvidia,droop-ctrl = <0x00000f00>; + nvidia,force-mode = <1>; + nvidia,cf = <10>; + nvidia,ci = <0>; + nvidia,cg = <2>; + status = "disabled"; + }; + ahub at 0,70300000 { compatible = "nvidia,tegra124-ahub"; reg = <0x0 0x70300000 0x0 0x200>,
Signature · 1 line
2.3.0
PATCH v8 12/18 ARM: tegra: Enable the DFLL on the Jetson TK1
In reply to Mikko PerttunenFrom: Tuomas Tynkkynen <[email protected]>
Add the board-specific properties of the DFLL for the Jetson TK1 board. On this board, the DFLL will take control of the sd0 regulator on the on-board AS3722 PMIC.
---
v8:
- Changed dfll@ -> clock@
arch/arm/boot/dts/tegra124-jetson-tk1.dts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/arm/boot/dts/tegra124-jetson-tk1.dts +8 -1
@@ -1509,7 +1509,7 @@ vin-ldo9-10-supply = <&vdd_5v0_sys>; vin-ldo11-supply = <&vdd_3v3_run>; - sd0 { + vdd_cpu: sd0 { regulator-name = "+VDD_CPU_AP"; regulator-min-microvolt = <700000>; regulator-max-microvolt = <1400000>;
@@ -1737,6 +1737,13 @@ non-removable; }; + /* CPU DFLL clock */ + clock at 0,70110000 { + status = "okay"; + vdd-cpu-supply = <&vdd_cpu>; + nvidia,i2c-fs-rate = <400000>; + }; + ahub at 0,70300000 { i2s at 0,70301100 { status = "okay";
Signature · 1 line
2.3.0
PATCH v8 13/18 cpufreq: tegra124: Add device tree bindings
In reply to Mikko PerttunenFrom: Tuomas Tynkkynen <[email protected]>
The cpufreq driver for Tegra124 will be a different one than the old Tegra20 cpufreq driver (tegra-cpufreq), which does not use the device tree.
--- .../bindings/cpufreq/tegra124-cpufreq.txt | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/tegra124-cpufreq.txt
Documentation/devicetree/bindings/cpufreq/tegra124-cpufreq.txt new file +44 -0
@@ -0,0 +1,44 @@ +Tegra124 CPU frequency scaling driver bindings +---------------------------------------------- + +Both required and optional properties listed below must be defined +under node /cpus/cpu at 0. + +Required properties: +- clocks: Must contain an entry for each entry in clock-names. + 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. +- vdd-cpu-supply: Regulator for CPU voltage + +Optional properties: +- clock-latency: Specify the possible maximum transition latency for clock, + in unit of nanoseconds. + +Example: +-------- +cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu at 0 { + device_type = "cpu"; + compatible = "arm,cortex-a15"; + 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-latency = <300000>; + vdd-cpu-supply: <&vdd_cpu>; + }; + + <...> +};
--
2.3.0
PATCH v8 14/18 cpufreq: tegra: Rename tegra-cpufreq to tegra20-cpufreq
In reply to Mikko PerttunenFrom: Tuomas Tynkkynen <[email protected]>
The Tegra124 will use a different driver for frequency scaling, so rename the old driver (which handles only Tegra20) appropriately.
---
drivers/cpufreq/Kconfig.arm | 6 +++---
drivers/cpufreq/Makefile | 2 +-
drivers/cpufreq/{tegra-cpufreq.c => tegra20-cpufreq.c} | 0
3 files changed, 4 insertions(+), 4 deletions(-)
rename drivers/cpufreq/{tegra-cpufreq.c => tegra20-cpufreq.c} (100%)drivers/cpufreq/Kconfig.arm +3 -3
@@ -249,12 +249,12 @@ config ARM_SPEAR_CPUFREQ help This adds the CPUFreq driver support for SPEAr SOCs. -config ARM_TEGRA_CPUFREQ - bool "TEGRA CPUFreq support" +config ARM_TEGRA20_CPUFREQ + bool "Tegra20 CPUFreq support" depends on ARCH_TEGRA default y help - This adds the CPUFreq driver support for TEGRA SOCs. + This adds the CPUFreq driver support for Tegra20 SOCs. config ARM_PXA2xx_CPUFREQ tristate "Intel PXA2xx CPUfreq driver"
drivers/cpufreq/Makefile +1 -1
@@ -76,7 +76,7 @@ obj-$(CONFIG_ARM_S5PV210_CPUFREQ) += s5pv210-cpufreq.o obj-$(CONFIG_ARM_SA1100_CPUFREQ) += sa1100-cpufreq.o obj-$(CONFIG_ARM_SA1110_CPUFREQ) += sa1110-cpufreq.o obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o -obj-$(CONFIG_ARM_TEGRA_CPUFREQ) += tegra-cpufreq.o +obj-$(CONFIG_ARM_TEGRA20_CPUFREQ) += tegra20-cpufreq.o obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ) += vexpress-spc-cpufreq.o ##################################################################################
drivers/cpufreq/tegra20-cpufreq.c renamed from drivers/cpufreq/tegra-cpufreq.c +0 -0
Signature · 1 line
2.3.0
PATCH v8 15/18 cpufreq: Add cpufreq driver for Tegra124
In reply to Mikko PerttunenFrom: Tuomas Tynkkynen <[email protected]>
Add a new cpufreq driver for Tegra124. Instead of using the PLLX as the CPU clocksource, switch immediately to the DFLL. It allows the use of higher clock rates, and will automatically scale the CPU voltage as well. Besides the CPU clocksource switch, we let the cpufreq-dt driver for all the cpufreq operations.
This driver also relies on the DFLL driver to fill the OPP table for the CPU0 device, so that the cpufreq-dt driver knows what frequencies to use.
--- drivers/cpufreq/Kconfig.arm | 7 ++ drivers/cpufreq/Makefile | 1 + drivers/cpufreq/tegra124-cpufreq.c | 217 +++++++++++++++++++++++++++++++++++++ 3 files changed, 225 insertions(+) create mode 100644 drivers/cpufreq/tegra124-cpufreq.c
drivers/cpufreq/Kconfig.arm +7 -0
@@ -256,6 +256,13 @@ config ARM_TEGRA20_CPUFREQ help This adds the CPUFreq driver support for Tegra20 SOCs. +config ARM_TEGRA124_CPUFREQ + bool "Tegra124 CPUFreq support" + depends on ARCH_TEGRA && CPUFREQ_DT + default y + help + This adds the CPUFreq driver support for Tegra124 SOCs. + config ARM_PXA2xx_CPUFREQ tristate "Intel PXA2xx CPUfreq driver" depends on PXA27x || PXA25x
drivers/cpufreq/Makefile +1 -0
@@ -77,6 +77,7 @@ obj-$(CONFIG_ARM_SA1100_CPUFREQ) += sa1100-cpufreq.o obj-$(CONFIG_ARM_SA1110_CPUFREQ) += sa1110-cpufreq.o obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o obj-$(CONFIG_ARM_TEGRA20_CPUFREQ) += tegra20-cpufreq.o +obj-$(CONFIG_ARM_TEGRA124_CPUFREQ) += tegra124-cpufreq.o obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ) += vexpress-spc-cpufreq.o ##################################################################################
drivers/cpufreq/tegra124-cpufreq.c new file +217 -0
217 lines not on this page · raw message
Signature · 1 line
2.3.0
Re: [PATCH v8 15/18] cpufreq: Add cpufreq driver for Tegra124
drivers/cpufreq/Kconfig.arm config ARM_TEGRA20_CPUFREQ · line 260
Quoted 8 lines · Mikko Perttunen
drivers/cpufreq/Kconfig.arm +2
-0@@ -256,6 +256,13 @@ config ARM_TEGRA20_CPUFREQ help This adds the CPUFreq driver support for Tegra20 SOCs. +config ARM_TEGRA124_CPUFREQ + bool "Tegra124 CPUFreq support"
This adds a bool Kconfig symbol...
Quoted 13 lines
drivers/cpufreq/Kconfig.arm +5
-0+ depends on ARCH_TEGRA && CPUFREQ_DT + default y + help + This adds the CPUFreq driver support for Tegra124 SOCs. + config ARM_PXA2xx_CPUFREQ tristate "Intel PXA2xx CPUfreq driver" depends on PXA27x || PXA25xdrivers/cpufreq/Makefile +0
-0
drivers/cpufreq/Makefile obj-$(CONFIG_ARM_SA1100_CPUFREQ) += sa1100-cpufreq.o · line 80
Quoted 4 lines
drivers/cpufreq/Makefile +1
-0@@ -77,6 +77,7 @@ obj-$(CONFIG_ARM_SA1100_CPUFREQ) += sa1100-cpufreq.o obj-$(CONFIG_ARM_SA1110_CPUFREQ) += sa1110-cpufreq.o obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o obj-$(CONFIG_ARM_TEGRA20_CPUFREQ) += tegra20-cpufreq.o +obj-$(CONFIG_ARM_TEGRA124_CPUFREQ) += tegra124-cpufreq.o
... so this object will either not be built or be built-in.
Quoted 20 lines
drivers/cpufreq/Makefile +0
-0obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ) += vexpress-spc-cpufreq.o ##################################################################################drivers/cpufreq/tegra124-cpufreq.c new file +11
-0@@ -0,0 +1,217 @@ +/* +* Tegra 124 cpufreq driver +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details.
drivers/cpufreq/tegra124-cpufreq.c line 21
Quoted 10 lines
drivers/cpufreq/tegra124-cpufreq.c new file +10
-0+*/ + +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt + +#include <linux/clk.h> +#include <linux/cpufreq-dt.h> +#include <linux/err.h> +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h>
Is linux/module.h needed?
Quoted 6 lines
drivers/cpufreq/tegra124-cpufreq.c new file +6
-0+#include <linux/of_device.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/pm_opp.h> +#include <linux/regulator/consumer.h> +#include <linux/types.h>
[...]
drivers/cpufreq/tegra124-cpufreq.c line 183
Quoted 4 lines
drivers/cpufreq/tegra124-cpufreq.c new file +4
-0+static struct platform_driver tegra124_cpufreq_platdrv = { + .driver = { + .name ="cpufreq-tegra124" , + .owner =THIS_MODULE ,
.owner will always be, in short, NULL.
Quoted 4 lines
drivers/cpufreq/tegra124-cpufreq.c new file +4
-0+ }, + .probe = tegra124_cpufreq_probe, + .remove = tegra124_cpufreq_remove, +};
[...]
Quoted 1 line
+module_init(tegra_cpufreq_init);
This might as well be, I think, device_initcall().
drivers/cpufreq/tegra124-cpufreq.c line 217
Quoted 3 lines
drivers/cpufreq/tegra124-cpufreq.c new file +3
-0+MODULE_AUTHOR ("Tuomas Tynkkynen <[email protected]>" ); +MODULE_DESCRIPTION ("cpufreq driver for NVIDIA Tegra124" ); +MODULE_LICENSE ("GPL v2" );
The strings in these macros will always be preprocessed away, because this driver cannot become a module.
Paul Bolle
Re: [PATCH v8 15/18] cpufreq: Add cpufreq driver for Tegra124
Quoted 100 lines · Paul Bolle
drivers/cpufreq/Kconfig.arm config ARM_TEGRA20_CPUFREQ · line 260
Quoted 8 lines · Mikko Perttunen
drivers/cpufreq/Kconfig.arm +2
-0@@ -256,6 +256,13 @@ config ARM_TEGRA20_CPUFREQ help This adds the CPUFreq driver support for Tegra20 SOCs. +config ARM_TEGRA124_CPUFREQ + bool "Tegra124 CPUFreq support"This adds a bool
Kconfigsymbol...Quoted 13 lines
drivers/cpufreq/Kconfig.arm +5
-0+ depends on ARCH_TEGRA && CPUFREQ_DT + default y + help + This adds the CPUFreq driver support for Tegra124 SOCs. + config ARM_PXA2xx_CPUFREQ tristate "Intel PXA2xx CPUfreq driver" depends on PXA27x || PXA25xdrivers/cpufreq/Makefile +0
-0drivers/cpufreq/Makefile obj-$(CONFIG_ARM_SA1100_CPUFREQ) += sa1100-cpufreq.o · line 80
Quoted 4 lines
drivers/cpufreq/Makefile +1
-0@@ -77,6 +77,7 @@ obj-$(CONFIG_ARM_SA1100_CPUFREQ) += sa1100-cpufreq.o obj-$(CONFIG_ARM_SA1110_CPUFREQ) += sa1110-cpufreq.o obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o obj-$(CONFIG_ARM_TEGRA20_CPUFREQ) += tegra20-cpufreq.o +obj-$(CONFIG_ARM_TEGRA124_CPUFREQ) += tegra124-cpufreq.o... so this object will either not be built or be built-in.
Quoted 20 lines
drivers/cpufreq/Makefile +0
-0obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ) += vexpress-spc-cpufreq.o ##################################################################################drivers/cpufreq/tegra124-cpufreq.c new file +11
-0@@ -0,0 +1,217 @@ +/* +* Tegra 124 cpufreq driver +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. drivers/cpufreq/tegra124-cpufreq.c line 21
Quoted 10 lines
drivers/cpufreq/tegra124-cpufreq.c new file +10
-0+*/ + +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt + +#include <linux/clk.h> +#include <linux/cpufreq-dt.h> +#include <linux/err.h> +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> Is
linux/module.hneeded?Quoted 6 lines
drivers/cpufreq/tegra124-cpufreq.c new file +6
-0+#include <linux/of_device.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/pm_opp.h> +#include <linux/regulator/consumer.h> +#include <linux/types.h> [...]
drivers/cpufreq/tegra124-cpufreq.c line 183
Quoted 4 lines
drivers/cpufreq/tegra124-cpufreq.c new file +4
-0+static struct platform_driver tegra124_cpufreq_platdrv = { + .driver = { + .name ="cpufreq-tegra124" , + .owner =THIS_MODULE ,.owner will always be, in short, NULL.
Quoted 4 lines
drivers/cpufreq/tegra124-cpufreq.c new file +4
-0+ }, + .probe = tegra124_cpufreq_probe, + .remove = tegra124_cpufreq_remove, +};[...]
Quoted 1 line
+module_init(tegra_cpufreq_init);
This might as well be, I think,
device_initcall().drivers/cpufreq/tegra124-cpufreq.c line 217
Quoted 3 lines
drivers/cpufreq/tegra124-cpufreq.c new file +3
-0+MODULE_AUTHOR ("Tuomas Tynkkynen <[email protected]>" ); +MODULE_DESCRIPTION ("cpufreq driver for NVIDIA Tegra124" ); +MODULE_LICENSE ("GPL v2" );The strings in these macros will always be preprocessed away, because this driver cannot become a module.
Quoted 2 lines
Paul Bolle
Well noticed! I changed the config symbol to be tristate.
Thanks,
Mikko Perttunen
Re: [PATCH v8 15/18] cpufreq: Add cpufreq driver for Tegra124
Quoted 5 lines · Mikko Perttunen
Quoted 4 lines · Paul Bolle
On Sun, 2015-03-01 at 14:44 +0200, Mikko Perttunen wrote:
[...]
Quoted 7 lines
Quoted 7 lines
drivers/cpufreq/tegra124-cpufreq.c line 183
Quoted 4 lines
drivers/cpufreq/tegra124-cpufreq.c new file +4
-0+static struct platform_driver tegra124_cpufreq_platdrv = { + .driver = { + .name ="cpufreq-tegra124" , + .owner =THIS_MODULE ,.owner will always be, in short, NULL.
Which reminds me: recently there have been cleanups that remove the .owner field assignments (e.g. 30f51f248c1d "cpufreq: drop owner assignment from platform_drivers"), so it can be removed from here as well.
Quoted 6 lines
Well noticed! I changed the config symbol to be tristate.
Thanks,
Mikko Perttunen
Re: [PATCH v8 15/18] cpufreq: Add cpufreq driver for Tegra124
Quoted 11 lines · Tuomas Tynkkynen
Quoted 10 lines · Mikko Perttunen
Quoted 9 lines · Paul Bolle
On Sun, 2015-03-01 at 14:44 +0200, Mikko Perttunen wrote:
[...]
Quoted 4 lines
drivers/cpufreq/tegra124-cpufreq.c new file +4
-0+static struct platform_driver tegra124_cpufreq_platdrv = { + .driver = { + .name ="cpufreq-tegra124" , + .owner =THIS_MODULE ,
Quoted 14 lines
Quoted 2 lines
Quoted 2 lines
.owner will always be, in short, NULL.
Which reminds me: recently there have been cleanups that remove the .owner field assignments (e.g.
30f51f248c1d"cpufreq: drop owner assignment fromplatform_drivers"), so it can be removed from here as well.Quoted 6 lines
Well noticed! I changed the config symbol to be tristate.
Thanks,
Mikko Perttunen
Yep, will remove.
Mikko
PATCH v8 16/18 ARM: tegra: Add entries for cpufreq on Tegra124
In reply to Mikko PerttunenFrom: Tuomas Tynkkynen <[email protected]>
The Tegra124 cpufreq driver relies on certain clocks being present in the /cpus/cpu at 0 node.
--- arch/arm/boot/dts/tegra124.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm/boot/dts/tegra124.dtsi +9 -0
@@ -915,6 +915,15 @@ device_type = "cpu"; compatible = "arm,cortex-a15"; 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"; + /* FIXME: what's the actual transition time? */ + clock-latency = <300000>; }; cpu at 1 {
Signature · 1 line
2.3.0
PATCH v8 17/18 ARM: tegra: Add CPU regulator to the Jetson TK1 device tree
In reply to Mikko PerttunenSpecify the CPU voltage regulator for the cpufreq driver.
--- arch/arm/boot/dts/tegra124-jetson-tk1.dts | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/tegra124-jetson-tk1.dts +6 -0
@@ -1782,6 +1782,12 @@ }; }; + cpus { + cpu at 0 { + vdd-cpu-supply = <&vdd_cpu>; + }; + }; + gpio-keys { compatible = "gpio-keys";
Signature · 1 line
2.3.0
PATCH v8 18/18 ARM: tegra: enable Tegra124 cpufreq driver by default
In reply to Mikko PerttunenFrom: Tuomas Tynkkynen <[email protected]>
The Tegra124 cpufreq driver depends on CONFIG_CPUFREQ_DT, so enable it to get the Tegra driver to build by default.
--- arch/arm/configs/tegra_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/configs/tegra_defconfig +1 -0
@@ -42,6 +42,7 @@ CONFIG_KEXEC=y CONFIG_CPU_FREQ=y CONFIG_CPU_FREQ_STAT_DETAILS=y CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y +CONFIG_CPUFREQ_DT=y CONFIG_CPU_IDLE=y CONFIG_VFP=y CONFIG_NEON=y
--
2.3.0
Hi Mike,
Have you had a chance to look at these changes to the Tegra clock driver? If you're fine with it, I'd like to take these patches through the Tegra tree because the rest of the series depends on them. I can provide a stable branch in case we need to base other Tegra clock changes on top of this.
Thierry
Quoted 122 lines · Mikko Perttunen
Hi, this is v8 of the Tegra124 cpufreq series. Aside rebasing on latest -next, the following changes have been done:
clk: tegra: Add binding for the Tegra124 DFLL clocksource
- Changed dfll@ -> clock@
- Changed compatibility string to "nvidia,tegra124-dfll"
- Clarified how the vdd-cpu-supply property is used
- Marked nvidia,cg-scale as optional since it is a boolean property
- Expanded the 'FS mode' term to 'full speed mode'
- Added dvco reset controlARM: tegra: Add the DFLL to Tegra124 device tree
- Changed dfll@ -> clock@
- Added dvco reset controlARM: tegra: Enable the DFLL on the Jetson TK1
- Changed dfll@ -> clock@clk: tegra: Initialize
PLL_XbeforeCCLK_Gto ensure it has a parent
- Addedclk: tegra: Introduce ability for SoC-specific reset control callbacks
- Addedclk: tegra: Add DFLL DVCO reset control for Tegra124
- Changed to use SoC-specific reset control callbackclk: tegra: Add Tegra124 DFLL clocksource platform driver
- Don't set DVCO reset handlersclk: tegra: Add library for the DFLL clock source (open-loop mode)
- Use reset control instead of function pointersalso added acks from v7.
The series is available in a git repository at
git://github.com/cyndis/linux.gitcldvfs-v8Tested by me on Jetson-TK1 (rev. D).
Original cover letter:
This series implements the DFLL/CL-DVFS clock source for the fast CPU cluster on Tegra124, and a cpufreq driver that uses the DFLL for clocking the CPU. Most of this is based on Paul Walmsley's public patch set from December 2013, which is available at
http://comments.gmane.org/gmane.linux.ports.tegra/15273The DFLL clock hardware is a voltage-controlled oscillator plus control logic that compares the generated output clock with a 51 MHz reference clock, and can make decisions to either lower or raise the DFLL voltage to keep the output rate close to the software-requested rate. The voltage changes are done by communicating with an off-chip PMIC via either I2C or PWM. As the DFLL oscillator is powered via the CPU rail, using the DFLL as the CPU clocksource also gives us dynamic CPU voltage scaling.
This series has been tested on the Jetson TK1 (Rev C). Porting this to the Venice2 should be simple, though do note that it does not have active cooling.
Thanks,
TuomasMikko Perttunen (3):
clk: tegra: Introduce ability for SoC-specific reset control callbacks
clk: tegra: InitializePLL_XbeforeCCLK_Gto ensure it has a parent
ARM: tegra: Add CPU regulator to the Jetson TK1 device treePaul Walmsley (1):
clk: tegra: Add DFLL DVCO reset control for Tegra124Tuomas Tynkkynen (14):
clk: tegra: Add binding for the Tegra124 DFLL clocksource
clk: tegra: Add library for the DFLL clock source (open-loop mode)
clk: tegra: Add closed loop support for the DFLL
clk: tegra: Add functions for parsing CVB tables
clk: tegra: Add Tegra124 DFLL clocksource platform driver
clk: tegra: Save/restoreCCLKG_BURST_POLICYon suspend
clk: tegra: Add the DFLL as a possible parent of thecclk_gclock
ARM: tegra: Add the DFLL to Tegra124 device tree
ARM: tegra: Enable the DFLL on the Jetson TK1
cpufreq: tegra124: Add device tree bindings
cpufreq: tegra: Rename tegra-cpufreq to tegra20-cpufreq
cpufreq: Add cpufreq driver for Tegra124
ARM: tegra: Add entries for cpufreq on Tegra124
ARM: tegra: enable Tegra124 cpufreq driver by default.../bindings/clock/nvidia,tegra124-dfll.txt | 79 + .../bindings/cpufreq/tegra124-cpufreq.txt | 44 + arch/arm/boot/dts/tegra124-jetson-tk1.dts | 15 +- arch/arm/boot/dts/tegra124.dtsi | 34 + arch/arm/configs/tegra_defconfig | 1 + arch/arm/mach-tegra/Kconfig | 1 + drivers/clk/tegra/Makefile | 3 + drivers/clk/tegra/clk-dfll.c | 1755 ++++++++++++++++++++ drivers/clk/tegra/clk-dfll.h | 54 + drivers/clk/tegra/clk-tegra-super-gen4.c | 50 +- drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 163 ++ drivers/clk/tegra/clk-tegra124.c | 82 + drivers/clk/tegra/clk.c | 36 +- drivers/clk/tegra/clk.h | 3 + drivers/clk/tegra/cvb.c | 133 ++ drivers/clk/tegra/cvb.h | 67 + drivers/cpufreq/Kconfig.arm | 13 +- drivers/cpufreq/Makefile | 3 +- drivers/cpufreq/tegra124-cpufreq.c | 217 +++ .../cpufreq/{tegra-cpufreq.c => tegra20-cpufreq.c} | 0 include/dt-bindings/reset/tegra124-car.h | 11 + 21 files changed, 2730 insertions(+), 34 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt create mode 100644 Documentation/devicetree/bindings/cpufreq/tegra124-cpufreq.txt create mode 100644 drivers/clk/tegra/clk-dfll.c create mode 100644 drivers/clk/tegra/clk-dfll.h create mode 100644 drivers/clk/tegra/clk-tegra124-dfll-fcpu.c create mode 100644 drivers/clk/tegra/cvb.c create mode 100644 drivers/clk/tegra/cvb.h create mode 100644 drivers/cpufreq/tegra124-cpufreq.c rename drivers/cpufreq/{tegra-cpufreq.c => tegra20-cpufreq.c} (100%) create mode 100644 include/dt-bindings/reset/tegra124-car.h
Quoted 3 lines
--
2.3.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150311/eebe9464/attachment.sig>
v8 cover Tegra124 CL-DVFS / DFLL clocksource + cpufreq
Quoting Thierry Reding (2015-03-11 03:07:43)
Quoted 7 lines
Hi Mike,
Have you had a chance to look at these changes to the Tegra clock driver? If you're fine with it, I'd like to take these patches through the Tegra tree because the rest of the series depends on them. I can provide a stable branch in case we need to base other Tegra clock changes on top of this.
Hi Thierry,
Clock patches (and corresponding DT binding descriptions and changes to DTS) look fine to me. Please add:
I did have a question about the beahvior of clk_put in one of Mikko's patches but it should not gate this series. I'm just trying to find out if we have a bug in the framework or if the Tegra driver is a special case.
Also I do not think a stable branch is necessary.
Regards,
Mike
Quoted 129 lines
Thierry
Quoted 125 lines · Mikko Perttunen
Hi, this is v8 of the Tegra124 cpufreq series. Aside rebasing on latest -next, the following changes have been done:
clk: tegra: Add binding for the Tegra124 DFLL clocksource
- Changed dfll@ -> clock@
- Changed compatibility string to "nvidia,tegra124-dfll"
- Clarified how the vdd-cpu-supply property is used
- Marked nvidia,cg-scale as optional since it is a boolean property
- Expanded the 'FS mode' term to 'full speed mode'
- Added dvco reset controlARM: tegra: Add the DFLL to Tegra124 device tree
- Changed dfll@ -> clock@
- Added dvco reset controlARM: tegra: Enable the DFLL on the Jetson TK1
- Changed dfll@ -> clock@clk: tegra: Initialize
PLL_XbeforeCCLK_Gto ensure it has a parent
- Addedclk: tegra: Introduce ability for SoC-specific reset control callbacks
- Addedclk: tegra: Add DFLL DVCO reset control for Tegra124
- Changed to use SoC-specific reset control callbackclk: tegra: Add Tegra124 DFLL clocksource platform driver
- Don't set DVCO reset handlersclk: tegra: Add library for the DFLL clock source (open-loop mode)
- Use reset control instead of function pointersalso added acks from v7.
The series is available in a git repository at
git://github.com/cyndis/linux.gitcldvfs-v8Tested by me on Jetson-TK1 (rev. D).
Original cover letter:
This series implements the DFLL/CL-DVFS clock source for the fast CPU cluster on Tegra124, and a cpufreq driver that uses the DFLL for clocking the CPU. Most of this is based on Paul Walmsley's public patch set from December 2013, which is available at
http://comments.gmane.org/gmane.linux.ports.tegra/15273The DFLL clock hardware is a voltage-controlled oscillator plus control logic that compares the generated output clock with a 51 MHz reference clock, and can make decisions to either lower or raise the DFLL voltage to keep the output rate close to the software-requested rate. The voltage changes are done by communicating with an off-chip PMIC via either I2C or PWM. As the DFLL oscillator is powered via the CPU rail, using the DFLL as the CPU clocksource also gives us dynamic CPU voltage scaling.
This series has been tested on the Jetson TK1 (Rev C). Porting this to the Venice2 should be simple, though do note that it does not have active cooling.
Thanks,
TuomasMikko Perttunen (3):
clk: tegra: Introduce ability for SoC-specific reset control callbacks
clk: tegra: InitializePLL_XbeforeCCLK_Gto ensure it has a parent
ARM: tegra: Add CPU regulator to the Jetson TK1 device treePaul Walmsley (1):
clk: tegra: Add DFLL DVCO reset control for Tegra124Tuomas Tynkkynen (14):
clk: tegra: Add binding for the Tegra124 DFLL clocksource
clk: tegra: Add library for the DFLL clock source (open-loop mode)
clk: tegra: Add closed loop support for the DFLL
clk: tegra: Add functions for parsing CVB tables
clk: tegra: Add Tegra124 DFLL clocksource platform driver
clk: tegra: Save/restoreCCLKG_BURST_POLICYon suspend
clk: tegra: Add the DFLL as a possible parent of thecclk_gclock
ARM: tegra: Add the DFLL to Tegra124 device tree
ARM: tegra: Enable the DFLL on the Jetson TK1
cpufreq: tegra124: Add device tree bindings
cpufreq: tegra: Rename tegra-cpufreq to tegra20-cpufreq
cpufreq: Add cpufreq driver for Tegra124
ARM: tegra: Add entries for cpufreq on Tegra124
ARM: tegra: enable Tegra124 cpufreq driver by default.../bindings/clock/nvidia,tegra124-dfll.txt | 79 + .../bindings/cpufreq/tegra124-cpufreq.txt | 44 + arch/arm/boot/dts/tegra124-jetson-tk1.dts | 15 +- arch/arm/boot/dts/tegra124.dtsi | 34 + arch/arm/configs/tegra_defconfig | 1 + arch/arm/mach-tegra/Kconfig | 1 + drivers/clk/tegra/Makefile | 3 + drivers/clk/tegra/clk-dfll.c | 1755 ++++++++++++++++++++ drivers/clk/tegra/clk-dfll.h | 54 + drivers/clk/tegra/clk-tegra-super-gen4.c | 50 +- drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 163 ++ drivers/clk/tegra/clk-tegra124.c | 82 + drivers/clk/tegra/clk.c | 36 +- drivers/clk/tegra/clk.h | 3 + drivers/clk/tegra/cvb.c | 133 ++ drivers/clk/tegra/cvb.h | 67 + drivers/cpufreq/Kconfig.arm | 13 +- drivers/cpufreq/Makefile | 3 +- drivers/cpufreq/tegra124-cpufreq.c | 217 +++ .../cpufreq/{tegra-cpufreq.c => tegra20-cpufreq.c} | 0 include/dt-bindings/reset/tegra124-car.h | 11 + 21 files changed, 2730 insertions(+), 34 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txt create mode 100644 Documentation/devicetree/bindings/cpufreq/tegra124-cpufreq.txt create mode 100644 drivers/clk/tegra/clk-dfll.c create mode 100644 drivers/clk/tegra/clk-dfll.h create mode 100644 drivers/clk/tegra/clk-tegra124-dfll-fcpu.c create mode 100644 drivers/clk/tegra/cvb.c create mode 100644 drivers/clk/tegra/cvb.h create mode 100644 drivers/cpufreq/tegra124-cpufreq.c rename drivers/cpufreq/{tegra-cpufreq.c => tegra20-cpufreq.c} (100%) create mode 100644 include/dt-bindings/reset/tegra124-car.h--
2.3.0
Quoted 21 lines · Michael Turquette
Quoting Thierry Reding (2015-03-11 03:07:43)
Quoted 7 lines
Hi Mike,
Have you had a chance to look at these changes to the Tegra clock driver? If you're fine with it, I'd like to take these patches through the Tegra tree because the rest of the series depends on them. I can provide a stable branch in case we need to base other Tegra clock changes on top of this.
Hi Thierry,
Clock patches (and corresponding DT binding descriptions and changes to DTS) look fine to me. Please add:
I did have a question about the beahvior of
clk_putin one of Mikko's patches but it should not gate this series. I'm just trying to find out if we have a bug in the framework or if the Tegra driver is a special case.
Quoted 5 lines
Also I do not think a stable branch is necessary.
Regards,
Mike
Looks like in the meantime, this has been partially broken by 03bc10ab5b0f "clk: check ->determine/round_rate() return value in clk_calc_new_rates". The highest rates supported by the DFLL clock have 1 in the MSB, so those cannot be entered after the aforementioned patch, as the return value of round_rate is interpreted as an error. Avenues that I can see: 1) revert the above patch 2) restrict the cpu clock rate to those with 0 in the MSB 3) move to 64-bit clock rates.
Cheers,
Mikko.
Quoted 129 lines
Quoted 129 lines
Thierry
Quoted 125 lines · Mikko Perttunen
Hi, this is v8 of the Tegra124 cpufreq series. Aside rebasing on latest -next, the following changes have been done:
clk: tegra: Add binding for the Tegra124 DFLL clocksource
- Changed dfll@ -> clock@
- Changed compatibility string to "nvidia,tegra124-dfll"
- Clarified how the vdd-cpu-supply property is used
- Marked nvidia,cg-scale as optional since it is a boolean property
- Expanded the 'FS mode' term to 'full speed mode'
- Added dvco reset controlARM: tegra: Add the DFLL to Tegra124 device tree
- Changed dfll@ -> clock@
- Added dvco reset controlARM: tegra: Enable the DFLL on the Jetson TK1
- Changed dfll@ -> clock@clk: tegra: Initialize
PLL_XbeforeCCLK_Gto ensure it has a parent
- Addedclk: tegra: Introduce ability for SoC-specific reset control callbacks
- Addedclk: tegra: Add DFLL DVCO reset control for Tegra124
- Changed to use SoC-specific reset control callbackclk: tegra: Add Tegra124 DFLL clocksource platform driver
- Don't set DVCO reset handlersclk: tegra: Add library for the DFLL clock source (open-loop mode)
- Use reset control instead of function pointersalso added acks from v7.
The series is available in a git repository at
git://github.com/cyndis/linux.gitcldvfs-v8Tested by me on Jetson-TK1 (rev. D).
Original cover letter:
This series implements the DFLL/CL-DVFS clock source for the fast CPU cluster on Tegra124, and a cpufreq driver that uses the DFLL for clocking the CPU. Most of this is based on Paul Walmsley's public patch set from December 2013, which is available at
http://comments.gmane.org/gmane.linux.ports.tegra/15273The DFLL clock hardware is a voltage-controlled oscillator plus control logic that compares the generated output clock with a 51 MHz reference clock, and can make decisions to either lower or raise the DFLL voltage to keep the output rate close to the software-requested rate. The voltage changes are done by communicating with an off-chip PMIC via either I2C or PWM. As the DFLL oscillator is powered via the CPU rail, using the DFLL as the CPU clocksource also gives us dynamic CPU voltage scaling.
This series has been tested on the Jetson TK1 (Rev C). Porting this to the Venice2 should be simple, though do note that it does not have active cooling.
Thanks,
TuomasMikko Perttunen (3):
clk: tegra: Introduce ability for SoC-specific reset control callbacks
clk: tegra: InitializePLL_XbeforeCCLK_Gto ensure it has a parent
ARM: tegra: Add CPU regulator to the Jetson TK1 device treePaul Walmsley (1):
clk: tegra: Add DFLL DVCO reset control for Tegra124Tuomas Tynkkynen (14):
clk: tegra: Add binding for the Tegra124 DFLL clocksource
clk: tegra: Add library for the DFLL clock source (open-loop mode)
clk: tegra: Add closed loop support for the DFLL
clk: tegra: Add functions for parsing CVB tables
clk: tegra: Add Tegra124 DFLL clocksource platform driver
clk: tegra: Save/restoreCCLKG_BURST_POLICYon suspend
clk: tegra: Add the DFLL as a possible parent of thecclk_gclock
ARM: tegra: Add the DFLL to Tegra124 device tree
ARM: tegra: Enable the DFLL on the Jetson TK1
cpufreq: tegra124: Add device tree bindings
cpufreq: tegra: Rename tegra-cpufreq to tegra20-cpufreq
cpufreq: Add cpufreq driver for Tegra124
ARM: tegra: Add entries for cpufreq on Tegra124
ARM: tegra: enable Tegra124 cpufreq driver by default.../bindings/clock/nvidia,tegra124-dfll.txt | 79 + .../bindings/cpufreq/tegra124-cpufreq.txt | 44 + arch/arm/boot/dts/tegra124-jetson-tk1.dts | 15 +- arch/arm/boot/dts/tegra124.dtsi | 34 + arch/arm/configs/tegra_defconfig | 1 + arch/arm/mach-tegra/Kconfig | 1 + drivers/clk/tegra/Makefile | 3 + drivers/clk/tegra/clk-dfll.c | 1755 ++++++++++++++++++++ drivers/clk/tegra/clk-dfll.h | 54 + drivers/clk/tegra/clk-tegra-super-gen4.c | 50 +- drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 163 ++ drivers/clk/tegra/clk-tegra124.c | 82 + drivers/clk/tegra/clk.c | 36 +- drivers/clk/tegra/clk.h | 3 + drivers/clk/tegra/cvb.c | 133 ++ drivers/clk/tegra/cvb.h | 67 + drivers/cpufreq/Kconfig.arm | 13 +- drivers/cpufreq/Makefile | 3 +- drivers/cpufreq/tegra124-cpufreq.c | 217 +++ .../cpufreq/{tegra-cpufreq.c => tegra20-cpufreq.c} | 0 include/dt-bindings/reset/tegra124-car.h | 11 + 21 files changed, 2730 insertions(+), 34 deletions(-)create mode 100644
Documentation/devicetree/bindings/clock/nvidia,tegra124-dfll.txtcreate mode 100644Documentation/devicetree/bindings/cpufreq/tegra124-cpufreq.txtcreate mode 100644drivers/clk/tegra/clk-dfll.c
create mode 100644drivers/clk/tegra/clk-dfll.h
create mode 100644drivers/clk/tegra/clk-tegra124-dfll-fcpu.c
create mode 100644drivers/clk/tegra/cvb.c
create mode 100644drivers/clk/tegra/cvb.h
create mode 100644drivers/cpufreq/tegra124-cpufreq.c
renamedrivers/cpufreq/{tegra-cpufreq.c=>tegra20-cpufreq.c} (100%) create mode 100644include/dt-bindings/reset/tegra124-car.h--
2.3.0
Hi Mikko,
Quoted 28 lines · On Tue, 14 Apr 2015 14:25:59 +0300 Mikko Perttunen <[email protected]>…
Quoted 21 lines · Michael Turquette
Quoting Thierry Reding (2015-03-11 03:07:43)
Quoted 7 lines
Hi Mike,
Have you had a chance to look at these changes to the Tegra clock driver? If you're fine with it, I'd like to take these patches through the Tegra tree because the rest of the series depends on them. I can provide a stable branch in case we need to base other Tegra clock changes on top of this.
Hi Thierry,
Clock patches (and corresponding DT binding descriptions and changes to DTS) look fine to me. Please add:
I did have a question about the beahvior of
clk_putin one of Mikko's patches but it should not gate this series. I'm just trying to find out if we have a bug in the framework or if the Tegra driver is a special case.Quoted 5 lines
Also I do not think a stable branch is necessary.
Regards,
Mike
Quoted 7 lines
Looks like in the meantime, this has been partially broken by
03bc10ab5b0f"clk: check ->determine/round_rate() return value inclk_calc_new_rates". The highest rates supported by the DFLL clock have 1 in the MSB, so those cannot be entered after the aforementioned patch, as the return value ofround_rateis interpreted as an error. Avenues that I can see: 1) revert the above patch 2) restrict the cpu clock rate to those with 0 in the MSB 3) move to 64-bit clock rates.
How about changing ->determine_rate() and ->round_rate() prototypes so that they always return 0 or an error code and passing the adjusted_rate as an argument ?
Something like that:
int (*round_rate)(struct clk_hw *hw, unsigned long *rate,
unsigned long *parent_rate);
int (*determine_rate)(struct clk_hw *hw, unsigned long *rate,
unsigned long min_rate, unsigned long max_rate, unsigned long *best_parent_rate, struct clk_hw **best_parent_hw);
I know this implies a lot of changes (in all clock drivers and in the core infrastructure), but I really think we should not mix error codes and clock frequencies (even if we decide to move to a 64 bits rate approach).
Anyway, IMHO the only alternative to this solution is solution #3, because #1 implies re-introducing another bug where ->round_rate()/->determine_rate() are silently ignored, and #2 implies lying about your DFLL capabilities.
Mike, what's your opinion ?
Best Regards,
Boris
Signature · 3 lines
Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Quoted 55 lines · Boris Brezillon
Hi Mikko,
Quoted 28 lines · On Tue, 14 Apr 2015 14:25:59 +0300 Mikko Perttunen <[email protected]>…
Quoted 21 lines · Michael Turquette
Quoting Thierry Reding (2015-03-11 03:07:43)
Quoted 7 lines
Hi Mike,
Have you had a chance to look at these changes to the Tegra clock driver? If you're fine with it, I'd like to take these patches through the Tegra tree because the rest of the series depends on them. I can provide a stable branch in case we need to base other Tegra clock changes on top of this.
Hi Thierry,
Clock patches (and corresponding DT binding descriptions and changes to DTS) look fine to me. Please add:
I did have a question about the beahvior of
clk_putin one of Mikko's patches but it should not gate this series. I'm just trying to find out if we have a bug in the framework or if the Tegra driver is a special case.Quoted 5 lines
Also I do not think a stable branch is necessary.
Regards,
MikeQuoted 7 lines
Looks like in the meantime, this has been partially broken by
03bc10ab5b0f"clk: check ->determine/round_rate() return value inclk_calc_new_rates". The highest rates supported by the DFLL clock have 1 in the MSB, so those cannot be entered after the aforementioned patch, as the return value ofround_rateis interpreted as an error. Avenues that I can see: 1) revert the above patch 2) restrict the cpu clock rate to those with 0 in the MSB 3) move to 64-bit clock rates.How about changing ->determine_rate() and ->round_rate() prototypes so that they always return 0 or an error code and passing the
adjusted_rateas an argument ?Something like that:
int (*round_rate)(struct
clk_hw*hw, unsigned long *rate,
unsigned long*parent_rate);
int (*determine_rate)(structclk_hw*hw, unsigned long *rate,
unsigned longmin_rate, unsigned longmax_rate, unsigned long*best_parent_rate, structclk_hw**best_parent_hw);
Quoted 4 lines
I know this implies a lot of changes (in all clock drivers and in the core infrastructure), but I really think we should not mix error codes and clock frequencies (even if we decide to move to a 64 bits rate approach).
This sounds like a good idea, too.
Quoted 6 lines
Anyway, IMHO the only alternative to this solution is solution #3, because #1 implies re-introducing another bug where ->round_rate()/->determine_rate() are silently ignored, and #2 implies lying about your DFLL capabilities.
Yeah, #1 and #2 weren't really meant as realistic options to end up with :)
Quoted 6 lines
Mike, what's your opinion ?
Best Regards,
Boris
Cheers,
Mikko.
Quoting Mikko Perttunen (2015-04-14 12:40:36)
Quoted 56 lines · Boris Brezillon
Quoted 55 lines
Hi Mikko,
Quoted 28 lines · On Tue, 14 Apr 2015 14:25:59 +0300 Mikko Perttunen <[email protected]>…
Quoted 21 lines · Michael Turquette
Quoting Thierry Reding (2015-03-11 03:07:43)
Quoted 7 lines
Hi Mike,
Have you had a chance to look at these changes to the Tegra clock driver? If you're fine with it, I'd like to take these patches through the Tegra tree because the rest of the series depends on them. I can provide a stable branch in case we need to base other Tegra clock changes on top of this.
Hi Thierry,
Clock patches (and corresponding DT binding descriptions and changes to DTS) look fine to me. Please add:
I did have a question about the beahvior of
clk_putin one of Mikko's patches but it should not gate this series. I'm just trying to find out if we have a bug in the framework or if the Tegra driver is a special case.Quoted 5 lines
Also I do not think a stable branch is necessary.
Regards,
MikeQuoted 7 lines
Looks like in the meantime, this has been partially broken by
03bc10ab5b0f"clk: check ->determine/round_rate() return value inclk_calc_new_rates". The highest rates supported by the DFLL clock have 1 in the MSB, so those cannot be entered after the aforementioned patch, as the return value ofround_rateis interpreted as an error. Avenues that I can see: 1) revert the above patch 2) restrict the cpu clock rate to those with 0 in the MSB 3) move to 64-bit clock rates.How about changing ->determine_rate() and ->round_rate() prototypes so that they always return 0 or an error code and passing the
adjusted_rateas an argument ?Something like that:
int (*round_rate)(struct
clk_hw*hw, unsigned long *rate,
unsigned long*parent_rate);
int (*determine_rate)(structclk_hw*hw, unsigned long *rate,
unsigned longmin_rate, unsigned longmax_rate, unsigned long*best_parent_rate, structclk_hw**best_parent_hw);
Quoted 6 lines
Quoted 4 lines
I know this implies a lot of changes (in all clock drivers and in the core infrastructure), but I really think we should not mix error codes and clock frequencies (even if we decide to move to a 64 bits rate approach).
This sounds like a good idea, too.
I've had this idea as well, which is to never return rates but only error codes, and rates are passed by reference like in your example above. Clearly the *best_parent_rate stuff already functions this way. Would be cool to use a programming language that supported complex return types ;-)
Quoted 9 lines
Quoted 7 lines
Anyway, IMHO the only alternative to this solution is solution #3, because #1 implies re-introducing another bug where ->round_rate()/->determine_rate() are silently ignored, and #2 implies lying about your DFLL capabilities.
Yeah, #1 and #2 weren't really meant as realistic options to end up with :)
Yes, seems that we're heading towards #3. In the mean time option #1.5 (the one where we change the round_rate/determine_rate semantics) is probably a good idea and can resolve this issue in the shorter term compared to signed 64-bit rates (and will be necessary anyhow if we use unsigned 64-bit rates).
I'll add this to the high priority todo list since the Tegra EMC stuff won't go for 4.1 but will very likely go for 4.2.
Regards,
Mike
Quoted 11 lines
Quoted 7 lines
Mike, what's your opinion ?
Best Regards,
Boris
Cheers,
Mikko.
Quoted 62 lines · Michael Turquette
Quoting Mikko Perttunen (2015-04-14 12:40:36)
Quoted 61 lines · Boris Brezillon
Quoted 59 lines
Hi Mikko,
Quoted 28 lines · On Tue, 14 Apr 2015 14:25:59 +0300 Mikko Perttunen <[email protected]>…
Quoted 21 lines · Michael Turquette
Quoting Thierry Reding (2015-03-11 03:07:43)
Quoted 7 lines
Hi Mike,
Have you had a chance to look at these changes to the Tegra clock driver? If you're fine with it, I'd like to take these patches through the Tegra tree because the rest of the series depends on them. I can provide a stable branch in case we need to base other Tegra clock changes on top of this.
Hi Thierry,
Clock patches (and corresponding DT binding descriptions and changes to DTS) look fine to me. Please add:
I did have a question about the beahvior of
clk_putin one of Mikko's patches but it should not gate this series. I'm just trying to find out if we have a bug in the framework or if the Tegra driver is a special case.Quoted 5 lines
Also I do not think a stable branch is necessary.
Regards,
MikeQuoted 7 lines
Looks like in the meantime, this has been partially broken by
03bc10ab5b0f"clk: check ->determine/round_rate() return value inclk_calc_new_rates". The highest rates supported by the DFLL clock have 1 in the MSB, so those cannot be entered after the aforementioned patch, as the return value ofround_rateis interpreted as an error. Avenues that I can see: 1) revert the above patch 2) restrict the cpu clock rate to those with 0 in the MSB 3) move to 64-bit clock rates.How about changing ->determine_rate() and ->round_rate() prototypes so that they always return 0 or an error code and passing the
adjusted_rateas an argument ?Something like that:
int (*round_rate)(struct
clk_hw*hw, unsigned long *rate,
unsigned long*parent_rate);
int (*determine_rate)(structclk_hw*hw, unsigned long *rate,
unsigned longmin_rate, unsigned longmax_rate, unsigned long*best_parent_rate, structclk_hw**best_parent_hw);I know this implies a lot of changes (in all clock drivers and in the core infrastructure), but I really think we should not mix error codes and clock frequencies (even if we decide to move to a 64 bits rate approach).
Quoted 7 lines
Quoted 1 line
This sounds like a good idea, too.
I've had this idea as well, which is to never return rates but only error codes, and rates are passed by reference like in your example above. Clearly the
*best_parent_ratestuff already functions this way. Would be cool to use a programming language that supported complex return types ;-)
Algebraic data type pipe dreams.. :)
Quoted 11 lines
Quoted 10 lines
Quoted 8 lines
Anyway, IMHO the only alternative to this solution is solution #3, because #1 implies re-introducing another bug where ->round_rate()/->determine_rate() are silently ignored, and #2 implies lying about your DFLL capabilities.
Yeah, #1 and #2 weren't really meant as realistic options to end up with :)
Quoted 8 lines
Yes, seems that we're heading towards #3. In the mean time option #1.5 (the one where we change the round_rate/determine_rate semantics) is probably a good idea and can resolve this issue in the shorter term compared to signed 64-bit rates (and will be necessary anyhow if we use unsigned 64-bit rates).
I'll add this to the high priority todo list since the Tegra EMC stuff won't go for 4.1 but will very likely go for 4.2.
Wonderful :)
Thanks,
Mikko
Quoted 15 lines
Regards,
MikeQuoted 11 lines
Quoted 7 lines
Mike, what's your opinion ?
Best Regards,
Boris
Cheers,
Mikko.
Quoted 14 lines · Michael Turquette
Quoting Thierry Reding (2015-03-11 03:07:43)
Quoted 7 lines
Hi Mike,
Have you had a chance to look at these changes to the Tegra clock driver? If you're fine with it, I'd like to take these patches through the Tegra tree because the rest of the series depends on them. I can provide a stable branch in case we need to base other Tegra clock changes on top of this.
Hi Thierry,
Clock patches (and corresponding DT binding descriptions and changes to DTS) look fine to me. Please add:
Quoted 8 lines
I did have a question about the beahvior of
clk_putin one of Mikko's patches but it should not gate this series. I'm just trying to find out if we have a bug in the framework or if the Tegra driver is a special case.Also I do not think a stable branch is necessary.
Given how this didn't work at all for v4.1, why don't we try to do this the conventional way for v4.2? What I propose is that I collect all the patches that I've had in these branches into a single branch that I can send you shortly after v4.1-rc1. Then you can pull that into the clock tree when you're happy and I can pull that into the Tegra tree again if needed to resolve dependencies.
One problem that I foresee is that the EMC clock driver relies on some symbols exported by the EMC driver, so it will fail to build on its own if merged into the clock tree. Usually I'd say we can solve this by merging a stable branch from the Tegra tree into the clock tree, but if any of the ARM SoC maintainers then decides that, for whatever reason, the Tegra pull request isn't good enough, you'd need to either redo the clock tree or we slip in the changes via the clock tree anyway.
Perhaps a solution would be to implement stubs for the API exposed by the EMC driver and merge that through the clock tree, which should give us a tree that can be built but be a no-op at runtime. Then we can add the actual code to enable EMC scaling in the Tegra tree by providing a real implementation. That way we only have the Tegra tree depend on the clock tree.
How does that sound?
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150414/d4f41106/attachment.sig>
v8 cover Tegra124 CL-DVFS / DFLL clocksource + cpufreq
Quoting Thierry Reding (2015-04-14 07:43:41)
Quoted 22 lines · Michael Turquette
Quoted 21 lines
Quoting Thierry Reding (2015-03-11 03:07:43)
Quoted 7 lines
Hi Mike,
Have you had a chance to look at these changes to the Tegra clock driver? If you're fine with it, I'd like to take these patches through the Tegra tree because the rest of the series depends on them. I can provide a stable branch in case we need to base other Tegra clock changes on top of this.
Hi Thierry,
Clock patches (and corresponding DT binding descriptions and changes to DTS) look fine to me. Please add:
I did have a question about the beahvior of
clk_putin one of Mikko's patches but it should not gate this series. I'm just trying to find out if we have a bug in the framework or if the Tegra driver is a special case.
Quoted 8 lines
Quoted 1 line
Also I do not think a stable branch is necessary.
Given how this didn't work at all for v4.1, why don't we try to do this the conventional way for v4.2? What I propose is that I collect all the patches that I've had in these branches into a single branch that I can send you shortly after v4.1-rc1. Then you can pull that into the clock tree when you're happy and I can pull that into the Tegra tree again if needed to resolve dependencies.
Sounds fine, so long as you do not rebase your branch.
Quoted 9 lines
One problem that I foresee is that the EMC clock driver relies on some symbols exported by the EMC driver, so it will fail to build on its own if merged into the clock tree. Usually I'd say we can solve this by merging a stable branch from the Tegra tree into the clock tree, but if any of the ARM SoC maintainers then decides that, for whatever reason, the Tegra pull request isn't good enough, you'd need to either redo the clock tree or we slip in the changes via the clock tree anyway.
Quoted 6 lines
Perhaps a solution would be to implement stubs for the API exposed by the EMC driver and merge that through the clock tree, which should give us a tree that can be built but be a no-op at runtime. Then we can add the actual code to enable EMC scaling in the Tegra tree by providing a real implementation. That way we only have the Tegra tree depend on the clock tree.
That sounds OK, but it does create some extra work for you. Alternatively you can just take these patches through your tegra tree into arm-soc with my Ack (which is the reason I gave it out in the first place).
However if you have other clock patches which conflict then having the stable branch makes good sense. The choice is yours since it will be an extra burden on your to stub things out.
Regards,
Mike
Quoted 4 lines
How does that sound?
Thierry