Skip to content

Commit

Permalink
Merge branches 'clk-uniphier', 'clk-warn-critical', 'clk-ux500', 'clk…
Browse files Browse the repository at this point in the history
…-kconfig' and 'clk-at91' into clk-next

 - Warn about critical clks that fail to enable or prepare
 - Detect more PRMCU variants in ux500 driver

* clk-uniphier:
  clk: uniphier: Add SCSSI clock gate for each channel

* clk-warn-critical:
  clk: Warn about critical clks that fail to enable
  clk: Don't try to enable critical clocks if prepare failed
  clk: tegra: Fix double-free in tegra_clk_init()
  clk: samsung: exynos5420: Keep top G3D clocks enabled
  clk: qcom: Avoid SMMU/cx gdsc corner cases
  clk: qcom: gcc-sc7180: Fix setting flag for votable GDSCs
  clk: Move clk_core_reparent_orphans() under CONFIG_OF
  clk: at91: fix possible deadlock
  clk: walk orphan list on clock provider registration
  clk: imx: pll14xx: fix clk_pll14xx_wait_lock
  clk: imx: clk-imx7ulp: Add missing sentinel of ulp_div_table
  clk: imx: clk-composite-8m: add lock to gate/mux

* clk-ux500:
  clk: ux500: Fix up the SGA clock for some variants

* clk-kconfig:
  clk: Fix Kconfig indentation

* clk-at91:
  clk: at91: sam9x60: fix programmable clock prescaler
  clk: at91: sam9x60-pll: adapt PMC_PLL_ACR default value
  • Loading branch information
Stephen Boyd committed Jan 31, 2020
6 parents 28db9a8 + 1ec09a2 + 2d26999 + 248fdcc + 333d2d1 + 66d9f52 commit 36bf7a5
Show file tree
Hide file tree
Showing 23 changed files with 124 additions and 68 deletions.
2 changes: 1 addition & 1 deletion drivers/clk/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ config COMMON_CLK_WM831X
tristate "Clock driver for WM831x/2x PMICs"
depends on MFD_WM831X
---help---
Supports the clocking subsystem of the WM831x/2x series of
Supports the clocking subsystem of the WM831x/2x series of
PMICs from Wolfson Microelectronics.

source "drivers/clk/versatile/Kconfig"
Expand Down
2 changes: 1 addition & 1 deletion drivers/clk/at91/at91sam9260.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,
return;
mainxtal_name = of_clk_get_parent_name(np, i);

regmap = syscon_node_to_regmap(np);
regmap = device_node_to_regmap(np);
if (IS_ERR(regmap))
return;

Expand Down
2 changes: 1 addition & 1 deletion drivers/clk/at91/at91sam9rl.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
return;
mainxtal_name = of_clk_get_parent_name(np, i);

regmap = syscon_node_to_regmap(np);
regmap = device_node_to_regmap(np);
if (IS_ERR(regmap))
return;

Expand Down
2 changes: 1 addition & 1 deletion drivers/clk/at91/at91sam9x5.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
return;
mainxtal_name = of_clk_get_parent_name(np, i);

regmap = syscon_node_to_regmap(np);
regmap = device_node_to_regmap(np);
if (IS_ERR(regmap))
return;

Expand Down
8 changes: 6 additions & 2 deletions drivers/clk/at91/clk-sam9x60-pll.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
#define PMC_PLL_CTRL1_MUL_MSK GENMASK(30, 24)

#define PMC_PLL_ACR 0x18
#define PMC_PLL_ACR_DEFAULT 0x1b040010UL
#define PMC_PLL_ACR_DEFAULT_UPLL 0x12020010UL
#define PMC_PLL_ACR_DEFAULT_PLLA 0x00020010UL
#define PMC_PLL_ACR_UTMIVR BIT(12)
#define PMC_PLL_ACR_UTMIBG BIT(13)
#define PMC_PLL_ACR_LOOP_FILTER_MSK GENMASK(31, 24)
Expand Down Expand Up @@ -88,7 +89,10 @@ static int sam9x60_pll_prepare(struct clk_hw *hw)
}

/* Recommended value for PMC_PLL_ACR */
val = PMC_PLL_ACR_DEFAULT;
if (pll->characteristics->upll)
val = PMC_PLL_ACR_DEFAULT_UPLL;
else
val = PMC_PLL_ACR_DEFAULT_PLLA;
regmap_write(regmap, PMC_PLL_ACR, val);

