| .. | .. |
|---|
| 54 | 54 | #include <linux/nvram.h> |
|---|
| 55 | 55 | #include <linux/adb.h> |
|---|
| 56 | 56 | #include <linux/cuda.h> |
|---|
| 57 | | -#include <asm/io.h> |
|---|
| 58 | 57 | #ifdef CONFIG_MAC |
|---|
| 59 | 58 | #include <asm/macintosh.h> |
|---|
| 60 | 59 | #else |
|---|
| 61 | 60 | #include <asm/prom.h> |
|---|
| 62 | 61 | #endif |
|---|
| 63 | | -#include <asm/pgtable.h> |
|---|
| 64 | 62 | |
|---|
| 65 | 63 | #include "macmodes.h" |
|---|
| 66 | 64 | #include "valkyriefb.h" |
|---|
| 67 | 65 | |
|---|
| 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 |
|---|
| 74 | 66 | static int default_vmode = VMODE_NVRAM; |
|---|
| 75 | 67 | static int default_cmode = CMODE_NVRAM; |
|---|
| 76 | | -#endif |
|---|
| 77 | 68 | |
|---|
| 78 | 69 | struct fb_par_valkyrie { |
|---|
| 79 | 70 | int vmode, cmode; |
|---|
| .. | .. |
|---|
| 122 | 113 | static void valkyrie_par_to_fix(struct fb_par_valkyrie *par, struct fb_fix_screeninfo *fix); |
|---|
| 123 | 114 | static void valkyrie_init_fix(struct fb_fix_screeninfo *fix, struct fb_info_valkyrie *p); |
|---|
| 124 | 115 | |
|---|
| 125 | | -static struct fb_ops valkyriefb_ops = { |
|---|
| 116 | +static const struct fb_ops valkyriefb_ops = { |
|---|
| 126 | 117 | .owner = THIS_MODULE, |
|---|
| 127 | 118 | .fb_check_var = valkyriefb_check_var, |
|---|
| 128 | 119 | .fb_set_par = valkyriefb_set_par, |
|---|
| .. | .. |
|---|
| 285 | 276 | printk(KERN_INFO "Monitor sense value = 0x%x\n", p->sense); |
|---|
| 286 | 277 | |
|---|
| 287 | 278 | /* 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) |
|---|
| 290 | 281 | 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 | | - } |
|---|
| 296 | 282 | #endif |
|---|
| 297 | | - if (default_vmode == VMODE_CHOOSE) |
|---|
| 283 | + if (default_vmode <= 0 || default_vmode > VMODE_MAX || |
|---|
| 284 | + !valkyrie_reg_init[default_vmode - 1]) { |
|---|
| 298 | 285 | 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) |
|---|
| 303 | 292 | default_cmode = nvram_read_byte(NV_CMODE); |
|---|
| 304 | 293 | #endif |
|---|
| 305 | | - |
|---|
| 306 | 294 | /* |
|---|
| 307 | 295 | * Reduce the pixel size if we don't have enough VRAM or bandwidth. |
|---|
| 308 | 296 | */ |
|---|
| .. | .. |
|---|
| 318 | 306 | int __init valkyriefb_init(void) |
|---|
| 319 | 307 | { |
|---|
| 320 | 308 | struct fb_info_valkyrie *p; |
|---|
| 321 | | - unsigned long frame_buffer_phys, cmap_regs_phys, flags; |
|---|
| 309 | + unsigned long frame_buffer_phys, cmap_regs_phys; |
|---|
| 322 | 310 | int err; |
|---|
| 323 | 311 | char *option = NULL; |
|---|
| 324 | 312 | |
|---|
| .. | .. |
|---|
| 337 | 325 | /* Hardcoded addresses... welcome to 68k Macintosh country :-) */ |
|---|
| 338 | 326 | frame_buffer_phys = 0xf9000000; |
|---|
| 339 | 327 | cmap_regs_phys = 0x50f24000; |
|---|
| 340 | | - flags = IOMAP_NOCACHE_SER; /* IOMAP_WRITETHROUGH?? */ |
|---|
| 341 | 328 | #else /* ppc (!CONFIG_MAC) */ |
|---|
| 342 | 329 | { |
|---|
| 343 | 330 | struct device_node *dp; |
|---|
| 344 | 331 | struct resource r; |
|---|
| 345 | 332 | |
|---|
| 346 | 333 | dp = of_find_node_by_name(NULL, "valkyrie"); |
|---|
| 347 | | - if (dp == 0) |
|---|
| 334 | + if (!dp) |
|---|
| 348 | 335 | return 0; |
|---|
| 349 | 336 | |
|---|
| 350 | 337 | if (of_address_to_resource(dp, 0, &r)) { |
|---|
| .. | .. |
|---|
| 354 | 341 | |
|---|
| 355 | 342 | frame_buffer_phys = r.start; |
|---|
| 356 | 343 | cmap_regs_phys = r.start + 0x304000; |
|---|
| 357 | | - flags = _PAGE_WRITETHRU; |
|---|
| 358 | 344 | } |
|---|
| 359 | 345 | #endif /* ppc (!CONFIG_MAC) */ |
|---|
| 360 | 346 | |
|---|
| 361 | 347 | p = kzalloc(sizeof(*p), GFP_ATOMIC); |
|---|
| 362 | | - if (p == 0) |
|---|
| 348 | + if (!p) |
|---|
| 363 | 349 | return -ENOMEM; |
|---|
| 364 | 350 | |
|---|
| 365 | 351 | /* Map in frame buffer and registers */ |
|---|
| .. | .. |
|---|
| 369 | 355 | } |
|---|
| 370 | 356 | p->total_vram = 0x100000; |
|---|
| 371 | 357 | 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 |
|---|
| 373 | 363 | p->cmap_regs_phys = cmap_regs_phys; |
|---|
| 374 | 364 | p->cmap_regs = ioremap(p->cmap_regs_phys, 0x1000); |
|---|
| 375 | 365 | p->valkyrie_regs_phys = cmap_regs_phys+0x6000; |
|---|