forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/video/fbdev/pxa3xx-gcu.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * pxa3xx-gcu.c - Linux kernel module for PXA3xx graphics controllers
34 *
....@@ -7,20 +8,6 @@
78 * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
89 * Copyright (c) 2009 Janine Kropp <nin@directfb.org>
910 * Copyright (c) 2009 Denis Oliver Kropp <dok@directfb.org>
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License as published by
13
- * the Free Software Foundation; either version 2 of the License, or
14
- * (at your option) any later version.
15
- *
16
- * This program is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU General Public License
22
- * along with this program; if not, write to the Free Software
23
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2411 */
2512
2613 /*
....@@ -49,7 +36,6 @@
4936 #include "pxa3xx-gcu.h"
5037
5138 #define DRV_NAME "pxa3xx-gcu"
52
-#define MISCDEV_MINOR 197
5339
5440 #define REG_GCCR 0x00
5541 #define GCCR_SYNC_CLR (1 << 9)
....@@ -96,6 +82,7 @@
9682 };
9783
9884 struct pxa3xx_gcu_priv {
85
+ struct device *dev;
9986 void __iomem *mmio_base;
10087 struct clk *clk;
10188 struct pxa3xx_gcu_shared *shared;
....@@ -394,7 +381,7 @@
394381 struct pxa3xx_gcu_batch *buffer;
395382 struct pxa3xx_gcu_priv *priv = to_pxa3xx_gcu_priv(file);
396383
397
- int words = count / 4;
384
+ size_t words = count / 4;
398385
399386 /* Does not need to be atomic. There's a lock in user space,
400387 * but anyhow, this is just for statistics. */
....@@ -493,7 +480,7 @@
493480 if (size != SHARED_SIZE)
494481 return -EINVAL;
495482
496
- return dma_mmap_coherent(NULL, vma,
483
+ return dma_mmap_coherent(priv->dev, vma,
497484 priv->shared, priv->shared_phys, size);
498485
499486 case SHARED_SIZE >> PAGE_SHIFT:
....@@ -607,7 +594,7 @@
607594 * container_of(). This isn't really necessary as we have a fixed minor
608595 * number anyway, but this is to avoid statics. */
609596
610
- priv->misc_dev.minor = MISCDEV_MINOR,
597
+ priv->misc_dev.minor = PXA3XX_GCU_MINOR,
611598 priv->misc_dev.name = DRV_NAME,
612599 priv->misc_dev.fops = &pxa3xx_gcu_miscdev_fops;
613600
....@@ -650,7 +637,7 @@
650637 ret = misc_register(&priv->misc_dev);
651638 if (ret < 0) {
652639 dev_err(dev, "misc_register() for minor %d failed\n",
653
- MISCDEV_MINOR);
640
+ PXA3XX_GCU_MINOR);
654641 goto err_free_dma;
655642 }
656643
....@@ -663,6 +650,7 @@
663650 for (i = 0; i < 8; i++) {
664651 ret = pxa3xx_gcu_add_buffer(dev, priv);
665652 if (ret) {
653
+ pxa3xx_gcu_free_buffers(dev, priv);
666654 dev_err(dev, "failed to allocate DMA memory\n");
667655 goto err_disable_clk;
668656 }
....@@ -670,6 +658,7 @@
670658
671659 platform_set_drvdata(pdev, priv);
672660 priv->resource_mem = r;
661
+ priv->dev = dev;
673662 pxa3xx_gcu_reset(priv);
674663 pxa3xx_gcu_init_debug_timer(priv);
675664
....@@ -678,15 +667,15 @@
678667 SHARED_SIZE, irq);
679668 return 0;
680669
681
-err_free_dma:
682
- dma_free_coherent(dev, SHARED_SIZE,
683
- priv->shared, priv->shared_phys);
670
+err_disable_clk:
671
+ clk_disable_unprepare(priv->clk);
684672
685673 err_misc_deregister:
686674 misc_deregister(&priv->misc_dev);
687675
688
-err_disable_clk:
689
- clk_disable_unprepare(priv->clk);
676
+err_free_dma:
677
+ dma_free_coherent(dev, SHARED_SIZE,
678
+ priv->shared, priv->shared_phys);
690679
691680 return ret;
692681 }
....@@ -699,6 +688,7 @@
699688 pxa3xx_gcu_wait_idle(priv);
700689 misc_deregister(&priv->misc_dev);
701690 dma_free_coherent(dev, SHARED_SIZE, priv->shared, priv->shared_phys);
691
+ clk_disable_unprepare(priv->clk);
702692 pxa3xx_gcu_free_buffers(dev, priv);
703693
704694 return 0;
....@@ -725,7 +715,7 @@
725715
726716 MODULE_DESCRIPTION("PXA3xx graphics controller unit driver");
727717 MODULE_LICENSE("GPL");
728
-MODULE_ALIAS_MISCDEV(MISCDEV_MINOR);
718
+MODULE_ALIAS_MISCDEV(PXA3XX_GCU_MINOR);
729719 MODULE_AUTHOR("Janine Kropp <nin@directfb.org>, "
730720 "Denis Oliver Kropp <dok@directfb.org>, "
731721 "Daniel Mack <daniel@caiaq.de>");