1 From 5c1128ebe6c7a4af3f1784a640df7f3698233e9d Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Mon, 13 Feb 2017 17:20:08 +0000
4 Subject: [PATCH] clk-bcm2835: Add claim-clocks property
6 The claim-clocks property can be used to prevent PLLs and dividers
7 from being marked as critical. It contains a vector of clock IDs,
8 as defined by dt-bindings/clock/bcm2835.h.
10 Use this mechanism to claim PLLD_DSI0, PLLD_DSI1, PLLH_AUX and
11 PLLH_PIX for the vc4_kms_v3d driver.
13 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
15 arch/arm/boot/dts/overlays/vc4-kms-v3d-overlay.dts | 14 +++++++++
16 drivers/clk/bcm/clk-bcm2835.c | 34 ++++++++++++++++++++--
17 2 files changed, 46 insertions(+), 2 deletions(-)
19 --- a/arch/arm/boot/dts/overlays/vc4-kms-v3d-overlay.dts
20 +++ b/arch/arm/boot/dts/overlays/vc4-kms-v3d-overlay.dts
25 +#include <dt-bindings/clock/bcm2835.h>
28 compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
47 cma-256 = <0>,"+0-1-2-3-4";
48 cma-192 = <0>,"-0+1-2-3-4";
49 --- a/drivers/clk/bcm/clk-bcm2835.c
50 +++ b/drivers/clk/bcm/clk-bcm2835.c
51 @@ -1302,6 +1302,8 @@ static const struct clk_ops bcm2835_vpu_
52 .debug_init = bcm2835_clock_debug_init,
55 +static bool bcm2835_clk_is_claimed(const char *name);
57 static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
58 const struct bcm2835_pll_data *data)
60 @@ -1318,6 +1320,9 @@ static struct clk_hw *bcm2835_register_p
61 init.ops = &bcm2835_pll_clk_ops;
62 init.flags = CLK_IGNORE_UNUSED;
64 + if (!bcm2835_clk_is_claimed(data->name))
65 + init.flags |= CLK_IS_CRITICAL;
67 pll = kzalloc(sizeof(*pll), GFP_KERNEL);
70 @@ -1371,8 +1376,10 @@ bcm2835_register_pll_divider(struct bcm2
71 divider->div.table = NULL;
73 if (!(cprman_read(cprman, data->cm_reg) & data->hold_mask)) {
74 - init.flags |= CLK_IS_CRITICAL;
75 - divider->div.flags |= CLK_IS_CRITICAL;
76 + if (!bcm2835_clk_is_claimed(data->source_pll))
77 + init.flags |= CLK_IS_CRITICAL;
78 + if (!bcm2835_clk_is_claimed(data->name))
79 + divider->div.flags |= CLK_IS_CRITICAL;
82 divider->cprman = cprman;
83 @@ -2108,6 +2115,8 @@ static const struct bcm2835_clk_desc clk
84 .ctl_reg = CM_PERIICTL),
87 +static bool bcm2835_clk_claimed[ARRAY_SIZE(clk_desc_array)];
90 * Permanently take a reference on the parent of the SDRAM clock.
92 @@ -2127,6 +2136,19 @@ static int bcm2835_mark_sdc_parent_criti
93 return clk_prepare_enable(parent);
96 +static bool bcm2835_clk_is_claimed(const char *name)
100 + for (i = 0; i < ARRAY_SIZE(clk_desc_array); i++) {
101 + const char *clk_name = *(const char **)(clk_desc_array[i].data);
102 + if (!strcmp(name, clk_name))
103 + return bcm2835_clk_claimed[i];
109 static int bcm2835_clk_probe(struct platform_device *pdev)
111 struct device *dev = &pdev->dev;
112 @@ -2136,6 +2158,7 @@ static int bcm2835_clk_probe(struct plat
113 const struct bcm2835_clk_desc *desc;
114 const size_t asize = ARRAY_SIZE(clk_desc_array);
119 cprman = devm_kzalloc(dev, sizeof(*cprman) +
120 @@ -2151,6 +2174,13 @@ static int bcm2835_clk_probe(struct plat
121 if (IS_ERR(cprman->regs))
122 return PTR_ERR(cprman->regs);
124 + memset(bcm2835_clk_claimed, 0, sizeof(bcm2835_clk_claimed));
126 + !of_property_read_u32_index(pdev->dev.of_node, "claim-clocks",
129 + bcm2835_clk_claimed[clk_id]= true;
131 memcpy(cprman->real_parent_names, cprman_parent_names,
132 sizeof(cprman_parent_names));
133 of_clk_parent_fill(dev->of_node, cprman->real_parent_names,