Skip to content

Commit 2d4235b

Browse files
committed
Merge tag 'for-6.20-clk' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux into clk-tegra
Pull Tegra clk driver updates from Thierry Reding: This series updates the Tegra clock driver to improve hardware support and code correctness. Key changes include fixing camera and display clock hierarchies for Tegra20/30 (adding CSI pad gates, reparenting DSI/CSUS), resolving a memory leak in the Tegra124 EMC driver, and optimizing system suspend/resume callbacks to remove redundant runtime PM overhead. * tag 'for-6.20-clk' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux: clk: tegra30: Add CSI pad clock gates clk: tegra: Set CSUS as vi_sensor's gate for Tegra20, Tegra30 and Tegra114 clk: tegra20: Reparent dsi clock to pll_d_out0 clk: tegra: tegra124-emc: Simplify with scoped for each OF child loop clk: tegra: Adjust callbacks in tegra_clock_pm clk: tegra: tegra124-emc: Fix potential memory leak in tegra124_clk_register_emc()
2 parents 8f0b4cc + e897e86 commit 2d4235b

5 files changed

Lines changed: 56 additions & 18 deletions

File tree

drivers/clk/tegra/clk-device.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,19 @@ static int tegra_clock_probe(struct platform_device *pdev)
174174
* problem. In practice this makes no difference from a power management
175175
* perspective since voltage is kept at a nominal level during suspend anyways.
176176
*/
177+
static inline int tegra_clock_suspend(struct device *dev)
178+
{
179+
int ret;
180+
181+
ret = pm_runtime_resume(dev);
182+
if (ret < 0)
183+
return ret;
184+
185+
return 0;
186+
}
187+
177188
static const struct dev_pm_ops tegra_clock_pm = {
178-
SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_resume_and_get, pm_runtime_put)
189+
SET_SYSTEM_SLEEP_PM_OPS(tegra_clock_suspend, NULL)
179190
};
180191

