]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/msm: move utility functions from msm_drv.c
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Wed, 19 Jan 2022 22:16:14 +0000 (01:16 +0300)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Fri, 18 Feb 2022 15:32:52 +0000 (18:32 +0300)
Move clock/IO/hrtimer utility functions from msm_drv.c to new
msm_io_utils.c file.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Jessica Zhang <quic_jesszhan@quicinc.com>
Link: https://lore.kernel.org/r/20220119221616.3089119-2-dmitry.baryshkov@linaro.org
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
drivers/gpu/drm/msm/Makefile
drivers/gpu/drm/msm/msm_drv.c
drivers/gpu/drm/msm/msm_io_utils.c [new file with mode: 0644]

index 03ab55c37beb6fe74eedc4c1e6e0079ad696f095..5b6e37477079af190473bf72d586abbeb2042d1b 100644 (file)
@@ -87,6 +87,7 @@ msm-y := \
        msm_gem_vma.o \
        msm_gpu.o \
        msm_gpu_devfreq.o \
+       msm_io_utils.o \
        msm_iommu.o \
        msm_perf.o \
        msm_rd.o \
index 68524e3a11138db1f9915ef58bb3cc9acae5b90f..d1bad842fcf2e5896ea3c5dcd06d37ba8cb08e96 100644 (file)
@@ -75,124 +75,6 @@ static bool modeset = true;
 MODULE_PARM_DESC(modeset, "Use kernel modesetting [KMS] (1=on (default), 0=disable)");
 module_param(modeset, bool, 0600);
 
