.. | .. |
---|
30 | 30 | #include <asm/io.h> |
---|
31 | 31 | #include <linux/uaccess.h> |
---|
32 | 32 | |
---|
33 | | -#if defined(CONFIG_PPC) |
---|
| 33 | +#if defined(CONFIG_PPC_PMAC) |
---|
34 | 34 | #include <linux/nvram.h> |
---|
35 | | -#include <asm/prom.h> |
---|
36 | 35 | #include "macmodes.h" |
---|
37 | 36 | #endif |
---|
38 | 37 | |
---|
.. | .. |
---|
327 | 326 | TVP = 1 |
---|
328 | 327 | }; |
---|
329 | 328 | |
---|
330 | | -#define USE_NV_MODES 1 |
---|
331 | 329 | #define INIT_BPP 8 |
---|
332 | 330 | #define INIT_XRES 640 |
---|
333 | 331 | #define INIT_YRES 480 |
---|
334 | 332 | |
---|
335 | 333 | static int inverse = 0; |
---|
336 | 334 | static char fontname[40] __initdata = { 0 }; |
---|
337 | | -#if defined(CONFIG_PPC) |
---|
| 335 | +#if defined(CONFIG_PPC_PMAC) |
---|
338 | 336 | static signed char init_vmode = -1, init_cmode = -1; |
---|
339 | 337 | #endif |
---|
340 | 338 | |
---|
.. | .. |
---|
1335 | 1333 | .remove = imsttfb_remove, |
---|
1336 | 1334 | }; |
---|
1337 | 1335 | |
---|
1338 | | -static struct fb_ops imsttfb_ops = { |
---|
| 1336 | +static const struct fb_ops imsttfb_ops = { |
---|
1339 | 1337 | .owner = THIS_MODULE, |
---|
1340 | 1338 | .fb_check_var = imsttfb_check_var, |
---|
1341 | 1339 | .fb_set_par = imsttfb_set_par, |
---|
.. | .. |
---|
1348 | 1346 | .fb_ioctl = imsttfb_ioctl, |
---|
1349 | 1347 | }; |
---|
1350 | 1348 | |
---|
1351 | | -static void init_imstt(struct fb_info *info) |
---|
| 1349 | +static int init_imstt(struct fb_info *info) |
---|
1352 | 1350 | { |
---|
1353 | 1351 | struct imstt_par *par = info->par; |
---|
1354 | 1352 | __u32 i, tmp, *ip, *end; |
---|
.. | .. |
---|
1390 | 1388 | } |
---|
1391 | 1389 | } |
---|
1392 | 1390 | |
---|
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)) { |
---|
1395 | 1393 | int vmode = init_vmode, cmode = init_cmode; |
---|
1396 | 1394 | |
---|
1397 | 1395 | if (vmode == -1) { |
---|
.. | .. |
---|
1409 | 1407 | info->var.yres = info->var.yres_virtual = INIT_YRES; |
---|
1410 | 1408 | info->var.bits_per_pixel = INIT_BPP; |
---|
1411 | 1409 | } |
---|
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 |
---|
1417 | 1411 | #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 | + } |
---|
1418 | 1417 | |
---|
1419 | 1418 | if ((info->var.xres * info->var.yres) * (info->var.bits_per_pixel >> 3) > info->fix.smem_len |
---|
1420 | 1419 | || !(compute_imstt_regvals(par, info->var.xres, info->var.yres))) { |
---|
1421 | 1420 | printk("imsttfb: %ux%ux%u not supported\n", info->var.xres, info->var.yres, info->var.bits_per_pixel); |
---|
1422 | 1421 | framebuffer_release(info); |
---|
1423 | | - return; |
---|
| 1422 | + return -ENODEV; |
---|
1424 | 1423 | } |
---|
1425 | 1424 | |
---|
1426 | 1425 | sprintf(info->fix.id, "IMS TT (%s)", par->ramdac == IBM ? "IBM" : "TVP"); |
---|
.. | .. |
---|
1456 | 1455 | |
---|
1457 | 1456 | if (register_framebuffer(info) < 0) { |
---|
1458 | 1457 | framebuffer_release(info); |
---|
1459 | | - return; |
---|
| 1458 | + return -ENODEV; |
---|
1460 | 1459 | } |
---|
1461 | 1460 | |
---|
1462 | 1461 | tmp = (read_reg_le32(par->dc_regs, SSTATUS) & 0x0f00) >> 8; |
---|
1463 | 1462 | fb_info(info, "%s frame buffer; %uMB vram; chip version %u\n", |
---|
1464 | 1463 | info->fix.id, info->fix.smem_len >> 20, tmp); |
---|
| 1464 | + return 0; |
---|
1465 | 1465 | } |
---|
1466 | 1466 | |
---|
1467 | 1467 | static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
---|
.. | .. |
---|
1470 | 1470 | struct imstt_par *par; |
---|
1471 | 1471 | struct fb_info *info; |
---|
1472 | 1472 | struct device_node *dp; |
---|
| 1473 | + int ret = -ENOMEM; |
---|
1473 | 1474 | |
---|
1474 | 1475 | dp = pci_device_to_OF_node(pdev); |
---|
1475 | 1476 | 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); |
---|
1477 | 1478 | else if (IS_ENABLED(CONFIG_OF)) |
---|
1478 | 1479 | printk(KERN_ERR "imsttfb: no OF node for pci device\n"); |
---|
1479 | 1480 | |
---|
1480 | 1481 | 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) |
---|
1484 | 1483 | return -ENOMEM; |
---|
1485 | | - } |
---|
1486 | 1484 | |
---|
1487 | 1485 | par = info->par; |
---|
1488 | 1486 | |
---|
.. | .. |
---|
1498 | 1496 | switch (pdev->device) { |
---|
1499 | 1497 | case PCI_DEVICE_ID_IMS_TT128: /* IMS,tt128mbA */ |
---|
1500 | 1498 | 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")) |
---|
1503 | 1501 | par->ramdac = TVP; |
---|
1504 | 1502 | break; |
---|
1505 | 1503 | case PCI_DEVICE_ID_IMS_TT3D: /* IMS,tt3d */ |
---|
.. | .. |
---|
1508 | 1506 | default: |
---|
1509 | 1507 | printk(KERN_INFO "imsttfb: Device 0x%x unknown, " |
---|
1510 | 1508 | "contact maintainer.\n", pdev->device); |
---|
1511 | | - release_mem_region(addr, size); |
---|
1512 | | - framebuffer_release(info); |
---|
1513 | | - return -ENODEV; |
---|
| 1509 | + ret = -ENODEV; |
---|
| 1510 | + goto error; |
---|
1514 | 1511 | } |
---|
1515 | 1512 | |
---|
1516 | 1513 | info->fix.smem_start = addr; |
---|
1517 | 1514 | info->screen_base = (__u8 *)ioremap(addr, par->ramdac == IBM ? |
---|
1518 | 1515 | 0x400000 : 0x800000); |
---|
| 1516 | + if (!info->screen_base) |
---|
| 1517 | + goto error; |
---|
1519 | 1518 | info->fix.mmio_start = addr + 0x800000; |
---|
1520 | 1519 | par->dc_regs = ioremap(addr + 0x800000, 0x1000); |
---|
| 1520 | + if (!par->dc_regs) |
---|
| 1521 | + goto error; |
---|
1521 | 1522 | par->cmap_regs_phys = addr + 0x840000; |
---|
1522 | 1523 | par->cmap_regs = (__u8 *)ioremap(addr + 0x840000, 0x1000); |
---|
| 1524 | + if (!par->cmap_regs) |
---|
| 1525 | + goto error; |
---|
1523 | 1526 | 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; |
---|
1525 | 1531 | |
---|
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; |
---|
1528 | 1540 | } |
---|
1529 | 1541 | |
---|
1530 | 1542 | static void imsttfb_remove(struct pci_dev *pdev) |
---|
.. | .. |
---|
1565 | 1577 | inverse = 1; |
---|
1566 | 1578 | fb_invert_cmaps(); |
---|
1567 | 1579 | } |
---|
1568 | | -#if defined(CONFIG_PPC) |
---|
| 1580 | +#if defined(CONFIG_PPC_PMAC) |
---|
1569 | 1581 | else if (!strncmp(this_opt, "vmode:", 6)) { |
---|
1570 | 1582 | int vmode = simple_strtoul(this_opt+6, NULL, 0); |
---|
1571 | 1583 | if (vmode > 0 && vmode <= VMODE_MAX) |
---|