forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-09 244b2c5ca8b14627e4a17755e5922221e121c771
kernel/drivers/video/fbdev/valkyriefb.c
....@@ -54,26 +54,17 @@
5454 #include <linux/nvram.h>
5555 #include <linux/adb.h>
5656 #include <linux/cuda.h>
57
-#include <asm/io.h>
5857 #ifdef CONFIG_MAC
5958 #include <asm/macintosh.h>
6059 #else
6160 #include <asm/prom.h>
6261 #endif
63
-#include <asm/pgtable.h>
6462
6563 #include "macmodes.h"
6664 #include "valkyriefb.h"
6765
68
-#ifdef CONFIG_MAC
69
-/* We don't yet have functions to read the PRAM... perhaps we can
70
- adapt them from the PPC code? */
71
-static int default_vmode = VMODE_CHOOSE;
72
-static int default_cmode = CMODE_8;
73
-#else
7466 static int default_vmode = VMODE_NVRAM;
7567 static int default_cmode = CMODE_NVRAM;
76
-#endif
7768
7869 struct fb_par_valkyrie {
7970 int vmode, cmode;
....@@ -122,7 +113,7 @@
122113 static void valkyrie_par_to_fix(struct fb_par_valkyrie *par, struct fb_fix_screeninfo *fix);
123114 static void valkyrie_init_fix(struct fb_fix_screeninfo *fix, struct fb_info_valkyrie *p);
124115
125
-static struct fb_ops valkyriefb_ops = {
116
+static const struct fb_ops valkyriefb_ops = {
126117 .owner = THIS_MODULE,
127118 .fb_check_var = valkyriefb_check_var,
128119 .fb_set_par = valkyriefb_set_par,
....@@ -285,24 +276,21 @@
285276 printk(KERN_INFO "Monitor sense value = 0x%x\n", p->sense);
286277
287278 /* Try to pick a video mode out of NVRAM if we have one. */
288
-#if !defined(CONFIG_MAC) && defined(CONFIG_NVRAM)
289
- if (default_vmode == VMODE_NVRAM) {
279
+#ifdef CONFIG_PPC_PMAC
280
+ if (IS_REACHABLE(CONFIG_NVRAM) && default_vmode == VMODE_NVRAM)
290281 default_vmode = nvram_read_byte(NV_VMODE);
291
- if (default_vmode <= 0
292
- || default_vmode > VMODE_MAX
293
- || !valkyrie_reg_init[default_vmode - 1])
294
- default_vmode = VMODE_CHOOSE;
295
- }
296282 #endif
297
- if (default_vmode == VMODE_CHOOSE)
283
+ if (default_vmode <= 0 || default_vmode > VMODE_MAX ||
284
+ !valkyrie_reg_init[default_vmode - 1]) {
298285 default_vmode = mac_map_monitor_sense(p->sense);
299
- if (!valkyrie_reg_init[default_vmode - 1])
300
- default_vmode = VMODE_640_480_67;
301
-#if !defined(CONFIG_MAC) && defined(CONFIG_NVRAM)
302
- if (default_cmode == CMODE_NVRAM)
286
+ if (!valkyrie_reg_init[default_vmode - 1])
287
+ default_vmode = VMODE_640_480_67;
288
+ }
289
+
290
+#ifdef CONFIG_PPC_PMAC
291
+ if (IS_REACHABLE(CONFIG_NVRAM) && default_cmode == CMODE_NVRAM)
303292 default_cmode = nvram_read_byte(NV_CMODE);
304293 #endif
305
-
306294 /*
307295 * Reduce the pixel size if we don't have enough VRAM or bandwidth.
308296 */
....@@ -318,7 +306,7 @@
318306 int __init valkyriefb_init(void)
319307 {
320308 struct fb_info_valkyrie *p;
321
- unsigned long frame_buffer_phys, cmap_regs_phys, flags;
309
+ unsigned long frame_buffer_phys, cmap_regs_phys;
322310 int err;
323311 char *option = NULL;
324312
....@@ -337,14 +325,13 @@
337325 /* Hardcoded addresses... welcome to 68k Macintosh country :-) */
338326 frame_buffer_phys = 0xf9000000;
339327 cmap_regs_phys = 0x50f24000;
340
- flags = IOMAP_NOCACHE_SER; /* IOMAP_WRITETHROUGH?? */
341328 #else /* ppc (!CONFIG_MAC) */
342329 {
343330 struct device_node *dp;
344331 struct resource r;
345332
346333 dp = of_find_node_by_name(NULL, "valkyrie");
347
- if (dp == 0)
334
+ if (!dp)
348335 return 0;
349336
350337 if (of_address_to_resource(dp, 0, &r)) {
....@@ -354,12 +341,11 @@
354341
355342 frame_buffer_phys = r.start;
356343 cmap_regs_phys = r.start + 0x304000;
357
- flags = _PAGE_WRITETHRU;
358344 }
359345 #endif /* ppc (!CONFIG_MAC) */
360346
361347 p = kzalloc(sizeof(*p), GFP_ATOMIC);
362
- if (p == 0)
348
+ if (!p)
363349 return -ENOMEM;
364350
365351 /* Map in frame buffer and registers */
....@@ -369,7 +355,11 @@
369355 }
370356 p->total_vram = 0x100000;
371357 p->frame_buffer_phys = frame_buffer_phys;
372
- p->frame_buffer = __ioremap(frame_buffer_phys, p->total_vram, flags);
358
+#ifdef CONFIG_MAC
359
+ p->frame_buffer = ioremap(frame_buffer_phys, p->total_vram);
360
+#else
361
+ p->frame_buffer = ioremap_wt(frame_buffer_phys, p->total_vram);
362
+#endif
373363 p->cmap_regs_phys = cmap_regs_phys;
374364 p->cmap_regs = ioremap(p->cmap_regs_phys, 0x1000);
375365 p->valkyrie_regs_phys = cmap_regs_phys+0x6000;