181192
static const struct of_device_id tegra_clock_match[] = {

drivers/clk/tegra/clk-tegra114.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,6 @@ static struct tegra_clk tegra114_clks[tegra_clk_max] __initdata = {
690690
[tegra_clk_tsec] = { .dt_id = TEGRA114_CLK_TSEC, .present = true },
691691
[tegra_clk_xusb_host] = { .dt_id = TEGRA114_CLK_XUSB_HOST, .present = true },
692692
[tegra_clk_msenc] = { .dt_id = TEGRA114_CLK_MSENC, .present = true },
693-
[tegra_clk_csus] = { .dt_id = TEGRA114_CLK_CSUS, .present = true },
694693
[tegra_clk_mselect] = { .dt_id = TEGRA114_CLK_MSELECT, .present = true },
695694
[tegra_clk_tsensor] = { .dt_id = TEGRA114_CLK_TSENSOR, .present = true },
696695
[tegra_clk_i2s3] = { .dt_id = TEGRA114_CLK_I2S3, .present = true },
@@ -1046,6 +1045,12 @@ static __init void tegra114_periph_clk_init(void __iomem *clk_base,
10461045
0, 82, periph_clk_enb_refcnt);
10471046
clks[TEGRA114_CLK_DSIB] = clk;
10481047

1048+
/* csus */
1049+
clk = tegra_clk_register_periph_gate("csus", "vi_sensor", 0,
1050+
clk_base, 0, TEGRA114_CLK_CSUS,
1051+
periph_clk_enb_refcnt);
1052+
clks[TEGRA114_CLK_CSUS] = clk;
1053+
10491054
/* emc mux */
10501055
clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm,
10511056
ARRAY_SIZE(mux_pllmcp_clkm),

drivers/clk/tegra/clk-tegra124-emc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,6 @@ static int load_timings_from_dt(struct tegra_clk_emc *tegra,
444444
u32 ram_code)
445445
{
446446
struct emc_timing *timings_ptr;
447-
struct device_node *child;
448447
int child_count = of_get_child_count(node);
449448
int i = 0, err;
450449
size_t size;
@@ -458,12 +457,11 @@ static int load_timings_from_dt(struct tegra_clk_emc *tegra,
458457
timings_ptr = tegra->timings + tegra->num_timings;
459458
tegra->num_timings += child_count;
460459

461-
for_each_child_of_node(node, child) {
460+
for_each_child_of_node_scoped(node, child) {
462461
struct emc_timing *timing = timings_ptr + (i++);
463462

464463
err = load_one_timing_from_dt(tegra, timing, child);
465464
if (err) {
466-
of_node_put(child);
467465
kfree(tegra->timings);
468466
return err;
469467
}
@@ -538,8 +536,10 @@ struct clk *tegra124_clk_register_emc(void __iomem *base, struct device_node *np
538536
tegra->hw.init = &init;
539537

540538
clk = clk_register(NULL, &tegra->hw);
541-
if (IS_ERR(clk))
539+
if (IS_ERR(clk)) {
540+
kfree(tegra);
542541
return clk;
542+
}
543543

544544
tegra->prev_parent = clk_hw_get_parent_by_index(
545545
&tegra->hw, emc_get_parent(&tegra->hw))->clk;

drivers/clk/tegra/clk-tegra20.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ static struct tegra_clk tegra20_clks[tegra_clk_max] __initdata = {
530530
[tegra_clk_rtc] = { .dt_id = TEGRA20_CLK_RTC, .present = true },
531531
[tegra_clk_timer] = { .dt_id = TEGRA20_CLK_TIMER, .present = true },
532532
[tegra_clk_kbc] = { .dt_id = TEGRA20_CLK_KBC, .present = true },
533-
[tegra_clk_csus] = { .dt_id = TEGRA20_CLK_CSUS, .present = true },
534533
[tegra_clk_vcp] = { .dt_id = TEGRA20_CLK_VCP, .present = true },
535534
[tegra_clk_bsea] = { .dt_id = TEGRA20_CLK_BSEA, .present = true },
536535
[tegra_clk_bsev] = { .dt_id = TEGRA20_CLK_BSEV, .present = true },
@@ -802,9 +801,9 @@ static void __init tegra20_periph_clk_init(void)
802801
clks[TEGRA20_CLK_MC] = clk;
803802

804803
/* dsi */
805-
clk = tegra_clk_register_periph_gate("dsi", "pll_d", 0, clk_base, 0,
806-
48, periph_clk_enb_refcnt);
807-
clk_register_clkdev(clk, NULL, "dsi");
804+
clk = tegra_clk_register_periph_gate("dsi", "pll_d_out0", 0,
805+
clk_base, 0, TEGRA20_CLK_DSI,
806+
periph_clk_enb_refcnt);
808807
clks[TEGRA20_CLK_DSI] = clk;
809808

810809
/* pex */
@@ -834,6 +833,12 @@ static void __init tegra20_periph_clk_init(void)
834833
clk_base, 0, 93, periph_clk_enb_refcnt);
835834
clks[TEGRA20_CLK_CDEV2] = clk;
836835

836+
/* csus */
837+
clk = tegra_clk_register_periph_gate("csus", "csus_mux", 0,
838+
clk_base, 0, TEGRA20_CLK_CSUS,
839+
periph_clk_enb_refcnt);
840+
clks[TEGRA20_CLK_CSUS] = clk;
841+
837842
for (i = 0; i < ARRAY_SIZE(tegra_periph_clk_list); i++) {
838843
data = &tegra_periph_clk_list[i];
839844
clk = tegra_clk_register_periph_data(clk_base, data);
@@ -1093,14 +1098,15 @@ static struct clk *tegra20_clk_src_onecell_get(struct of_phandle_args *clkspec,
10931098
hw = __clk_get_hw(clk);
10941099

10951100
/*
1096-
* Tegra20 CDEV1 and CDEV2 clocks are a bit special case, their parent
1097-
* clock is created by the pinctrl driver. It is possible for clk user
1098-
* to request these clocks before pinctrl driver got probed and hence
1099-
* user will get an orphaned clock. That might be undesirable because
1100-
* user may expect parent clock to be enabled by the child.
1101+
* Tegra20 CDEV1, CDEV2 and CSUS clocks are a bit special case, their
1102+
* parent clock is created by the pinctrl driver. It is possible for
1103+
* clk user to request these clocks before pinctrl driver got probed
1104+
* and hence user will get an orphaned clock. That might be undesirable
1105+
* because user may expect parent clock to be enabled by the child.
11011106
*/
11021107
if (clkspec->args[0] == TEGRA20_CLK_CDEV1 ||
1103-
clkspec->args[0] == TEGRA20_CLK_CDEV2) {
1108+
clkspec->args[0] == TEGRA20_CLK_CDEV2 ||
1109+
clkspec->args[0] == TEGRA20_CLK_CSUS) {
11041110
parent_hw = clk_hw_get_parent(hw);
11051111
if (!parent_hw)
11061112
return ERR_PTR(-EPROBE_DEFER);

drivers/clk/tegra/clk-tegra30.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ static unsigned long input_freq;
154154

155155
static DEFINE_SPINLOCK(cml_lock);
156156
static DEFINE_SPINLOCK(pll_d_lock);
157+
static DEFINE_SPINLOCK(pll_d2_lock);
157158

158159
#define TEGRA_INIT_DATA_MUX(_name, _parents, _offset, \
159160
_clk_num, _gate_flags, _clk_id) \
@@ -780,7 +781,6 @@ static struct tegra_clk tegra30_clks[tegra_clk_max] __initdata = {
780781
[tegra_clk_rtc] = { .dt_id = TEGRA30_CLK_RTC, .present = true },
781782
[tegra_clk_timer] = { .dt_id = TEGRA30_CLK_TIMER, .present = true },
782783
[tegra_clk_kbc] = { .dt_id = TEGRA30_CLK_KBC, .present = true },
783-
[tegra_clk_csus] = { .dt_id = TEGRA30_CLK_CSUS, .present = true },
784784
[tegra_clk_vcp] = { .dt_id = TEGRA30_CLK_VCP, .present = true },
785785
[tegra_clk_bsea] = { .dt_id = TEGRA30_CLK_BSEA, .present = true },
786786
[tegra_clk_bsev] = { .dt_id = TEGRA30_CLK_BSEV, .present = true },
@@ -860,7 +860,7 @@ static void __init tegra30_pll_init(void)
860860

861861
/* PLLD2 */
862862
clk = tegra_clk_register_pll("pll_d2", "pll_ref", clk_base, pmc_base, 0,
863-
&pll_d2_params, NULL);
863+
&pll_d2_params, &pll_d2_lock);
864864
clks[TEGRA30_CLK_PLL_D2] = clk;
865865

866866
/* PLLD2_OUT0 */
@@ -1009,6 +1009,22 @@ static void __init tegra30_periph_clk_init(void)
10091009
0, 48, periph_clk_enb_refcnt);
10101010
clks[TEGRA30_CLK_DSIA] = clk;
10111011

1012+
/* csia_pad */
1013+
clk = clk_register_gate(NULL, "csia_pad", "pll_d", CLK_SET_RATE_PARENT,
1014+
clk_base + PLLD_BASE, 26, 0, &pll_d_lock);
1015+
clks[TEGRA30_CLK_CSIA_PAD] = clk;
1016+
1017+
/* csib_pad */
1018+
clk = clk_register_gate(NULL, "csib_pad", "pll_d2", CLK_SET_RATE_PARENT,
1019+
clk_base + PLLD2_BASE, 26, 0, &pll_d2_lock);
1020+
clks[TEGRA30_CLK_CSIB_PAD] = clk;
1021+
1022+
/* csus */
1023+
clk = tegra_clk_register_periph_gate("csus", "vi_sensor", 0,
1024+
clk_base, 0, TEGRA30_CLK_CSUS,
1025+
periph_clk_enb_refcnt);
1026+
clks[TEGRA30_CLK_CSUS] = clk;
1027+
10121028
/* pcie */
10131029
clk = tegra_clk_register_periph_gate("pcie", "clk_m", 0, clk_base, 0,
10141030
70, periph_clk_enb_refcnt);

0 commit comments

Comments
 (0)