regmap_write(regmap, PMC_PLL_CTRL1,
Expand Down
2 changes: 1 addition & 1 deletion drivers/clk/at91/pmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ static int __init pmc_register_ops(void)

np = of_find_matching_node(NULL, sama5d2_pmc_dt_ids);

pmcreg = syscon_node_to_regmap(np);
pmcreg = device_node_to_regmap(np);
if (IS_ERR(pmcreg))
return PTR_ERR(pmcreg);

Expand Down
1 change: 1 addition & 0 deletions drivers/clk/at91/sam9x60.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static const struct clk_programmable_layout sam9x60_programmable_layout = {
.pres_shift = 8,
.css_mask = 0x1f,
.have_slck_mck = 0,
.is_pres_direct = 1,
};

static const struct clk_pcr_layout sam9x60_pcr_layout = {
Expand Down
2 changes: 1 addition & 1 deletion drivers/clk/at91/sama5d2.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
return;
mainxtal_name = of_clk_get_parent_name(np, i);

regmap = syscon_node_to_regmap(np);
regmap = device_node_to_regmap(np);
if (IS_ERR(regmap))
return;

Expand Down
2 changes: 1 addition & 1 deletion drivers/clk/at91/sama5d4.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np)
return;
mainxtal_name = of_clk_get_parent_name(np, i);

regmap = syscon_node_to_regmap(np);
regmap = device_node_to_regmap(np);
if (IS_ERR(regmap))
return;

Expand Down
77 changes: 53 additions & 24 deletions drivers/clk/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -3249,6 +3249,34 @@ static inline void clk_debug_unregister(struct clk_core *core)
}
#endif

static void clk_core_reparent_orphans_nolock(void)
{
struct clk_core *orphan;
struct hlist_node *tmp2;

/*
* walk the list of orphan clocks and reparent any that newly finds a
* parent.
*/
hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) {
struct clk_core *parent = __clk_init_parent(orphan);

/*
* We need to use __clk_set_parent_before() and _after() to
* to properly migrate any prepare/enable count of the orphan
* clock. This is important for CLK_IS_CRITICAL clocks, which
* are enabled during init but might not have a parent yet.
*/
if (parent) {
/* update the clk tree topology */
__clk_set_parent_before(orphan, parent);
__clk_set_parent_after(orphan, parent, NULL);
__clk_recalc_accuracies(orphan);
__clk_recalc_rates(orphan, 0);
}
}
}

/**
* __clk_core_init - initialize the data structures in a struct clk_core
* @core: clk_core being initialized
Expand All @@ -3259,8 +3287,6 @@ static inline void clk_debug_unregister(struct clk_core *core)
static int __clk_core_init(struct clk_core *core)
{
int ret;
struct clk_core *orphan;
struct hlist_node *tmp2;
unsigned long rate;

if (!core)
Expand Down Expand Up @@ -3409,34 +3435,26 @@ static int __clk_core_init(struct clk_core *core)
if (core->flags & CLK_IS_CRITICAL) {
unsigned long flags;

clk_core_prepare(core);
ret = clk_core_prepare(core);
if (ret) {
pr_warn("%s: critical clk '%s' failed to prepare\n",
__func__, core->name);
goto out;
}

flags = clk_enable_lock();
clk_core_enable(core);
ret = clk_core_enable(core);
clk_enable_unlock(flags);
if (ret) {
pr_warn("%s: critical clk '%s' failed to enable\n",
__func__, core->name);
clk_core_unprepare(core);
goto out;
}
}

/*
* walk the list of orphan clocks and reparent any that newly finds a
* parent.
*/
hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) {
struct clk_core *parent = __clk_init_parent(orphan);
clk_core_reparent_orphans_nolock();

/*
* We need to use __clk_set_parent_before() and _after() to
* to properly migrate any prepare/enable count of the orphan
* clock. This is important for CLK_IS_CRITICAL clocks, which
* are enabled during init but might not have a parent yet.
*/
if (parent) {
/* update the clk tree topology */
__clk_set_parent_before(orphan, parent);
__clk_set_parent_after(orphan, parent, NULL);
__clk_recalc_accuracies(orphan);
__clk_recalc_rates(orphan, 0);
}
}

