Tegra114 clockframework
v5 cover Tegra114 clockframework
This is the fifth version of the Tegra114 clockframework. It is based on the for-next branch ofgit://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-tegra.git and
http://www.spinics.net/lists/arm-kernel/msg220452.html.
It has been boottested on Pluto.
Changes from v4:
* Split the new PLL types patch into smaller patches
* Fix some bugs in the PLL patches
Changes from v3:
* Merge with for-next branch
* Provide empty tegra_cpu_car_ops to make SMP boot not crash
Changes from v2:
* Added missing PLLs
* Added bindings to tegra114.dtsi
* Moved the table patch for clk-mux.c to 'clk: add table lookup to mux'
* Bugfixes
Changes from v1:
* Remove SATA and PCIe clocks. They don't appear in the internal TRM, so I assume they don't exist.
* Rebase on top of Hiroshi's latest Tegra114 patches
* More generic mux code. This is necessary for the AHUB and DAM clocks.
TODO:
* Remove clk_register_clkdev() where possible
* PLL clock init functions are incomplete and/or need refactoring
* Superclocks are missing
* The audio clocks are almost the same then Tegra30. Refactor the code to avoid duplication.
* Should blink and blink_override be clocks?
Peter De Schrijver (10):
clk: tegra: Refactor PLL programming code
clk: tegra: Add TEGRA_PLL_BYPASS flag
clk: tegra: Add PLL post divider table
clk: tegra: Add new fields and PLL types for Tegra114
clk: tegra: Add flags to tegra_clk_periph()
clk: tegra: Workaround for Tegra114 MSENC problem
ARM: tegra: Define Tegra114 CAR binding
ARM: dt: Add references to tegra_car clocks
clk: tegra: Implement clocks for Tegra114
clk: tegra: devicetree match for nvidia,tegra114-car
.../bindings/clock/nvidia,tegra114-car.txt | 311 +++ arch/arm/boot/dts/tegra114.dtsi | 7 +- drivers/clk/tegra/Makefile | 1 + drivers/clk/tegra/clk-periph-gate.c | 9 + drivers/clk/tegra/clk-periph.c | 11 +- drivers/clk/tegra/clk-pll.c | 940 +++++++++- drivers/clk/tegra/clk-tegra114.c | 2002 ++++++++++++++++++++ drivers/clk/tegra/clk-tegra20.c | 153 +- drivers/clk/tegra/clk-tegra30.c | 243 ++-- drivers/clk/tegra/clk.c | 1 + drivers/clk/tegra/clk.h | 85 +- 11 files changed, 3481 insertions(+), 282 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/nvidia,tegra114-car.txt create mode 100644 drivers/clk/tegra/clk-tegra114.c
PATCH v5 1/10 clk: tegra: Refactor PLL programming code
Refactor the PLL programming code to make it useable by the new PLL types introduced by Tegra114.
The following changes were done:
* Split programming the PLL into updating m,n,p and updating cpcon
* Move locking from _update_pll_cpcon() to clk_pll_set_rate()
* Introduce _get_pll_mnp() helper
* Move check for identical m,n,p values to clk_pll_set_rate()
* struct tegra_clk_pll_freq_table will always contain the values as defined by the hardware.
* Simplify the arguments to clk_pll_wait_for_lock()
--- drivers/clk/tegra/clk-pll.c | 178 +++++++++++++++++------------ drivers/clk/tegra/clk-tegra20.c | 144 ++++++++++++------------ drivers/clk/tegra/clk-tegra30.c | 234 +++++++++++++++++++------------------- 3 files changed, 294 insertions(+), 262 deletions(-)
drivers/clk/tegra/clk-pll.c +105 -73
@@ -1,5 +1,5 @@/* -* Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. +* Copyright (c) 2012, 2013, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License,
@@ -113,20 +113,23 @@ static void clk_pll_enable_lock(struct tegra_clk_pll *pll)pll_writel_misc (val, pll); } -static int clk_pll_wait_for_lock (struct tegra_clk_pll *pll, -void __iomem *lock_addr,u32 lock_bit_idx) +static int clk_pll_wait_for_lock (struct tegra_clk_pll *pll) {int i; -u32 val; +u32 val, lock_bit; +void __iomem *lock_addr;if (!(pll->flags &TEGRA_PLL_USE_LOCK )) {udelay (pll->params->lock_delay);return 0 ; } + lock_addr = pll->clk_base + pll->params->base_reg; + lock_bit =BIT (pll->params->lock_bit_idx); +for (i =0 ; i < pll->params->lock_delay; i++) { val =readl_relaxed (lock_addr); -if (val &BIT (lock_bit_idx)) { +if (val & lock_bit) {udelay (PLL_POST_LOCK_DELAY );return 0 ; }
@@ -155,7 +158,7 @@ static int clk_pll_is_enabled(struct clk_hw *hw)return val &PLL_BASE_ENABLE ?1 :0 ; } -static int _clk_pll_enable (struct clk_hw *hw) +static void _clk_pll_enable (struct clk_hw *hw) {struct tegra_clk_pll *pll =to_clk_pll (hw);u32 val;
@@ -172,11 +175,6 @@ static int _clk_pll_enable(struct clk_hw *hw) val |=PMC_PLLP_WB0_OVERRIDE_PLLM_ENABLE ;writel_relaxed (val, pll->pmc +PMC_PLLP_WB0_OVERRIDE ); } - -clk_pll_wait_for_lock (pll, pll->clk_base + pll->params->base_reg, - pll->params->lock_bit_idx); - -return 0 ; }static void _clk_pll_disable (struct clk_hw *hw)
@@ -204,7 +202,9 @@ static int clk_pll_enable(struct clk_hw *hw)if (pll->lock)spin_lock_irqsave (pll->lock, flags); - ret =_clk_pll_enable (hw); +_clk_pll_enable (hw); + + ret =clk_pll_wait_for_lock (pll);if (pll->lock)spin_unlock_irqrestore (pll->lock, flags);
@@ -241,8 +241,6 @@ static int _get_table_rate(struct clk_hw *hw,if (sel->input_rate ==0 )return -EINVAL ; -BUG_ON (sel->p <1 ); - cfg->input_rate = sel->input_rate; cfg->output_rate = sel->output_rate; cfg->m = sel->m;
@@ -290,88 +288,109 @@ static int _calc_rate(struct clk_hw *hw, struct tegra_clk_pll_freq_table *cfg, cfg->output_rate <<= 1) p_div++; - cfg->p =1 << p_div; + cfg->p = p_div; cfg->m = parent_rate / cfreq; cfg->n = cfg->output_rate / cfreq; cfg->cpcon =OUT_OF_TABLE_CPCON ;if (cfg->m >divm_max (pll) || cfg->n >divn_max (pll) || - cfg->p >divp_max (pll) || cfg->output_rate > pll->params->vco_max) { + (1 << p_div) >divp_max (pll) + || cfg->output_rate > pll->params->vco_max) {pr_err ("%s: Failed to set %s rate %lu\n" , __func__,__clk_get_name (hw->clk), rate);return -EINVAL ; } +if (pll->flags &TEGRA_PLLU ) + cfg->p ^=1 ; +return 0 ; } -static int _program_pll (struct clk_hw *hw,struct tegra_clk_pll_freq_table *cfg, -unsigned long rate) +static void _update_pll_mnp (struct tegra_clk_pll *pll, +struct tegra_clk_pll_freq_table *cfg) { -struct tegra_clk_pll *pll =to_clk_pll (hw); -unsigned long flags =0 ; -u32 divp, val, old_base; -int state; - - divp =__ffs (cfg->p); - -if (pll->flags &TEGRA_PLLU ) - divp ^=1 ; +u32 val; -if (pll->lock) -spin_lock_irqsave (pll->lock, flags); + val =pll_readl_base (pll); - old_base = val =pll_readl_base (pll); val &= ~((divm_mask (pll) << pll->divm_shift) | (divn_mask (pll) << pll->divn_shift) | (divp_mask (pll) << pll->divp_shift)); val |= ((cfg->m << pll->divm_shift) | (cfg->n << pll->divn_shift) | - (divp << pll->divp_shift)); -if (val == old_base) { -if (pll->lock) -spin_unlock_irqrestore (pll->lock, flags); -return 0 ; + (cfg->p << pll->divp_shift)); + +pll_writel_base (val, pll); +} + +static void _get_pll_mnp (struct tegra_clk_pll *pll, +struct tegra_clk_pll_freq_table *cfg) +{ +u32 val; + + val =pll_readl_base (pll); + + cfg->m = (val >> pll->divm_shift) & (divm_mask (pll)); + cfg->n = (val >> pll->divn_shift) & (divn_mask (pll)); + cfg->p = (val >> pll->divp_shift) & (divp_mask (pll)); +} + +static void _update_pll_cpcon (struct tegra_clk_pll *pll, +struct tegra_clk_pll_freq_table *cfg, +unsigned long rate) +{ +u32 val; + + val =pll_readl_misc (pll); + + val &= ~(PLL_MISC_CPCON_MASK <<PLL_MISC_CPCON_SHIFT ); + val |= cfg->cpcon <<PLL_MISC_CPCON_SHIFT ; + +if (pll->flags &TEGRA_PLL_SET_LFCON ) { + val &= ~(PLL_MISC_LFCON_MASK <<PLL_MISC_LFCON_SHIFT ); +if (cfg->n >=PLLDU_LFCON_SET_DIVN ) + val |=1 <<PLL_MISC_LFCON_SHIFT ; + }else if (pll->flags &TEGRA_PLL_SET_DCCON ) { + val &= ~(1 <<PLL_MISC_DCCON_SHIFT ); +if (rate >= (pll->params->vco_max >>1 )) + val |=1 <<PLL_MISC_DCCON_SHIFT ; } +pll_writel_misc (val, pll); +} + +static int _program_pll (struct clk_hw *hw,struct tegra_clk_pll_freq_table *cfg, +unsigned long rate) +{ +struct tegra_clk_pll *pll =to_clk_pll (hw); +int state, ret =0 ; + state =clk_pll_is_enabled (hw); -if (state) { +if (state)_clk_pll_disable (hw); - val &= ~(PLL_BASE_BYPASS |PLL_BASE_ENABLE ); - } -pll_writel_base (val, pll); -if (pll->flags &TEGRA_PLL_HAS_CPCON ) { - val =pll_readl_misc (pll); - val &= ~(PLL_MISC_CPCON_MASK <<PLL_MISC_CPCON_SHIFT ); - val |= cfg->cpcon <<PLL_MISC_CPCON_SHIFT ; -if (pll->flags &TEGRA_PLL_SET_LFCON ) { - val &= ~(PLL_MISC_LFCON_MASK <<PLL_MISC_LFCON_SHIFT ); -if (cfg->n >=PLLDU_LFCON_SET_DIVN ) - val |=0x1 <<PLL_MISC_LFCON_SHIFT ; - }else if (pll->flags &TEGRA_PLL_SET_DCCON ) { - val &= ~(0x1 <<PLL_MISC_DCCON_SHIFT ); -if (rate >= (pll->params->vco_max >>1 )) - val |=0x1 <<PLL_MISC_DCCON_SHIFT ; - } -pll_writel_misc (val, pll); - } +_update_pll_mnp (pll, cfg); -if (pll->lock) -spin_unlock_irqrestore (pll->lock, flags); +if (pll->flags &TEGRA_PLL_HAS_CPCON ) +_update_pll_cpcon (pll, cfg, rate); -if (state) -clk_pll_enable (hw); +if (state) { +_clk_pll_enable (hw); + ret =clk_pll_wait_for_lock (pll); + } -return 0 ; +return ret; }static int clk_pll_set_rate (struct clk_hw *hw,unsigned long rate,unsigned long parent_rate) {struct tegra_clk_pll *pll =to_clk_pll (hw); -struct tegra_clk_pll_freq_table cfg; +struct tegra_clk_pll_freq_table cfg, old_cfg; +unsigned long flags =0 ; +int ret =0 ;if (pll->flags &TEGRA_PLL_FIXED ) {if (rate != pll->fixed_rate) {
@@ -387,7 +406,18 @@ static int clk_pll_set_rate(struct clk_hw *hw, unsigned long rate, _calc_rate(hw, &cfg, rate, parent_rate))return -EINVAL ; -return _program_pll (hw, &cfg, rate); +if (pll->lock) +spin_lock_irqsave (pll->lock, flags); + +_get_pll_mnp (pll, &old_cfg); + +if (old_cfg.m != cfg.m || old_cfg.n != cfg.n || old_cfg.p != cfg.p) + ret =_program_pll (hw, &cfg, rate); + +if (pll->lock) +spin_unlock_irqrestore (pll->lock, flags); + +return ret; } static long clk_pll_round_rate(struct clk_hw *hw, unsigned long rate,
@@ -409,7 +439,7 @@ static long clk_pll_round_rate(struct clk_hw *hw, unsigned long rate,return -EINVAL ; output_rate *= cfg.n; -do_div (output_rate, cfg.m * cfg.p); +do_div (output_rate, cfg.m * (1 << cfg.p));return output_rate; }
@@ -418,10 +448,12 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) {struct tegra_clk_pll *pll =to_clk_pll (hw); -u32 val =pll_readl_base (pll); -u32 divn =0 , divm =0 , divp =0 ; +struct tegra_clk_pll_freq_table cfg; +u32 val;u64 rate = parent_rate; + val =pll_readl_base (pll); +if (val &PLL_BASE_BYPASS )return parent_rate;
@@ -435,16 +467,16 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw,return pll->fixed_rate; } - divp = (val >> pll->divp_shift) & (divp_mask (pll)); +_get_pll_mnp (pll, &cfg); +if (pll->flags &TEGRA_PLLU ) - divp ^=1 ; + cfg.p ^=1 ; - divn = (val >> pll->divn_shift) & (divn_mask (pll)); - divm = (val >> pll->divm_shift) & (divm_mask (pll)); - divm *= (1 << divp); + cfg.m *=1 << cfg.p; + + rate *= cfg.n; +do_div (rate, cfg.m); - rate *= divn; -do_div (rate, divm);return rate; }
@@ -538,8 +570,8 @@ static int clk_plle_enable(struct clk_hw *hw) val |= (PLL_BASE_BYPASS |PLL_BASE_ENABLE );pll_writel_base (val, pll); -clk_pll_wait_for_lock (pll, pll->clk_base + pll->params->misc_reg, - pll->params->lock_bit_idx); +clk_pll_wait_for_lock (pll); +return 0 ; }
drivers/clk/tegra/clk-tegra20.c +72 -72
197 lines not on this page · raw message
drivers/clk/tegra/clk-tegra30.c +117 -117
281 lines not on this page · raw message
Prashant Gaikwad
maintainerRe: [PATCH v5 01/10] clk: tegra: Refactor PLL programming code
Quoted 40 lines · Peter De Schrijver
Refactor the PLL programming code to make it useable by the new PLL types introduced by Tegra114.
The following changes were done:
* Split programming the PLL into updating m,n,p and updating cpcon
* Move locking from_update_pll_cpcon()toclk_pll_set_rate()
* Introduce_get_pll_mnp()helper
* Move check for identical m,n,p values toclk_pll_set_rate()
* structtegra_clk_pll_freq_tablewill always contain the values as defined by the hardware.
* Simplify the arguments toclk_pll_wait_for_lock()Signed-off-by Peter De Schrijver <[email protected]>--- drivers/clk/tegra/clk-pll.c | 178 +++++++++++++++++------------ drivers/clk/tegra/clk-tegra20.c | 144 ++++++++++++------------ drivers/clk/tegra/clk-tegra30.c | 234 +++++++++++++++++++------------------- 3 files changed, 294 insertions(+), 262 deletions(-)drivers/clk/tegra/clk-pll.c +2
-3@@ -1,5 +1,5 @@/* -* Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. +* Copyright (c) 2012, 2013, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -113,20 +113,23 @@ static void clk_pll_enable_lock(struct tegra_clk_pll *pll)pll_writel_misc (val, pll); } -static int clk_pll_wait_for_lock (struct tegra_clk_pll *pll, -void __iomem *lock_addr,u32 lock_bit_idx) +static int clk_pll_wait_for_lock (struct tegra_clk_pll *pll) {int i;
drivers/clk/tegra/clk-pll.c static void clk_pll_enable_lock(struct tegra_clk_pll *pll) · line 127
Quoted 10 lines
drivers/clk/tegra/clk-pll.c +3
-1-u32 val; +u32 val, lock_bit; +void __iomem *lock_addr;if (!(pll->flags &TEGRA_PLL_USE_LOCK )) {udelay (pll->params->lock_delay);return 0 ; } + lock_addr = pll->clk_base + pll->params->base_reg;
This will not work for PLLE. Lock bit for PLLE is in misc register.
drivers/clk/tegra/clk-pll.c static void clk_pll_enable_lock(struct tegra_clk_pll *pll) · line 132
Quoted 6 lines
drivers/clk/tegra/clk-pll.c +3
-1+ lock_bit =BIT (pll->params->lock_bit_idx); +for (i =0 ; i < pll->params->lock_delay; i++) { val =readl_relaxed (lock_addr); -if (val &BIT (lock_bit_idx)) { +if (val & lock_bit) {
Need to change the lock bit idx parameter for Tegra20 and Tegra30 PLLs else this patch will break those.
Quoted 6 lines
drivers/clk/tegra/clk-pll.c +0
-0udelay (PLL_POST_LOCK_DELAY );return 0 ; }@@ -155,7 +158,7 @@ static int clk_pll_is_enabled(struct clk_hw *hw)return val &PLL_BASE_ENABLE ?1 :0 ; }
<snip>
Quoted 10 lines
drivers/clk/tegra/clk-pll.c +2
-2@@ -538,8 +570,8 @@ static int clk_plle_enable(struct clk_hw *hw) val |= (PLL_BASE_BYPASS |PLL_BASE_ENABLE );pll_writel_base (val, pll); -clk_pll_wait_for_lock (pll, pll->clk_base + pll->params->misc_reg, - pll->params->lock_bit_idx); +clk_pll_wait_for_lock (pll); +return 0 ; }
<snip>
Quoted 100 lines
static struct tegra_clk_pll_freq_table pll_x_freq_table[] = { /* 1.7 GHz */drivers/clk/tegra/clk-pll.c +40
-40- { 12000000, 1700000000, 850, 6, 1, 8}, - { 13000000, 1700000000, 915, 7, 1, 8}, /* actual: 1699.2 MHz */ - { 16800000, 1700000000, 708, 7, 1, 8}, /* actual: 1699.2 MHz */ - { 19200000, 1700000000, 885, 10, 1, 8}, /* actual: 1699.2 MHz */ - { 26000000, 1700000000, 850, 13, 1, 8}, + { 12000000, 1700000000, 850, 6, 0, 8}, + { 13000000, 1700000000, 915, 7, 0, 8}, /* actual: 1699.2 MHz */ + { 16800000, 1700000000, 708, 7, 0, 8}, /* actual: 1699.2 MHz */ + { 19200000, 1700000000, 885, 10, 0, 8}, /* actual: 1699.2 MHz */ + { 26000000, 1700000000, 850, 13, 0, 8},/* 1.6 GHz */ - { 12000000, 1600000000, 800, 6, 1, 8}, - { 13000000, 1600000000, 738, 6, 1, 8}, /* actual: 1599.0 MHz */ - { 16800000, 1600000000, 857, 9, 1, 8}, /* actual: 1599.7 MHz */ - { 19200000, 1600000000, 500, 6, 1, 8}, - { 26000000, 1600000000, 800, 13, 1, 8}, + { 12000000, 1600000000, 800, 6, 0, 8}, + { 13000000, 1600000000, 738, 6, 0, 8}, /* actual: 1599.0 MHz */ + { 16800000, 1600000000, 857, 9, 0, 8}, /* actual: 1599.7 MHz */ + { 19200000, 1600000000, 500, 6, 0, 8}, + { 26000000, 1600000000, 800, 13, 0, 8},/* 1.5 GHz */ - { 12000000, 1500000000, 750, 6, 1, 8}, - { 13000000, 1500000000, 923, 8, 1, 8}, /* actual: 1499.8 MHz */ - { 16800000, 1500000000, 625, 7, 1, 8}, - { 19200000, 1500000000, 625, 8, 1, 8}, - { 26000000, 1500000000, 750, 13, 1, 8}, + { 12000000, 1500000000, 750, 6, 0, 8}, + { 13000000, 1500000000, 923, 8, 0, 8}, /* actual: 1499.8 MHz */ + { 16800000, 1500000000, 625, 7, 0, 8}, + { 19200000, 1500000000, 625, 8, 0, 8}, + { 26000000, 1500000000, 750, 13, 0, 8},/* 1.4 GHz */ - { 12000000, 1400000000, 700, 6, 1, 8}, - { 13000000, 1400000000, 969, 9, 1, 8}, /* actual: 1399.7 MHz */ - { 16800000, 1400000000, 1000, 12, 1, 8}, - { 19200000, 1400000000, 875, 12, 1, 8}, - { 26000000, 1400000000, 700, 13, 1, 8}, + { 12000000, 1400000000, 700, 6, 0, 8}, + { 13000000, 1400000000, 969, 9, 0, 8}, /* actual: 1399.7 MHz */ + { 16800000, 1400000000, 1000, 12, 0, 8}, + { 19200000, 1400000000, 875, 12, 0, 8}, + { 26000000, 1400000000, 700, 13, 0, 8},/* 1.3 GHz */ - { 12000000, 1300000000, 975, 9, 1, 8}, - { 13000000, 1300000000, 1000, 10, 1, 8}, - { 16800000, 1300000000, 928, 12, 1, 8}, /* actual: 1299.2 MHz */ - { 19200000, 1300000000, 812, 12, 1, 8}, /* actual: 1299.2 MHz */ - { 26000000, 1300000000, 650, 13, 1, 8}, + { 12000000, 1300000000, 975, 9, 0, 8}, + { 13000000, 1300000000, 1000, 10, 0, 8}, + { 16800000, 1300000000, 928, 12, 0, 8}, /* actual: 1299.2 MHz */ + { 19200000, 1300000000, 812, 12, 0, 8}, /* actual: 1299.2 MHz */ + { 26000000, 1300000000, 650, 13, 0, 8},/* 1.2 GHz */ - { 12000000, 1200000000, 1000, 10, 1, 8}, - { 13000000, 1200000000, 923, 10, 1, 8}, /* actual: 1199.9 MHz */ - { 16800000, 1200000000, 1000, 14, 1, 8}, - { 19200000, 1200000000, 1000, 16, 1, 8}, - { 26000000, 1200000000, 600, 13, 1, 8}, + { 12000000, 1200000000, 1000, 10, 0, 8}, + { 13000000, 1200000000, 923, 10, 0, 8}, /* actual: 1199.9 MHz */ + { 16800000, 1200000000, 1000, 14, 0, 8}, + { 19200000, 1200000000, 1000, 16, 0, 8}, + { 26000000, 1200000000, 600, 13, 0, 8},/* 1.1 GHz */ - { 12000000, 1100000000, 825, 9, 1, 8}, - { 13000000, 1100000000, 846, 10, 1, 8}, /* actual: 1099.8 MHz */ - { 16800000, 1100000000, 982, 15, 1, 8}, /* actual: 1099.8 MHz */ - { 19200000, 1100000000, 859, 15, 1, 8}, /* actual: 1099.5 MHz */ - { 26000000, 1100000000, 550, 13, 1, 8}, + { 12000000, 1100000000, 825, 9, 0, 8}, + { 13000000, 1100000000, 846, 10, 0, 8}, /* actual: 1099.8 MHz */ + { 16800000, 1100000000, 982, 15, 0, 8}, /* actual: 1099.8 MHz */ + { 19200000, 1100000000, 859, 15, 0, 8}, /* actual: 1099.5 MHz */ + { 26000000, 1100000000, 550, 13, 0, 8},/* 1 GHz */ - { 12000000, 1000000000, 1000, 12, 1, 8}, - { 13000000, 1000000000, 1000, 13, 1, 8}, - { 16800000, 1000000000, 833, 14, 1, 8}, /* actual: 999.6 MHz */ - { 19200000, 1000000000, 625, 12, 1, 8}, - { 26000000, 1000000000, 1000, 26, 1, 8}, + { 12000000, 1000000000, 1000, 12, 0, 8}, + { 13000000, 1000000000, 1000, 13, 0, 8}, + { 16800000, 1000000000, 833, 14, 0, 8}, /* actual: 999.6 MHz */ + { 19200000, 1000000000, 625, 12, 0, 8}, + { 26000000, 1000000000, 1000, 26, 0, 8}, { 0, 0, 0, 0, 0, 0 }, };
Re: [PATCH v5 01/10] clk: tegra: Refactor PLL programming code
Quoted 1 line · Prashant Gaikwad
On Friday 01 February 2013 03:48 PM, Peter De Schrijver wrote:
...
Quoted 26 lines
Quoted 6 lines
drivers/clk/tegra/clk-pll.c +1
-2-static int clk_pll_wait_for_lock (struct tegra_clk_pll *pll, -void __iomem *lock_addr,u32 lock_bit_idx) +static int clk_pll_wait_for_lock (struct tegra_clk_pll *pll) {int i;drivers/clk/tegra/clk-pll.c static void clk_pll_enable_lock(struct tegra_clk_pll *pll) · line 127
Quoted 10 lines
drivers/clk/tegra/clk-pll.c +3
-1-u32 val; +u32 val, lock_bit; +void __iomem *lock_addr;if (!(pll->flags &TEGRA_PLL_USE_LOCK )) {udelay (pll->params->lock_delay);return 0 ; } + lock_addr = pll->clk_base + pll->params->base_reg;This will not work for PLLE. Lock bit for PLLE is in misc register.
drivers/clk/tegra/clk-pll.c static void clk_pll_enable_lock(struct tegra_clk_pll *pll) · line 132
Quoted 6 lines
drivers/clk/tegra/clk-pll.c +3
-1+ lock_bit =BIT (pll->params->lock_bit_idx); +for (i =0 ; i < pll->params->lock_delay; i++) { val =readl_relaxed (lock_addr); -if (val &BIT (lock_bit_idx)) { +if (val & lock_bit) {
Quoted 3 lines
Need to change the lock bit idx parameter for Tegra20 and Tegra30 PLLs else this patch will break those.
Looking at commit 37c26a906527b8a6a252614ca83d21ad318c4e84 and commit b08e8c0ecc42afa3a2e1019851af741980dd5a6b, these fields seem correctly initialized for both Tegra20 and Tegra30? Or am I missing something?
Thanks,
Peter.
Prashant Gaikwad
maintainerRe: [PATCH v5 01/10] clk: tegra: Refactor PLL programming code
Quoted 27 lines · Peter De Schrijver
Quoted 1 line · Prashant Gaikwad
On Friday 01 February 2013 03:48 PM, Peter De Schrijver wrote:
...
Quoted 23 lines
Quoted 5 lines
drivers/clk/tegra/clk-pll.c +1
-2-static int clk_pll_wait_for_lock (struct tegra_clk_pll *pll, -void __iomem *lock_addr,u32 lock_bit_idx) +static int clk_pll_wait_for_lock (struct tegra_clk_pll *pll) {int i;drivers/clk/tegra/clk-pll.c static void clk_pll_enable_lock(struct tegra_clk_pll *pll) · line 127
Quoted 10 lines
drivers/clk/tegra/clk-pll.c +3
-1-u32 val; +u32 val, lock_bit; +void __iomem *lock_addr;if (!(pll->flags &TEGRA_PLL_USE_LOCK )) {udelay (pll->params->lock_delay);return 0 ; } + lock_addr = pll->clk_base + pll->params->base_reg;This will not work for PLLE. Lock bit for PLLE is in misc register.
Quoted 6 lines
drivers/clk/tegra/clk-pll.c +3
-1+ lock_bit =BIT (pll->params->lock_bit_idx); +for (i =0 ; i < pll->params->lock_delay; i++) { val =readl_relaxed (lock_addr); -if (val &BIT (lock_bit_idx)) { +if (val & lock_bit) {
Quoted 6 lines
Quoted 3 lines
Need to change the lock bit idx parameter for Tegra20 and Tegra30 PLLs else this patch will break those.
Looking at commit
37c26a906527b8a6a252614ca83d21ad318c4e84and commitb08e8c0ecc42afa3a2e1019851af741980dd5a6b, these fields seem correctly initialized for both Tegra20 and Tegra30? Or am I missing something?
Ohh, I missed to read
lock_bit = BIT(pll->params->lock_bit_idx);
Am I missing something about PLLE lock_addr also?
Quoted 3 lines
Thanks,
Peter.
Re: [PATCH v5 01/10] clk: tegra: Refactor PLL programming code
Quoted 35 lines · Prashant Gaikwad
Quoted 27 lines · Peter De Schrijver
Quoted 1 line · Prashant Gaikwad
On Friday 01 February 2013 03:48 PM, Peter De Schrijver wrote:
...
Quoted 23 lines
Quoted 5 lines
drivers/clk/tegra/clk-pll.c +1
-2-static int clk_pll_wait_for_lock (struct tegra_clk_pll *pll, -void __iomem *lock_addr,u32 lock_bit_idx) +static int clk_pll_wait_for_lock (struct tegra_clk_pll *pll) {int i;drivers/clk/tegra/clk-pll.c static void clk_pll_enable_lock(struct tegra_clk_pll *pll) · line 127
Quoted 10 lines
drivers/clk/tegra/clk-pll.c +3
-1-u32 val; +u32 val, lock_bit; +void __iomem *lock_addr;if (!(pll->flags &TEGRA_PLL_USE_LOCK )) {udelay (pll->params->lock_delay);return 0 ; } + lock_addr = pll->clk_base + pll->params->base_reg;This will not work for PLLE. Lock bit for PLLE is in misc register.
Quoted 6 lines
drivers/clk/tegra/clk-pll.c +3
-1+ lock_bit =BIT (pll->params->lock_bit_idx); +for (i =0 ; i < pll->params->lock_delay; i++) { val =readl_relaxed (lock_addr); -if (val &BIT (lock_bit_idx)) { +if (val & lock_bit) {Quoted 6 lines
Quoted 3 lines
Need to change the lock bit idx parameter for Tegra20 and Tegra30 PLLs else this patch will break those.
Looking at commit
37c26a906527b8a6a252614ca83d21ad318c4e84and commitb08e8c0ecc42afa3a2e1019851af741980dd5a6b, these fields seem correctly initialized for both Tegra20 and Tegra30? Or am I missing something?
Quoted 7 lines
Ohh, I missed to read
lock_bit=BIT(pll->params->lock_bit_idx);Am I missing something about PLLE
lock_addralso?
Ah no indeed... my bad. So we need a lock_addr field.
Cheers,
Peter.
Re: [PATCH v5 01/10] clk: tegra: Refactor PLL programming code
Quoted 38 lines · Peter De Schrijver
Quoted 37 lines · Prashant Gaikwad
Quoted 27 lines · Peter De Schrijver
Quoted 1 line · Prashant Gaikwad
On Friday 01 February 2013 03:48 PM, Peter De Schrijver wrote:
...
Quoted 23 lines
Quoted 5 lines
drivers/clk/tegra/clk-pll.c +1
-2-static int clk_pll_wait_for_lock (struct tegra_clk_pll *pll, -void __iomem *lock_addr,u32 lock_bit_idx) +static int clk_pll_wait_for_lock (struct tegra_clk_pll *pll) {int i;drivers/clk/tegra/clk-pll.c static void clk_pll_enable_lock(struct tegra_clk_pll *pll) · line 127
Quoted 10 lines
drivers/clk/tegra/clk-pll.c +3
-1-u32 val; +u32 val, lock_bit; +void __iomem *lock_addr;if (!(pll->flags &TEGRA_PLL_USE_LOCK )) {udelay (pll->params->lock_delay);return 0 ; } + lock_addr = pll->clk_base + pll->params->base_reg;This will not work for PLLE. Lock bit for PLLE is in misc register.
Quoted 6 lines
drivers/clk/tegra/clk-pll.c +3
-1+ lock_bit =BIT (pll->params->lock_bit_idx); +for (i =0 ; i < pll->params->lock_delay; i++) { val =readl_relaxed (lock_addr); -if (val &BIT (lock_bit_idx)) { +if (val & lock_bit) {Quoted 6 lines
Quoted 3 lines
Need to change the lock bit idx parameter for Tegra20 and Tegra30 PLLs else this patch will break those.
Looking at commit
37c26a906527b8a6a252614ca83d21ad318c4e84and commitb08e8c0ecc42afa3a2e1019851af741980dd5a6b, these fields seem correctly initialized for both Tegra20 and Tegra30? Or am I missing something?Ohh, I missed to read
Quoted 8 lines
Quoted 5 lines
lock_bit=BIT(pll->params->lock_bit_idx);Am I missing something about PLLE
lock_addralso?Ah no indeed... my bad. So we need a
lock_addrfield.
Or a flag. Flag seems less invasive for now.
Cheers,
Peter.
Re: [PATCH v5 01/10] clk: tegra: Refactor PLL programming code
In reply to Peter De SchrijverQuoted 2 lines · Peter De Schrijver
Refactor the PLL programming code to make it useable by the new PLL types introduced by Tegra114.
I tested this series on Tegra20 and Tegra30 for regressions and found none. Note that I didn't test on Tegra114. The series,
Also, I briefly reviewed the code and aside from comments that have already been made, so the series,
PATCH v5 2/10 clk: tegra: Add TEGRA_PLL_BYPASS flag
In reply to Peter De SchrijverNot all PLLs in Tegra114 have a bypass bit. Adapt the common code to only use this bit when available.
--- drivers/clk/tegra/clk-pll.c | 15 ++++++++++----- drivers/clk/tegra/clk.h | 8 +++++--- 2 files changed, 15 insertions(+), 8 deletions(-)
drivers/clk/tegra/clk-pll.c +10 -5
@@ -166,7 +166,8 @@ static void _clk_pll_enable(struct clk_hw *hw)clk_pll_enable_lock (pll); val =pll_readl_base (pll); - val &= ~PLL_BASE_BYPASS ; +if (pll->flags &TEGRA_PLL_BYPASS ) + val &= ~PLL_BASE_BYPASS ; val |=PLL_BASE_ENABLE ;pll_writel_base (val, pll);
@@ -183,7 +184,9 @@ static void _clk_pll_disable(struct clk_hw *hw)u32 val; val =pll_readl_base (pll); - val &= ~(PLL_BASE_BYPASS |PLL_BASE_ENABLE ); +if (pll->flags &TEGRA_PLL_BYPASS ) + val &= ~PLL_BASE_BYPASS ; + val &= ~PLL_BASE_ENABLE ;pll_writel_base (val, pll);if (pll->flags &TEGRA_PLLM ) {
@@ -454,7 +457,7 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw, val =pll_readl_base (pll); -if (val &PLL_BASE_BYPASS ) +if ((pll->flags &TEGRA_PLL_BYPASS ) && (val &PLL_BASE_BYPASS ))return parent_rate;if ((pll->flags &TEGRA_PLL_FIXED ) && !(val &PLL_BASE_OVERRIDE )) {
@@ -660,9 +663,10 @@ static struct clk *_tegra_clk_register_pll(const char *name,struct clk *tegra_clk_register_pll (const char *name,const char *parent_name,void __iomem *clk_base,void __iomem *pmc,unsigned long flags,unsigned long fixed_rate, -struct tegra_clk_pll_params *pll_params,u8 pll_flags, +struct tegra_clk_pll_params *pll_params,u32 pll_flags,struct tegra_clk_pll_freq_table *freq_table,spinlock_t *lock) { + pll_flags |=TEGRA_PLL_BYPASS ;return _tegra_clk_register_pll (name, parent_name, clk_base, pmc, flags, fixed_rate, pll_params, pll_flags, freq_table, lock, &tegra_clk_pll_ops);
@@ -671,9 +675,10 @@ struct clk *tegra_clk_register_pll(const char *name, const char *parent_name,struct clk *tegra_clk_register_plle (const char *name,const char *parent_name,void __iomem *clk_base,void __iomem *pmc,unsigned long flags,unsigned long fixed_rate, -struct tegra_clk_pll_params *pll_params,u8 pll_flags, +struct tegra_clk_pll_params *pll_params,u32 pll_flags,struct tegra_clk_pll_freq_table *freq_table,spinlock_t *lock) { + pll_flags |=TEGRA_PLL_BYPASS ;return _tegra_clk_register_pll (name, parent_name, clk_base, pmc, flags, fixed_rate, pll_params, pll_flags, freq_table, lock, &tegra_clk_plle_ops);
drivers/clk/tegra/clk.h +5 -3
@@ -182,12 +182,13 @@ struct tegra_clk_pll_params {* TEGRA_PLL_FIXED - We are not supposed to change output frequency * of some plls. * TEGRA_PLLE_CONFIGURE - Configure PLLE when enabling. +* TEGRA_PLL_BYPASS - PLL has bypass bit */ struct tegra_clk_pll {struct clk_hw hw;void __iomem *clk_base;void __iomem *pmc; -u8 flags; +u32 flags;unsigned long fixed_rate;spinlock_t *lock;u8 divn_shift;
@@ -210,18 +211,19 @@ struct tegra_clk_pll {#define TEGRA_PLLM BIT(5)#define TEGRA_PLL_FIXED BIT(6)#define TEGRA_PLLE_CONFIGURE BIT(7) +#define TEGRA_PLL_BYPASS BIT(8)extern const struct clk_ops tegra_clk_pll_ops;extern const struct clk_ops tegra_clk_plle_ops;struct clk *tegra_clk_register_pll (const char *name,const char *parent_name,void __iomem *clk_base,void __iomem *pmc,unsigned long flags,unsigned long fixed_rate, -struct tegra_clk_pll_params *pll_params,u8 pll_flags, +struct tegra_clk_pll_params *pll_params,u32 pll_flags,struct tegra_clk_pll_freq_table *freq_table,spinlock_t *lock);struct clk *tegra_clk_register_plle (const char *name,const char *parent_name,void __iomem *clk_base,void __iomem *pmc,unsigned long flags,unsigned long fixed_rate, -struct tegra_clk_pll_params *pll_params,u8 pll_flags, +struct tegra_clk_pll_params *pll_params,u32 pll_flags,struct tegra_clk_pll_freq_table *freq_table,spinlock_t *lock);/**
Re: [PATCH v5 02/10] clk: tegra: Add TEGRA_PLL_BYPASS flag
Quoted 5 lines · Peter De Schrijver
Not all PLLs in Tegra114 have a bypass bit. Adapt the common code to only use this bit when available.
Signed-off-by Peter De Schrijver <[email protected]>---
Looks good to me.
Quoted 103 lines
drivers/clk/tegra/clk-pll.c | 15 ++++++++++----- drivers/clk/tegra/clk.h | 8 +++++--- 2 files changed, 15 insertions(+), 8 deletions(-)drivers/clk/tegra/clk-pll.c +10
-5@@ -166,7 +166,8 @@ static void _clk_pll_enable(struct clk_hw *hw)clk_pll_enable_lock (pll); val =pll_readl_base (pll); - val &= ~PLL_BASE_BYPASS ; +if (pll->flags &TEGRA_PLL_BYPASS ) + val &= ~PLL_BASE_BYPASS ; val |=PLL_BASE_ENABLE ;pll_writel_base (val, pll);@@ -183,7 +184,9 @@ static void _clk_pll_disable(struct clk_hw *hw)u32 val; val =pll_readl_base (pll); - val &= ~(PLL_BASE_BYPASS |PLL_BASE_ENABLE ); +if (pll->flags &TEGRA_PLL_BYPASS ) + val &= ~PLL_BASE_BYPASS ; + val &= ~PLL_BASE_ENABLE ;pll_writel_base (val, pll);if (pll->flags &TEGRA_PLLM ) {@@ -454,7 +457,7 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw, val =pll_readl_base (pll); -if (val &PLL_BASE_BYPASS ) +if ((pll->flags &TEGRA_PLL_BYPASS ) && (val &PLL_BASE_BYPASS ))return parent_rate;if ((pll->flags &TEGRA_PLL_FIXED ) && !(val &PLL_BASE_OVERRIDE )) {@@ -660,9 +663,10 @@ static struct clk *_tegra_clk_register_pll(const char *name,struct clk *tegra_clk_register_pll (const char *name,const char *parent_name,void __iomem *clk_base,void __iomem *pmc,unsigned long flags,unsigned long fixed_rate, -struct tegra_clk_pll_params *pll_params,u8 pll_flags, +struct tegra_clk_pll_params *pll_params,u32 pll_flags,struct tegra_clk_pll_freq_table *freq_table,spinlock_t *lock) { + pll_flags |=TEGRA_PLL_BYPASS ;return _tegra_clk_register_pll (name, parent_name, clk_base, pmc, flags, fixed_rate, pll_params, pll_flags, freq_table, lock, &tegra_clk_pll_ops);@@ -671,9 +675,10 @@ struct clk *tegra_clk_register_pll(const char *name, const char *parent_name,struct clk *tegra_clk_register_plle (const char *name,const char *parent_name,void __iomem *clk_base,void __iomem *pmc,unsigned long flags,unsigned long fixed_rate, -struct tegra_clk_pll_params *pll_params,u8 pll_flags, +struct tegra_clk_pll_params *pll_params,u32 pll_flags,struct tegra_clk_pll_freq_table *freq_table,spinlock_t *lock) { + pll_flags |=TEGRA_PLL_BYPASS ;return _tegra_clk_register_pll (name, parent_name, clk_base, pmc, flags, fixed_rate, pll_params, pll_flags, freq_table, lock, &tegra_clk_plle_ops);drivers/clk/tegra/clk.h +5
-3@@ -182,12 +182,13 @@ struct tegra_clk_pll_params {* TEGRA_PLL_FIXED - We are not supposed to change output frequency * of some plls. * TEGRA_PLLE_CONFIGURE - Configure PLLE when enabling. +* TEGRA_PLL_BYPASS - PLL has bypass bit */ struct tegra_clk_pll {struct clk_hw hw;void __iomem *clk_base;void __iomem *pmc; -u8 flags; +u32 flags;unsigned long fixed_rate;spinlock_t *lock;u8 divn_shift;@@ -210,18 +211,19 @@ struct tegra_clk_pll {#define TEGRA_PLLM BIT(5)#define TEGRA_PLL_FIXED BIT(6)#define TEGRA_PLLE_CONFIGURE BIT(7) +#define TEGRA_PLL_BYPASS BIT(8)extern const struct clk_ops tegra_clk_pll_ops;extern const struct clk_ops tegra_clk_plle_ops;struct clk *tegra_clk_register_pll (const char *name,const char *parent_name,void __iomem *clk_base,void __iomem *pmc,unsigned long flags,unsigned long fixed_rate, -struct tegra_clk_pll_params *pll_params,u8 pll_flags, +struct tegra_clk_pll_params *pll_params,u32 pll_flags,struct tegra_clk_pll_freq_table *freq_table,spinlock_t *lock);struct clk *tegra_clk_register_plle (const char *name,const char *parent_name,void __iomem *clk_base,void __iomem *pmc,unsigned long flags,unsigned long fixed_rate, -struct tegra_clk_pll_params *pll_params,u8 pll_flags, +struct tegra_clk_pll_params *pll_params,u32 pll_flags,struct tegra_clk_pll_freq_table *freq_table,spinlock_t *lock);/**
PATCH v5 3/10 clk: tegra: Add PLL post divider table
In reply to Peter De SchrijverSome PLLs in Tegra114 don't use a power of 2 mapping for the post divider. Introduce a table based approach and switch PLLU to it.
--- drivers/clk/tegra/clk-pll.c | 38 ++++++++++++++++++++++++++++++++------ drivers/clk/tegra/clk-tegra20.c | 7 +++++++ drivers/clk/tegra/clk-tegra30.c | 7 +++++++ drivers/clk/tegra/clk.h | 13 +++++++++++++ 4 files changed, 59 insertions(+), 6 deletions(-)
drivers/clk/tegra/clk-pll.c +32 -6
@@ -258,6 +258,7 @@ static int _calc_rate(struct clk_hw *hw, struct tegra_clk_pll_freq_table *cfg, unsigned long rate, unsigned long parent_rate) { struct tegra_clk_pll *pll = to_clk_pll(hw); +struct pdiv_map *p_tohw = pll->params->pdiv_tohw;unsigned long cfreq;u32 p_div =0 ;
@@ -291,7 +292,6 @@ static int _calc_rate(struct clk_hw *hw, struct tegra_clk_pll_freq_table *cfg, cfg->output_rate <<= 1) p_div++; - cfg->p = p_div; cfg->m = parent_rate / cfreq; cfg->n = cfg->output_rate / cfreq; cfg->cpcon =OUT_OF_TABLE_CPCON ;
@@ -304,8 +304,19 @@ static int _calc_rate(struct clk_hw *hw, struct tegra_clk_pll_freq_table *cfg,return -EINVAL ; } -if (pll->flags &TEGRA_PLLU ) - cfg->p ^=1 ; +if (p_tohw) { + p_div =1 << p_div; +while (p_tohw->pdiv) { +if (p_div <= p_tohw->pdiv) { + cfg->p = p_tohw->hw_val; +break ; + } + p_tohw++; + } +if (!p_tohw->pdiv) +return -EINVAL ; + }else + cfg->p = p_div;return 0 ; }
@@ -452,8 +463,10 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw, {struct tegra_clk_pll *pll =to_clk_pll (hw);struct tegra_clk_pll_freq_table cfg; +struct pdiv_map *p_tohw = pll->params->pdiv_tohw;u32 val;u64 rate = parent_rate; +int pdiv; val =pll_readl_base (pll);
@@ -472,10 +485,23 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw,_get_pll_mnp (pll, &cfg); -if (pll->flags &TEGRA_PLLU ) - cfg.p ^=1 ; +if (p_tohw) { +while (p_tohw->pdiv) { +if (cfg.p == p_tohw->hw_val) { + pdiv = p_tohw->pdiv; +break ; + } + p_tohw++; + } + +if (!p_tohw->pdiv) { +WARN_ON (1 ); + pdiv =1 ; + } + }else + pdiv =1 << cfg.p; - cfg.m *=1 << cfg.p; + cfg.m *= pdiv; rate *= cfg.n;do_div (rate, cfg.m);
drivers/clk/tegra/clk-tegra20.c +7 -0
@@ -440,6 +440,12 @@ static struct tegra_clk_pll_params pll_d_params = { .lock_delay = 1000, }; +static struct pdiv_map pllu_p[] = { + { .pdiv =1 , .hw_val =1 }, + { .pdiv =2 , .hw_val =0 }, + { .pdiv =0 , .hw_val =0 }, +}; +static struct tegra_clk_pll_params pll_u_params = { .input_min =2000000 , .input_max =40000000 ,
@@ -452,6 +458,7 @@ static struct tegra_clk_pll_params pll_u_params = { .lock_bit_idx = PLL_BASE_LOCK, .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, .lock_delay = 1000, + .pdiv_tohw = pllu_p, };static struct tegra_clk_pll_params pll_x_params = {
drivers/clk/tegra/clk-tegra30.c +7 -0
@@ -466,6 +466,12 @@ static struct tegra_clk_pll_freq_table pll_d_freq_table[] = { { 0, 0, 0, 0, 0, 0 }, }; +static struct pdiv_map pllu_p[] = { + { .pdiv =1 , .hw_val =1 }, + { .pdiv =2 , .hw_val =0 }, + { .pdiv =0 , .hw_val =0 }, +}; +static struct tegra_clk_pll_freq_table pll_u_freq_table[] = { {12000000 ,480000000 ,960 ,12 ,0 ,12 }, { 13000000, 480000000, 960, 13, 0, 12},
@@ -639,6 +645,7 @@ static struct tegra_clk_pll_params pll_u_params = { .lock_bit_idx = PLL_BASE_LOCK, .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, .lock_delay = 1000, + .pdiv_tohw = pllu_p, };static struct tegra_clk_pll_params pll_x_params = {
drivers/clk/tegra/clk.h +13 -0
@@ -117,6 +117,17 @@ struct tegra_clk_pll_freq_table { };/** +* struct pdiv_map - map post divider to hw value +* +* @pdiv: post divider +* @hw_val: value to be written to the PLL hw +*/ +struct pdiv_map { +u8 pdiv; +u8 hw_val; +}; + +/** * struct clk_pll_params - PLL parameters * * @input_min: Minimum input frequency
@@ -146,6 +157,8 @@ struct tegra_clk_pll_params {u32 lock_bit_idx;u32 lock_enable_bit_idx;int lock_delay; +int max_p; +struct pdiv_map *pdiv_tohw; };/**
Re: [PATCH v5 03/10] clk: tegra: Add PLL post divider table
Quoted 5 lines · Peter De Schrijver
Some PLLs in Tegra114 don't use a power of 2 mapping for the post divider. Introduce a table based approach and switch PLLU to it.
Signed-off-by Peter De Schrijver <[email protected]>---
Looks good to me.
Quoted 168 lines
drivers/clk/tegra/clk-pll.c | 38 ++++++++++++++++++++++++++++++++------ drivers/clk/tegra/clk-tegra20.c | 7 +++++++ drivers/clk/tegra/clk-tegra30.c | 7 +++++++ drivers/clk/tegra/clk.h | 13 +++++++++++++ 4 files changed, 59 insertions(+), 6 deletions(-)drivers/clk/tegra/clk-pll.c +32
-6@@ -258,6 +258,7 @@ static int _calc_rate(struct clk_hw *hw, struct tegra_clk_pll_freq_table *cfg, unsigned long rate, unsigned long parent_rate) { struct tegra_clk_pll *pll = to_clk_pll(hw); +struct pdiv_map *p_tohw = pll->params->pdiv_tohw;unsigned long cfreq;u32 p_div =0 ;@@ -291,7 +292,6 @@ static int _calc_rate(struct clk_hw *hw, struct tegra_clk_pll_freq_table *cfg, cfg->output_rate <<= 1) p_div++; - cfg->p = p_div; cfg->m = parent_rate / cfreq; cfg->n = cfg->output_rate / cfreq; cfg->cpcon =OUT_OF_TABLE_CPCON ;@@ -304,8 +304,19 @@ static int _calc_rate(struct clk_hw *hw, struct tegra_clk_pll_freq_table *cfg,return -EINVAL ; } -if (pll->flags &TEGRA_PLLU ) - cfg->p ^=1 ; +if (p_tohw) { + p_div =1 << p_div; +while (p_tohw->pdiv) { +if (p_div <= p_tohw->pdiv) { + cfg->p = p_tohw->hw_val; +break ; + } + p_tohw++; + } +if (!p_tohw->pdiv) +return -EINVAL ; + }else + cfg->p = p_div;return 0 ; }@@ -452,8 +463,10 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw, {struct tegra_clk_pll *pll =to_clk_pll (hw);struct tegra_clk_pll_freq_table cfg; +struct pdiv_map *p_tohw = pll->params->pdiv_tohw;u32 val;u64 rate = parent_rate; +int pdiv; val =pll_readl_base (pll);@@ -472,10 +485,23 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw,_get_pll_mnp (pll, &cfg); -if (pll->flags &TEGRA_PLLU ) - cfg.p ^=1 ; +if (p_tohw) { +while (p_tohw->pdiv) { +if (cfg.p == p_tohw->hw_val) { + pdiv = p_tohw->pdiv; +break ; + } + p_tohw++; + } + +if (!p_tohw->pdiv) { +WARN_ON (1 ); + pdiv =1 ; + } + }else + pdiv =1 << cfg.p; - cfg.m *=1 << cfg.p; + cfg.m *= pdiv; rate *= cfg.n;do_div (rate, cfg.m);drivers/clk/tegra/clk-tegra20.c +7
-0@@ -440,6 +440,12 @@ static struct tegra_clk_pll_params pll_d_params = { .lock_delay = 1000, }; +static struct pdiv_map pllu_p[] = { + { .pdiv =1 , .hw_val =1 }, + { .pdiv =2 , .hw_val =0 }, + { .pdiv =0 , .hw_val =0 }, +}; +static struct tegra_clk_pll_params pll_u_params = { .input_min =2000000 , .input_max =40000000 ,@@ -452,6 +458,7 @@ static struct tegra_clk_pll_params pll_u_params = { .lock_bit_idx = PLL_BASE_LOCK, .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, .lock_delay = 1000, + .pdiv_tohw = pllu_p, };static struct tegra_clk_pll_params pll_x_params = {drivers/clk/tegra/clk-tegra30.c +7
-0@@ -466,6 +466,12 @@ static struct tegra_clk_pll_freq_table pll_d_freq_table[] = { { 0, 0, 0, 0, 0, 0 }, }; +static struct pdiv_map pllu_p[] = { + { .pdiv =1 , .hw_val =1 }, + { .pdiv =2 , .hw_val =0 }, + { .pdiv =0 , .hw_val =0 }, +}; +static struct tegra_clk_pll_freq_table pll_u_freq_table[] = { {12000000 ,480000000 ,960 ,12 ,0 ,12 }, { 13000000, 480000000, 960, 13, 0, 12},@@ -639,6 +645,7 @@ static struct tegra_clk_pll_params pll_u_params = { .lock_bit_idx = PLL_BASE_LOCK, .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, .lock_delay = 1000, + .pdiv_tohw = pllu_p, };static struct tegra_clk_pll_params pll_x_params = {drivers/clk/tegra/clk.h +13
-0@@ -117,6 +117,17 @@ struct tegra_clk_pll_freq_table { };/** +* struct pdiv_map - map post divider to hw value +* +* @pdiv: post divider +* @hw_val: value to be written to the PLL hw +*/ +struct pdiv_map { +u8 pdiv; +u8 hw_val; +}; + +/** * struct clk_pll_params - PLL parameters * * @input_min: Minimum input frequency @@ -146,6 +157,8 @@ struct tegra_clk_pll_params {u32 lock_bit_idx;u32 lock_enable_bit_idx;int lock_delay; +int max_p; +struct pdiv_map *pdiv_tohw; };/**
PATCH v5 4/10 clk: tegra: Add new fields and PLL types for Tegra114
In reply to Peter De SchrijverTegra114 introduces new PLL types. This requires new clocktypes as well as some new fields in the pll structure.
--- drivers/clk/tegra/clk-pll.c | 719 +++++++++++++++++++++++++++++++++++++++++++ drivers/clk/tegra/clk.h | 47 +++ 2 files changed, 766 insertions(+), 0 deletions(-)
drivers/clk/tegra/clk-pll.c +719 -0
@@ -79,6 +79,36 @@#define PLLE_SS_CTRL 0x68#define PLLE_SS_DISABLE (7 << 10) +#define PLLE_AUX_PLLP_SEL BIT(2) +#define PLLE_AUX_ENABLE_SWCTL BIT(4) +#define PLLE_AUX_SEQ_ENABLE BIT(24) +#define PLLE_AUX_PLLRE_SEL BIT(28) + +#define PLLE_MISC_PLLE_PTS BIT(8) +#define PLLE_MISC_IDDQ_SW_VALUE BIT(13) +#define PLLE_MISC_IDDQ_SW_CTRL BIT(14) +#define PLLE_MISC_VREG_BG_CTRL_SHIFT 4 +#define PLLE_MISC_VREG_BG_CTRL_MASK (3 << PLLE_MISC_VREG_BG_CTRL_SHIFT) +#define PLLE_MISC_VREG_CTRL_SHIFT 2 +#define PLLE_MISC_VREG_CTRL_MASK (2 << PLLE_MISC_VREG_CTRL_SHIFT) + +#define PLLCX_MISC_STROBE BIT(31) +#define PLLCX_MISC_RESET BIT(30) +#define PLLCX_MISC_SDM_DIV_SHIFT 28 +#define PLLCX_MISC_SDM_DIV_MASK (0x3 << PLLCX_MISC_SDM_DIV_SHIFT) +#define PLLCX_MISC_FILT_DIV_SHIFT 26 +#define PLLCX_MISC_FILT_DIV_MASK (0x3 << PLLCX_MISC_FILT_DIV_SHIFT) +#define PLLCX_MISC_DIV_LOW_RANGE \ + ((0x2 << PLLCX_MISC_SDM_DIV_SHIFT) | \ + (0x2 << PLLCX_MISC_FILT_DIV_SHIFT)) +#define PLLCX_MISC_DIV_HIGH_RANGE \ + ((0x1 << PLLCX_MISC_SDM_DIV_SHIFT) | \ + (0x1 << PLLCX_MISC_FILT_DIV_SHIFT)) + +#define PMC_PLLM_WB0_OVERRIDE 0x1dc +#define PMC_PLLM_WB0_OVERRIDE_2 0x2b0 +#define PMC_PLLM_WB0_OVERRIDE_2_DIVP_MASK BIT(27) +#define PMC_SATA_PWRGT 0x1ac#define PMC_SATA_PWRGT_PLLE_IDDQ_VALUE BIT(5)#define PMC_SATA_PWRGT_PLLE_IDDQ_SWCTL BIT(4)
@@ -101,6 +131,24 @@#define divn_max (p) (divn_mask(p))#define divp_max (p) (1 << (divp_mask(p))) + +#ifdef CONFIG_ARCH_TEGRA_114_SOC +/* PLLXC has 4-bit PDIV, but entry 15 is not allowed in h/w */ +#define PLLXC_PDIV_MAX 14 + +/* non-monotonic mapping below is not a typo */ +static u8 pllxc_p[PLLXC_PDIV_MAX +1 ] = { +/* PDIV: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 */ +/* p: */ 1 ,2 ,3 ,4 ,5 ,6 ,8 ,10 ,12 ,16 ,12 ,16 ,20 ,24 ,32 +}; + +#define PLLCX_PDIV_MAX 7 +static u8 pllcx_p[PLLCX_PDIV_MAX +1 ] = { +/* PDIV: 0, 1, 2, 3, 4, 5, 6, 7 */ +/* p: */ 1 ,2 ,3 ,4 ,6 ,8 ,12 ,16 +}; +#endif +static void clk_pll_enable_lock (struct tegra_clk_pll *pll) {u32 val;
@@ -638,6 +686,515 @@ const struct clk_ops tegra_clk_plle_ops = { .enable = clk_plle_enable, }; +#ifdef CONFIG_ARCH_TEGRA_114_SOC + +static int clk_pll_iddq_enable (struct clk_hw *hw) +{ +struct tegra_clk_pll *pll =to_clk_pll (hw); +unsigned long flags =0 ; + +u32 val; +int ret; + +if (pll->lock) +spin_lock_irqsave (pll->lock, flags); + + val =pll_readl (pll->params->iddq_reg, pll); + val &= ~BIT (pll->params->iddq_bit_idx); +pll_writel (val, pll->params->iddq_reg, pll); +udelay (2 ); + +_clk_pll_enable (hw); + + ret =clk_pll_wait_for_lock (pll); + +if (pll->lock) +spin_unlock_irqrestore (pll->lock, flags); + +return 0 ; +} + +static void clk_pll_iddq_disable (struct clk_hw *hw) +{ +struct tegra_clk_pll *pll =to_clk_pll (hw); +unsigned long flags =0 ; +u32 val; + +if (pll->lock) +spin_lock_irqsave (pll->lock, flags); + +_clk_pll_disable (hw); + + val =pll_readl (pll->params->iddq_reg, pll); + val |=BIT (pll->params->iddq_bit_idx); +pll_writel (val, pll->params->iddq_reg, pll); +udelay (2 ); + +if (pll->lock) +spin_unlock_irqrestore (pll->lock, flags); +} + +static int _calc_dynamic_ramp_rate (struct clk_hw *hw, +struct tegra_clk_pll_freq_table *cfg, +unsigned long rate,unsigned long parent_rate) +{ +struct tegra_clk_pll *pll =to_clk_pll (hw); +unsigned int p; + +if (!rate) +return -EINVAL ; + + p =DIV_ROUND_UP (pll->params->vco_min, rate); + cfg->m = (parent_rate > pll->params->cf_max) ?2 :1 ; + cfg->p = p; + cfg->output_rate = rate * cfg->p; + cfg->n = cfg->output_rate * cfg->m / parent_rate; + +if (cfg->n >divn_max (pll) || cfg->output_rate > pll->params->vco_max) +return -EINVAL ; + +return 0 ; +} + +static int _pll_ramp_calc_pll (struct clk_hw *hw, +struct tegra_clk_pll_freq_table *cfg, +unsigned long rate,unsigned long parent_rate) +{ +struct tegra_clk_pll *pll =to_clk_pll (hw); +int ret =0 ; + + ret =_get_table_rate (hw, cfg, rate, parent_rate); +if (ret <0 ) { + ret =_calc_dynamic_ramp_rate (hw, cfg, rate, parent_rate); +return ret; + }else { +int fixed_mdiv; + + fixed_mdiv = (parent_rate > pll->params->cf_max) ?2 :1 ; +if (cfg->m != fixed_mdiv) { +WARN_ON (1 ); +return -EINVAL ; + } + } + +if (!cfg->p || (cfg->p > pll->params->max_p)) +return -EINVAL ; + +return 0 ; +} + +static int clk_pllxc_set_rate (struct clk_hw *hw,unsigned long rate, +unsigned long parent_rate) +{ +struct tegra_clk_pll *pll =to_clk_pll (hw); +struct tegra_clk_pll_freq_table cfg, old_cfg; +unsigned long flags =0 ; +int ret =0 ; +u8 old_p; + + ret =_pll_ramp_calc_pll (hw, &cfg, rate, parent_rate); +if (ret <0 ) +return ret; + +if (pll->lock) +spin_lock_irqsave (pll->lock, flags); + +_get_pll_mnp (pll, &old_cfg); + + old_p = pllxc_p[old_cfg.p]; +if (old_cfg.m != cfg.m && old_cfg.n != cfg.n && old_p != cfg.p) { + cfg.p -=1 ; + ret =_program_pll (hw, &cfg, rate); + } + +if (pll->lock) +spin_unlock_irqrestore (pll->lock, flags); + +return ret; +} + +static long clk_pll_ramp_round_rate (struct clk_hw *hw,unsigned long rate, +unsigned long *prate) +{ +struct tegra_clk_pll_freq_table cfg; +int ret =0 ; +u64 output_rate = *prate; + + ret =_pll_ramp_calc_pll (hw, &cfg, rate, *prate); +if (ret <0 ) +return ret; + + output_rate *= cfg.n; +do_div (output_rate, cfg.m * cfg.p); + +return output_rate; +} + +static int clk_pllm_set_rate (struct clk_hw *hw,unsigned long rate, +unsigned long parent_rate) +{ +struct tegra_clk_pll_freq_table cfg; +struct tegra_clk_pll *pll =to_clk_pll (hw); +unsigned long flags =0 ; +int state, ret =0 ; +u32 val; + +if (pll->lock) +spin_lock_irqsave (pll->lock, flags); + + state =clk_pll_is_enabled (hw); +if (state) { +if (rate !=clk_get_rate (hw->clk)) { +pr_err ("%s: Cannot change active PLLM\n" , __func__); + ret = -EINVAL ; + goto out; + } + goto out; + } + + ret =_pll_ramp_calc_pll (hw, &cfg, rate, parent_rate); +if (ret <0 ) + goto out; + + cfg.p -=1 ; + + val =readl_relaxed (pll->pmc +PMC_PLLM_WB0_OVERRIDE ); +if (val &PMC_PLLP_WB0_OVERRIDE_PLLM_OVERRIDE ) { + val =readl_relaxed (pll->pmc +PMC_PLLM_WB0_OVERRIDE_2 ); + val = cfg.p ? (val |PMC_PLLM_WB0_OVERRIDE_2_DIVP_MASK ) : + (val & ~PMC_PLLM_WB0_OVERRIDE_2_DIVP_MASK ); +writel_relaxed (val, pll->pmc +PMC_PLLM_WB0_OVERRIDE_2 ); + + val =readl_relaxed (pll->pmc +PMC_PLLM_WB0_OVERRIDE ); + val &= ~(divn_mask (pll) |divm_mask (pll)); + val |= (cfg.m << pll->divm_shift) | (cfg.n << pll->divn_shift); +writel_relaxed (val, pll->pmc +PMC_PLLM_WB0_OVERRIDE ); + }else +_update_pll_mnp (pll, &cfg); + + +out: +if (pll->lock) +spin_unlock_irqrestore (pll->lock, flags); + +return ret; +} + +static void _pllcx_strobe (struct tegra_clk_pll *pll) +{ +u32 val; + + val =pll_readl_misc (pll); + val |=PLLCX_MISC_STROBE ; +pll_writel_misc (val, pll); +udelay (2 ); + + val &= ~PLLCX_MISC_STROBE ; +pll_writel_misc (val, pll); +} + +static int clk_pllc_enable (struct clk_hw *hw) +{ +struct tegra_clk_pll *pll =to_clk_pll (hw); +u32 val; +int ret =0 ; +unsigned long flags =0 ; + +if (pll->lock) +spin_lock_irqsave (pll->lock, flags); + +_clk_pll_enable (hw); +udelay (2 ); + + val =pll_readl_misc (pll); + val &= ~PLLCX_MISC_RESET ; +pll_writel_misc (val, pll); +udelay (2 ); + +_pllcx_strobe (pll); + + ret =clk_pll_wait_for_lock (pll); + +if (pll->lock) +spin_unlock_irqrestore (pll->lock, flags); + +return ret; +} + +static void _clk_pllc_disable (struct clk_hw *hw) +{ +struct tegra_clk_pll *pll =to_clk_pll (hw); +u32 val; + +_clk_pll_disable (hw); + + val =pll_readl_misc (pll); + val |=PLLCX_MISC_RESET ; +pll_writel_misc (val, pll); +udelay (2 ); +} + +static void clk_pllc_disable (struct clk_hw *hw) +{ +struct tegra_clk_pll *pll =to_clk_pll (hw); +unsigned long flags =0 ; + +if (pll->lock) +spin_lock_irqsave (pll->lock, flags); + +_clk_pllc_disable (hw); + +if (pll->lock) +spin_unlock_irqrestore (pll->lock, flags); +} + +static int _pllcx_update_dynamic_coef (struct tegra_clk_pll *pll, +unsigned long input_rate,u32 n) +{ +u32 val, n_threshold; + +switch (input_rate) { +case 12000000 : + n_threshold =70 ; +break ; +case 13000000 : +case 26000000 : + n_threshold =71 ; +break ; +case 16800000 : + n_threshold =55 ; +break ; +case 19200000 : + n_threshold =48 ; +break ; +default : +pr_err ("%s: Unexpected reference rate %lu\n" , + __func__, input_rate); +return -EINVAL ; + } + + val =pll_readl_misc (pll); + val &= ~(PLLCX_MISC_SDM_DIV_MASK |PLLCX_MISC_FILT_DIV_MASK ); + val |= n <= n_threshold ? +PLLCX_MISC_DIV_LOW_RANGE :PLLCX_MISC_DIV_HIGH_RANGE ; +pll_writel_misc (val, pll); + +return 0 ; +} + +static int clk_pllc_set_rate (struct clk_hw *hw,unsigned long rate, +unsigned long parent_rate) +{ +struct tegra_clk_pll_freq_table cfg; +struct tegra_clk_pll *pll =to_clk_pll (hw); +unsigned long flags =0 ; +int state, ret =0 ; +u32 val; +u16 old_m, old_n; +u8 old_p; + +if (pll->lock) +spin_lock_irqsave (pll->lock, flags); + + ret =_pll_ramp_calc_pll (hw, &cfg, rate, parent_rate); +if (ret <0 ) + goto out; + + val =pll_readl_base (pll); + old_m = (val >> pll->divm_shift) & (divm_mask (pll)); + old_n = (val >> pll->divn_shift) & (divn_mask (pll)); + old_p = pllcx_p[(val >> pll->divp_shift) & (divp_mask (pll))]; + +if (cfg.m != old_m) { +WARN_ON (1 ); + goto out; + } + +if (old_n == cfg.n && old_p == cfg.p) + goto out; + + cfg.p -=1 ; + + state =clk_pll_is_enabled (hw); +if (state) +_clk_pllc_disable (hw); + + ret =_pllcx_update_dynamic_coef (pll, parent_rate, cfg.n); +if (ret <0 ) + goto out; + +_update_pll_mnp (pll, &cfg); + +if (state) + ret =clk_pllc_enable (hw); + +out: +if (pll->lock) +spin_unlock_irqrestore (pll->lock, flags); + +return ret; +} + +static long _pllre_calc_rate (struct tegra_clk_pll *pll, +struct tegra_clk_pll_freq_table *cfg, +unsigned long rate,unsigned long parent_rate) +{ +u16 m, n; +u64 output_rate = parent_rate; + + m = (parent_rate > pll->params->cf_max ?2 :1 ); + n = rate * m / parent_rate; + + output_rate *= n; +do_div (output_rate, m); + +if (cfg) { + cfg->m = m; + cfg->n = n; + } + +return output_rate; +} +static int clk_pllre_set_rate (struct clk_hw *hw,unsigned long rate, +unsigned long parent_rate) +{ +struct tegra_clk_pll_freq_table cfg, old_cfg; +struct tegra_clk_pll *pll =to_clk_pll (hw); +unsigned long flags =0 ; +int state, ret =0 ; + +if (pll->lock) +spin_lock_irqsave (pll->lock, flags); + +_pllre_calc_rate (pll, &cfg, rate, parent_rate); +_get_pll_mnp (pll, &old_cfg); + cfg.p = old_cfg.p; + +if (cfg.m != old_cfg.m || cfg.n != old_cfg.n) { + state =clk_pll_is_enabled (hw); +if (state) +_clk_pll_disable (hw); + +_update_pll_mnp (pll, &cfg); + +if (state) { +_clk_pll_enable (hw); + ret =clk_pll_wait_for_lock (pll); + } + } + +if (pll->lock) +spin_unlock_irqrestore (pll->lock, flags); + +return ret; +} + +static unsigned long clk_pllre_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +struct tegra_clk_pll_freq_table cfg; +struct tegra_clk_pll *pll =to_clk_pll (hw); +u64 rate = parent_rate; + +_get_pll_mnp (pll, &cfg); + + rate *= cfg.n; +do_div (rate, cfg.m); + +return rate; +} + +static long clk_pllre_round_rate (struct clk_hw *hw,unsigned long rate, +unsigned long *prate) +{ +struct tegra_clk_pll *pll =to_clk_pll (hw); + +return _pllre_calc_rate (pll,NULL , rate, *prate); +} + +static int clk_plle_tegra114_enable (struct clk_hw *hw) +{ +struct tegra_clk_pll *pll =to_clk_pll (hw); +struct tegra_clk_pll_freq_table sel; +u32 val; +int ret; +unsigned long flags =0 ; +unsigned long input_rate =clk_get_rate (clk_get_parent (hw->clk)); + +if (_get_table_rate (hw, &sel, pll->fixed_rate, input_rate)) +return -EINVAL ; + +if (pll->lock) +spin_lock_irqsave (pll->lock, flags); + + val =pll_readl_base (pll); + val &= ~BIT (29 );/* Disable lock override */ +pll_writel_base (val, pll); + + val =pll_readl (pll->params->aux_reg, pll); + val |=PLLE_AUX_ENABLE_SWCTL ; + val &= ~PLLE_AUX_SEQ_ENABLE ; +pll_writel (val, pll->params->aux_reg, pll); +udelay (1 ); + + val =pll_readl_misc (pll); + val |=PLLE_MISC_LOCK_ENABLE ; + val |=PLLE_MISC_IDDQ_SW_CTRL ; + val &= ~PLLE_MISC_IDDQ_SW_VALUE ; + val |=PLLE_MISC_PLLE_PTS ; + val |=PLLE_MISC_VREG_BG_CTRL_MASK |PLLE_MISC_VREG_CTRL_MASK ; +pll_writel_misc (val, pll); +udelay (5 ); + + val =pll_readl (PLLE_SS_CTRL , pll); + val |=PLLE_SS_DISABLE ; +pll_writel (val,PLLE_SS_CTRL , pll); + + val =pll_readl_base (pll); + val &= ~(divm_mask (pll) |divn_mask (pll) |divp_mask (pll)); + val &= ~(PLLE_BASE_DIVCML_WIDTH <<PLLE_BASE_DIVCML_SHIFT ); + val |= sel.m << pll->divm_shift; + val |= sel.n << pll->divn_shift; + val |= sel.cpcon <<PLLE_BASE_DIVCML_SHIFT ; +pll_writel_base (val, pll); +udelay (1 ); + +_clk_pll_enable (hw); + ret =clk_pll_wait_for_lock (pll); + +if (ret <0 ) + goto out; + +/* TODO: enable hw control of xusb brick pll */ + +out: +if (pll->lock) +spin_unlock_irqrestore (pll->lock, flags); + +return ret; +} + +static void clk_plle_tegra114_disable (struct clk_hw *hw) +{ +struct tegra_clk_pll *pll =to_clk_pll (hw); +unsigned long flags =0 ; +u32 val; + +if (pll->lock) +spin_lock_irqsave (pll->lock, flags); + +_clk_pll_disable (hw); + + val =pll_readl_misc (pll); + val |=PLLE_MISC_IDDQ_SW_CTRL |PLLE_MISC_IDDQ_SW_VALUE ; +pll_writel_misc (val, pll); +udelay (1 ); + +if (pll->lock) +spin_unlock_irqrestore (pll->lock, flags); +} +#endif + static struct clk *_tegra_clk_register_pll(const char *name, const char *parent_name, void __iomem *clk_base, void __iomem *pmc, unsigned long flags,
@@ -709,3 +1266,165 @@ struct clk *tegra_clk_register_plle(const char *name, const char *parent_name, flags, fixed_rate, pll_params, pll_flags, freq_table, lock, &tegra_clk_plle_ops); } + +#ifdef CONFIG_ARCH_TEGRA_114_SOC +const struct clk_ops tegra_clk_pllxc_ops = { + .is_enabled = clk_pll_is_enabled, + .enable = clk_pll_iddq_enable, + .disable = clk_pll_iddq_disable, + .recalc_rate = clk_pll_recalc_rate, + .round_rate = clk_pll_ramp_round_rate, + .set_rate = clk_pllxc_set_rate, +}; + +const struct clk_ops tegra_clk_pllm_ops = { + .is_enabled = clk_pll_is_enabled, + .enable = clk_pll_iddq_enable, + .disable = clk_pll_iddq_disable, + .recalc_rate = clk_pll_recalc_rate, + .round_rate = clk_pll_ramp_round_rate, + .set_rate = clk_pllm_set_rate, +}; + +const struct clk_ops tegra_clk_pllc_ops = { + .is_enabled = clk_pll_is_enabled, + .enable = clk_pllc_enable, + .disable = clk_pllc_disable, + .recalc_rate = clk_pll_recalc_rate, + .round_rate = clk_pll_ramp_round_rate, + .set_rate = clk_pllc_set_rate, +}; + +const struct clk_ops tegra_clk_pllre_ops = { + .is_enabled = clk_pll_is_enabled, + .enable = clk_pll_iddq_enable, + .disable = clk_pll_iddq_disable, + .recalc_rate = clk_pllre_recalc_rate, + .round_rate = clk_pllre_round_rate, + .set_rate = clk_pllre_set_rate, +}; + +const struct clk_ops tegra_clk_plle_tegra114_ops = { + .is_enabled = clk_pll_is_enabled, + .enable = clk_plle_tegra114_enable, + .disable = clk_plle_tegra114_disable, + .recalc_rate = clk_pll_recalc_rate, +}; + + +struct clk *tegra_clk_register_pllxc (const char *name,const char *parent_name, +void __iomem *clk_base,void __iomem *pmc, +unsigned long flags,unsigned long fixed_rate, +struct tegra_clk_pll_params *pll_params, +u32 pll_flags, +struct tegra_clk_pll_freq_table *freq_table, +spinlock_t *lock) +{ +if (!pll_params->pdiv_tohw) +return -EINVAL ; + +return _tegra_clk_register_pll (name, parent_name, clk_base, pmc, flags, + fixed_rate, pll_params, pll_flags, freq_table, + lock, &tegra_clk_pllxc_ops); +} + +struct clk *tegra_clk_register_pllre (const char *name,const char *parent_name, +void __iomem *clk_base,void __iomem *pmc, +unsigned long flags,unsigned long fixed_rate, +struct tegra_clk_pll_params *pll_params, +u32 pll_flags, +struct tegra_clk_pll_freq_table *freq_table, +spinlock_t *lock,unsigned long parent_rate) +{ +u32 val; + +/* program minimum rate by default */ + + val =readl_relaxed (clk_base + pll_params->base_reg); +if (val &PLL_BASE_ENABLE ) +WARN_ON (val & pll_params->iddq_bit_idx); +else { +int m; + + m = (parent_rate > pll_params->cf_max) ?2 :1 ; + val = m <<PLL_BASE_DIVM_SHIFT ; + val |= (pll_params->vco_min / parent_rate) + <<PLL_BASE_DIVN_SHIFT ; +writel_relaxed (val, clk_base + pll_params->base_reg); + } + +/* disable lock override */ + + val =readl_relaxed (clk_base + pll_params->misc_reg); + val &= ~BIT (29 ); +writel_relaxed (val, clk_base + pll_params->misc_reg); + +return _tegra_clk_register_pll (name, parent_name, clk_base, pmc, flags, + fixed_rate, pll_params, pll_flags, freq_table, + lock, &tegra_clk_pllre_ops); +} + +struct clk *tegra_clk_register_pllm (const char *name,const char *parent_name, +void __iomem *clk_base,void __iomem *pmc, +unsigned long flags,unsigned long fixed_rate, +struct tegra_clk_pll_params *pll_params, +u32 pll_flags, +struct tegra_clk_pll_freq_table *freq_table, +spinlock_t *lock) +{ +if (!pll_params->pdiv_tohw) +return -EINVAL ; + + pll_flags |=TEGRA_PLL_BYPASS ; +return _tegra_clk_register_pll (name, parent_name, clk_base, pmc, flags, + fixed_rate, pll_params, pll_flags, freq_table, + lock, &tegra_clk_pllm_ops); +} + +struct clk *tegra_clk_register_pllc (const char *name,const char *parent_name, +void __iomem *clk_base,void __iomem *pmc, +unsigned long flags,unsigned long fixed_rate, +struct tegra_clk_pll_params *pll_params, +u32 pll_flags, +struct tegra_clk_pll_freq_table *freq_table, +spinlock_t *lock) +{ +if (!pll_params->pdiv_tohw) +return -EINVAL ; + + pll_flags |=TEGRA_PLL_BYPASS ; +return _tegra_clk_register_pll (name, parent_name, clk_base, pmc, flags, + fixed_rate, pll_params, pll_flags, freq_table, + lock, &tegra_clk_pllc_ops); + +} + +struct clk *tegra_clk_register_plle_tegra114 (const char *name, +const char *parent_name, +void __iomem *clk_base,unsigned long flags, +unsigned long fixed_rate, +struct tegra_clk_pll_params *pll_params, +struct tegra_clk_pll_freq_table *freq_table, +spinlock_t *lock) +{ +u32 val, val_aux; + +/* ensure parent is set to pll_re_vco */ + + val =readl_relaxed (clk_base + pll_params->base_reg); + val_aux =readl_relaxed (clk_base + pll_params->aux_reg); + +if (val &PLL_BASE_ENABLE ) { +if (!(val_aux &PLLE_AUX_PLLRE_SEL )) +WARN (1 ,"pll_e enabled with unsupported parent %s\n" , + (val &PLLE_AUX_PLLP_SEL ) ?"pllp_out0" :"pll_ref" ); + }else { + val_aux |=PLLE_AUX_PLLRE_SEL ; +writel_relaxed (val, clk_base + pll_params->aux_reg); + } + +return _tegra_clk_register_pll (name, parent_name, clk_base,NULL , flags, + fixed_rate, pll_params,0 , freq_table, lock, + &tegra_clk_plle_tegra114_ops); +} +#endif
drivers/clk/tegra/clk.h +47 -0
65 lines not on this page · raw message
Re: [PATCH v5 04/10] clk: tegra: Add new fields and PLL types for Tegra114
Quoted 15 lines · Peter De Schrijver
Tegra114 introduces new PLL types. This requires new clocktypes as well as some new fields in the pll structure.
Signed-off-by Peter De Schrijver <[email protected]>--- drivers/clk/tegra/clk-pll.c | 719 +++++++++++++++++++++++++++++++++++++++++++ drivers/clk/tegra/clk.h | 47 +++ 2 files changed, 766 insertions(+), 0 deletions(-)drivers/clk/tegra/clk-pll.c +1
-0+struct clk *tegra_clk_register_pllxc(const char *name, const char *parent_name,
drivers/clk/tegra/clk-pll.c struct clk *tegra_clk_register_plle(const char *name, const char *parent_name, · line 1325
Quoted 10 lines
drivers/clk/tegra/clk-pll.c +10
-0+ void __iomem *clk_base, void __iomem *pmc, + unsigned long flags, unsigned long fixed_rate, + struct tegra_clk_pll_params *pll_params, + u32 pll_flags, + struct tegra_clk_pll_freq_table *freq_table, + spinlock_t *lock) +{ + if (!pll_params->pdiv_tohw) + return -EINVAL; +
This will cause the following warning:
warning: return makes pointer from integer without a cast
Same with occurrences in tegra_clk_register_pllm and tegra_clk_register_pllc.
Should this instead be returning NULL?
-rhyland
Signature · 1 line
nvpublic
Prashant Gaikwad
maintainerRe: [PATCH v5 04/10] clk: tegra: Add new fields and PLL types for Tegra114
Quoted 29 lines · Rhyland Klein
Quoted 15 lines · Peter De Schrijver
Tegra114 introduces new PLL types. This requires new clocktypes as well as some new fields in the pll structure.
Signed-off-by Peter De Schrijver <[email protected]>--- drivers/clk/tegra/clk-pll.c | 719 +++++++++++++++++++++++++++++++++++++++++++ drivers/clk/tegra/clk.h | 47 +++ 2 files changed, 766 insertions(+), 0 deletions(-)drivers/clk/tegra/clk-pll.c +1
-0+struct clk *tegra_clk_register_pllxc(const char *name, const char *parent_name,drivers/clk/tegra/clk-pll.c struct clk *tegra_clk_register_plle(const char *name, const char *parent_name, · line 1325
Quoted 10 lines
drivers/clk/tegra/clk-pll.c +10
-0+ void __iomem *clk_base, void __iomem *pmc, + unsigned long flags, unsigned long fixed_rate, + struct tegra_clk_pll_params *pll_params, + u32 pll_flags, + struct tegra_clk_pll_freq_table *freq_table, + spinlock_t *lock) +{ + if (!pll_params->pdiv_tohw) + return -EINVAL; +This will cause the following warning:
warning: return makes pointer from integer without a cast
Quoted 4 lines
Same with occurrences in
tegra_clk_register_pllmandtegra_clk_register_pllc.Should this instead be returning NULL?
return ERR_PTR(-EINVAL)
Quoted 3 lines
-rhyland
Re: [PATCH v5 04/10] clk: tegra: Add new fields and PLL types for Tegra114
Quoted 30 lines · Prashant Gaikwad
Quoted 29 lines · Rhyland Klein
Quoted 15 lines · Peter De Schrijver
Tegra114 introduces new PLL types. This requires new clocktypes as well as some new fields in the pll structure.
Signed-off-by Peter De Schrijver <[email protected]>--- drivers/clk/tegra/clk-pll.c | 719 +++++++++++++++++++++++++++++++++++++++++++ drivers/clk/tegra/clk.h | 47 +++ 2 files changed, 766 insertions(+), 0 deletions(-)drivers/clk/tegra/clk-pll.c +1
-0+struct clk *tegra_clk_register_pllxc(const char *name, const char *parent_name,drivers/clk/tegra/clk-pll.c struct clk *tegra_clk_register_plle(const char *name, const char *parent_name, · line 1325
Quoted 10 lines
drivers/clk/tegra/clk-pll.c +10
-0+ void __iomem *clk_base, void __iomem *pmc, + unsigned long flags, unsigned long fixed_rate, + struct tegra_clk_pll_params *pll_params, + u32 pll_flags, + struct tegra_clk_pll_freq_table *freq_table, + spinlock_t *lock) +{ + if (!pll_params->pdiv_tohw) + return -EINVAL; +This will cause the following warning:
warning: return makes pointer from integer without a cast
Quoted 7 lines
Quoted 4 lines
Same with occurrences in
tegra_clk_register_pllmandtegra_clk_register_pllc.Should this instead be returning NULL?
return
ERR_PTR(-EINVAL)
Indeed. I noticed that only after I sent this patchset. Already fixed in my own tree.
Cheers,
Peter.
PATCH v5 5/10 clk: tegra: Add flags to tegra_clk_periph()
In reply to Peter De SchrijverWe will need some tegra peripheral clocks with the CLK_IGNORE_UNUSED flag, most notably mselect, which is a bridge between AXI and most peripherals.
--- drivers/clk/tegra/clk-periph.c | 11 ++++++----- drivers/clk/tegra/clk-tegra20.c | 2 +- drivers/clk/tegra/clk-tegra30.c | 2 +- drivers/clk/tegra/clk.h | 9 ++++++--- 4 files changed, 14 insertions(+), 10 deletions(-)
drivers/clk/tegra/clk-periph.c +6 -5
@@ -170,14 +170,15 @@ const struct clk_ops tegra_clk_periph_nodiv_ops = {static struct clk *_tegra_clk_register_periph (const char *name,const char **parent_names,int num_parents,struct tegra_clk_periph *periph, -void __iomem *clk_base,u32 offset,bool div) +void __iomem *clk_base,u32 offset,bool div, +unsigned long flags) {struct clk *clk;struct clk_init_data init; init.name = name; init.ops = div ? &tegra_clk_periph_ops : &tegra_clk_periph_nodiv_ops; - init.flags = div ?0 :CLK_SET_RATE_PARENT ; + init.flags = flags; init.parent_names = parent_names; init.num_parents = num_parents;
@@ -202,10 +203,10 @@ static struct clk *_tegra_clk_register_periph(const char *name,struct clk *tegra_clk_register_periph (const char *name,const char **parent_names,int num_parents,struct tegra_clk_periph *periph,void __iomem *clk_base, -u32 offset) +u32 offset,unsigned long flags) {return _tegra_clk_register_periph (name, parent_names, num_parents, - periph, clk_base, offset, true); + periph, clk_base, offset, true, flags); } struct clk *tegra_clk_register_periph_nodiv(const char *name,
@@ -214,5 +215,5 @@ struct clk *tegra_clk_register_periph_nodiv(const char *name, u32 offset) {return _tegra_clk_register_periph (name, parent_names, num_parents, - periph, clk_base, offset, false); + periph, clk_base, offset, false,CLK_SET_RATE_PARENT ); }
drivers/clk/tegra/clk-tegra20.c +1 -1
@@ -1048,7 +1048,7 @@ static void __init tegra20_periph_clk_init(void) data = &tegra_periph_clk_list[i]; clk =tegra_clk_register_periph (data->name, data->parent_names, data->num_parents, &data->periph, - clk_base, data->offset); + clk_base, data->offset, data->flags);clk_register_clkdev (clk, data->con_id, data->dev_id); clks[data->clk_id] = clk; }
drivers/clk/tegra/clk-tegra30.c +1 -1
@@ -1665,7 +1665,7 @@ static void __init tegra30_periph_clk_init(void) data = &tegra_periph_clk_list[i]; clk =tegra_clk_register_periph (data->name, data->parent_names, data->num_parents, &data->periph, - clk_base, data->offset); + clk_base, data->offset, data->flags);clk_register_clkdev (clk, data->con_id, data->dev_id); clks[data->clk_id] = clk; }
drivers/clk/tegra/clk.h +6 -3
@@ -411,7 +411,7 @@ extern const struct clk_ops tegra_clk_periph_ops;struct clk *tegra_clk_register_periph (const char *name,const char **parent_names,int num_parents,struct tegra_clk_periph *periph,void __iomem *clk_base, -u32 offset); +u32 offset,unsigned long flags); struct clk *tegra_clk_register_periph_nodiv(const char *name, const char **parent_names, int num_parents, struct tegra_clk_periph *periph, void __iomem *clk_base,
@@ -454,12 +454,14 @@ struct tegra_periph_init_data {u32 offset;const char *con_id;const char *dev_id; +unsigned long flags; };#define TEGRA_INIT_DATA_TABLE (_name, _con_id, _dev_id, _parent_names, _offset,\ _mux_shift, _mux_mask, _mux_flags, _div_shift, \ _div_width, _div_frac_width, _div_flags, _regs, \ - _clk_num, _enb_refcnt, _gate_flags, _clk_id, _table) \ + _clk_num, _enb_refcnt, _gate_flags, _clk_id, _table,\ + _flags) \ { \ .name = _name, \ .clk_id = _clk_id, \
@@ -474,6 +476,7 @@ struct tegra_periph_init_data { .offset = _offset, \ .con_id = _con_id, \ .dev_id = _dev_id, \ + .flags = _flags \ } #define TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parent_names, _offset,\
@@ -484,7 +487,7 @@ struct tegra_periph_init_data { _mux_shift,BIT (_mux_width) -1 , _mux_flags, \ _div_shift, _div_width, _div_frac_width, _div_flags, \ _regs, _clk_num, _enb_refcnt, _gate_flags, _clk_id,\ - NULL) + NULL, 0)/** * struct clk_super_mux - super clock
Re: [PATCH v5 05/10] clk: tegra: Add flags to tegra_clk_periph()
Quoted 5 lines · Peter De Schrijver
We will need some tegra peripheral clocks with the
CLK_IGNORE_UNUSEDflag, most notably mselect, which is a bridge between AXI and most peripherals.Signed-off-by Peter De Schrijver <[email protected]>---
Looks good to me.
Quoted 121 lines
drivers/clk/tegra/clk-periph.c | 11 ++++++----- drivers/clk/tegra/clk-tegra20.c | 2 +- drivers/clk/tegra/clk-tegra30.c | 2 +- drivers/clk/tegra/clk.h | 9 ++++++--- 4 files changed, 14 insertions(+), 10 deletions(-)drivers/clk/tegra/clk-periph.c +6
-5@@ -170,14 +170,15 @@ const struct clk_ops tegra_clk_periph_nodiv_ops = {static struct clk *_tegra_clk_register_periph (const char *name,const char **parent_names,int num_parents,struct tegra_clk_periph *periph, -void __iomem *clk_base,u32 offset,bool div) +void __iomem *clk_base,u32 offset,bool div, +unsigned long flags) {struct clk *clk;struct clk_init_data init; init.name = name; init.ops = div ? &tegra_clk_periph_ops : &tegra_clk_periph_nodiv_ops; - init.flags = div ?0 :CLK_SET_RATE_PARENT ; + init.flags = flags; init.parent_names = parent_names; init.num_parents = num_parents;@@ -202,10 +203,10 @@ static struct clk *_tegra_clk_register_periph(const char *name,struct clk *tegra_clk_register_periph (const char *name,const char **parent_names,int num_parents,struct tegra_clk_periph *periph,void __iomem *clk_base, -u32 offset) +u32 offset,unsigned long flags) {return _tegra_clk_register_periph (name, parent_names, num_parents, - periph, clk_base, offset, true); + periph, clk_base, offset, true, flags); } struct clk *tegra_clk_register_periph_nodiv(const char *name,@@ -214,5 +215,5 @@ struct clk *tegra_clk_register_periph_nodiv(const char *name, u32 offset) {return _tegra_clk_register_periph (name, parent_names, num_parents, - periph, clk_base, offset, false); + periph, clk_base, offset, false,CLK_SET_RATE_PARENT ); }drivers/clk/tegra/clk-tegra20.c +1
-1@@ -1048,7 +1048,7 @@ static void __init tegra20_periph_clk_init(void) data = &tegra_periph_clk_list[i]; clk =tegra_clk_register_periph (data->name, data->parent_names, data->num_parents, &data->periph, - clk_base, data->offset); + clk_base, data->offset, data->flags);clk_register_clkdev (clk, data->con_id, data->dev_id); clks[data->clk_id] = clk; }drivers/clk/tegra/clk-tegra30.c +1
-1@@ -1665,7 +1665,7 @@ static void __init tegra30_periph_clk_init(void) data = &tegra_periph_clk_list[i]; clk =tegra_clk_register_periph (data->name, data->parent_names, data->num_parents, &data->periph, - clk_base, data->offset); + clk_base, data->offset, data->flags);clk_register_clkdev (clk, data->con_id, data->dev_id); clks[data->clk_id] = clk; }drivers/clk/tegra/clk.h +6
-3@@ -411,7 +411,7 @@ extern const struct clk_ops tegra_clk_periph_ops;struct clk *tegra_clk_register_periph (const char *name,const char **parent_names,int num_parents,struct tegra_clk_periph *periph,void __iomem *clk_base, -u32 offset); +u32 offset,unsigned long flags); struct clk *tegra_clk_register_periph_nodiv(const char *name, const char **parent_names, int num_parents, struct tegra_clk_periph *periph, void __iomem *clk_base,@@ -454,12 +454,14 @@ struct tegra_periph_init_data {u32 offset;const char *con_id;const char *dev_id; +unsigned long flags; };#define TEGRA_INIT_DATA_TABLE (_name, _con_id, _dev_id, _parent_names, _offset,\ _mux_shift, _mux_mask, _mux_flags, _div_shift, \ _div_width, _div_frac_width, _div_flags, _regs, \ - _clk_num, _enb_refcnt, _gate_flags, _clk_id, _table) \ + _clk_num, _enb_refcnt, _gate_flags, _clk_id, _table,\ + _flags) \ { \ .name = _name, \ .clk_id = _clk_id, \@@ -474,6 +476,7 @@ struct tegra_periph_init_data { .offset = _offset, \ .con_id = _con_id, \ .dev_id = _dev_id, \ + .flags = _flags \ } #define TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parent_names, _offset,\@@ -484,7 +487,7 @@ struct tegra_periph_init_data { _mux_shift,BIT (_mux_width) -1 , _mux_flags, \ _div_shift, _div_width, _div_frac_width, _div_flags, \ _regs, _clk_num, _enb_refcnt, _gate_flags, _clk_id,\ - NULL) + NULL, 0)/** * struct clk_super_mux - super clock
PATCH v5 6/10 clk: tegra: Workaround for Tegra114 MSENC problem
In reply to Peter De SchrijverWorkaround a hardware bug in MSENC during clock enable.
--- drivers/clk/tegra/clk-periph-gate.c | 9 +++++++++ drivers/clk/tegra/clk.h | 1 + 2 files changed, 10 insertions(+), 0 deletions(-)
drivers/clk/tegra/clk-periph-gate.c +9 -0
@@ -43,6 +43,8 @@ static DEFINE_SPINLOCK(periph_ref_lock);#define periph_clk_to_bit (periph) (1 << (gate->clk_num % 32)) +#define LVL2_CLK_GATE_OVRE 0x554 +/* Peripheral gate clock ops */ static int clk_periph_is_enabled (struct clk_hw *hw) {
@@ -83,6 +85,13 @@ static int clk_periph_enable(struct clk_hw *hw) } } +if (gate->flags &TEGRA_PERIPH_WAR_1005168 ) { +writel_relaxed (0 , gate->clk_base +LVL2_CLK_GATE_OVRE ); +writel_relaxed (BIT (22 ), gate->clk_base +LVL2_CLK_GATE_OVRE ); +udelay (1 ); +writel_relaxed (0 , gate->clk_base +LVL2_CLK_GATE_OVRE ); + } +spin_unlock_irqrestore (&periph_ref_lock, flags);return 0 ;
drivers/clk/tegra/clk.h +1 -0
@@ -371,6 +371,7 @@ struct tegra_clk_periph_gate {#define TEGRA_PERIPH_NO_RESET BIT(0)#define TEGRA_PERIPH_MANUAL_RESET BIT(1)#define TEGRA_PERIPH_ON_APB BIT(2) +#define TEGRA_PERIPH_WAR_1005168 BIT(3)void tegra_periph_reset (struct tegra_clk_periph_gate *gate,bool assert);extern const struct clk_ops tegra_clk_periph_gate_ops;
Re: [PATCH v5 06/10] clk: tegra: Workaround for Tegra114 MSENC problem
Quoted 40 lines · Peter De Schrijver
Workaround a hardware bug in MSENC during clock enable.
Signed-off-by Peter De Schrijver <[email protected]>--- drivers/clk/tegra/clk-periph-gate.c | 9 +++++++++ drivers/clk/tegra/clk.h | 1 + 2 files changed, 10 insertions(+), 0 deletions(-)drivers/clk/tegra/clk-periph-gate.c +9
-0@@ -43,6 +43,8 @@ static DEFINE_SPINLOCK(periph_ref_lock);#define periph_clk_to_bit (periph) (1 << (gate->clk_num % 32)) +#define LVL2_CLK_GATE_OVRE 0x554 +/* Peripheral gate clock ops */ static int clk_periph_is_enabled (struct clk_hw *hw) {@@ -83,6 +85,13 @@ static int clk_periph_enable(struct clk_hw *hw) } } +if (gate->flags &TEGRA_PERIPH_WAR_1005168 ) { +writel_relaxed (0 , gate->clk_base +LVL2_CLK_GATE_OVRE ); +writel_relaxed (BIT (22 ), gate->clk_base +LVL2_CLK_GATE_OVRE ); +udelay (1 ); +writel_relaxed (0 , gate->clk_base +LVL2_CLK_GATE_OVRE ); + } +spin_unlock_irqrestore (&periph_ref_lock, flags);return 0 ;drivers/clk/tegra/clk.h +0
-0
drivers/clk/tegra/clk.h struct tegra_clk_periph_gate { · line 375
Quoted 5 lines
drivers/clk/tegra/clk.h +1
-0@@ -371,6 +371,7 @@ struct tegra_clk_periph_gate {#define TEGRA_PERIPH_NO_RESET BIT(0)#define TEGRA_PERIPH_MANUAL_RESET BIT(1)#define TEGRA_PERIPH_ON_APB BIT(2) +#define TEGRA_PERIPH_WAR_1005168 BIT(3)
Comment for this flag, otherwise
Quoted 3 lines
drivers/clk/tegra/clk.h +0
-0void tegra_periph_reset (struct tegra_clk_periph_gate *gate,bool assert);extern const struct clk_ops tegra_clk_periph_gate_ops;
PATCH v5 7/10 ARM: tegra: Define Tegra114 CAR binding
In reply to Peter De SchrijverThe device tree binding models Tegra114 CAR (Clock And Reset) as a single monolithic clock provider.
--- .../bindings/clock/nvidia,tegra114-car.txt | 311 ++++++++++++++++++++ 1 files changed, 311 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/nvidia,tegra114-car.txt
Documentation/devicetree/bindings/clock/nvidia,tegra114-car.txt new file +311 -0
@@ -0,0 +1,311 @@ +NVIDIA Tegra114 Clock And Reset Controller + +This binding uses the common clock binding: +Documentation/devicetree/bindings/clock/clock-bindings.txt + +The CAR (Clock And Reset) Controller on Tegra is the HW module responsible +for muxing and gating Tegra's clocks, and setting their rates. + +Required properties : +- compatible : Should be "nvidia,tegra114-car" +- reg : Should contain CAR registers location and length +- clocks : Should contain phandle and clock specifiers for two clocks: + the 32 KHz "32k_in", and the board-specific oscillator "osc". +- #clock-cells : Should be 1. + In clock consumers, this cell represents the clock ID exposed by the CAR. + + The first 160 clocks are numbered to match the bits in the CAR's CLK_OUT_ENB + registers. These IDs often match those in the CAR's RST_DEVICES registers, + but not in all cases. Some bits in CLK_OUT_ENB affect multiple clocks. In + this case, those clocks are assigned IDs above 160 in order to highlight + this issue. Implementations that interpret these clock IDs as bit values + within the CLK_OUT_ENB or RST_DEVICES registers should be careful to + explicitly handle these special cases. + + The balance of the clocks controlled by the CAR are assigned IDs of 160 and + above. + + 0 cpu + 1 unassigned + 2 unassigned + 3 unassigned + 4 rtc + 5 timer + 6 uarta + 7 unassigned (register bit affects uartb and vfir) + 8 unassigned + 9 sdmmc2 + 10 unassigned (register bit affects spdif_in and spdif_out) + 11 i2s1 + 12 i2c1 + 13 ndflash + 14 sdmmc1 + 15 sdmmc4 + 16 unassigned + 17 pwm + 18 i2s2 + 19 epp + 20 unassigned (register bit affects vi and vi_sensor) + 21 2d + 22 usbd + 23 isp + 24 3d + 25 unassigned + 26 disp2 + 27 disp1 + 28 host1x + 29 vcp + 30 i2s0 + 31 unassigned + + 32 unassigned + 33 unassigned + 34 apbdma + 35 unassigned + 36 kbc + 37 unassigned + 38 unassigned + 39 unassigned (register bit affects fuse and fuse_burn) + 40 kfuse + 41 sbc1 + 42 nor + 43 unassigned + 44 sbc2 + 45 unassigned + 46 sbc3 + 47 i2c5 + 48 dsia + 49 unassigned + 50 mipi + 51 hdmi + 52 csi + 53 unassigned + 54 i2c2 + 55 uartc + 56 mipi-cal + 57 unassigned + 58 usb2 + 59 usb3 + 60 msenc + 61 vde + 62 bsea + 63 bsev + + 64 unassigned + 65 uartd + 66 unassigned + 67 i2c3 + 68 sbc4 + 69 sdmmc3 + 70 unassigned + 71 owr + 72 afi + 73 csite + 74 unassigned + 75 unassigned + 76 la + 77 trace + 78 soc_therm + 79 dtv + 80 ndspeed + 81 i2cslow + 82 dsib + 83 tsec + 84 unassigned + 85 unassigned + 86 unassigned + 87 unassigned + 88 unassigned + 89 xusb_host + 90 unassigned + 91 msenc + 92 csus + 93 unassigned + 94 unassigned + 95 unassigned (bit affects xusb_dev and xusb_dev_src) + + 96 unassigned + 97 unassigned + 98 unassigned + 99 mselect + 100 tsensor + 101 i2s3 + 102 i2s4 + 103 i2c4 + 104 sbc5 + 105 sbc6 + 106 d_audio + 107 apbif + 108 dam0 + 109 dam1 + 110 dam2 + 111 hda2codec_2x + 112 unassigned + 113 audio0_2x + 114 audio1_2x + 115 audio2_2x + 116 audio3_2x + 117 audio4_2x + 118 spdif_2x + 119 actmon + 120 extern1 + 121 extern2 + 122 extern3 + 123 unassigned + 124 unassigned + 125 hda + 126 unassigned + 127 se + + 128 hda2hdmi + 129 unassigned + 130 unassigned + 131 unassigned + 132 unassigned + 133 unassigned + 134 unassigned + 135 unassigned + 136 unassigned + 137 unassigned + 138 unassigned + 139 unassigned + 140 unassigned + 141 unassigned + 142 unassigned + 143 unassigned (bit affects xusb_falcon_src, xusb_fs_src, + xusb_host_src and xusb_ss_src) + 144 cilab + 145 cilcd + 146 cile + 147 dsialp + 148 dsiblp + 149 unassigned + 150 dds + 151 unassigned + 152 dp2 + 153 amx + 154 adx + 155 unassigned + 156 xusb_ss + + 192 uartb + 193 vfir + 194 spdif_in + 195 spdif_out + 196 vi + 197 vi_sensor + 198 fuse + 199 fuse_burn + 200 clk_32k + 201 clk_m + 202 clk_m_div2 + 203 clk_m_div4 + 204 pll_ref + 205 pll_c + 206 pll_c_out1 + 207 pll_c2 + 208 pll_c3 + 209 pll_m + 210 pll_m_out1 + 211 pll_p + 212 pll_p_out1 + 213 pll_p_out2 + 214 pll_p_out3 + 215 pll_p_out4 + 216 pll_a + 217 pll_a_out1 + 218 pll_d + 219 pll_d_out0 + 220 pll_d2 + 221 pll_d2_out0 + 222 pll_u + 223 pll_u_480M + 224 pll_u_60M + 225 pll_u_48M + 226 pll_u_12M + 227 pll_x + 228 pll_x_out0 + 229 pll_re_vco + 230 pll_re_out + 231 pll_e_out0 + 232 spdif_in_sync + 233 i2s0_sync + 234 i2s1_sync + 235 i2s2_sync + 236 i2s3_sync + 237 i2s4_sync + 238 vimclk_sync + 239 audio0 + 240 audio1 + 241 audio2 + 242 audio3 + 243 audio4 + 244 spdif + 245 clk_out_1 + 246 clk_out_2 + 247 clk_out_3 + 248 blink + 249 mipi_cal_fast + 250 dsi1_fixed + 251 dsi2_fixed + 252 xusb_host_src + 253 xusb_falcon_src + 254 xusb_fs_src + 255 xusb_ss_src + 256 xusb_dev_src + 257 xusb_dev + 258 xusb_hs_src + +Mux clocks + + 300 audio0_mux + 301 audio1_mux + 302 audio2_mux + 303 audio3_mux + 304 audio4_mux + 305 spdif_mux + 306 clk_out_1_mux + 307 clk_out_2_mux + 308 clk_out_3_mux + +Example SoC include file: + +/ { + tegra_car: clock { + compatible = "nvidia,tegra114-car"; + reg = <0x60006000 0x1000>; + #clock-cells = <1>; + }; + + usb at c5004000 { + clocks = <&tegra_car 58>; /* usb2 */ + }; +}; + +Example board file: + +/ { + clocks { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <0>; + + osc: clock at 0 { + compatible = "fixed-clock"; + reg = <0>; + #clock-cells = <0>; + clock-frequency = <12000000>; + }; + + clk_32k: clock at 1 { + compatible = "fixed-clock"; + reg = <1>; + #clock-cells = <0>; + clock-frequency = <32768>; + }; + }; + + &tegra_car { + clocks = <&clk_32k> <&osc>; + }; +};
Re: [PATCH v5 07/10] ARM: tegra: Define Tegra114 CAR binding
Quoted 2 lines · Peter De Schrijver
The device tree binding models Tegra114 CAR (Clock And Reset) as a single monolithic clock provider.
...
Quoted 2 lines
+- #clock-cells : Should be 1. + In clock consumers, this cell represents the clock ID exposed by the CAR.
...
Documentation/devicetree/bindings/clock/nvidia,tegra114-car.txt line 225
Quoted 5 lines
Documentation/devicetree/bindings/clock/nvidia,tegra114-car.txt new file +5
-0+ 222 pll_u + 223 pll_u_480M + 224 pll_u_60M + 225 pll_u_48M + 226 pll_u_12M
I notice here that we have separate clock IDs for the various PLL u outputs. We don't have this on Tegra20 or Tegra30, but I wonder if we should have them there too?
PATCH v5 8/10 ARM: dt: Add references to tegra_car clocks
In reply to Peter De SchrijverAdd references to tegra_car clocks for the basic device nodes.
--- arch/arm/boot/dts/tegra114.dtsi | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
arch/arm/boot/dts/tegra114.dtsi +6 -1
@@ -27,7 +27,7 @@ }; tegra_car: clock { - compatible = "nvidia,tegra114-car, nvidia,tegra30-car"; + compatible = "nvidia,tegra114-car"; reg = <0x60006000 0x1000>; #clock-cells = <1>; };
@@ -43,6 +43,7 @@ reg-shift = <2>; interrupts = <0 36 0x04>; status = "disabled"; + clocks = <&tegra_car 6>; }; serial at 70006040 {
@@ -51,6 +52,7 @@ reg-shift = <2>; interrupts = <0 37 0x04>; status = "disabled"; + clocks = <&tegra_car 192>; }; serial at 70006200 {
@@ -59,6 +61,7 @@ reg-shift = <2>; interrupts = <0 46 0x04>; status = "disabled"; + clocks = <&tegra_car 55>; }; serial at 70006300 {
@@ -67,12 +70,14 @@ reg-shift = <2>; interrupts = <0 90 0x04>; status = "disabled"; + clocks = <&tegra_car 65>; }; rtc { compatible = "nvidia,tegra114-rtc", "nvidia,tegra20-rtc"; reg = <0x7000e000 0x100>; interrupts = <0 2 0x04>; + clocks = <&tegra_car 4>; }; pmc {
Re: [PATCH v5 08/10] ARM: dt: Add references to tegra_car clocks
Quoted 4 lines · Peter De Schrijver
Add references to
tegra_carclocks for the basic device nodes.Signed-off-by Peter De Schrijver <[email protected]>---
Quoted 56 lines
arch/arm/boot/dts/tegra114.dtsi | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)arch/arm/boot/dts/tegra114.dtsi +6
-1@@ -27,7 +27,7 @@ }; tegra_car: clock { - compatible = "nvidia,tegra114-car, nvidia,tegra30-car"; + compatible = "nvidia,tegra114-car"; reg = <0x60006000 0x1000>; #clock-cells = <1>; };@@ -43,6 +43,7 @@ reg-shift = <2>; interrupts = <0 36 0x04>; status = "disabled"; + clocks = <&tegra_car 6>; }; serial at 70006040 {@@ -51,6 +52,7 @@ reg-shift = <2>; interrupts = <0 37 0x04>; status = "disabled"; + clocks = <&tegra_car 192>; }; serial at 70006200 {@@ -59,6 +61,7 @@ reg-shift = <2>; interrupts = <0 46 0x04>; status = "disabled"; + clocks = <&tegra_car 55>; }; serial at 70006300 {@@ -67,12 +70,14 @@ reg-shift = <2>; interrupts = <0 90 0x04>; status = "disabled"; + clocks = <&tegra_car 65>; }; rtc { compatible = "nvidia,tegra114-rtc", "nvidia,tegra20-rtc"; reg = <0x7000e000 0x100>; interrupts = <0 2 0x04>; + clocks = <&tegra_car 4>; }; pmc {
PATCH v5 9/10 clk: tegra: Implement clocks for Tegra114
In reply to Peter De SchrijverImplement most clocks for Tegra114. The super clocks for the CPU complex are still missing and will be implemented in a future version.
--- drivers/clk/tegra/Makefile | 1 + drivers/clk/tegra/clk-tegra114.c | 2002 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 2003 insertions(+), 0 deletions(-) create mode 100644 drivers/clk/tegra/clk-tegra114.c
drivers/clk/tegra/Makefile +1 -0
@@ -9,3 +9,4 @@ obj-y += clk-super.o 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
drivers/clk/tegra/clk-tegra114.c new file +2002 -0
2,002 lines not on this page · raw message
Prashant Gaikwad
maintainerRe: [PATCH v5 09/10] clk: tegra: Implement clocks for Tegra114
Quoted 59 lines · Peter De Schrijver
Implement most clocks for Tegra114. The super clocks for the CPU complex are still missing and will be implemented in a future version.
Signed-off-by Peter De Schrijver <[email protected]>--- drivers/clk/tegra/Makefile | 1 + drivers/clk/tegra/clk-tegra114.c | 2002 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 2003 insertions(+), 0 deletions(-)create mode 100644
drivers/clk/tegra/clk-tegra114.cdrivers/clk/tegra/Makefile +1
-0@@ -9,3 +9,4 @@ obj-y += clk-super.o 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.odrivers/clk/tegra/clk-tegra114.c new file +34
-0@@ -0,0 +1,2002 @@ +/* +* Copyright (c) 2012, 2013, NVIDIA CORPORATION. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope 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. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <linux/io.h> +#include <linux/clk.h> +#include <linux/clk-provider.h> +#include <linux/clkdev.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/delay.h> +#include <linux/clk/tegra.h> + +#include "clk.h" + +#define RST_DEVICES_L 0x004 +#define RST_DEVICES_H 0x008 +#define RST_DEVICES_U 0x00C +#define RST_DEVICES_V 0x358 +#define RST_DEVICES_W 0x35C +#define RST_DEVICES_X 0x28C +#define RST_DEVICES_SET_L 0x300
drivers/clk/tegra/clk-tegra114.c line 44
Quoted 10 lines
drivers/clk/tegra/clk-tegra114.c new file +10
-0+#define RST_DEVICES_CLR_L 0x304 +#define RST_DEVICES_SET_H 0x308 +#define RST_DEVICES_CLR_H 0x30c +#define RST_DEVICES_SET_U 0x310 +#define RST_DEVICES_CLR_U 0x314 +#define RST_DEVICES_SET_V 0x430 +#define RST_DEVICES_CLR_V 0x434 +#define RST_DEVICES_SET_W 0x438 +#define RST_DEVICES_CLR_W 0x43c +#define RST_DEVICES_NUM 5
RST_DEVICES_SET/CLR_X?
Quoted 20 lines
drivers/clk/tegra/clk-tegra114.c new file +20
-0+ +#define CLK_OUT_ENB_L 0x010 +#define CLK_OUT_ENB_H 0x014 +#define CLK_OUT_ENB_U 0x018 +#define CLK_OUT_ENB_V 0x360 +#define CLK_OUT_ENB_W 0x364 +#define CLK_OUT_ENB_X 0x280 +#define CLK_OUT_ENB_SET_L 0x320 +#define CLK_OUT_ENB_CLR_L 0x324 +#define CLK_OUT_ENB_SET_H 0x328 +#define CLK_OUT_ENB_CLR_H 0x32c +#define CLK_OUT_ENB_SET_U 0x330 +#define CLK_OUT_ENB_CLR_U 0x334 +#define CLK_OUT_ENB_SET_V 0x440 +#define CLK_OUT_ENB_CLR_V 0x444 +#define CLK_OUT_ENB_SET_W 0x448 +#define CLK_OUT_ENB_CLR_W 0x44c +#define CLK_OUT_ENB_SET_X 0x284 +#define CLK_OUT_ENB_CLR_X 0x288 +#define CLK_OUT_ENB_NUM 6
<snip>
Quoted 13 lines
drivers/clk/tegra/clk-tegra114.c new file +13
-0+ +/* dsia */ + clk =clk_register_mux (NULL ,"dsia_mux" , mux_plld_out0_plld2_out0, +ARRAY_SIZE (mux_plld_out0_plld2_out0),0 , + clk_base +PLLD_BASE ,25 ,1 ,0 , &pll_d_lock); + clks[dsia_mux] = clk; + clk =tegra_clk_register_periph_gate ("dsia" ,"dsia_mux" ,0 , clk_base, +0 ,48 , &periph_h_regs, + periph_clk_enb_refcnt); +clk_register_clkdev (clk,"dsia" ,"tegradc.0" ); + clks[dsia] = clk; + +/* dsib */
drivers/clk/tegra/clk-tegra114.c line 1890
Quoted 10 lines
drivers/clk/tegra/clk-tegra114.c new file +10
-0+ clk =clk_register_mux (NULL ,"dsib_mux" , mux_plld_out0_plld2_out0, +ARRAY_SIZE (mux_plld_out0_plld2_out0),0 , + clk_base +PLLD2_BASE ,25 ,1 ,0 , &pll_d2_lock); + clks[dsib_mux] = clk; + clk =tegra_clk_register_periph_gate ("dsib" ,"dsib_mux" ,0 , clk_base, +0 ,82 , &periph_u_regs, + periph_clk_enb_refcnt); +clk_register_clkdev (clk,"dsib" ,"tegradc.1" ); + clks[dsib] = clk; +
Can we use periph no div clock here for dsia and dsib?
drivers/clk/tegra/clk-tegra114.c line 1899
Quoted 9 lines
drivers/clk/tegra/clk-tegra114.c new file +9
-0+/* xusb_hs_src */ + val =readl (clk_base +CLK_SOURCE_XUSB_SS_SRC ); + val |=BIT (25 );/* always select PLLU_60M */ +writel (val, clk_base +CLK_SOURCE_XUSB_SS_SRC ); + + clk =clk_register_fixed_factor (NULL ,"xusb_hs_src" ,"pll_u_60M" ,0 , +1 ,1 ); + clks[xusb_hs_src] = clk; +
With device tree we can directly use pll_u_60M, no need to register clock with fixed factor 1.
Same comment for dis1-fixed, dsi2-fixed and mipi-cal-fast clocks.
Quoted 9 lines
drivers/clk/tegra/clk-tegra114.c new file +9
-0+/* xusb_host */ + clk =tegra_clk_register_periph_gate ("xusb_host" ,"xusb_host_src" ,0 , + clk_base,0 ,89 , &periph_u_regs, + periph_clk_enb_refcnt); +clk_register_clkdev (clk,"tegra_xhci" ,"host" ); + clks[xusb_host] = clk; + +/* xusb_ss */ + clk = tegra_clk_register_periph_gate("xusb_ss", "xusb_ss_src", 0,
drivers/clk/tegra/clk-tegra114.c line 1918
Quoted 10 lines
drivers/clk/tegra/clk-tegra114.c new file +10
-0+ clk_base,0 ,156 , &periph_w_regs, + periph_clk_enb_refcnt); +clk_register_clkdev (clk,"tegra_xhci" ,"ss" ); + clks[xusb_host] = clk; + +/* xusb_dev */ + clk =tegra_clk_register_periph_gate ("xusb_dev" ,"xusb_dev_src" ,0 , + clk_base,0 ,95 , &periph_u_regs, + periph_clk_enb_refcnt); +clk_register_clkdev (clk,"tegra_xhci" ,"dev" );
clks[xusb_dev] = clk;
Quoted 85 lines
drivers/clk/tegra/clk-tegra114.c new file +84
-0+ +for (i =0 ; i <ARRAY_SIZE (tegra_periph_clk_list); i++) { + data = &tegra_periph_clk_list[i]; + clk =tegra_clk_register_periph (data->name, data->parent_names, + data->num_parents, &data->periph, + clk_base, data->offset, data->flags); +clk_register_clkdev (clk, data->con_id, data->dev_id); + clks[data->clk_id] = clk; + } + +for (i =0 ; i <ARRAY_SIZE (tegra_periph_nodiv_clk_list); i++) { + data = &tegra_periph_nodiv_clk_list[i]; + clk =tegra_clk_register_periph_nodiv (data->name, + data->parent_names, data->num_parents, + &data->periph, clk_base, data->offset); +clk_register_clkdev (clk, data->con_id, data->dev_id); + clks[data->clk_id] = clk; + } +} + +static struct tegra_cpu_car_ops tegra114_cpu_car_ops; + +static const struct of_device_id pmc_match[]__initconst = { + { .compatible ="nvidia,tegra114-pmc" }, + {}, +}; + +static __initdata struct tegra_clk_init_table init_table[] = { + {uartd, pll_p,408000000 ,1 }, + {clk_max, clk_max,0 ,0 },/* This MUST be the last entry. */ +}; + +void __init tegra114_clock_init (struct device_node *np) +{ +struct device_node *node; +int i; + + clk_base =of_iomap (np,0 ); +if (!clk_base) { +pr_err ("ioremap tegra114 CAR failed\n" ); +return ; + } + + node =of_find_matching_node (NULL , pmc_match); +if (!node) { +pr_err ("Failed to find pmc node\n" ); +WARN_ON (1 ); +return ; + } + + pmc_base =of_iomap (node,0 ); +if (!pmc_base) { +pr_err ("Can't map pmc registers\n" ); +WARN_ON (1 ); +return ; + } + +if (tegra114_osc_clk_init (clk_base) <0 ) +return ; + +tegra114_fixed_clk_init (clk_base); +tegra114_pll_init (clk_base, pmc_base); +tegra114_periph_clk_init (clk_base); +tegra114_audio_clk_init (clk_base); +tegra114_pmc_clk_init (pmc_base); + +for (i =0 ; i <ARRAY_SIZE (clks); i++) { +if (IS_ERR (clks[i])) { +pr_err + ("Tegra114 clk %d: register failed with %ld\n" , + i,PTR_ERR (clks[i])); + } +if (!clks[i]) + clks[i] =ERR_PTR (-EINVAL ); + } + + clk_data.clks = clks; + clk_data.clk_num =ARRAY_SIZE (clks); +of_clk_add_provider (np, of_clk_src_onecell_get, &clk_data); + +tegra_init_from_table (init_table, clks, clk_max); + + tegra_cpu_car_ops = &tegra114_cpu_car_ops; +}
Re: [PATCH v5 09/10] clk: tegra: Implement clocks for Tegra114
On Mon, Feb 04, 2013 at 08:08:55AM +0100, Prashant Gaikwad wrote:
...
Quoted 11 lines
Quoted 11 lines
drivers/clk/tegra/clk-tegra114.c new file +11
-0+#define RST_DEVICES_L 0x004 +#define RST_DEVICES_H 0x008 +#define RST_DEVICES_U 0x00C +#define RST_DEVICES_V 0x358 +#define RST_DEVICES_W 0x35C +#define RST_DEVICES_X 0x28C +#define RST_DEVICES_SET_L 0x300 +#define RST_DEVICES_CLR_L 0x304 +#define RST_DEVICES_SET_H 0x308 +#define RST_DEVICES_CLR_H 0x30c +#define RST_DEVICES_SET_U 0x310
Quoted 9 lines
drivers/clk/tegra/clk-tegra114.c line 44
Quoted 6 lines
drivers/clk/tegra/clk-tegra114.c new file +6
-0+#define RST_DEVICES_CLR_U 0x314 +#define RST_DEVICES_SET_V 0x430 +#define RST_DEVICES_CLR_V 0x434 +#define RST_DEVICES_SET_W 0x438 +#define RST_DEVICES_CLR_W 0x43c +#define RST_DEVICES_NUM 5RST_DEVICES_SET/CLR_X?
For all I can see (from the not yet public TRM), this is not actually used? So I decided to not mention it here.
Quoted 40 lines
Quoted 20 lines
drivers/clk/tegra/clk-tegra114.c new file +20
-0+ +#define CLK_OUT_ENB_L 0x010 +#define CLK_OUT_ENB_H 0x014 +#define CLK_OUT_ENB_U 0x018 +#define CLK_OUT_ENB_V 0x360 +#define CLK_OUT_ENB_W 0x364 +#define CLK_OUT_ENB_X 0x280 +#define CLK_OUT_ENB_SET_L 0x320 +#define CLK_OUT_ENB_CLR_L 0x324 +#define CLK_OUT_ENB_SET_H 0x328 +#define CLK_OUT_ENB_CLR_H 0x32c +#define CLK_OUT_ENB_SET_U 0x330 +#define CLK_OUT_ENB_CLR_U 0x334 +#define CLK_OUT_ENB_SET_V 0x440 +#define CLK_OUT_ENB_CLR_V 0x444 +#define CLK_OUT_ENB_SET_W 0x448 +#define CLK_OUT_ENB_CLR_W 0x44c +#define CLK_OUT_ENB_SET_X 0x284 +#define CLK_OUT_ENB_CLR_X 0x288 +#define CLK_OUT_ENB_NUM 6<snip>
Quoted 17 lines
drivers/clk/tegra/clk-tegra114.c new file +17
-0+ +/* dsia */ + clk =clk_register_mux (NULL ,"dsia_mux" , mux_plld_out0_plld2_out0, +ARRAY_SIZE (mux_plld_out0_plld2_out0),0 , + clk_base +PLLD_BASE ,25 ,1 ,0 , &pll_d_lock); + clks[dsia_mux] = clk; + clk =tegra_clk_register_periph_gate ("dsia" ,"dsia_mux" ,0 , clk_base, +0 ,48 , &periph_h_regs, + periph_clk_enb_refcnt); +clk_register_clkdev (clk,"dsia" ,"tegradc.0" ); + clks[dsia] = clk; + +/* dsib */ + clk =clk_register_mux (NULL ,"dsib_mux" , mux_plld_out0_plld2_out0, +ARRAY_SIZE (mux_plld_out0_plld2_out0),0 , + clk_base +PLLD2_BASE ,25 ,1 ,0 , &pll_d2_lock); + clks[dsib_mux] = clk;
Quoted 9 lines
drivers/clk/tegra/clk-tegra114.c line 1890
Quoted 6 lines
drivers/clk/tegra/clk-tegra114.c new file +6
-0+ clk =tegra_clk_register_periph_gate ("dsib" ,"dsib_mux" ,0 , clk_base, +0 ,82 , &periph_u_regs, + periph_clk_enb_refcnt); +clk_register_clkdev (clk,"dsib" ,"tegradc.1" ); + clks[dsib] = clk; +Can we use periph no div clock here for dsia and dsib?
Will check.
Quoted 4 lines
Quoted 4 lines
drivers/clk/tegra/clk-tegra114.c new file +4
-0+/* xusb_hs_src */ + val =readl (clk_base +CLK_SOURCE_XUSB_SS_SRC ); + val |=BIT (25 );/* always select PLLU_60M */ +writel (val, clk_base +CLK_SOURCE_XUSB_SS_SRC );
Quoted 8 lines
drivers/clk/tegra/clk-tegra114.c line 1899
Quoted 5 lines
drivers/clk/tegra/clk-tegra114.c new file +5
-0+ + clk =clk_register_fixed_factor (NULL ,"xusb_hs_src" ,"pll_u_60M" ,0 , +1 ,1 ); + clks[xusb_hs_src] = clk; +With device tree we can directly use
pll_u_60M, no need to register clock with fixed factor 1.
This is true for now. In the future these clocks will need to be dvfs aware though. I think it makes sense to have a separate clock then?
Quoted 2 lines
Same comment for dis1-fixed, dsi2-fixed and mipi-cal-fast clocks.
Those might not need to become dvfs aware.
Quoted 13 lines
Quoted 13 lines
drivers/clk/tegra/clk-tegra114.c new file +13
-0+/* xusb_host */ + clk =tegra_clk_register_periph_gate ("xusb_host" ,"xusb_host_src" ,0 , + clk_base,0 ,89 , &periph_u_regs, + periph_clk_enb_refcnt); +clk_register_clkdev (clk,"tegra_xhci" ,"host" ); + clks[xusb_host] = clk; + +/* xusb_ss */ + clk =tegra_clk_register_periph_gate ("xusb_ss" ,"xusb_ss_src" ,0 , + clk_base,0 ,156 , &periph_w_regs, + periph_clk_enb_refcnt); +clk_register_clkdev (clk,"tegra_xhci" ,"ss" ); + clks[xusb_host] = clk;
Quoted 9 lines
drivers/clk/tegra/clk-tegra114.c line 1918
Quoted 6 lines
drivers/clk/tegra/clk-tegra114.c new file +6
-0+ +/* xusb_dev */ + clk =tegra_clk_register_periph_gate ("xusb_dev" ,"xusb_dev_src" ,0 , + clk_base,0 ,95 , &periph_u_regs, + periph_clk_enb_refcnt); +clk_register_clkdev (clk,"tegra_xhci" ,"dev" );clks[xusb_dev] = clk;
Missing indeed.
Cheers,
Peter.
Re: [PATCH v5 09/10] clk: tegra: Implement clocks for Tegra114
Quoted 1 line · Peter De Schrijver
On Mon, Feb 04, 2013 at 08:08:55AM +0100, Prashant Gaikwad wrote:
...
Quoted 27 lines
Quoted 17 lines
Quoted 17 lines
drivers/clk/tegra/clk-tegra114.c new file +17
-0+ +/* dsia */ + clk =clk_register_mux (NULL ,"dsia_mux" , mux_plld_out0_plld2_out0, +ARRAY_SIZE (mux_plld_out0_plld2_out0),0 , + clk_base +PLLD_BASE ,25 ,1 ,0 , &pll_d_lock); + clks[dsia_mux] = clk; + clk =tegra_clk_register_periph_gate ("dsia" ,"dsia_mux" ,0 , clk_base, +0 ,48 , &periph_h_regs, + periph_clk_enb_refcnt); +clk_register_clkdev (clk,"dsia" ,"tegradc.0" ); + clks[dsia] = clk; + +/* dsib */ + clk =clk_register_mux (NULL ,"dsib_mux" , mux_plld_out0_plld2_out0, +ARRAY_SIZE (mux_plld_out0_plld2_out0),0 , + clk_base +PLLD2_BASE ,25 ,1 ,0 , &pll_d2_lock); + clks[dsib_mux] = clk;Quoted 9 lines
drivers/clk/tegra/clk-tegra114.c line 1890
Quoted 6 lines
drivers/clk/tegra/clk-tegra114.c new file +6
-0+ clk =tegra_clk_register_periph_gate ("dsib" ,"dsib_mux" ,0 , clk_base, +0 ,82 , &periph_u_regs, + periph_clk_enb_refcnt); +clk_register_clkdev (clk,"dsib" ,"tegradc.1" ); + clks[dsib] = clk; +Can we use periph no div clock here for dsia and dsib?
Quoted 2 lines
Will check.
Not as such. As you can see the muxes need a lock to protect access to the PLLD_BASE and PLLD2_BASE registers respectively. The periph no div clock doesn't provide for these locks though. Do you think it makes sense to add the lock support for these 2 clocks?
Cheers,
Peter.
Re: [PATCH v5 09/10] clk: tegra: Implement clocks for Tegra114
In reply to Peter De SchrijverQuoted 15 lines · Peter De Schrijver
Quoted 4 lines · Prashant Gaikwad
Quoted 4 lines
drivers/clk/tegra/clk-tegra114.c new file +4
-0+/* xusb_hs_src */ + val =readl (clk_base +CLK_SOURCE_XUSB_SS_SRC ); + val |=BIT (25 );/* always select PLLU_60M */ +writel (val, clk_base +CLK_SOURCE_XUSB_SS_SRC );Quoted 8 lines
drivers/clk/tegra/clk-tegra114.c line 1899
Quoted 5 lines
drivers/clk/tegra/clk-tegra114.c new file +5
-0+ + clk =clk_register_fixed_factor (NULL ,"xusb_hs_src" ,"pll_u_60M" ,0 , +1 ,1 ); + clks[xusb_hs_src] = clk; +With device tree we can directly use
pll_u_60M, no need to register clock with fixed factor 1.
Quoted 2 lines
This is true for now. In the future these clocks will need to be dvfs aware though. I think it makes sense to have a separate clock then?
Why does DVFS-awareness require it to be a different clock/ID?
Re: [PATCH v5 09/10] clk: tegra: Implement clocks for Tegra114
In reply to Peter De SchrijverQuoted 14 lines
Quoted 13 lines
drivers/clk/tegra/clk-tegra114.c line 1899
Quoted 10 lines
drivers/clk/tegra/clk-tegra114.c new file +9
-0+/* xusb_hs_src */ + val =readl (clk_base +CLK_SOURCE_XUSB_SS_SRC ); + val |=BIT (25 );/* always select PLLU_60M */ +writel (val, clk_base +CLK_SOURCE_XUSB_SS_SRC ); + + clk =clk_register_fixed_factor (NULL ,"xusb_hs_src" ,"pll_u_60M" ,0 , +1 ,1 ); + clks[xusb_hs_src] = clk; +With device tree we can directly use
pll_u_60M, no need to register clock with fixed factor 1.
Quoted 3 lines
This is true for now. In the future these clocks will need to be dvfs aware though. I think it makes sense to have a separate clock then?
As this seems to be a different clock (ie. the hw allows you to select a different parent), I think keeping this node makes sense.
Cheers,
Peter.
Re: [PATCH v5 09/10] clk: tegra: Implement clocks for Tegra114
In reply to Prashant GaikwadQuoted 1 line · Prashant Gaikwad
On Friday 01 February 2013 03:48 PM, Peter De Schrijver wrote:
...
Quoted 5 lines
Quoted 5 lines
drivers/clk/tegra/clk-tegra114.c new file +5
-0+/* xusb_hs_src */ + val =readl (clk_base +CLK_SOURCE_XUSB_SS_SRC ); + val |=BIT (25 );/* always select PLLU_60M */ +writel (val, clk_base +CLK_SOURCE_XUSB_SS_SRC ); +
Quoted 9 lines
drivers/clk/tegra/clk-tegra114.c line 1899
Quoted 4 lines
drivers/clk/tegra/clk-tegra114.c new file +4
-0+ clk =clk_register_fixed_factor (NULL ,"xusb_hs_src" ,"pll_u_60M" ,0 , +1 ,1 ); + clks[xusb_hs_src] = clk; +With device tree we can directly use
pll_u_60M, no need to register clock with fixed factor 1.
Same comment for dis1-fixed, dsi2-fixed and mipi-cal-fast clocks.
Does it make sense to have separate DT IDs at all then?
Cheers,
Peter.
Prashant Gaikwad
maintainerRe: [PATCH v5 09/10] clk: tegra: Implement clocks for Tegra114
Quoted 17 lines · Peter De Schrijver
Quoted 1 line · Prashant Gaikwad
On Friday 01 February 2013 03:48 PM, Peter De Schrijver wrote:
...
Quoted 4 lines
Quoted 4 lines
drivers/clk/tegra/clk-tegra114.c new file +4
-0+/* xusb_hs_src */ + val =readl (clk_base +CLK_SOURCE_XUSB_SS_SRC ); + val |=BIT (25 );/* always select PLLU_60M */ +writel (val, clk_base +CLK_SOURCE_XUSB_SS_SRC );Quoted 9 lines
drivers/clk/tegra/clk-tegra114.c line 1899
Quoted 5 lines
drivers/clk/tegra/clk-tegra114.c new file +5
-0+ + clk =clk_register_fixed_factor (NULL ,"xusb_hs_src" ,"pll_u_60M" ,0 , +1 ,1 ); + clks[xusb_hs_src] = clk; +With device tree we can directly use
pll_u_60M, no need to register clock with fixed factor 1.
Same comment for dis1-fixed, dsi2-fixed and mipi-cal-fast clocks.
Quoted 1 line
Does it make sense to have separate DT IDs at all then?
We can use same DT ID.
Quoted 3 lines
Cheers,
Peter.
PATCH v5 10/10 clk: tegra: devicetree match for nvidia,tegra114-car
In reply to Peter De Schrijver--- drivers/clk/tegra/clk.c | 1 + drivers/clk/tegra/clk.h | 7 +++++++ 2 files changed, 8 insertions(+), 0 deletions(-)
drivers/clk/tegra/clk.c +1 -0
@@ -76,6 +76,7 @@ void __init tegra_init_from_table(struct tegra_clk_init_table *tbl,static const struct of_device_id tegra_dt_clk_match[] = { { .compatible ="nvidia,tegra20-car" , .data = tegra20_clock_init }, { .compatible ="nvidia,tegra30-car" , .data = tegra30_clock_init }, + { .compatible ="nvidia,tegra114-car" , .data = tegra114_clock_init }, { } };
drivers/clk/tegra/clk.h +7 -0
@@ -576,4 +576,11 @@ void tegra30_clock_init(struct device_node *np);static inline void tegra30_clock_init (struct device_node *np) {}#endif /* CONFIG_ARCH_TEGRA_3x_SOC */ +#ifdef CONFIG_ARCH_TEGRA_114_SOC +void tegra114_clock_init (struct device_node *np); +#else +static inline void tegra114_clock_init (struct device_node *np) {} +#endif /* CONFIG_ARCH_TEGRA114_SOC */ + +#endif /* TEGRA_CLK_H */
Re: [PATCH v5 10/10] clk: tegra: devicetree match for nvidia,tegra114-car
Quoted 2 lines · Peter De Schrijver
Signed-off-by Peter De Schrijver <[email protected]>---
Quoted 33 lines
drivers/clk/tegra/clk.c | 1 + drivers/clk/tegra/clk.h | 7 +++++++ 2 files changed, 8 insertions(+), 0 deletions(-)drivers/clk/tegra/clk.c +1
-0@@ -76,6 +76,7 @@ void __init tegra_init_from_table(struct tegra_clk_init_table *tbl,static const struct of_device_id tegra_dt_clk_match[] = { { .compatible ="nvidia,tegra20-car" , .data = tegra20_clock_init }, { .compatible ="nvidia,tegra30-car" , .data = tegra30_clock_init }, + { .compatible ="nvidia,tegra114-car" , .data = tegra114_clock_init }, { } };drivers/clk/tegra/clk.h +7
-0@@ -576,4 +576,11 @@ void tegra30_clock_init(struct device_node *np);static inline void tegra30_clock_init (struct device_node *np) {}#endif /* CONFIG_ARCH_TEGRA_3x_SOC */ +#ifdef CONFIG_ARCH_TEGRA_114_SOC +void tegra114_clock_init (struct device_node *np); +#else +static inline void tegra114_clock_init (struct device_node *np) {} +#endif /* CONFIG_ARCH_TEGRA114_SOC */ + +#endif /* TEGRA_CLK_H */