Skip to content

Commit 5bc7532

Browse files
committed
Merge tag 'tegra-for-4.7-clk' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux into clk-next
Pull tegra clk driver changes from Thierry Reding: This set of changes contains a bunch of cleanups and minor fixes along with some new clocks, mainly on Tegra210, in preparation for supporting DisplayPort and HDMI 2.0. * tag 'tegra-for-4.7-clk' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux: clk: tegra: dfll: Reformat CVB frequency table clk: tegra: dfll: Properly clean up on failure and removal clk: tegra: dfll: Make code more comprehensible clk: tegra: dfll: Reference CVB table instead of copying data clk: tegra: dfll: Update kerneldoc clk: tegra: Fix PLL_U post divider and initial rate on Tegra30 clk: tegra: Initialize PLL_C to sane rate on Tegra30 clk: tegra: Fix pllre Tegra210 and add pll_re_out1 clk: tegra: Add sor_safe clock clk: tegra: dpaux and dpaux1 are fixed factor clocks clk: tegra: Add dpaux1 clock clk: tegra: Use correct parent for dpaux clock clk: tegra: Add fixed factor peripheral clock type clk: tegra: Special-case mipi-cal parent on Tegra114 clk: tegra: Remove trailing blank line clk: tegra: Constify peripheral clock registers clk: tegra: Add interface to enable hardware control of SATA/XUSB PLLs
2 parents 5569aed + 2690e91 commit 5bc7532

21 files changed

Lines changed: 433 additions & 115 deletions

‎drivers/clk/tegra/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ obj-y += clk-audio-sync.o
33
obj-y += clk-dfll.o
44
obj-y += clk-divider.o
55
obj-y += clk-periph.o
6+
obj-y += clk-periph-fixed.o
67
obj-y += clk-periph-gate.o
78
obj-y += clk-pll.o
89
obj-y += clk-pll-out.o

‎drivers/clk/tegra/clk-dfll.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include <linux/seq_file.h>
5656

5757
#include "clk-dfll.h"
58+
#include "cvb.h"
5859

