Commit 42d21900 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux

Pull clk fixes from Stephen Boyd:
 "A few fixes for code that came in during the merge window or that
  started getting exercised differently this time around:

   - Select regmap MMIO kconfig in spreadtrum driver to avoid compile
     errors

   - Complete kerneldoc on devm_clk_bulk_get_optional()

   - Register an essential clk earlier on mediatek mt8183 SoCs so the
     clocksource driver can use it

   - Fix divisor math in the at91 driver

   - Plug a race in Renesas reset control logic"

* tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux:
  clk: renesas: cpg-mssr: Fix reset control race condition
  clk: sprd: Select REGMAP_MMIO to avoid compile errors
  clk: mediatek: mt8183: Register 13MHz clock earlier for clocksource
  clk: Add missing documentation of devm_clk_bulk_get_optional() argument
  clk: at91: generated: Truncate divisor to GENERATED_MAX_DIV + 1
parents 234172f6 e1f1ae80
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -141,6 +141,8 @@ static int clk_generated_determine_rate(struct clk_hw *hw,
			continue;

		div = DIV_ROUND_CLOSEST(parent_rate, req->rate);
		if (div > GENERATED_MAX_DIV + 1)
			div = GENERATED_MAX_DIV + 1;

		clk_generated_best_diff(req, parent, parent_rate, div,
					&best_diff, &best_rate);
+34 −12
Original line number Diff line number Diff line
@@ -25,9 +25,11 @@ static const struct mtk_fixed_clk top_fixed_clks[] = {
	FIXED_CLK(CLK_TOP_UNIVP_192M, "univpll_192m", "univpll", 192000000),
};

static const struct mtk_fixed_factor top_early_divs[] = {
	FACTOR(CLK_TOP_CLK13M, "clk13m", "clk26m", 1, 2),
};

static const struct mtk_fixed_factor top_divs[] = {
	FACTOR(CLK_TOP_CLK13M, "clk13m", "clk26m", 1,
		2),
	FACTOR(CLK_TOP_F26M_CK_D2, "csw_f26m_ck_d2", "clk26m", 1,
		2),
	FACTOR(CLK_TOP_SYSPLL_CK, "syspll_ck", "mainpll", 1,
@@ -1148,37 +1150,57 @@ static int clk_mt8183_apmixed_probe(struct platform_device *pdev)
	return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
}

static struct clk_onecell_data *top_clk_data;

static void clk_mt8183_top_init_early(struct device_node *node)
{
	int i;

	top_clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);

	for (i = 0; i < CLK_TOP_NR_CLK; i++)
		top_clk_data->clks[i] = ERR_PTR(-EPROBE_DEFER);

	mtk_clk_register_factors(top_early_divs, ARRAY_SIZE(top_early_divs),
			top_clk_data);

	of_clk_add_provider(node, of_clk_src_onecell_get, top_clk_data);
}

CLK_OF_DECLARE_DRIVER(mt8183_topckgen, "mediatek,mt8183-topckgen",
			clk_mt8183_top_init_early);

static int clk_mt8183_top_probe(struct platform_device *pdev)
{
	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	void __iomem *base;
	struct clk_onecell_data *clk_data;
	struct device_node *node = pdev->dev.of_node;

	base = devm_ioremap_resource(&pdev->dev, res);
	if (IS_ERR(base))
		return PTR_ERR(base);

	clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);

	mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
		clk_data);
		top_clk_data);

	mtk_clk_register_factors(top_early_divs, ARRAY_SIZE(top_early_divs),
		top_clk_data);

	mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
	mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data);

	mtk_clk_register_muxes(top_muxes, ARRAY_SIZE(top_muxes),
		node, &mt8183_clk_lock, clk_data);
		node, &mt8183_clk_lock, top_clk_data);

	mtk_clk_register_composites(top_aud_muxes, ARRAY_SIZE(top_aud_muxes),
		base, &mt8183_clk_lock, clk_data);
		base, &mt8183_clk_lock, top_clk_data);

	mtk_clk_register_composites(top_aud_divs, ARRAY_SIZE(top_aud_divs),
		base, &mt8183_clk_lock, clk_data);
		base, &mt8183_clk_lock, top_clk_data);

	mtk_clk_register_gates(node, top_clks, ARRAY_SIZE(top_clks),
		clk_data);
		top_clk_data);

	return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
	return of_clk_add_provider(node, of_clk_src_onecell_get, top_clk_data);
}

static int clk_mt8183_infra_probe(struct platform_device *pdev)
+2 −14
Original line number Diff line number Diff line
@@ -572,17 +572,11 @@ static int cpg_mssr_reset(struct reset_controller_dev *rcdev,
	unsigned int reg = id / 32;
	unsigned int bit = id % 32;
	u32 bitmask = BIT(bit);
	unsigned long flags;
	u32 value;

	dev_dbg(priv->dev, "reset %u%02u\n", reg, bit);

	/* Reset module */
	spin_lock_irqsave(&priv->rmw_lock, flags);
	value = readl(priv->base + SRCR(reg));
	value |= bitmask;
	writel(value, priv->base + SRCR(reg));
	spin_unlock_irqrestore(&priv->rmw_lock, flags);
	writel(bitmask, priv->base + SRCR(reg));

	/* Wait for at least one cycle of the RCLK clock (@ ca. 32 kHz) */
	udelay(35);
@@ -599,16 +593,10 @@ static int cpg_mssr_assert(struct reset_controller_dev *rcdev, unsigned long id)
	unsigned int reg = id / 32;
	unsigned int bit = id % 32;
	u32 bitmask = BIT(bit);
	unsigned long flags;
	u32 value;

	dev_dbg(priv->dev, "assert %u%02u\n", reg, bit);

	spin_lock_irqsave(&priv->rmw_lock, flags);
	value = readl(priv->base + SRCR(reg));
	value |= bitmask;
	writel(value, priv->base + SRCR(reg));
	spin_unlock_irqrestore(&priv->rmw_lock, flags);
	writel(bitmask, priv->base + SRCR(reg));
	return 0;
}

+1 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ config SPRD_COMMON_CLK
	tristate "Clock support for Spreadtrum SoCs"
	depends on ARCH_SPRD || COMPILE_TEST
	default ARCH_SPRD
	select REGMAP_MMIO

if SPRD_COMMON_CLK

+1 −0
Original line number Diff line number Diff line
@@ -359,6 +359,7 @@ int __must_check devm_clk_bulk_get(struct device *dev, int num_clks,
/**
 * devm_clk_bulk_get_optional - managed get multiple optional consumer clocks
 * @dev: device for clock "consumer"
 * @num_clks: the number of clk_bulk_data
 * @clks: pointer to the clk_bulk_data table of consumer
 *
 * Behaves the same as devm_clk_bulk_get() except where there is no clock