]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
clk-bcm2835: Add claim-clocks property
authorPhil Elwell <phil@raspberrypi.org>
Mon, 13 Feb 2017 17:20:08 +0000 (17:20 +0000)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 8 Aug 2017 12:51:58 +0000 (14:51 +0200)
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>
arch/arm/boot/dts/overlays/vc4-kms-v3d-overlay.dts
drivers/clk/bcm/clk-bcm2835.c

index 4f1cc20f90dc6780f74e08ebee00e5a1a6062c85..fb45c6456b181b047d6cff8784f7696eb75da3c7 100644 (file)
@@ -5,6 +5,8 @@
 /dts-v1/;
 /plugin/;
 
+#include <dt-bindings/clock/bcm2835.h>
+
 / {
        compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
 
                };
        };
 
+
+       fragment@16 {
+               target = <&clocks>;
+               __overlay__  {
+                       claim-clocks = <
+                               BCM2835_PLLD_DSI0
+                               BCM2835_PLLD_DSI1
+                               BCM2835_PLLH_AUX
+                               BCM2835_PLLH_PIX
+                       >;
+               };
+       };
+
        __overrides__ {
                cma-256 = <0>,"+0-1-2-3-4";
                cma-192 = <0>,"-0+1-2-3-4";
index 33bfa2008479153402d188d71d382f0274c104ea..0b62d20f8b718cfd03c0346af784688e26e9dcb6 100644 (file)
@@ -1198,6 +1198,8 @@ static const struct clk_ops bcm2835_vpu_clock_clk_ops = {
        .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)
 {
@@ -1214,6 +1216,9 @@ static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
        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;
@@ -1267,8 +1272,10 @@ bcm2835_register_pll_divider(struct bcm2835_cprman *cprman,
        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;
@@ -1901,6 +1908,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
                .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.
  *
@@ -1920,6 +1929,19 @@ static int bcm2835_mark_sdc_parent_critical(struct clk *sdc)
        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;
@@ -1929,6 +1951,7 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
        const struct bcm2835_clk_desc *desc;
        const size_t asize = ARRAY_SIZE(clk_desc_array);
        size_t i;
+       u32 clk_id;
        int ret;
 
        cprman = devm_kzalloc(dev, sizeof(*cprman) +
@@ -1944,6 +1967,13 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
        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;
+
        cprman->osc_name = of_clk_get_parent_name(dev->of_node, 0);
        if (!cprman->osc_name)
                return -ENODEV;