kref_init(&core->ref);
out:
Expand Down Expand Up @@ -4216,6 +4234,13 @@ int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb)
EXPORT_SYMBOL_GPL(clk_notifier_unregister);

#ifdef CONFIG_OF
static void clk_core_reparent_orphans(void)
{
clk_prepare_lock();
clk_core_reparent_orphans_nolock();
clk_prepare_unlock();
}

/**
* struct of_clk_provider - Clock provider registration structure
* @link: Entry in global list of clock providers
Expand Down Expand Up @@ -4311,6 +4336,8 @@ int of_clk_add_provider(struct device_node *np,
mutex_unlock(&of_clk_mutex);
pr_debug("Added clock from %pOF\n", np);

clk_core_reparent_orphans();

ret = of_clk_set_defaults(np, true);
if (ret < 0)
of_clk_del_provider(np);
Expand Down Expand Up @@ -4346,6 +4373,8 @@ int of_clk_add_hw_provider(struct device_node *np,
mutex_unlock(&of_clk_mutex);
pr_debug("Added clk_hw provider from %pOF\n", np);

clk_core_reparent_orphans();

ret = of_clk_set_defaults(np, true);
if (ret < 0)
of_clk_del_provider(np);
Expand Down
2 changes: 2 additions & 0 deletions drivers/clk/imx/clk-composite-8m.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ struct clk *imx8m_clk_composite_flags(const char *name,
mux->reg = reg;
mux->shift = PCG_PCS_SHIFT;
mux->mask = PCG_PCS_MASK;
mux->lock = &imx_ccm_lock;

div = kzalloc(sizeof(*div), GFP_KERNEL);
if (!div)
Expand All @@ -161,6 +162,7 @@ struct clk *imx8m_clk_composite_flags(const char *name,
gate_hw = &gate->hw;
gate->reg = reg;
gate->bit_idx = PCG_CGC_SHIFT;
gate->lock = &imx_ccm_lock;

hw = clk_hw_register_composite(NULL, name, parent_names, num_parents,
mux_hw, &clk_mux_ops, div_hw,
Expand Down
1 change: 1 addition & 0 deletions drivers/clk/imx/clk-imx7ulp.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ static const struct clk_div_table ulp_div_table[] = {
{ .val = 5, .div = 16, },
{ .val = 6, .div = 32, },
{ .val = 7, .div = 64, },
{ /* sentinel */ },
};

