2020-02-29 08:25:20 +00:00
|
|
|
From b7c3fda0df5da90e87b037348c6d27f669c38388 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Phil Elwell <phil@raspberrypi.org>
|
|
|
|
Date: Mon, 13 Feb 2017 17:20:08 +0000
|
|
|
|
Subject: [PATCH] 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 <phil@raspberrypi.org>
|
|
|
|
---
|
|
|
|
drivers/clk/bcm/clk-bcm2835.c | 34 ++++++++++++++++++++++++++++++++--
|
|
|
|
1 file changed, 32 insertions(+), 2 deletions(-)
|
|
|
|
|
|
|
|
--- a/drivers/clk/bcm/clk-bcm2835.c
|
|
|
|
+++ b/drivers/clk/bcm/clk-bcm2835.c
|
2020-08-21 16:16:42 +00:00
|
|
|
@@ -1311,6 +1311,8 @@ static const struct clk_ops bcm2835_vpu_
|
2020-02-29 08:25:20 +00:00
|
|
|
.debug_init = bcm2835_clock_debug_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
+static bool bcm2835_clk_is_claimed(const char *name);
|
|
|
|
+
|
|
|
|
static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
|
|
|
|
const struct bcm2835_pll_data *data)
|
|
|
|
{
|
2020-08-21 16:16:42 +00:00
|
|
|
@@ -1327,6 +1329,9 @@ static struct clk_hw *bcm2835_register_p
|
2020-02-29 08:25:20 +00:00
|
|
|
init.ops = &bcm2835_pll_clk_ops;
|
|
|
|
init.flags = CLK_IGNORE_UNUSED;
|
|
|
|
|
|
|
|
+ if (!bcm2835_clk_is_claimed(data->name))
|
|
|
|
+ init.flags |= CLK_IS_CRITICAL;
|
|
|
|
+
|
|
|
|
pll = kzalloc(sizeof(*pll), GFP_KERNEL);
|
|
|
|
if (!pll)
|
|
|
|
return NULL;
|
2020-08-21 16:16:42 +00:00
|
|
|
@@ -1380,8 +1385,10 @@ bcm2835_register_pll_divider(struct bcm2
|
2020-02-29 08:25:20 +00:00
|
|
|
divider->div.table = NULL;
|
|
|
|
|
|
|
|
if (!(cprman_read(cprman, data->cm_reg) & data->hold_mask)) {
|
|
|
|
- init.flags |= CLK_IS_CRITICAL;
|
|
|
|
- divider->div.flags |= CLK_IS_CRITICAL;
|
|
|
|
+ if (!bcm2835_clk_is_claimed(data->source_pll))
|
|
|
|
+ init.flags |= CLK_IS_CRITICAL;
|
|
|
|
+ if (!bcm2835_clk_is_claimed(data->name))
|
|
|
|
+ divider->div.flags |= CLK_IS_CRITICAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
divider->cprman = cprman;
|
2020-08-21 16:16:42 +00:00
|
|
|
@@ -2189,6 +2196,8 @@ static const struct bcm2835_clk_desc clk
|
2020-02-29 08:25:20 +00:00
|
|
|
.ctl_reg = CM_PERIICTL),
|
|
|
|
};
|
|
|
|
|
|
|
|
+static bool bcm2835_clk_claimed[ARRAY_SIZE(clk_desc_array)];
|
|
|
|
+
|
|
|
|
/*
|
|
|
|
* Permanently take a reference on the parent of the SDRAM clock.
|
|
|
|
*
|
2020-08-21 16:16:42 +00:00
|
|
|
@@ -2208,6 +2217,19 @@ static int bcm2835_mark_sdc_parent_criti
|
2020-02-29 08:25:20 +00:00
|
|
|
return clk_prepare_enable(parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
+static bool bcm2835_clk_is_claimed(const char *name)
|
|
|
|
+{
|
|
|
|
+ int i;
|
|
|
|
+
|
|
|
|
+ for (i = 0; i < ARRAY_SIZE(clk_desc_array); i++) {
|
|
|
|
+ const char *clk_name = *(const char **)(clk_desc_array[i].data);
|
|
|
|
+ if (!strcmp(name, clk_name))
|
|
|
|
+ return bcm2835_clk_claimed[i];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static int bcm2835_clk_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct device *dev = &pdev->dev;
|
2020-08-21 16:16:42 +00:00
|
|
|
@@ -2218,6 +2240,7 @@ static int bcm2835_clk_probe(struct plat
|
2020-02-29 08:25:20 +00:00
|
|
|
const size_t asize = ARRAY_SIZE(clk_desc_array);
|
|
|
|
const struct cprman_plat_data *pdata;
|
|
|
|
size_t i;
|
|
|
|
+ u32 clk_id;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
pdata = of_device_get_match_data(&pdev->dev);
|
2020-08-21 16:16:42 +00:00
|
|
|
@@ -2237,6 +2260,13 @@ static int bcm2835_clk_probe(struct plat
|
2020-02-29 08:25:20 +00:00
|
|
|
if (IS_ERR(cprman->regs))
|
|
|
|
return PTR_ERR(cprman->regs);
|
|
|
|
|
|
|
|
+ memset(bcm2835_clk_claimed, 0, sizeof(bcm2835_clk_claimed));
|
|
|
|
+ for (i = 0;
|
|
|
|
+ !of_property_read_u32_index(pdev->dev.of_node, "claim-clocks",
|
|
|
|
+ i, &clk_id);
|
|
|
|
+ i++)
|
|
|
|
+ bcm2835_clk_claimed[clk_id]= true;
|
|
|
|
+
|
|
|
|
memcpy(cprman->real_parent_names, cprman_parent_names,
|
|
|
|
sizeof(cprman_parent_names));
|
|
|
|
of_clk_parent_fill(dev->of_node, cprman->real_parent_names,
|