drm: panfrost: add optional bus_clock
authorClément Péron <peron.clem@gmail.com>
Tue, 21 May 2019 16:10:57 +0000 (18:10 +0200)
committerRob Herring <robh@kernel.org>
Wed, 22 May 2019 19:23:29 +0000 (14:23 -0500)
Allwinner H6 has an ARM Mali-T720 MP2 which required a bus_clock.

Add an optional bus_clock at the init of the panfrost driver.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190521161102.29620-2-peron.clem@gmail.com
drivers/gpu/drm/panfrost/panfrost_device.c
drivers/gpu/drm/panfrost/panfrost_device.h

index 970f669c6d29336ce513d2e1df12219030a3c17a..e6b3171c71798c14c276e55b4b2088779e8eda71 100644 (file)
@@ -55,11 +55,33 @@ static int panfrost_clk_init(struct panfrost_device *pfdev)
        if (err)
                return err;
 
+       pfdev->bus_clock = devm_clk_get_optional(pfdev->dev, "bus");
+       if (IS_ERR(pfdev->bus_clock)) {
+               dev_err(pfdev->dev, "get bus_clock failed %ld\n",
+                       PTR_ERR(pfdev->bus_clock));
+               return PTR_ERR(pfdev->bus_clock);
+       }
+
+       if (pfdev->bus_clock) {
+               rate = clk_get_rate(pfdev->bus_clock);
+               dev_info(pfdev->dev, "bus_clock rate = %lu\n", rate);
+
+               err = clk_prepare_enable(pfdev->bus_clock);
+               if (err)
+                       goto disable_clock;
+       }
+
        return 0;
+
+disable_clock:
+       clk_disable_unprepare(pfdev->clock);
+
+       return err;
 }
 
 static void panfrost_clk_fini(struct panfrost_device *pfdev)
 {
+       clk_disable_unprepare(pfdev->bus_clock);
        clk_disable_unprepare(pfdev->clock);
 }
 
index 56f452dfb4900ef586aacf16c78f7f5a7d64ade5..8074f221034bc1b42aab4ce2a288ea155013f23b 100644 (file)
@@ -66,6 +66,7 @@ struct panfrost_device {
 
        void __iomem *iomem;
        struct clk *clock;
+       struct clk *bus_clock;
        struct regulator *regulator;
        struct reset_control *rstc;