Skip to content

Commit 204050d

Browse files
Phil Elwellpopcornmix
Phil Elwell
authored andcommitted
clk-bcm2835: Add claim-clocks property
The claim-clocks property can be used to prevent PLLs and dividers from being marked as critical. It contains a vector of clock IDs, as defined by dt-bindings/clock/bcm2835.h. Use this mechanism to claim PLLD_DSI0, PLLD_DSI1, PLLH_AUX and PLLH_PIX for the vc4_kms_v3d driver. Signed-off-by: Phil Elwell <[email protected]>
1 parent 5c083e5 commit 204050d

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

arch/arm/boot/dts/overlays/vc4-kms-v3d-overlay.dts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
/dts-v1/;
66
/plugin/;
77

8+
#include <dt-bindings/clock/bcm2835.h>
9+
810
/ {
911
compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
1012

@@ -155,6 +157,18 @@
155157
};
156158
};
157159

160+
fragment@19 {
161+
target = <&clocks>;
162+
__overlay__ {
163+
claim-clocks = <
164+
BCM2835_PLLD_DSI0
165+
BCM2835_PLLD_DSI1
166+
BCM2835_PLLH_AUX
167+
BCM2835_PLLH_PIX
168+
>;
169+
};
170+
};
171+
158172
__overrides__ {
159173
cma-256 = <0>,"+0-1-2-3-4";
160174
cma-192 = <0>,"-0+1-2-3-4";

drivers/clk/bcm/clk-bcm2835.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,8 @@ static const struct clk_ops bcm2835_vpu_clock_clk_ops = {
12981298
.debug_init = bcm2835_clock_debug_init,
12991299
};
13001300

1301+
static bool bcm2835_clk_is_claimed(const char *name);
1302+
13011303
static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
13021304
const struct bcm2835_pll_data *data)
13031305
{
@@ -1314,6 +1316,9 @@ static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
13141316
init.ops = &bcm2835_pll_clk_ops;
13151317
init.flags = CLK_IGNORE_UNUSED;
13161318

1319+
if (!bcm2835_clk_is_claimed(data->name))
1320+
init.flags |= CLK_IS_CRITICAL;
1321+
13171322
pll = kzalloc(sizeof(*pll), GFP_KERNEL);
13181323
if (!pll)
13191324
return NULL;
@@ -1367,8 +1372,10 @@ bcm2835_register_pll_divider(struct bcm2835_cprman *cprman,
13671372
divider->div.table = NULL;
13681373

13691374
if (!(cprman_read(cprman, data->cm_reg) & data->hold_mask)) {
1370-
init.flags |= CLK_IS_CRITICAL;
1371-
divider->div.flags |= CLK_IS_CRITICAL;
1375+
if (!bcm2835_clk_is_claimed(data->source_pll))
1376+
init.flags |= CLK_IS_CRITICAL;
1377+
if (!bcm2835_clk_is_claimed(data->name))
1378+
divider->div.flags |= CLK_IS_CRITICAL;
13721379
}
13731380

13741381
divider->cprman = cprman;
@@ -2104,6 +2111,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
21042111
.ctl_reg = CM_PERIICTL),
21052112
};
21062113

2114+
static bool bcm2835_clk_claimed[ARRAY_SIZE(clk_desc_array)];
2115+
21072116
/*
21082117
* Permanently take a reference on the parent of the SDRAM clock.
21092118
*
@@ -2123,6 +2132,19 @@ static int bcm2835_mark_sdc_parent_critical(struct clk *sdc)
21232132
return clk_prepare_enable(parent);
21242133
}
21252134

2135+
static bool bcm2835_clk_is_claimed(const char *name)
2136+
{
2137+
int i;
2138+
2139+
for (i = 0; i < ARRAY_SIZE(clk_desc_array); i++) {
2140+
const char *clk_name = *(const char **)(clk_desc_array[i].data);
2141+
if (!strcmp(name, clk_name))
2142+
return bcm2835_clk_claimed[i];
2143+
}
2144+
2145+
return false;
2146+
}
2147+
21262148
static int bcm2835_clk_probe(struct platform_device *pdev)
21272149
{
21282150
struct device *dev = &pdev->dev;
@@ -2132,6 +2154,7 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
21322154
const struct bcm2835_clk_desc *desc;
21332155
const size_t asize = ARRAY_SIZE(clk_desc_array);
21342156
size_t i;
2157+
u32 clk_id;
21352158
int ret;
21362159

21372160
cprman = devm_kzalloc(dev, sizeof(*cprman) +
@@ -2147,6 +2170,13 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
21472170
if (IS_ERR(cprman->regs))
21482171
return PTR_ERR(cprman->regs);
21492172

2173+
memset(bcm2835_clk_claimed, 0, sizeof(bcm2835_clk_claimed));
2174+
for (i = 0;
2175+
!of_property_read_u32_index(pdev->dev.of_node, "claim-clocks",
2176+
i, &clk_id);
2177+
i++)
2178+
bcm2835_clk_claimed[clk_id]= true;
2179+
21502180
memcpy(cprman->real_parent_names, cprman_parent_names,
21512181
sizeof(cprman_parent_names));
21522182
of_clk_parent_fill(dev->of_node, cprman->real_parent_names,

0 commit comments

Comments
 (0)