Merge master.kernel.org:/home/rmk/linux-2.6-arm
[pandora-kernel.git] / drivers / video / aty / aty128fb.c
index 8a4ba3b..e380ee8 100644 (file)
@@ -350,10 +350,8 @@ static int default_vmode __initdata = VMODE_1024_768_60;
 static int default_cmode __initdata = CMODE_8;
 #endif
 
-#ifdef CONFIG_PMAC_PBOOK
 static int default_crt_on __initdata = 0;
 static int default_lcd_on __initdata = 1;
-#endif
 
 #ifdef CONFIG_MTRR
 static int mtrr = 1;
@@ -808,8 +806,8 @@ static void __iomem * __init aty128_map_ROM(const struct aty128fb_par *par, stru
 
        /* Very simple test to make sure it appeared */
        if (BIOS_IN16(0) != 0xaa55) {
-               printk(KERN_ERR "aty128fb: Invalid ROM signature %x should be 0xaa55\n",
-                      BIOS_IN16(0));
+               printk(KERN_DEBUG "aty128fb: Invalid ROM signature %x should "
+                       " be 0xaa55\n", BIOS_IN16(0));
                goto failed;
        }
 
@@ -1249,7 +1247,6 @@ static int aty128_crtc_to_var(const struct aty128_crtc *crtc,
        return 0;
 }
 
-#ifdef CONFIG_PMAC_PBOOK
 static void aty128_set_crt_enable(struct aty128fb_par *par, int on)
 {
        if (on) {
@@ -1284,7 +1281,6 @@ static void aty128_set_lcd_enable(struct aty128fb_par *par, int on)
                aty_st_le32(LVDS_GEN_CNTL, reg);
        }
 }
-#endif /* CONFIG_PMAC_PBOOK */
 
 static void aty128_set_pll(struct aty128_pll *pll, const struct aty128fb_par *par)
 {
@@ -1491,12 +1487,10 @@ static int aty128fb_set_par(struct fb_info *info)
        info->fix.visual = par->crtc.bpp == 8 ? FB_VISUAL_PSEUDOCOLOR
                : FB_VISUAL_DIRECTCOLOR;
 
-#ifdef CONFIG_PMAC_PBOOK
        if (par->chip_gen == rage_M3) {
                aty128_set_crt_enable(par, par->crt_on);
                aty128_set_lcd_enable(par, par->lcd_on);
        }
-#endif
        if (par->accel_flags & FB_ACCELF_TEXT)
                aty128_init_engine(par);
 
@@ -1652,7 +1646,6 @@ static int __init aty128fb_setup(char *options)
                return 0;
 
        while ((this_opt = strsep(&options, ",")) != NULL) {
-#ifdef CONFIG_PMAC_PBOOK
                if (!strncmp(this_opt, "lcd:", 4)) {
                        default_lcd_on = simple_strtoul(this_opt+4, NULL, 0);
                        continue;
@@ -1660,7 +1653,6 @@ static int __init aty128fb_setup(char *options)
                        default_crt_on = simple_strtoul(this_opt+4, NULL, 0);
                        continue;
                }
-#endif
 #ifdef CONFIG_MTRR
                if(!strncmp(this_opt, "nomtrr", 6)) {
                        mtrr = 0;
@@ -1752,10 +1744,8 @@ static int __init aty128_init(struct pci_dev *pdev, const struct pci_device_id *
        info->fbops = &aty128fb_ops;
        info->flags = FBINFO_FLAG_DEFAULT;
 
-#ifdef CONFIG_PMAC_PBOOK
        par->lcd_on = default_lcd_on;
        par->crt_on = default_crt_on;
-#endif
 
        var = default_var;
 #ifdef CONFIG_PPC_PMAC
@@ -2035,12 +2025,10 @@ static int aty128fb_blank(int blank, struct fb_info *fb)
 
        aty_st_8(CRTC_EXT_CNTL+1, state);
 
-#ifdef CONFIG_PMAC_PBOOK
        if (par->chip_gen == rage_M3) {
                aty128_set_crt_enable(par, par->crt_on && !blank);
                aty128_set_lcd_enable(par, par->lcd_on && !blank);
        }
-#endif 
 #ifdef CONFIG_PMAC_BACKLIGHT
        if ((_machine == _MACH_Pmac) && !blank)
                set_backlight_enable(1);
@@ -2124,7 +2112,6 @@ static int aty128fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
 static int aty128fb_ioctl(struct inode *inode, struct file *file, u_int cmd,
                          u_long arg, struct fb_info *info)
 {
-#ifdef CONFIG_PMAC_PBOOK
        struct aty128fb_par *par = info->par;
        u32 value;
        int rc;
@@ -2149,7 +2136,6 @@ static int aty128fb_ioctl(struct inode *inode, struct file *file, u_int cmd,
                value = (par->crt_on << 1) | par->lcd_on;
                return put_user(value, (__u32 __user *)arg);
        }
-#endif
        return -EINVAL;
 }
 
@@ -2331,24 +2317,22 @@ static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 {
        struct fb_info *info = pci_get_drvdata(pdev);
        struct aty128fb_par *par = info->par;
-       u8 agp;
 
        /* We don't do anything but D2, for now we return 0, but
         * we may want to change that. How do we know if the BIOS
         * can properly take care of D3 ? Also, with swsusp, we
         * know we'll be rebooted, ...
         */
-#ifdef CONFIG_PPC_PMAC
+#ifndef CONFIG_PPC_PMAC
        /* HACK ALERT ! Once I find a proper way to say to each driver
         * individually what will happen with it's PCI slot, I'll change
         * that. On laptops, the AGP slot is just unclocked, so D2 is
         * expected, while on desktops, the card is powered off
         */
-       if (state >= 3)
-               state = 2;
+       return 0;
 #endif /* CONFIG_PPC_PMAC */
         
-       if (state != 2 || state == pdev->dev.power.power_state)
+       if (state.event == pdev->dev.power.power_state.event)
                return 0;
 
        printk(KERN_DEBUG "aty128fb: suspending...\n");
@@ -2369,33 +2353,20 @@ static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state)
        par->asleep = 1;
        par->lock_blank = 1;
 
-       /* Disable AGP. The AGP host should have done it, but since ordering
-        * isn't always properly guaranteed in this specific case, let's make
-        * sure it's disabled on card side now. Ultimately, when merging fbdev
-        * and dri into some common infrastructure, this will be handled
-        * more nicely. The host bridge side will (or will not) be dealt with
-        * by the bridge AGP driver, we don't attempt to touch it here.
+#ifdef CONFIG_PPC_PMAC
+       /* On powermac, we have hooks to properly suspend/resume AGP now,
+        * use them here. We'll ultimately need some generic support here,
+        * but the generic code isn't quite ready for that yet
         */
-       agp = pci_find_capability(pdev, PCI_CAP_ID_AGP);
-       if (agp) {
-               u32 cmd;
-
-               pci_read_config_dword(pdev, agp + PCI_AGP_COMMAND, &cmd);
-               if (cmd & PCI_AGP_COMMAND_AGP) {
-                       printk(KERN_INFO "aty128fb: AGP was enabled, "
-                              "disabling ...\n");
-                       cmd &= ~PCI_AGP_COMMAND_AGP;
-                       pci_write_config_dword(pdev, agp + PCI_AGP_COMMAND,
-                                              cmd);
-               }
-       }
+       pmac_suspend_agp_for_card(pdev);
+#endif /* CONFIG_PPC_PMAC */
 
        /* We need a way to make sure the fbdev layer will _not_ touch the
         * framebuffer before we put the chip to suspend state. On 2.4, I
         * used dummy fb ops, 2.5 need proper support for this at the
         * fbdev level
         */
-       if (state == 2)
+       if (state.event != PM_EVENT_ON)
                aty128_set_suspend(par, 1);
 
        release_console_sem();
@@ -2410,12 +2381,11 @@ static int aty128_do_resume(struct pci_dev *pdev)
        struct fb_info *info = pci_get_drvdata(pdev);
        struct aty128fb_par *par = info->par;
 
-       if (pdev->dev.power.power_state == 0)
+       if (pdev->dev.power.power_state.event == PM_EVENT_ON)
                return 0;
 
        /* Wakeup chip */
-       if (pdev->dev.power.power_state == 2)
-               aty128_set_suspend(par, 0);
+       aty128_set_suspend(par, 0);
        par->asleep = 0;
 
        /* Restore display & engine */
@@ -2432,6 +2402,14 @@ static int aty128_do_resume(struct pci_dev *pdev)
        par->lock_blank = 0;
        aty128fb_blank(0, info);
 
+#ifdef CONFIG_PPC_PMAC
+       /* On powermac, we have hooks to properly suspend/resume AGP now,
+        * use them here. We'll ultimately need some generic support here,
+        * but the generic code isn't quite ready for that yet
+        */
+       pmac_resume_agp_for_card(pdev);
+#endif /* CONFIG_PPC_PMAC */
+
        pdev->dev.power.power_state = PMSG_ON;
 
        printk(KERN_DEBUG "aty128fb: resumed !\n");