5960
/*
6061
* DFLL control registers - access via dfll_{readl,writel}
@@ -442,8 +443,8 @@ static void dfll_tune_low(struct tegra_dfll *td)
442443
{
443444
td->tune_range = DFLL_TUNE_LOW;
444445

445-
dfll_writel(td, td->soc->tune0_low, DFLL_TUNE0);
446-
dfll_writel(td, td->soc->tune1, DFLL_TUNE1);
446+
dfll_writel(td, td->soc->cvb->cpu_dfll_data.tune0_low, DFLL_TUNE0);
447+
dfll_writel(td, td->soc->cvb->cpu_dfll_data.tune1, DFLL_TUNE1);
447448
dfll_wmb(td);
448449

449450
if (td->soc->set_clock_trimmers_low)
@@ -1449,7 +1450,7 @@ static int dfll_build_i2c_lut(struct tegra_dfll *td)
14491450
}
14501451
v_max = dev_pm_opp_get_voltage(opp);
14511452

1452-
v = td->soc->min_millivolts * 1000;
1453+
v = td->soc->cvb->min_millivolts * 1000;
14531454
lut = find_vdd_map_entry_exact(td, v);
14541455
if (lut < 0)
14551456
goto out;
@@ -1461,7 +1462,7 @@ static int dfll_build_i2c_lut(struct tegra_dfll *td)
14611462
break;
14621463
v_opp = dev_pm_opp_get_voltage(opp);
14631464

1464-
if (v_opp <= td->soc->min_millivolts * 1000)
1465+
if (v_opp <= td->soc->cvb->min_millivolts * 1000)
14651466
td->dvco_rate_min = dev_pm_opp_get_freq(opp);
14661467

14671468
for (;;) {
@@ -1490,7 +1491,7 @@ static int dfll_build_i2c_lut(struct tegra_dfll *td)
14901491

14911492
if (!td->dvco_rate_min)
14921493
dev_err(td->dev, "no opp above DFLL minimum voltage %d mV\n",
1493-
td->soc->min_millivolts);
1494+
td->soc->cvb->min_millivolts);
14941495
else
14951496
ret = 0;
14961497

‎drivers/clk/tegra/clk-dfll.h‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,18 @@
2424

2525
/**
2626
* struct tegra_dfll_soc_data - SoC-specific hooks/integration for the DFLL driver
27-
* @opp_dev: struct device * that holds the OPP table for the DFLL
28-
* @min_millivolts: minimum voltage (in mV) that the DFLL can operate
29-
* @tune0_low: DFLL tuning register 0 (low voltage range)
30-
* @tune0_high: DFLL tuning register 0 (high voltage range)
31-
* @tune1: DFLL tuning register 1
32-
* @assert_dvco_reset: fn ptr to place the DVCO in reset
33-
* @deassert_dvco_reset: fn ptr to release the DVCO reset
34-
* @set_clock_trimmers_high: fn ptr to tune clock trimmers for high voltage
35-
* @set_clock_trimmers_low: fn ptr to tune clock trimmers for low voltage
27+
* @dev: struct device * that holds the OPP table for the DFLL
28+
* @max_freq: maximum frequency supported on this SoC
29+
* @cvb: CPU frequency table for this SoC
30+
* @init_clock_trimmers: callback to initialize clock trimmers
31+
* @set_clock_trimmers_high: callback to tune clock trimmers for high voltage
32+
* @set_clock_trimmers_low: callback to tune clock trimmers for low voltage
3633
*/
3734
struct tegra_dfll_soc_data {
3835
struct device *dev;
39-
unsigned int min_millivolts;
40-
u32 tune0_low;
41-
u32 tune0_high;
42-
u32 tune1;
36+
unsigned long max_freq;
37+
const struct cvb_table *cvb;
38+
4339
void (*init_clock_trimmers)(void);
4440
void (*set_clock_trimmers_high)(void);
4541
void (*set_clock_trimmers_low)(void);

‎drivers/clk/tegra/clk-id.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ enum clk_id {
7171
tegra_clk_disp2_8,
7272
tegra_clk_dp2,
7373
tegra_clk_dpaux,
74+
tegra_clk_dpaux1,
7475
tegra_clk_dsialp,
7576
tegra_clk_dsia_mux,
7677
tegra_clk_dsiblp,
@@ -306,6 +307,7 @@ enum clk_id {
306307
tegra_clk_xusb_ss_div2,
307308
tegra_clk_xusb_ssp_src,
308309
tegra_clk_sclk_mux,
310+
tegra_clk_sor_safe,
309311
tegra_clk_max,
310312
};
311313

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/*
2+
* Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
3+
*
4+
* This program is free software; you can redistribute it and/or modify it
5+
* under the terms and conditions of the GNU General Public License,
6+
* version 2, as published by the Free Software Foundation.
7+
*
8+
* This program is distributed in the hope it will be useful, but WITHOUT
9+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11+
* more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
17+
#include <linux/clk-provider.h>
18+
19+
#include "clk.h"
20+
21+
static inline struct tegra_clk_periph_fixed *
22+
to_tegra_clk_periph_fixed(struct clk_hw *hw)
23+
{
24+
return container_of(hw, struct tegra_clk_periph_fixed, hw);
25+
}
26+
27+
static int tegra_clk_periph_fixed_is_enabled(struct clk_hw *hw)
28+
{
29+
struct tegra_clk_periph_fixed *fixed = to_tegra_clk_periph_fixed(hw);
30+
u32 mask = 1 << (fixed->num % 32), value;
31+
32+
value = readl(fixed->base + fixed->regs->enb_reg);
33+
if (value & mask) {
34+
value = readl(fixed->base + fixed->regs->rst_reg);
35+
if ((value & mask) == 0)
36+
return 1;
37+
}
38+
39+
return 0;
40+
}
41+
42+
static int tegra_clk_periph_fixed_enable(struct clk_hw *hw)
43+
{
44+
struct tegra_clk_periph_fixed *fixed = to_tegra_clk_periph_fixed(hw);
45+
u32 mask = 1 << (fixed->num % 32);
46+
47+
writel(mask, fixed->base + fixed->regs->enb_set_reg);
48+
49+
return 0;
50+
}
51+
52+
static void tegra_clk_periph_fixed_disable(struct clk_hw *hw)
53+
{
54+
struct tegra_clk_periph_fixed *fixed = to_tegra_clk_periph_fixed(hw);
55+
u32 mask = 1 << (fixed->num % 32);
56+
57+
writel(mask, fixed->base + fixed->regs->enb_clr_reg);
58+
}
59+
60+
static unsigned long
61+
tegra_clk_periph_fixed_recalc_rate(struct clk_hw *hw,
62+
unsigned long parent_rate)
63+
{
64+
struct tegra_clk_periph_fixed *fixed = to_tegra_clk_periph_fixed(hw);
65+
unsigned long long rate;
66+
67+
rate = (unsigned long long)parent_rate * fixed->mul;
68+
do_div(rate, fixed->div);
69+
70+
return (unsigned long)rate;
71+
}
72+
73+
static const struct clk_ops tegra_clk_periph_fixed_ops = {
74+
.is_enabled = tegra_clk_periph_fixed_is_enabled,
75+
.enable = tegra_clk_periph_fixed_enable,
76+
.disable = tegra_clk_periph_fixed_disable,
77+
.recalc_rate = tegra_clk_periph_fixed_recalc_rate,
78+
};
79+
80+
struct clk *tegra_clk_register_periph_fixed(const char *name,
81+
const char *parent,
82+
unsigned long flags,
83+
void __iomem *base,
84+
unsigned int mul,
85+
unsigned int div,
86+
unsigned int num)
87+
{
88+
const struct tegra_clk_periph_regs *regs;
89+
struct tegra_clk_periph_fixed *fixed;
90+
struct clk_init_data init;
91+
struct clk *clk;
92+
93+
regs = get_reg_bank(num);
94+
if (!regs)
95+
return ERR_PTR(-EINVAL);
96+
97+
fixed = kzalloc(sizeof(*fixed), GFP_KERNEL);
98+
if (!fixed)
99+
return ERR_PTR(-ENOMEM);
100+
101+
init.name = name;
102+
init.flags = flags;
103+
init.parent_names = parent ? &parent : NULL;
104+
init.num_parents = parent ? 1 : 0;
105+
init.ops = &tegra_clk_periph_fixed_ops;
106+
107+
fixed->base = base;
108+
fixed->regs = regs;
109+
fixed->mul = mul;
110+
fixed->div = div;
111+
fixed->num = num;
112+
113+
fixed->hw.init = &init;
114+
115+
clk = clk_register(NULL, &fixed->hw);
116+
if (IS_ERR(clk))
117+
kfree(fixed);
118+
119+
return clk;
120+
}

‎drivers/clk/tegra/clk-periph-gate.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ struct clk *tegra_clk_register_periph_gate(const char *name,
134134
struct tegra_clk_periph_gate *gate;
135135
struct clk *clk;
136136
struct clk_init_data init;
137-
struct tegra_clk_periph_regs *pregs;
137+
const struct tegra_clk_periph_regs *pregs;
138138

139139
pregs = get_reg_bank(clk_num);
140140
if (!pregs)

‎drivers/clk/tegra/clk-periph.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static struct clk *_tegra_clk_register_periph(const char *name,
145145
{
146146
struct clk *clk;
147147
struct clk_init_data init;
148-
struct tegra_clk_periph_regs *bank;
148+
const struct tegra_clk_periph_regs *bank;
149149
bool div = !(periph->gate.flags & TEGRA_PERIPH_NO_DIV);
150150

151151
if (periph->gate.flags & TEGRA_PERIPH_NO_DIV) {

‎drivers/clk/tegra/clk-pll.c‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,6 +2013,52 @@ struct clk *tegra_clk_register_pllss(const char *name, const char *parent_name,
20132013
#endif
20142014

20152015
#if defined(CONFIG_ARCH_TEGRA_210_SOC)
2016+
struct clk *tegra_clk_register_pllre_tegra210(const char *name,
2017+
const char *parent_name, void __iomem *clk_base,
2018+
void __iomem *pmc, unsigned long flags,
2019+
struct tegra_clk_pll_params *pll_params,
2020+
spinlock_t *lock, unsigned long parent_rate)
2021+
{
2022+
u32 val;
2023+
struct tegra_clk_pll *pll;
2024+
struct clk *clk;
2025+
2026+
pll_params->vco_min = _clip_vco_min(pll_params->vco_min, parent_rate);
2027+
2028+
if (pll_params->adjust_vco)
2029+
pll_params->vco_min = pll_params->adjust_vco(pll_params,
2030+
parent_rate);
2031+
2032+
pll = _tegra_init_pll(clk_base, pmc, pll_params, lock);
2033+
if (IS_ERR(pll))
2034+
return ERR_CAST(pll);
2035+
2036+
/* program minimum rate by default */
2037+
2038+
val = pll_readl_base(pll);
2039+
if (val & PLL_BASE_ENABLE)
2040+
WARN_ON(readl_relaxed(clk_base + pll_params->iddq_reg) &
2041+
BIT(pll_params->iddq_bit_idx));
2042+
else {
2043+
val = 0x4 << divm_shift(pll);
2044+
val |= 0x41 << divn_shift(pll);
2045+
pll_writel_base(val, pll);
2046+
}
2047+
2048+
/* disable lock override */
2049+
2050+
val = pll_readl_misc(pll);
2051+
val &= ~BIT(29);
2052+
pll_writel_misc(val, pll);
2053+
2054+
clk = _tegra_clk_register_pll(pll, name, parent_name, flags,
2055+
&tegra_clk_pllre_ops);
2056+
if (IS_ERR(clk))
2057+
kfree(pll);
2058+
2059+
return clk;
2060+
}
2061+
20162062
static int clk_plle_tegra210_enable(struct clk_hw *hw)
20172063
{
20182064
struct tegra_clk_pll *pll = to_clk_pll(hw);

‎drivers/clk/tegra/clk-tegra-fixed.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,3 @@ void __init tegra_fixed_clk_init(struct tegra_clk *tegra_clks)
107107
*dt_clk = clk;
108108
}
109109
}
110-

