forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/video/fbdev/imsttfb.c
....@@ -30,9 +30,8 @@
3030 #include <asm/io.h>
3131 #include <linux/uaccess.h>
3232
33
-#if defined(CONFIG_PPC)
33
+#if defined(CONFIG_PPC_PMAC)
3434 #include <linux/nvram.h>
35
-#include <asm/prom.h>
3635 #include "macmodes.h"
3736 #endif
3837
....@@ -327,14 +326,13 @@
327326 TVP = 1
328327 };
329328
330
-#define USE_NV_MODES 1
331329 #define INIT_BPP 8
332330 #define INIT_XRES 640
333331 #define INIT_YRES 480
334332
335333 static int inverse = 0;
336334 static char fontname[40] __initdata = { 0 };
337
-#if defined(CONFIG_PPC)
335
+#if defined(CONFIG_PPC_PMAC)
338336 static signed char init_vmode = -1, init_cmode = -1;
339337 #endif
340338
....@@ -1335,7 +1333,7 @@
13351333 .remove = imsttfb_remove,
13361334 };
13371335
1338
-static struct fb_ops imsttfb_ops = {
1336
+static const struct fb_ops imsttfb_ops = {
13391337 .owner = THIS_MODULE,
13401338 .fb_check_var = imsttfb_check_var,
13411339 .fb_set_par = imsttfb_set_par,
....@@ -1348,7 +1346,7 @@
13481346 .fb_ioctl = imsttfb_ioctl,
13491347 };
13501348
1351
-static void init_imstt(struct fb_info *info)
1349
+static int init_imstt(struct fb_info *info)
13521350 {
13531351 struct imstt_par *par = info->par;
13541352 __u32 i, tmp, *ip, *end;
....@@ -1390,8 +1388,8 @@
13901388 }
13911389 }
13921390
1393
-#if USE_NV_MODES && defined(CONFIG_PPC32)
1394
- {
1391
+#if defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32)
1392
+ if (IS_REACHABLE(CONFIG_NVRAM) && machine_is(powermac)) {
13951393 int vmode = init_vmode, cmode = init_cmode;
13961394
13971395 if (vmode == -1) {
....@@ -1409,18 +1407,19 @@
14091407 info->var.yres = info->var.yres_virtual = INIT_YRES;
14101408 info->var.bits_per_pixel = INIT_BPP;
14111409 }
1412
- }
1413
-#else
1414
- info->var.xres = info->var.xres_virtual = INIT_XRES;
1415
- info->var.yres = info->var.yres_virtual = INIT_YRES;
1416
- info->var.bits_per_pixel = INIT_BPP;
1410
+ } else
14171411 #endif
1412
+ {
1413
+ info->var.xres = info->var.xres_virtual = INIT_XRES;
1414
+ info->var.yres = info->var.yres_virtual = INIT_YRES;
1415
+ info->var.bits_per_pixel = INIT_BPP;
1416
+ }
14181417
14191418 if ((info->var.xres * info->var.yres) * (info->var.bits_per_pixel >> 3) > info->fix.smem_len
14201419 || !(compute_imstt_regvals(par, info->var.xres, info->var.yres))) {
14211420 printk("imsttfb: %ux%ux%u not supported\n", info->var.xres, info->var.yres, info->var.bits_per_pixel);
14221421 framebuffer_release(info);
1423
- return;
1422
+ return -ENODEV;
14241423 }
14251424
14261425 sprintf(info->fix.id, "IMS TT (%s)", par->ramdac == IBM ? "IBM" : "TVP");
....@@ -1456,12 +1455,13 @@
14561455
14571456 if (register_framebuffer(info) < 0) {
14581457 framebuffer_release(info);
1459
- return;
1458
+ return -ENODEV;
14601459 }
14611460
14621461 tmp = (read_reg_le32(par->dc_regs, SSTATUS) & 0x0f00) >> 8;
14631462 fb_info(info, "%s frame buffer; %uMB vram; chip version %u\n",
14641463 info->fix.id, info->fix.smem_len >> 20, tmp);
1464
+ return 0;
14651465 }
14661466
14671467 static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
....@@ -1470,19 +1470,17 @@
14701470 struct imstt_par *par;
14711471 struct fb_info *info;
14721472 struct device_node *dp;
1473
+ int ret = -ENOMEM;
14731474
14741475 dp = pci_device_to_OF_node(pdev);
14751476 if(dp)
1476
- printk(KERN_INFO "%s: OF name %s\n",__func__, dp->name);
1477
+ printk(KERN_INFO "%s: OF name %pOFn\n",__func__, dp);
14771478 else if (IS_ENABLED(CONFIG_OF))
14781479 printk(KERN_ERR "imsttfb: no OF node for pci device\n");
14791480
14801481 info = framebuffer_alloc(sizeof(struct imstt_par), &pdev->dev);
1481
-
1482
- if (!info) {
1483
- printk(KERN_ERR "imsttfb: Can't allocate memory\n");
1482
+ if (!info)
14841483 return -ENOMEM;
1485
- }
14861484
14871485 par = info->par;
14881486
....@@ -1498,8 +1496,8 @@
14981496 switch (pdev->device) {
14991497 case PCI_DEVICE_ID_IMS_TT128: /* IMS,tt128mbA */
15001498 par->ramdac = IBM;
1501
- if (dp && ((strcmp(dp->name, "IMS,tt128mb8") == 0) ||
1502
- (strcmp(dp->name, "IMS,tt128mb8A") == 0)))
1499
+ if (of_node_name_eq(dp, "IMS,tt128mb8") ||
1500
+ of_node_name_eq(dp, "IMS,tt128mb8A"))
15031501 par->ramdac = TVP;
15041502 break;
15051503 case PCI_DEVICE_ID_IMS_TT3D: /* IMS,tt3d */
....@@ -1508,23 +1506,37 @@
15081506 default:
15091507 printk(KERN_INFO "imsttfb: Device 0x%x unknown, "
15101508 "contact maintainer.\n", pdev->device);
1511
- release_mem_region(addr, size);
1512
- framebuffer_release(info);
1513
- return -ENODEV;
1509
+ ret = -ENODEV;
1510
+ goto error;
15141511 }
15151512
15161513 info->fix.smem_start = addr;
15171514 info->screen_base = (__u8 *)ioremap(addr, par->ramdac == IBM ?
15181515 0x400000 : 0x800000);
1516
+ if (!info->screen_base)
1517
+ goto error;
15191518 info->fix.mmio_start = addr + 0x800000;
15201519 par->dc_regs = ioremap(addr + 0x800000, 0x1000);
1520
+ if (!par->dc_regs)
1521
+ goto error;
15211522 par->cmap_regs_phys = addr + 0x840000;
15221523 par->cmap_regs = (__u8 *)ioremap(addr + 0x840000, 0x1000);
1524
+ if (!par->cmap_regs)
1525
+ goto error;
15231526 info->pseudo_palette = par->palette;
1524
- init_imstt(info);
1527
+ ret = init_imstt(info);
1528
+ if (!ret)
1529
+ pci_set_drvdata(pdev, info);
1530
+ return ret;
15251531
1526
- pci_set_drvdata(pdev, info);
1527
- return 0;
1532
+error:
1533
+ if (par->dc_regs)
1534
+ iounmap(par->dc_regs);
1535
+ if (info->screen_base)
1536
+ iounmap(info->screen_base);
1537
+ release_mem_region(addr, size);
1538
+ framebuffer_release(info);
1539
+ return ret;
15281540 }
15291541
15301542 static void imsttfb_remove(struct pci_dev *pdev)
....@@ -1565,7 +1577,7 @@
15651577 inverse = 1;
15661578 fb_invert_cmaps();
15671579 }
1568
-#if defined(CONFIG_PPC)
1580
+#if defined(CONFIG_PPC_PMAC)
15691581 else if (!strncmp(this_opt, "vmode:", 6)) {
15701582 int vmode = simple_strtoul(this_opt+6, NULL, 0);
15711583 if (vmode > 0 && vmode <= VMODE_MAX)