-/*
- * Util/helpers:
- */
-
-struct clk *msm_clk_bulk_get_clock(struct clk_bulk_data *bulk, int count,
-               const char *name)
-{
-       int i;
-       char n[32];
-
-       snprintf(n, sizeof(n), "%s_clk", name);
-
-       for (i = 0; bulk && i < count; i++) {
-               if (!strcmp(bulk[i].id, name) || !strcmp(bulk[i].id, n))
-                       return bulk[i].clk;
-       }
-
-
-       return NULL;
-}
-
-struct clk *msm_clk_get(struct platform_device *pdev, const char *name)
-{
-       struct clk *clk;
-       char name2[32];
-
-       clk = devm_clk_get(&pdev->dev, name);
-       if (!IS_ERR(clk) || PTR_ERR(clk) == -EPROBE_DEFER)
-               return clk;
-
-       snprintf(name2, sizeof(name2), "%s_clk", name);
-
-       clk = devm_clk_get(&pdev->dev, name2);
-       if (!IS_ERR(clk))
-               dev_warn(&pdev->dev, "Using legacy clk name binding.  Use "
-                               "\"%s\" instead of \"%s\"\n", name, name2);
-
-       return clk;
-}
-
-static void __iomem *_msm_ioremap(struct platform_device *pdev, const char *name,
-                                 bool quiet, phys_addr_t *psize)
-{
-       struct resource *res;
-       unsigned long size;
-       void __iomem *ptr;
-
-       if (name)
-               res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
-       else
-               res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
-       if (!res) {
-               if (!quiet)
-                       DRM_DEV_ERROR(&pdev->dev, "failed to get memory resource: %s\n", name);
-               return ERR_PTR(-EINVAL);
-       }
-
-       size = resource_size(res);
-
-       ptr = devm_ioremap(&pdev->dev, res->start, size);
-       if (!ptr) {
-               if (!quiet)
-                       DRM_DEV_ERROR(&pdev->dev, "failed to ioremap: %s\n", name);
-               return ERR_PTR(-ENOMEM);
-       }
-
-       if (psize)
-               *psize = size;
-
-       return ptr;
-}
-
-void __iomem *msm_ioremap(struct platform_device *pdev, const char *name)
-{
-       return _msm_ioremap(pdev, name, false, NULL);
-}
-
-void __iomem *msm_ioremap_quiet(struct platform_device *pdev, const char *name)
-{
-       return _msm_ioremap(pdev, name, true, NULL);
-}
-
-void __iomem *msm_ioremap_size(struct platform_device *pdev, const char *name,
-                         phys_addr_t *psize)
-{
-       return _msm_ioremap(pdev, name, false, psize);
-}
-
-static enum hrtimer_restart msm_hrtimer_worktimer(struct hrtimer *t)
-{
-       struct msm_hrtimer_work *work = container_of(t,
-                       struct msm_hrtimer_work, timer);
-
-       kthread_queue_work(work->worker, &work->work);
-
-       return HRTIMER_NORESTART;
-}
-
-void msm_hrtimer_queue_work(struct msm_hrtimer_work *work,
-                           ktime_t wakeup_time,
-                           enum hrtimer_mode mode)
-{
-       hrtimer_start(&work->timer, wakeup_time, mode);
-}
-
-void msm_hrtimer_work_init(struct msm_hrtimer_work *work,
-                          struct kthread_worker *worker,
-                          kthread_work_func_t fn,
-                          clockid_t clock_id,
-                          enum hrtimer_mode mode)
-{
-       hrtimer_init(&work->timer, clock_id, mode);
-       work->timer.function = msm_hrtimer_worktimer;
-       work->worker = worker;
-       kthread_init_work(&work->work, fn);
-}
-
 static irqreturn_t msm_irq(int irq, void *arg)
 {
        struct drm_device *dev = arg;
diff --git a/drivers/gpu/drm/msm/msm_io_utils.c b/drivers/gpu/drm/msm/msm_io_utils.c
new file mode 100644 (file)
index 0000000..7b50461
--- /dev/null
@@ -0,0 +1,126 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2016-2018, 2020-2021 The Linux Foundation. All rights reserved.
+ * Copyright (C) 2013 Red Hat
+ * Author: Rob Clark <robdclark@gmail.com>
+ */
+
+#include "msm_drv.h"
+
+/*
+ * Util/helpers:
+ */
+
+struct clk *msm_clk_bulk_get_clock(struct clk_bulk_data *bulk, int count,
+               const char *name)
+{
+       int i;
+       char n[32];
+
+       snprintf(n, sizeof(n), "%s_clk", name);
+
+       for (i = 0; bulk && i < count; i++) {
+               if (!strcmp(bulk[i].id, name) || !strcmp(bulk[i].id, n))
+                       return bulk[i].clk;
+       }
+
+
+       return NULL;
+}
+
+struct clk *msm_clk_get(struct platform_device *pdev, const char *name)
+{
+       struct clk *clk;
+       char name2[32];
+
+       clk = devm_clk_get(&pdev->dev, name);
+       if (!IS_ERR(clk) || PTR_ERR(clk) == -EPROBE_DEFER)
+               return clk;
+
+       snprintf(name2, sizeof(name2), "%s_clk", name);
+
+       clk = devm_clk_get(&pdev->dev, name2);
+       if (!IS_ERR(clk))
+               dev_warn(&pdev->dev, "Using legacy clk name binding.  Use "
+                               "\"%s\" instead of \"%s\"\n", name, name2);
+
+       return clk;
+}
+
+static void __iomem *_msm_ioremap(struct platform_device *pdev, const char *name,
+                                 bool quiet, phys_addr_t *psize)
+{
+       struct resource *res;
+       unsigned long size;
+       void __iomem *ptr;
+
+       if (name)
+               res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
+       else
+               res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+       if (!res) {
+               if (!quiet)
+                       DRM_DEV_ERROR(&pdev->dev, "failed to get memory resource: %s\n", name);
+               return ERR_PTR(-EINVAL);
+       }
+
+       size = resource_size(res);
+
+       ptr = devm_ioremap(&pdev->dev, res->start, size);
+       if (!ptr) {
+               if (!quiet)
+                       DRM_DEV_ERROR(&pdev->dev, "failed to ioremap: %s\n", name);
+               return ERR_PTR(-ENOMEM);
+       }
+
+       if (psize)
+               *psize = size;
+
+       return ptr;
+}
+
+void __iomem *msm_ioremap(struct platform_device *pdev, const char *name)
+{
+       return _msm_ioremap(pdev, name, false, NULL);
+}
+
+void __iomem *msm_ioremap_quiet(struct platform_device *pdev, const char *name)
+{
+       return _msm_ioremap(pdev, name, true, NULL);
+}
+
+void __iomem *msm_ioremap_size(struct platform_device *pdev, const char *name,
+                         phys_addr_t *psize)
+{
+       return _msm_ioremap(pdev, name, false, psize);
+}
+
+static enum hrtimer_restart msm_hrtimer_worktimer(struct hrtimer *t)
+{
+       struct msm_hrtimer_work *work = container_of(t,
+                       struct msm_hrtimer_work, timer);
+
+       kthread_queue_work(work->worker, &work->work);
+
+       return HRTIMER_NORESTART;
+}
+
+void msm_hrtimer_queue_work(struct msm_hrtimer_work *work,
+                           ktime_t wakeup_time,
+                           enum hrtimer_mode mode)
+{
+       hrtimer_start(&work->timer, wakeup_time, mode);
+}
+
+void msm_hrtimer_work_init(struct msm_hrtimer_work *work,
+                          struct kthread_worker *worker,
+                          kthread_work_func_t fn,
+                          clockid_t clock_id,
+                          enum hrtimer_mode mode)
+{
+       hrtimer_init(&work->timer, clock_id, mode);
+       work->timer.function = msm_hrtimer_worktimer;
+       work->worker = worker;
+       kthread_init_work(&work->work, fn);
+}