‎drivers/clk/tegra/clk-tegra-periph.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ static struct tegra_periph_init_data gate_clks[] = {
803803
GATE("hda2hdmi", "clk_m", 128, TEGRA_PERIPH_ON_APB, tegra_clk_hda2hdmi, 0),
804804
GATE("bsea", "clk_m", 62, 0, tegra_clk_bsea, 0),
805805
GATE("bsev", "clk_m", 63, 0, tegra_clk_bsev, 0),
806-
GATE("mipi-cal", "clk_m", 56, 0, tegra_clk_mipi_cal, 0),
806+
GATE("mipi-cal", "clk72mhz", 56, 0, tegra_clk_mipi_cal, 0),
807807
GATE("usbd", "clk_m", 22, 0, tegra_clk_usbd, 0),
808808
GATE("usb2", "clk_m", 58, 0, tegra_clk_usb2, 0),
809809
GATE("usb3", "clk_m", 59, 0, tegra_clk_usb3, 0),
@@ -821,7 +821,6 @@ static struct tegra_periph_init_data gate_clks[] = {
821821
GATE("ispb", "clk_m", 3, 0, tegra_clk_ispb, 0),
822822
GATE("vim2_clk", "clk_m", 11, 0, tegra_clk_vim2_clk, 0),
823823
GATE("pcie", "clk_m", 70, 0, tegra_clk_pcie, 0),
824-
GATE("dpaux", "clk_m", 181, 0, tegra_clk_dpaux, 0),
825824
GATE("gpu", "pll_ref", 184, 0, tegra_clk_gpu, 0),
826825
GATE("pllg_ref", "pll_ref", 189, 0, tegra_clk_pll_g_ref, 0),
827826
GATE("hsic_trk", "usb2_hsic_trk", 209, TEGRA_PERIPH_NO_RESET, tegra_clk_hsic_trk, 0),
@@ -877,7 +876,7 @@ static void __init periph_clk_init(void __iomem *clk_base,
877876
struct clk **dt_clk;
878877

879878
for (i = 0; i < ARRAY_SIZE(periph_clks); i++) {
880-
struct tegra_clk_periph_regs *bank;
879+
const struct tegra_clk_periph_regs *bank;
881880
struct tegra_periph_init_data *data;
882881

883882
data = periph_clks + i;

0 commit comments

Comments
 (0)