static const int pcc2_uart_clk_ids[] __initconst = {
Expand Down
2 changes: 1 addition & 1 deletion drivers/clk/imx/clk-pll14xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static int clk_pll14xx_wait_lock(struct clk_pll14xx *pll)
{
u32 val;

return readl_poll_timeout(pll->base, val, val & LOCK_TIMEOUT_US, 0,
return readl_poll_timeout(pll->base, val, val & LOCK_STATUS, 0,
LOCK_TIMEOUT_US);
}

Expand Down
44 changes: 22 additions & 22 deletions drivers/clk/mediatek/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -174,36 +174,36 @@ config COMMON_CLK_MT6779_AUDSYS
This driver supports Mediatek MT6779 audsys clocks.

config COMMON_CLK_MT6797
bool "Clock driver for MediaTek MT6797"
depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST
select COMMON_CLK_MEDIATEK
default ARCH_MEDIATEK && ARM64
---help---
This driver supports MediaTek MT6797 basic clocks.
bool "Clock driver for MediaTek MT6797"
depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST
select COMMON_CLK_MEDIATEK
default ARCH_MEDIATEK && ARM64
---help---
This driver supports MediaTek MT6797 basic clocks.

config COMMON_CLK_MT6797_MMSYS
bool "Clock driver for MediaTek MT6797 mmsys"
depends on COMMON_CLK_MT6797
---help---
This driver supports MediaTek MT6797 mmsys clocks.
bool "Clock driver for MediaTek MT6797 mmsys"
depends on COMMON_CLK_MT6797
---help---
This driver supports MediaTek MT6797 mmsys clocks.

config COMMON_CLK_MT6797_IMGSYS
bool "Clock driver for MediaTek MT6797 imgsys"
depends on COMMON_CLK_MT6797
---help---
This driver supports MediaTek MT6797 imgsys clocks.
bool "Clock driver for MediaTek MT6797 imgsys"
depends on COMMON_CLK_MT6797
---help---
This driver supports MediaTek MT6797 imgsys clocks.

config COMMON_CLK_MT6797_VDECSYS
bool "Clock driver for MediaTek MT6797 vdecsys"
depends on COMMON_CLK_MT6797
---help---
This driver supports MediaTek MT6797 vdecsys clocks.
bool "Clock driver for MediaTek MT6797 vdecsys"
depends on COMMON_CLK_MT6797
---help---
This driver supports MediaTek MT6797 vdecsys clocks.

config COMMON_CLK_MT6797_VENCSYS
bool "Clock driver for MediaTek MT6797 vencsys"
depends on COMMON_CLK_MT6797
---help---
This driver supports MediaTek MT6797 vencsys clocks.
bool "Clock driver for MediaTek MT6797 vencsys"
depends on COMMON_CLK_MT6797
---help---
This driver supports MediaTek MT6797 vencsys clocks.

config COMMON_CLK_MT7622
bool "Clock driver for MediaTek MT7622"
Expand Down
2 changes: 1 addition & 1 deletion drivers/clk/mvebu/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ config ARMADA_39X_CLK
select MVEBU_CLK_COMMON

config ARMADA_37XX_CLK
bool
bool

config ARMADA_XP_CLK
bool
Expand Down
4 changes: 2 additions & 2 deletions drivers/clk/qcom/Kconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only
config KRAIT_CLOCKS
bool
select KRAIT_L2_ACCESSORS
bool
select KRAIT_L2_ACCESSORS

config QCOM_GDSC
bool
Expand Down
6 changes: 4 additions & 2 deletions drivers/clk/qcom/gcc-sc7180.c
Original file line number Diff line number Diff line change
Expand Up @@ -2186,15 +2186,17 @@ static struct gdsc hlos1_vote_mmnoc_mmu_tbu_hf0_gdsc = {
.pd = {
.name = "hlos1_vote_mmnoc_mmu_tbu_hf0_gdsc",
},
.pwrsts = PWRSTS_OFF_ON | VOTABLE,
.pwrsts = PWRSTS_OFF_ON,
.flags = VOTABLE,
};

static struct gdsc hlos1_vote_mmnoc_mmu_tbu_sf_gdsc = {
.gdscr = 0x7d044,
.pd = {
.name = "hlos1_vote_mmnoc_mmu_tbu_sf_gdsc",
},
.pwrsts = PWRSTS_OFF_ON | VOTABLE,
.pwrsts = PWRSTS_OFF_ON,
.flags = VOTABLE,
};

static struct gdsc *gcc_sc7180_gdscs[] = {
Expand Down
2 changes: 2 additions & 0 deletions drivers/clk/qcom/gpucc-msm8998.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,12 @@ static struct clk_branch gfx3d_isense_clk = {

static struct gdsc gpu_cx_gdsc = {
.gdscr = 0x1004,
.gds_hw_ctrl = 0x1008,
.pd = {
.name = "gpu_cx",
},
.pwrsts = PWRSTS_OFF_ON,
.flags = VOTABLE,
};

static struct gdsc gpu_gx_gdsc = {
Expand Down
8 changes: 8 additions & 0 deletions drivers/clk/samsung/clk-exynos5420.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <linux/clk-provider.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/clk.h>

#include "clk.h"
#include "clk-cpu.h"
Expand Down Expand Up @@ -1646,6 +1647,13 @@ static void __init exynos5x_clk_init(struct device_node *np,
exynos5x_subcmus);
}

/*
* Keep top part of G3D clock path enabled permanently to ensure
* that the internal busses get their clock regardless of the
* main G3D clock enablement status.
*/
clk_prepare_enable(__clk_lookup("mout_sw_aclk_g3d"));

samsung_clk_of_add_provider(np, ctx);
}

Expand Down
4 changes: 3 additions & 1 deletion drivers/clk/tegra/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,10 @@ struct clk ** __init tegra_clk_init(void __iomem *regs, int num, int banks)
periph_banks = banks;

clks = kcalloc(num, sizeof(struct clk *), GFP_KERNEL);
if (!clks)
if (!clks) {
kfree(periph_clk_enb_refcnt);
return NULL;
}

clk_num = num;

Expand Down
Loading

0 comments on commit 36bf7a5

Please sign in to comment.