.. | .. |
---|
48 | 48 | |
---|
49 | 49 | ******************************************************************************/ |
---|
50 | 50 | |
---|
51 | | - |
---|
| 51 | +#include <linux/compat.h> |
---|
52 | 52 | #include <linux/module.h> |
---|
53 | 53 | #include <linux/moduleparam.h> |
---|
54 | 54 | #include <linux/kernel.h> |
---|
.. | .. |
---|
126 | 126 | #ifdef DEBUG |
---|
127 | 127 | #define DPRINTK(fmt, args...) printk(KERN_DEBUG "atyfb: " fmt, ## args) |
---|
128 | 128 | #else |
---|
129 | | -#define DPRINTK(fmt, args...) |
---|
| 129 | +#define DPRINTK(fmt, args...) no_printk(fmt, ##args) |
---|
130 | 130 | #endif |
---|
131 | 131 | |
---|
132 | 132 | #define PRINTKI(fmt, args...) printk(KERN_INFO "atyfb: " fmt, ## args) |
---|
133 | 133 | #define PRINTKE(fmt, args...) printk(KERN_ERR "atyfb: " fmt, ## args) |
---|
134 | 134 | |
---|
135 | | -#if defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || \ |
---|
136 | | -defined (CONFIG_FB_ATY_GENERIC_LCD) || defined(CONFIG_FB_ATY_BACKLIGHT) |
---|
| 135 | +#if defined(CONFIG_PMAC_BACKLIGHT) || defined(CONFIG_FB_ATY_GENERIC_LCD) || \ |
---|
| 136 | +defined(CONFIG_FB_ATY_BACKLIGHT) |
---|
137 | 137 | static const u32 lt_lcd_regs[] = { |
---|
138 | 138 | CNFG_PANEL_LG, |
---|
139 | 139 | LCD_GEN_CNTL_LG, |
---|
.. | .. |
---|
175 | 175 | return aty_ld_le32(LCD_DATA, par); |
---|
176 | 176 | } |
---|
177 | 177 | } |
---|
178 | | -#endif /* defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || defined (CONFIG_FB_ATY_GENERIC_LCD) */ |
---|
| 178 | +#endif /* defined(CONFIG_PMAC_BACKLIGHT) || defined (CONFIG_FB_ATY_GENERIC_LCD) */ |
---|
179 | 179 | |
---|
180 | 180 | #ifdef CONFIG_FB_ATY_GENERIC_LCD |
---|
181 | 181 | /* |
---|
.. | .. |
---|
235 | 235 | struct fb_info *info); |
---|
236 | 236 | static int atyfb_blank(int blank, struct fb_info *info); |
---|
237 | 237 | static int atyfb_ioctl(struct fb_info *info, u_int cmd, u_long arg); |
---|
| 238 | +#ifdef CONFIG_COMPAT |
---|
| 239 | +static int atyfb_compat_ioctl(struct fb_info *info, u_int cmd, u_long arg) |
---|
| 240 | +{ |
---|
| 241 | + return atyfb_ioctl(info, cmd, (u_long)compat_ptr(arg)); |
---|
| 242 | +} |
---|
| 243 | +#endif |
---|
| 244 | + |
---|
238 | 245 | #ifdef __sparc__ |
---|
239 | 246 | static int atyfb_mmap(struct fb_info *info, struct vm_area_struct *vma); |
---|
240 | 247 | #endif |
---|
.. | .. |
---|
290 | 297 | .fb_pan_display = atyfb_pan_display, |
---|
291 | 298 | .fb_blank = atyfb_blank, |
---|
292 | 299 | .fb_ioctl = atyfb_ioctl, |
---|
| 300 | +#ifdef CONFIG_COMPAT |
---|
| 301 | + .fb_compat_ioctl = atyfb_compat_ioctl, |
---|
| 302 | +#endif |
---|
293 | 303 | .fb_fillrect = atyfb_fillrect, |
---|
294 | 304 | .fb_copyarea = atyfb_copyarea, |
---|
295 | 305 | .fb_imageblit = atyfb_imageblit, |
---|
.. | .. |
---|
307 | 317 | static int xclk; |
---|
308 | 318 | static int comp_sync = -1; |
---|
309 | 319 | static char *mode; |
---|
310 | | - |
---|
311 | | -#ifdef CONFIG_PMAC_BACKLIGHT |
---|
312 | | -static int backlight = 1; |
---|
313 | | -#else |
---|
314 | | -static int backlight = 0; |
---|
315 | | -#endif |
---|
| 320 | +static int backlight = IS_BUILTIN(CONFIG_PMAC_BACKLIGHT); |
---|
316 | 321 | |
---|
317 | 322 | #ifdef CONFIG_PPC |
---|
318 | 323 | static int default_vmode = VMODE_CHOOSE; |
---|
.. | .. |
---|
1188 | 1193 | (c_sync ? FB_SYNC_COMP_HIGH_ACT : 0); |
---|
1189 | 1194 | |
---|
1190 | 1195 | switch (pix_width) { |
---|
1191 | | -#if 0 |
---|
1192 | | - case CRTC_PIX_WIDTH_4BPP: |
---|
1193 | | - bpp = 4; |
---|
1194 | | - var->red.offset = 0; |
---|
1195 | | - var->red.length = 8; |
---|
1196 | | - var->green.offset = 0; |
---|
1197 | | - var->green.length = 8; |
---|
1198 | | - var->blue.offset = 0; |
---|
1199 | | - var->blue.length = 8; |
---|
1200 | | - var->transp.offset = 0; |
---|
1201 | | - var->transp.length = 0; |
---|
1202 | | - break; |
---|
1203 | | -#endif |
---|
1204 | 1196 | case CRTC_PIX_WIDTH_8BPP: |
---|
1205 | 1197 | bpp = 8; |
---|
1206 | 1198 | var->red.offset = 0; |
---|
.. | .. |
---|
1329 | 1321 | par->accel_flags = var->accel_flags; /* hack */ |
---|
1330 | 1322 | |
---|
1331 | 1323 | if (var->accel_flags) { |
---|
1332 | | - info->fbops->fb_sync = atyfb_sync; |
---|
| 1324 | + atyfb_ops.fb_sync = atyfb_sync; |
---|
1333 | 1325 | info->flags &= ~FBINFO_HWACCEL_DISABLED; |
---|
1334 | 1326 | } else { |
---|
1335 | | - info->fbops->fb_sync = NULL; |
---|
| 1327 | + atyfb_ops.fb_sync = NULL; |
---|
1336 | 1328 | info->flags |= FBINFO_HWACCEL_DISABLED; |
---|
1337 | 1329 | } |
---|
1338 | 1330 | |
---|
.. | .. |
---|
1466 | 1458 | var->bits_per_pixel, |
---|
1467 | 1459 | par->crtc.vxres * var->bits_per_pixel / 8); |
---|
1468 | 1460 | #endif /* CONFIG_BOOTX_TEXT */ |
---|
1469 | | -#if 0 |
---|
1470 | | - /* switch to accelerator mode */ |
---|
1471 | | - if (!(par->crtc.gen_cntl & CRTC_EXT_DISP_EN)) |
---|
1472 | | - aty_st_le32(CRTC_GEN_CNTL, par->crtc.gen_cntl | CRTC_EXT_DISP_EN, par); |
---|
1473 | | -#endif |
---|
1474 | 1461 | #ifdef DEBUG |
---|
1475 | 1462 | { |
---|
1476 | 1463 | /* dump non shadow CRTC, pll, LCD registers */ |
---|
.. | .. |
---|
1480 | 1467 | base = 0x2000; |
---|
1481 | 1468 | printk("debug atyfb: Mach64 non-shadow register values:"); |
---|
1482 | 1469 | for (i = 0; i < 256; i = i+4) { |
---|
1483 | | - if (i % 16 == 0) |
---|
1484 | | - printk("\ndebug atyfb: 0x%04X: ", base + i); |
---|
1485 | | - printk(" %08X", aty_ld_le32(i, par)); |
---|
| 1470 | + if (i % 16 == 0) { |
---|
| 1471 | + pr_cont("\n"); |
---|
| 1472 | + printk("debug atyfb: 0x%04X: ", base + i); |
---|
| 1473 | + } |
---|
| 1474 | + pr_cont(" %08X", aty_ld_le32(i, par)); |
---|
1486 | 1475 | } |
---|
1487 | | - printk("\n\n"); |
---|
| 1476 | + pr_cont("\n\n"); |
---|
1488 | 1477 | |
---|
1489 | 1478 | #ifdef CONFIG_FB_ATY_CT |
---|
1490 | 1479 | /* PLL registers */ |
---|
1491 | 1480 | base = 0x00; |
---|
1492 | 1481 | printk("debug atyfb: Mach64 PLL register values:"); |
---|
1493 | 1482 | for (i = 0; i < 64; i++) { |
---|
1494 | | - if (i % 16 == 0) |
---|
1495 | | - printk("\ndebug atyfb: 0x%02X: ", base + i); |
---|
| 1483 | + if (i % 16 == 0) { |
---|
| 1484 | + pr_cont("\n"); |
---|
| 1485 | + printk("debug atyfb: 0x%02X: ", base + i); |
---|
| 1486 | + } |
---|
1496 | 1487 | if (i % 4 == 0) |
---|
1497 | | - printk(" "); |
---|
1498 | | - printk("%02X", aty_ld_pll_ct(i, par)); |
---|
| 1488 | + pr_cont(" "); |
---|
| 1489 | + pr_cont("%02X", aty_ld_pll_ct(i, par)); |
---|
1499 | 1490 | } |
---|
1500 | | - printk("\n\n"); |
---|
| 1491 | + pr_cont("\n\n"); |
---|
1501 | 1492 | #endif /* CONFIG_FB_ATY_CT */ |
---|
1502 | 1493 | |
---|
1503 | 1494 | #ifdef CONFIG_FB_ATY_GENERIC_LCD |
---|
.. | .. |
---|
1509 | 1500 | for (i = 0; i <= POWER_MANAGEMENT; i++) { |
---|
1510 | 1501 | if (i == EXT_VERT_STRETCH) |
---|
1511 | 1502 | continue; |
---|
1512 | | - printk("\ndebug atyfb: 0x%04X: ", |
---|
| 1503 | + pr_cont("\ndebug atyfb: 0x%04X: ", |
---|
1513 | 1504 | lt_lcd_regs[i]); |
---|
1514 | | - printk(" %08X", aty_ld_lcd(i, par)); |
---|
| 1505 | + pr_cont(" %08X", aty_ld_lcd(i, par)); |
---|
1515 | 1506 | } |
---|
1516 | 1507 | } else { |
---|
1517 | 1508 | for (i = 0; i < 64; i++) { |
---|
1518 | 1509 | if (i % 4 == 0) |
---|
1519 | | - printk("\ndebug atyfb: 0x%02X: ", |
---|
| 1510 | + pr_cont("\ndebug atyfb: 0x%02X: ", |
---|
1520 | 1511 | base + i); |
---|
1521 | | - printk(" %08X", aty_ld_lcd(i, par)); |
---|
| 1512 | + pr_cont(" %08X", aty_ld_lcd(i, par)); |
---|
1522 | 1513 | } |
---|
1523 | 1514 | } |
---|
1524 | | - printk("\n\n"); |
---|
| 1515 | + pr_cont("\n\n"); |
---|
1525 | 1516 | } |
---|
1526 | 1517 | #endif /* CONFIG_FB_ATY_GENERIC_LCD */ |
---|
1527 | 1518 | } |
---|
.. | .. |
---|
1998 | 1989 | |
---|
1999 | 1990 | |
---|
2000 | 1991 | |
---|
2001 | | -#if defined(CONFIG_PM) && defined(CONFIG_PCI) |
---|
| 1992 | +#if defined(CONFIG_PCI) |
---|
2002 | 1993 | |
---|
2003 | 1994 | #ifdef CONFIG_PPC_PMAC |
---|
2004 | 1995 | /* Power management routines. Those are used for PowerBook sleep. |
---|
.. | .. |
---|
2059 | 2050 | } |
---|
2060 | 2051 | #endif /* CONFIG_PPC_PMAC */ |
---|
2061 | 2052 | |
---|
2062 | | -static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state) |
---|
| 2053 | +static int atyfb_pci_suspend_late(struct device *dev, pm_message_t state) |
---|
2063 | 2054 | { |
---|
| 2055 | + struct pci_dev *pdev = to_pci_dev(dev); |
---|
2064 | 2056 | struct fb_info *info = pci_get_drvdata(pdev); |
---|
2065 | 2057 | struct atyfb_par *par = (struct atyfb_par *) info->par; |
---|
2066 | 2058 | |
---|
.. | .. |
---|
2086 | 2078 | * first save the config space content so the core can |
---|
2087 | 2079 | * restore it properly on resume. |
---|
2088 | 2080 | */ |
---|
2089 | | - pci_save_state(pdev); |
---|
2090 | 2081 | |
---|
2091 | 2082 | #ifdef CONFIG_PPC_PMAC |
---|
2092 | 2083 | /* Set chip to "suspend" mode */ |
---|
.. | .. |
---|
2098 | 2089 | console_unlock(); |
---|
2099 | 2090 | return -EIO; |
---|
2100 | 2091 | } |
---|
2101 | | -#else |
---|
2102 | | - pci_set_power_state(pdev, pci_choose_state(pdev, state)); |
---|
2103 | 2092 | #endif |
---|
2104 | 2093 | |
---|
2105 | 2094 | console_unlock(); |
---|
.. | .. |
---|
2107 | 2096 | pdev->dev.power.power_state = state; |
---|
2108 | 2097 | |
---|
2109 | 2098 | return 0; |
---|
| 2099 | +} |
---|
| 2100 | + |
---|
| 2101 | +static int __maybe_unused atyfb_pci_suspend(struct device *dev) |
---|
| 2102 | +{ |
---|
| 2103 | + return atyfb_pci_suspend_late(dev, PMSG_SUSPEND); |
---|
| 2104 | +} |
---|
| 2105 | + |
---|
| 2106 | +static int __maybe_unused atyfb_pci_hibernate(struct device *dev) |
---|
| 2107 | +{ |
---|
| 2108 | + return atyfb_pci_suspend_late(dev, PMSG_HIBERNATE); |
---|
| 2109 | +} |
---|
| 2110 | + |
---|
| 2111 | +static int __maybe_unused atyfb_pci_freeze(struct device *dev) |
---|
| 2112 | +{ |
---|
| 2113 | + return atyfb_pci_suspend_late(dev, PMSG_FREEZE); |
---|
2110 | 2114 | } |
---|
2111 | 2115 | |
---|
2112 | 2116 | static void aty_resume_chip(struct fb_info *info) |
---|
.. | .. |
---|
2123 | 2127 | aty_ld_le32(BUS_CNTL, par) | BUS_APER_REG_DIS, par); |
---|
2124 | 2128 | } |
---|
2125 | 2129 | |
---|
2126 | | -static int atyfb_pci_resume(struct pci_dev *pdev) |
---|
| 2130 | +static int __maybe_unused atyfb_pci_resume(struct device *dev) |
---|
2127 | 2131 | { |
---|
| 2132 | + struct pci_dev *pdev = to_pci_dev(dev); |
---|
2128 | 2133 | struct fb_info *info = pci_get_drvdata(pdev); |
---|
2129 | 2134 | struct atyfb_par *par = (struct atyfb_par *) info->par; |
---|
2130 | 2135 | |
---|
.. | .. |
---|
2166 | 2171 | return 0; |
---|
2167 | 2172 | } |
---|
2168 | 2173 | |
---|
2169 | | -#endif /* defined(CONFIG_PM) && defined(CONFIG_PCI) */ |
---|
| 2174 | +static const struct dev_pm_ops atyfb_pci_pm_ops = { |
---|
| 2175 | +#ifdef CONFIG_PM_SLEEP |
---|
| 2176 | + .suspend = atyfb_pci_suspend, |
---|
| 2177 | + .resume = atyfb_pci_resume, |
---|
| 2178 | + .freeze = atyfb_pci_freeze, |
---|
| 2179 | + .thaw = atyfb_pci_resume, |
---|
| 2180 | + .poweroff = atyfb_pci_hibernate, |
---|
| 2181 | + .restore = atyfb_pci_resume, |
---|
| 2182 | +#endif /* CONFIG_PM_SLEEP */ |
---|
| 2183 | +}; |
---|
| 2184 | + |
---|
| 2185 | +#endif /* defined(CONFIG_PCI) */ |
---|
2170 | 2186 | |
---|
2171 | 2187 | /* Backlight */ |
---|
2172 | 2188 | #ifdef CONFIG_FB_ATY_BACKLIGHT |
---|
.. | .. |
---|
2392 | 2408 | par->pll_ops = &aty_pll_ibm514; |
---|
2393 | 2409 | break; |
---|
2394 | 2410 | #endif |
---|
2395 | | -#if 0 /* dead code */ |
---|
2396 | | - case CLK_STG1703: |
---|
2397 | | - par->pll_ops = &aty_pll_stg1703; |
---|
2398 | | - break; |
---|
2399 | | - case CLK_CH8398: |
---|
2400 | | - par->pll_ops = &aty_pll_ch8398; |
---|
2401 | | - break; |
---|
2402 | | - case CLK_ATT20C408: |
---|
2403 | | - par->pll_ops = &aty_pll_att20c408; |
---|
2404 | | - break; |
---|
2405 | | -#endif |
---|
2406 | 2411 | default: |
---|
2407 | 2412 | PRINTKI("aty_init: CLK type not implemented yet!"); |
---|
2408 | 2413 | par->pll_ops = &aty_pll_unsupported; |
---|
.. | .. |
---|
2597 | 2602 | aty_ld_le32(DSP_ON_OFF, par), |
---|
2598 | 2603 | aty_ld_le32(CLOCK_CNTL, par)); |
---|
2599 | 2604 | for (i = 0; i < 40; i++) |
---|
2600 | | - printk(" %02x", aty_ld_pll_ct(i, par)); |
---|
2601 | | - printk("\n"); |
---|
| 2605 | + pr_cont(" %02x", aty_ld_pll_ct(i, par)); |
---|
| 2606 | + pr_cont("\n"); |
---|
2602 | 2607 | } |
---|
2603 | 2608 | #endif |
---|
2604 | 2609 | if (par->pll_ops->init_pll) |
---|
.. | .. |
---|
2727 | 2732 | |
---|
2728 | 2733 | #ifdef CONFIG_FB_ATY_CT |
---|
2729 | 2734 | if (!noaccel && M64_HAS(INTEGRATED)) |
---|
2730 | | - aty_init_cursor(info); |
---|
| 2735 | + aty_init_cursor(info, &atyfb_ops); |
---|
2731 | 2736 | #endif /* CONFIG_FB_ATY_CT */ |
---|
2732 | 2737 | info->var = var; |
---|
2733 | 2738 | |
---|
.. | .. |
---|
3546 | 3551 | |
---|
3547 | 3552 | /* Allocate framebuffer */ |
---|
3548 | 3553 | info = framebuffer_alloc(sizeof(struct atyfb_par), &pdev->dev); |
---|
3549 | | - if (!info) { |
---|
3550 | | - PRINTKE("atyfb_pci_probe() can't alloc fb_info\n"); |
---|
| 3554 | + if (!info) |
---|
3551 | 3555 | return -ENOMEM; |
---|
3552 | | - } |
---|
| 3556 | + |
---|
3553 | 3557 | par = info->par; |
---|
3554 | 3558 | par->bus_type = PCI; |
---|
3555 | 3559 | info->fix = atyfb_fix; |
---|
.. | .. |
---|
3639 | 3643 | } |
---|
3640 | 3644 | |
---|
3641 | 3645 | info = framebuffer_alloc(sizeof(struct atyfb_par), NULL); |
---|
3642 | | - if (!info) { |
---|
3643 | | - PRINTKE("atyfb_atari_probe() can't alloc fb_info\n"); |
---|
| 3646 | + if (!info) |
---|
3644 | 3647 | return -ENOMEM; |
---|
3645 | | - } |
---|
| 3648 | + |
---|
3646 | 3649 | par = info->par; |
---|
3647 | 3650 | |
---|
3648 | 3651 | info->fix = atyfb_fix; |
---|
.. | .. |
---|
3818 | 3821 | .id_table = atyfb_pci_tbl, |
---|
3819 | 3822 | .probe = atyfb_pci_probe, |
---|
3820 | 3823 | .remove = atyfb_pci_remove, |
---|
3821 | | -#ifdef CONFIG_PM |
---|
3822 | | - .suspend = atyfb_pci_suspend, |
---|
3823 | | - .resume = atyfb_pci_resume, |
---|
3824 | | -#endif /* CONFIG_PM */ |
---|
| 3824 | + .driver.pm = &atyfb_pci_pm_ops, |
---|
3825 | 3825 | }; |
---|
3826 | 3826 | |
---|
3827 | 3827 | #endif /* CONFIG_PCI */ |
---|
.. | .. |
---|
3836 | 3836 | |
---|
3837 | 3837 | while ((this_opt = strsep(&options, ",")) != NULL) { |
---|
3838 | 3838 | if (!strncmp(this_opt, "noaccel", 7)) { |
---|
3839 | | - noaccel = 1; |
---|
| 3839 | + noaccel = true; |
---|
3840 | 3840 | } else if (!strncmp(this_opt, "nomtrr", 6)) { |
---|
3841 | | - nomtrr = 1; |
---|
| 3841 | + nomtrr = true; |
---|
3842 | 3842 | } else if (!strncmp(this_opt, "vram:", 5)) |
---|
3843 | 3843 | vram = simple_strtoul(this_opt + 5, NULL, 0); |
---|
3844 | 3844 | else if (!strncmp(this_opt, "pll:", 4)) |
---|
.. | .. |
---|
3912 | 3912 | if (!reboot_info) |
---|
3913 | 3913 | goto out; |
---|
3914 | 3914 | |
---|
3915 | | - if (!lock_fb_info(reboot_info)) |
---|
3916 | | - goto out; |
---|
| 3915 | + lock_fb_info(reboot_info); |
---|
3917 | 3916 | |
---|
3918 | 3917 | par = reboot_info->par; |
---|
3919 | 3918 | |
---|