forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/video/fbdev/w100fb.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * linux/drivers/video/w100fb.c
34 *
....@@ -17,11 +18,6 @@
1718 *
1819 * Hardware acceleration support by Alberto Mardegan
1920 * <mardy@users.sourceforge.net>
20
- *
21
- * This program is free software; you can redistribute it and/or modify
22
- * it under the terms of the GNU General Public License version 2 as
23
- * published by the Free Software Foundation.
24
- *
2521 */
2622
2723 #include <linux/delay.h>
....@@ -65,9 +61,9 @@
6561 #define BITS_PER_PIXEL 16
6662
6763 /* Remapped addresses for base cfg, memmapped regs and the frame buffer itself */
68
-static void *remapped_base;
69
-static void *remapped_regs;
70
-static void *remapped_fbuf;
64
+static void __iomem *remapped_base;
65
+static void __iomem *remapped_regs;
66
+static void __iomem *remapped_fbuf;
7167
7268 #define REMAPPED_FB_LEN 0x15ffff
7369
....@@ -167,6 +163,15 @@
167163 }
168164
169165 static DEVICE_ATTR_RW(fastpllclk);
166
+
167
+static struct attribute *w100fb_attrs[] = {
168
+ &dev_attr_fastpllclk.attr,
169
+ &dev_attr_reg_read.attr,
170
+ &dev_attr_reg_write.attr,
171
+ &dev_attr_flip.attr,
172
+ NULL,
173
+};
174
+ATTRIBUTE_GROUPS(w100fb);
170175
171176 /*
172177 * Some touchscreens need hsync information from the video driver to
....@@ -544,7 +549,7 @@
544549 /*
545550 * Frame buffer operations
546551 */
547
-static struct fb_ops w100fb_ops = {
552
+static const struct fb_ops w100fb_ops = {
548553 .owner = THIS_MODULE,
549554 .fb_check_var = w100fb_check_var,
550555 .fb_set_par = w100fb_set_par,
....@@ -632,7 +637,7 @@
632637 #endif
633638
634639
635
-int w100fb_probe(struct platform_device *pdev)
640
+static int w100fb_probe(struct platform_device *pdev)
636641 {
637642 int err = -EIO;
638643 struct w100fb_mach_info *inf;
....@@ -645,12 +650,12 @@
645650 return -EINVAL;
646651
647652 /* Remap the chip base address */
648
- remapped_base = ioremap_nocache(mem->start+W100_CFG_BASE, W100_CFG_LEN);
653
+ remapped_base = ioremap(mem->start+W100_CFG_BASE, W100_CFG_LEN);
649654 if (remapped_base == NULL)
650655 goto out;
651656
652657 /* Map the register space */
653
- remapped_regs = ioremap_nocache(mem->start+W100_REG_BASE, W100_REG_LEN);
658
+ remapped_regs = ioremap(mem->start+W100_REG_BASE, W100_REG_LEN);
654659 if (remapped_regs == NULL)
655660 goto out;
656661
....@@ -669,7 +674,7 @@
669674 printk(" at 0x%08lx.\n", (unsigned long) mem->start+W100_CFG_BASE);
670675
671676 /* Remap the framebuffer */
672
- remapped_fbuf = ioremap_nocache(mem->start+MEM_WINDOW_BASE, MEM_WINDOW_SIZE);
677
+ remapped_fbuf = ioremap(mem->start+MEM_WINDOW_BASE, MEM_WINDOW_SIZE);
673678 if (remapped_fbuf == NULL)
674679 goto out;
675680
....@@ -758,14 +763,6 @@
758763 goto out;
759764 }
760765
761
- err = device_create_file(&pdev->dev, &dev_attr_fastpllclk);
762
- err |= device_create_file(&pdev->dev, &dev_attr_reg_read);
763
- err |= device_create_file(&pdev->dev, &dev_attr_reg_write);
764
- err |= device_create_file(&pdev->dev, &dev_attr_flip);
765
-
766
- if (err != 0)
767
- fb_warn(info, "failed to register attributes (%d)\n", err);
768
-
769766 fb_info(info, "%s frame buffer device\n", info->fix.id);
770767 return 0;
771768 out:
....@@ -773,12 +770,18 @@
773770 fb_dealloc_cmap(&info->cmap);
774771 kfree(info->pseudo_palette);
775772 }
776
- if (remapped_fbuf != NULL)
773
+ if (remapped_fbuf != NULL) {
777774 iounmap(remapped_fbuf);
778
- if (remapped_regs != NULL)
775
+ remapped_fbuf = NULL;
776
+ }
777
+ if (remapped_regs != NULL) {
779778 iounmap(remapped_regs);
780
- if (remapped_base != NULL)
779
+ remapped_regs = NULL;
780
+ }
781
+ if (remapped_base != NULL) {
781782 iounmap(remapped_base);
783
+ remapped_base = NULL;
784
+ }
782785 if (info)
783786 framebuffer_release(info);
784787 return err;
....@@ -790,11 +793,6 @@
790793 struct fb_info *info = platform_get_drvdata(pdev);
791794 struct w100fb_par *par=info->par;
792795
793
- device_remove_file(&pdev->dev, &dev_attr_fastpllclk);
794
- device_remove_file(&pdev->dev, &dev_attr_reg_read);
795
- device_remove_file(&pdev->dev, &dev_attr_reg_write);
796
- device_remove_file(&pdev->dev, &dev_attr_flip);
797
-
798796 unregister_framebuffer(info);
799797
800798 vfree(par->saved_intmem);
....@@ -803,8 +801,11 @@
803801 fb_dealloc_cmap(&info->cmap);
804802
805803 iounmap(remapped_base);
804
+ remapped_base = NULL;
806805 iounmap(remapped_regs);
806
+ remapped_regs = NULL;
807807 iounmap(remapped_fbuf);
808
+ remapped_fbuf = NULL;
808809
809810 framebuffer_release(info);
810811
....@@ -817,10 +818,11 @@
817818
818819 static void w100_soft_reset(void)
819820 {
820
- u16 val = readw((u16 *) remapped_base + cfgSTATUS);
821
- writew(val | 0x08, (u16 *) remapped_base + cfgSTATUS);
821
+ u16 val = readw((u16 __iomem *)remapped_base + cfgSTATUS);
822
+
823
+ writew(val | 0x08, (u16 __iomem *)remapped_base + cfgSTATUS);
822824 udelay(100);
823
- writew(0x00, (u16 *) remapped_base + cfgSTATUS);
825
+ writew(0x00, (u16 __iomem *)remapped_base + cfgSTATUS);
824826 udelay(100);
825827 }
826828
....@@ -1032,7 +1034,8 @@
10321034 return pll_entry->pll_table;
10331035 pll_entry++;
10341036 } while (pll_entry->xtal_freq);
1035
- return 0;
1037
+
1038
+ return NULL;
10361039 }
10371040
10381041
....@@ -1631,6 +1634,7 @@
16311634 .resume = w100fb_resume,
16321635 .driver = {
16331636 .name = "w100fb",
1637
+ .dev_groups = w100fb_groups,
16341638 },
16351639 };
16361640