[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 1 of 10] New/Updated drivers: ATI drivers backported from Linux Kernel Ver. 2.6.29.2



# HG changeset patch
# User root@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Date 1259014658 -3600
# Node ID 0659978a191179169437dbbc3ed224c23c6e1b8a
# Parent  1db1bb63824b25f97d127449faeb3a56f1272c97
ATI drivers backported from Linux Kernel Ver. 2.6.29.2
Signed-off-by: Daniel Kiper <dkiper@xxxxxxxxxxxx>

diff -r 1db1bb63824b -r 0659978a1911 Documentation/fb/aty128fb.txt
--- a/Documentation/fb/aty128fb.txt     Mon Nov 23 07:32:47 2009 +0000
+++ b/Documentation/fb/aty128fb.txt     Mon Nov 23 23:17:38 2009 +0100
@@ -54,8 +54,8 @@ Accepted options:
 
 noaccel  - do not use acceleration engine. It is default.
 accel    - use acceleration engine. Not finished.
-vmode:x  - chooses PowerMacintosh video mode <x>. Depreciated.
-cmode:x  - chooses PowerMacintosh colour mode <x>. Depreciated.
+vmode:x  - chooses PowerMacintosh video mode <x>. Deprecated.
+cmode:x  - chooses PowerMacintosh colour mode <x>. Deprecated.
 <XxX@X>  - selects startup videomode. See modedb.txt for detailed
           explanation. Default is 640x480x8bpp.
 
diff -r 1db1bb63824b -r 0659978a1911 drivers/video/aty/ati_ids.h
--- a/drivers/video/aty/ati_ids.h       Mon Nov 23 07:32:47 2009 +0000
+++ b/drivers/video/aty/ati_ids.h       Mon Nov 23 23:17:38 2009 +0100
@@ -188,10 +188,17 @@
 #define PCI_CHIP_MACH64VT              0x5654
 #define PCI_CHIP_MACH64VU              0x5655
 #define PCI_CHIP_MACH64VV              0x5656
+#define PCI_CHIP_RC410_5A62             0x5A62
 #define PCI_CHIP_RS300_5834            0x5834
 #define PCI_CHIP_RS300_5835            0x5835
 #define PCI_CHIP_RS300_5836            0x5836
 #define PCI_CHIP_RS300_5837            0x5837
+#define PCI_CHIP_RS480_5955             0x5955
+#define PCI_CHIP_RV280_5960            0x5960
+#define PCI_CHIP_RV280_5961            0x5961
+#define PCI_CHIP_RV280_5962            0x5962
+#define PCI_CHIP_RV280_5964            0x5964
+#define PCI_CHIP_RS482_5975            0x5975
 #define PCI_CHIP_RV370_5B60             0x5B60
 #define PCI_CHIP_RV370_5B61             0x5B61
 #define PCI_CHIP_RV370_5B62             0x5B62
@@ -200,13 +207,8 @@
 #define PCI_CHIP_RV370_5B65             0x5B65
 #define PCI_CHIP_RV370_5B66             0x5B66
 #define PCI_CHIP_RV370_5B67             0x5B67
-#define PCI_CHIP_RV280_5960            0x5960
-#define PCI_CHIP_RV280_5961            0x5961
-#define PCI_CHIP_RV280_5962            0x5962
-#define PCI_CHIP_RV280_5964            0x5964
 #define PCI_CHIP_RV280_5C61            0x5C61
 #define PCI_CHIP_RV280_5C63            0x5C63
 #define PCI_CHIP_R423_5D57              0x5D57
 #define PCI_CHIP_RS350_7834             0x7834
 #define PCI_CHIP_RS350_7835             0x7835
-
diff -r 1db1bb63824b -r 0659978a1911 drivers/video/aty/aty128fb.c
--- a/drivers/video/aty/aty128fb.c      Mon Nov 23 07:32:47 2009 +0000
+++ b/drivers/video/aty/aty128fb.c      Mon Nov 23 23:17:38 2009 +0100
@@ -56,7 +56,7 @@
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/fb.h>
 #include <linux/init.h>
 #include <linux/pci.h>
@@ -91,7 +91,7 @@
 #undef DEBUG
 
 #ifdef DEBUG
-#define DBG(fmt, args...)              printk(KERN_DEBUG "aty128fb: %s " fmt, 
__FUNCTION__, ##args);
+#define DBG(fmt, args...)              printk(KERN_DEBUG "aty128fb: %s " fmt, 
__func__, ##args);
 #else
 #define DBG(fmt, args...)
 #endif
@@ -357,6 +357,12 @@ static int mtrr = 1;
 static int mtrr = 1;
 #endif
 
+#ifdef CONFIG_PMAC_BACKLIGHT
+static int backlight __devinitdata = 1;
+#else
+static int backlight __devinitdata = 0;
+#endif
+
 /* PLL constants */
 struct aty128_constants {
        u32 ref_clk;
@@ -1334,13 +1340,16 @@ static int aty128_var_to_pll(u32 period_
                vclk = c.ppll_min/12;
 
        /* now, find an acceptable divider */
-       for (i = 0; i < sizeof(post_dividers); i++) {
+       for (i = 0; i < ARRAY_SIZE(post_dividers); i++) {
                output_freq = post_dividers[i] * vclk;
                if (output_freq >= c.ppll_min && output_freq <= c.ppll_max) {
                        pll->post_divider = post_dividers[i];
                        break;
                }
        }
+
+       if (i == ARRAY_SIZE(post_dividers))
+               return -EINVAL;
 
        /* calculate feedback divider */
        n = c.ref_divider * output_freq;
@@ -1466,7 +1475,7 @@ static int aty128fb_set_par(struct fb_in
        aty128_set_pll(&par->pll, par);
        aty128_set_fifo(&par->fifo_reg, par);
 
-       config = aty_ld_le32(CONFIG_CNTL) & ~3;
+       config = aty_ld_le32(CNFG_CNTL) & ~3;
 
 #if defined(__BIG_ENDIAN)
        if (par->crtc.bpp == 32)
@@ -1475,7 +1484,7 @@ static int aty128fb_set_par(struct fb_in
                config |= 1;    /* make aperture do 16 bit swapping */
 #endif
 
-       aty_st_le32(CONFIG_CNTL, config);
+       aty_st_le32(CNFG_CNTL, config);
        aty_st_8(CRTC_EXT_CNTL + 1, 0); /* turn the video back on */
 
        info->fix.line_length = (par->crtc.vxres * par->crtc.bpp) >> 3;
@@ -1646,6 +1655,9 @@ static int __devinit aty128fb_setup(char
                        continue;
                } else if (!strncmp(this_opt, "crt:", 4)) {
                        default_crt_on = simple_strtoul(this_opt+4, NULL, 0);
+                       continue;
+               } else if (!strncmp(this_opt, "backlight:", 10)) {
+                       backlight = simple_strtoul(this_opt+10, NULL, 0);
                        continue;
                }
 #ifdef CONFIG_MTRR
@@ -1690,9 +1702,6 @@ static int __devinit aty128fb_setup(char
 #ifdef CONFIG_FB_ATY128_BACKLIGHT
 #define MAX_LEVEL 0xFF
 
-static struct backlight_properties aty128_bl_data;
-
-/* Call with fb_info->bl_mutex held */
 static int aty128_bl_get_level_brightness(struct aty128fb_par *par,
                int level)
 {
@@ -1700,6 +1709,7 @@ static int aty128_bl_get_level_brightnes
        int atylevel;
 
        /* Get and convert the value */
+       /* No locking of bl_curve since we read a single value */
        atylevel = MAX_LEVEL -
                (info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL);
 
@@ -1719,19 +1729,18 @@ static int aty128_bl_get_level_brightnes
 /* That one prevents proper CRT output with LCD off */
 #undef BACKLIGHT_DAC_OFF
 
-/* Call with fb_info->bl_mutex held */
-static int __aty128_bl_update_status(struct backlight_device *bd)
-{
-       struct aty128fb_par *par = class_get_devdata(&bd->class_dev);
+static int aty128_bl_update_status(struct backlight_device *bd)
+{
+       struct aty128fb_par *par = bl_get_data(bd);
        unsigned int reg = aty_ld_le32(LVDS_GEN_CNTL);
        int level;
 
-       if (bd->props->power != FB_BLANK_UNBLANK ||
-           bd->props->fb_blank != FB_BLANK_UNBLANK ||
+       if (bd->props.power != FB_BLANK_UNBLANK ||
+           bd->props.fb_blank != FB_BLANK_UNBLANK ||
            !par->lcd_on)
                level = 0;
        else
-               level = bd->props->brightness;
+               level = bd->props.brightness;
 
        reg |= LVDS_BL_MOD_EN | LVDS_BLON;
        if (level > 0) {
@@ -1773,43 +1782,22 @@ static int __aty128_bl_update_status(str
        return 0;
 }
 
-static int aty128_bl_update_status(struct backlight_device *bd)
-{
-       struct aty128fb_par *par = class_get_devdata(&bd->class_dev);
-       struct fb_info *info = pci_get_drvdata(par->pdev);
-       int ret;
-
-       mutex_lock(&info->bl_mutex);
-       ret = __aty128_bl_update_status(bd);
-       mutex_unlock(&info->bl_mutex);
-
-       return ret;
-}
-
 static int aty128_bl_get_brightness(struct backlight_device *bd)
 {
-       return bd->props->brightness;
-}
-
-static struct backlight_properties aty128_bl_data = {
-       .owner          = THIS_MODULE,
+       return bd->props.brightness;
+}
+
+static struct backlight_ops aty128_bl_data = {
        .get_brightness = aty128_bl_get_brightness,
        .update_status  = aty128_bl_update_status,
-       .max_brightness = (FB_BACKLIGHT_LEVELS - 1),
 };
 
 static void aty128_bl_set_power(struct fb_info *info, int power)
 {
-       mutex_lock(&info->bl_mutex);
-
        if (info->bl_dev) {
-               down(&info->bl_dev->sem);
-               info->bl_dev->props->power = power;
-               __aty128_bl_update_status(info->bl_dev);
-               up(&info->bl_dev->sem);
-       }
-
-       mutex_unlock(&info->bl_mutex);
+               info->bl_dev->props.power = power;
+               backlight_update_status(info->bl_dev);
+       }
 }
 
 static void aty128_bl_init(struct aty128fb_par *par)
@@ -1829,32 +1817,22 @@ static void aty128_bl_init(struct aty128
 
        snprintf(name, sizeof(name), "aty128bl%d", info->node);
 
-       bd = backlight_device_register(name, par, &aty128_bl_data);
+       bd = backlight_device_register(name, info->dev, par, &aty128_bl_data);
        if (IS_ERR(bd)) {
                info->bl_dev = NULL;
                printk(KERN_WARNING "aty128: Backlight registration failed\n");
                goto error;
        }
 
-       mutex_lock(&info->bl_mutex);
        info->bl_dev = bd;
        fb_bl_default_curve(info, 0,
                 63 * FB_BACKLIGHT_MAX / MAX_LEVEL,
                219 * FB_BACKLIGHT_MAX / MAX_LEVEL);
-       mutex_unlock(&info->bl_mutex);
-
-       down(&bd->sem);
-       bd->props->brightness = aty128_bl_data.max_brightness;
-       bd->props->power = FB_BLANK_UNBLANK;
-       bd->props->update_status(bd);
-       up(&bd->sem);
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-       mutex_lock(&pmac_backlight_mutex);
-       if (!pmac_backlight)
-               pmac_backlight = bd;
-       mutex_unlock(&pmac_backlight_mutex);
-#endif
+
+       bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
+       bd->props.brightness = bd->props.max_brightness;
+       bd->props.power = FB_BLANK_UNBLANK;
+       backlight_update_status(bd);
 
        printk("aty128: Backlight initialized (%s)\n", name);
 
@@ -1864,31 +1842,10 @@ error:
        return;
 }
 
-static void aty128_bl_exit(struct aty128fb_par *par)
-{
-       struct fb_info *info = pci_get_drvdata(par->pdev);
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-       mutex_lock(&pmac_backlight_mutex);
-#endif
-
-       mutex_lock(&info->bl_mutex);
-       if (info->bl_dev) {
-#ifdef CONFIG_PMAC_BACKLIGHT
-               if (pmac_backlight == info->bl_dev)
-                       pmac_backlight = NULL;
-#endif
-
-               backlight_device_unregister(info->bl_dev);
-               info->bl_dev = NULL;
-
-               printk("aty128: Backlight unloaded\n");
-       }
-       mutex_unlock(&info->bl_mutex);
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-       mutex_unlock(&pmac_backlight_mutex);
-#endif
+static void aty128_bl_exit(struct backlight_device *bd)
+{
+       backlight_device_unregister(bd);
+       printk("aty128: Backlight unloaded\n");
 }
 #endif /* CONFIG_FB_ATY128_BACKLIGHT */
 
@@ -1896,13 +1853,14 @@ static void aty128_bl_exit(struct aty128
  *  Initialisation
  */
 
-#ifdef CONFIG_PPC_PMAC
+#ifdef CONFIG_PPC_PMAC__disabled
 static void aty128_early_resume(void *data)
 {
         struct aty128fb_par *par = data;
 
        if (try_acquire_console_sem())
                return;
+       pci_restore_state(par->pdev);
        aty128_do_resume(par->pdev);
        release_console_sem();
 }
@@ -1913,12 +1871,12 @@ static int __devinit aty128_init(struct 
        struct fb_info *info = pci_get_drvdata(pdev);
        struct aty128fb_par *par = info->par;
        struct fb_var_screeninfo var;
-       char video_card[DEVICE_NAME_SIZE];
+       char video_card[50];
        u8 chip_rev;
        u32 dac;
 
        /* Get the chip revision */
-       chip_rev = (aty_ld_le32(CONFIG_CNTL) >> 16) & 0x1F;
+       chip_rev = (aty_ld_le32(CNFG_CNTL) >> 16) & 0x1F;
 
        strcpy(video_card, "Rage128 XX ");
        video_card[8] = ent->device >> 8;
@@ -1926,7 +1884,7 @@ static int __devinit aty128_init(struct 
 
        /* range check to make sure */
        if (ent->driver_data < ARRAY_SIZE(r128_family))
-           strncat(video_card, r128_family[ent->driver_data], 
sizeof(video_card));
+           strlcat(video_card, r128_family[ent->driver_data], 
sizeof(video_card));
 
        printk(KERN_INFO "aty128fb: %s [chip rev 0x%x] ", video_card, chip_rev);
 
@@ -1950,7 +1908,14 @@ static int __devinit aty128_init(struct 
                /* Indicate sleep capability */
                if (par->chip_gen == rage_M3) {
                        pmac_call_feature(PMAC_FTR_DEVICE_CAN_WAKE, NULL, 0, 1);
+#if 0 /* Disable the early video resume hack for now as it's causing problems, 
among
+       * others we now rely on the PCI core restoring the config space for us, 
which
+       * isn't the case with that hack, and that code path causes various 
things to
+       * be called with interrupts off while they shouldn't. I'm leaving the 
code in
+       * as it can be useful for debugging purposes
+       */
                        pmac_set_early_video_resume(aty128_early_resume, par);
+#endif
                }
 
                /* Find default mode */
@@ -2035,7 +2000,8 @@ static int __devinit aty128_init(struct 
        par->lock_blank = 0;
 
 #ifdef CONFIG_FB_ATY128_BACKLIGHT
-       aty128_bl_init(par);
+       if (backlight)
+               aty128_bl_init(par);
 #endif
 
        if (register_framebuffer(info) < 0)
@@ -2099,7 +2065,7 @@ static int __devinit aty128_probe(struct
 
        /* Grab memory size from the card */
        // How does this relate to the resource length from the PCI hardware?
-       par->vram_size = aty_ld_le32(CONFIG_MEMSIZE) & 0x03FFFFFF;
+       par->vram_size = aty_ld_le32(CNFG_MEMSIZE) & 0x03FFFFFF;
 
        /* Virtualize the framebuffer */
        info->screen_base = ioremap(fb_addr, par->vram_size);
@@ -2175,11 +2141,12 @@ static void __devexit aty128_remove(stru
 
        par = info->par;
 
+       unregister_framebuffer(info);
+
 #ifdef CONFIG_FB_ATY128_BACKLIGHT
-       aty128_bl_exit(par);
-#endif
-
-       unregister_framebuffer(info);
+       aty128_bl_exit(info->bl_dev);
+#endif
+
 #ifdef CONFIG_MTRR
        if (par->mtrr.vram_valid)
                mtrr_del(par->mtrr.vram, info->fix.smem_start,
@@ -2204,34 +2171,35 @@ static int aty128fb_blank(int blank, str
 static int aty128fb_blank(int blank, struct fb_info *fb)
 {
        struct aty128fb_par *par = fb->par;
-       u8 state = 0;
+       u8 state;
 
        if (par->lock_blank || par->asleep)
                return 0;
 
-#ifdef CONFIG_FB_ATY128_BACKLIGHT
-       if (machine_is(powermac) && blank)
-               aty128_bl_set_power(fb, FB_BLANK_POWERDOWN);
-#endif
-
-       if (blank & FB_BLANK_VSYNC_SUSPEND)
-               state |= 2;
-       if (blank & FB_BLANK_HSYNC_SUSPEND)
-               state |= 1;
-       if (blank & FB_BLANK_POWERDOWN)
-               state |= 4;
-
+       switch (blank) {
+       case FB_BLANK_NORMAL:
+               state = 4;
+               break;
+       case FB_BLANK_VSYNC_SUSPEND:
+               state = 6;
+               break;
+       case FB_BLANK_HSYNC_SUSPEND:
+               state = 5;
+               break;
+       case FB_BLANK_POWERDOWN:
+               state = 7;
+               break;
+       case FB_BLANK_UNBLANK:
+       default:
+               state = 0;
+               break;
+       }
        aty_st_8(CRTC_EXT_CNTL+1, state);
 
        if (par->chip_gen == rage_M3) {
                aty128_set_crt_enable(par, par->crt_on && !blank);
                aty128_set_lcd_enable(par, par->lcd_on && !blank);
        }
-
-#ifdef CONFIG_FB_ATY128_BACKLIGHT
-       if (machine_is(powermac) && !blank)
-               aty128_bl_set_power(fb, FB_BLANK_UNBLANK);
-#endif
 
        return 0;
 }
@@ -2405,7 +2373,6 @@ static void aty128_set_suspend(struct at
 static void aty128_set_suspend(struct aty128fb_par *par, int suspend)
 {
        u32     pmgt;
-       u16     pwr_command;
        struct pci_dev *pdev = par->pdev;
 
        if (!par->pm_reg)
@@ -2414,6 +2381,8 @@ static void aty128_set_suspend(struct at
        /* Set the chip into the appropriate suspend mode (we use D2,
         * D3 would require a complete re-initialisation of the chip,
         * including PCI config registers, clocks, AGP configuration, ...)
+        *
+        * For resume, the core will have already brought us back to D0
         */
        if (suspend) {
                /* Make sure CRTC2 is reset. Remove that the day we decide to
@@ -2431,17 +2400,9 @@ static void aty128_set_suspend(struct at
                aty_st_le32(BUS_CNTL1, 0x00000010);
                aty_st_le32(MEM_POWER_MISC, 0x0c830000);
                mdelay(100);
-               pci_read_config_word(pdev, par->pm_reg+PCI_PM_CTRL, 
&pwr_command);
+
                /* Switch PCI power management to D2 */
-               pci_write_config_word(pdev, par->pm_reg+PCI_PM_CTRL,
-                       (pwr_command & ~PCI_PM_CTRL_STATE_MASK) | 2);
-               pci_read_config_word(pdev, par->pm_reg+PCI_PM_CTRL, 
&pwr_command);
-       } else {
-               /* Switch back PCI power management to D0 */
-               mdelay(100);
-               pci_write_config_word(pdev, par->pm_reg+PCI_PM_CTRL, 0);
-               pci_read_config_word(pdev, par->pm_reg+PCI_PM_CTRL, 
&pwr_command);
-               mdelay(100);
+               pci_set_power_state(pdev, PCI_D2);
        }
 }
 
@@ -2449,6 +2410,12 @@ static int aty128_pci_suspend(struct pci
 {
        struct fb_info *info = pci_get_drvdata(pdev);
        struct aty128fb_par *par = info->par;
+
+       /* Because we may change PCI D state ourselves, we need to
+        * first save the config space content so the core can
+        * restore it properly on resume.
+        */
+       pci_save_state(pdev);
 
        /* 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
@@ -2479,7 +2446,7 @@ static int aty128_pci_suspend(struct pci
        wait_for_idle(par);
 
        /* Blank display and LCD */
-       aty128fb_blank(VESA_POWERDOWN, info);
+       aty128fb_blank(FB_BLANK_POWERDOWN, info);
 
        /* Sleep */
        par->asleep = 1;
@@ -2515,6 +2482,11 @@ static int aty128_do_resume(struct pci_d
 
        if (pdev->dev.power.power_state.event == PM_EVENT_ON)
                return 0;
+
+       /* PCI state will have been restored by the core, so
+        * we should be in D0 now with our config space fully
+        * restored
+        */
 
        /* Wakeup chip */
        aty128_set_suspend(par, 0);
diff -r 1db1bb63824b -r 0659978a1911 drivers/video/aty/atyfb.h
--- a/drivers/video/aty/atyfb.h Mon Nov 23 07:32:47 2009 +0000
+++ b/drivers/video/aty/atyfb.h Mon Nov 23 23:17:38 2009 +0100
@@ -126,7 +126,7 @@ union aty_pll {
      */
 
 struct atyfb_par {
-       struct aty_cmap_regs __iomem *aty_cmap_regs;
+       u32 pseudo_palette[16];
        struct { u8 red, green, blue; } palette[256];
        const struct aty_dac_ops *dac_ops;
        const struct aty_pll_ops *pll_ops;
@@ -186,6 +186,7 @@ struct atyfb_par {
        int mtrr_aper;
        int mtrr_reg;
 #endif
+       u32 mem_cntl;
 };
 
     /*
@@ -227,7 +228,7 @@ static inline u32 aty_ld_le32(int regind
                regindex -= 0x800;
 
 #ifdef CONFIG_ATARI
-       return in_le32((volatile u32 *)(par->ati_regbase + regindex));
+       return in_le32(par->ati_regbase + regindex);
 #else
        return readl(par->ati_regbase + regindex);
 #endif
@@ -240,7 +241,7 @@ static inline void aty_st_le32(int regin
                regindex -= 0x800;
 
 #ifdef CONFIG_ATARI
-       out_le32((volatile u32 *)(par->ati_regbase + regindex), val);
+       out_le32(par->ati_regbase + regindex, val);
 #else
        writel(val, par->ati_regbase + regindex);
 #endif
@@ -253,7 +254,7 @@ static inline void aty_st_le16(int regin
        if (regindex >= 0x400)
                regindex -= 0x800;
 #ifdef CONFIG_ATARI
-       out_le16((volatile u16 *)(par->ati_regbase + regindex), val);
+       out_le16(par->ati_regbase + regindex, val);
 #else
        writel(val, par->ati_regbase + regindex);
 #endif
@@ -284,7 +285,8 @@ static inline void aty_st_8(int regindex
 #endif
 }
 
-#if defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || defined 
(CONFIG_FB_ATY_GENERIC_LCD)
+#if defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || \
+defined (CONFIG_FB_ATY_GENERIC_LCD) || defined (CONFIG_FB_ATY_BACKLIGHT)
 extern void aty_st_lcd(int index, u32 val, const struct atyfb_par *par);
 extern u32 aty_ld_lcd(int index, const struct atyfb_par *par);
 #endif
@@ -315,6 +317,7 @@ struct aty_pll_ops {
        void (*set_pll)   (const struct fb_info * info, const union aty_pll * 
pll);
        void (*get_pll)   (const struct fb_info *info, union aty_pll * pll);
        int (*init_pll)   (const struct fb_info * info, union aty_pll * pll);
+       void (*resume_pll)(const struct fb_info *info, union aty_pll *pll);
 };
 
 extern const struct aty_pll_ops aty_pll_ati18818_1; /* ATI 18818 */
@@ -355,5 +358,9 @@ static inline void wait_for_idle(struct 
 
 extern void aty_reset_engine(const struct atyfb_par *par);
 extern void aty_init_engine(struct atyfb_par *par, struct fb_info *info);
-extern void aty_st_pll_ct(int offset, u8 val, const struct atyfb_par *par);
 extern u8   aty_ld_pll_ct(int offset, const struct atyfb_par *par);
+
+void atyfb_copyarea(struct fb_info *info, const struct fb_copyarea *area);
+void atyfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
+void atyfb_imageblit(struct fb_info *info, const struct fb_image *image);
+
diff -r 1db1bb63824b -r 0659978a1911 drivers/video/aty/atyfb_base.c
--- a/drivers/video/aty/atyfb_base.c    Mon Nov 23 07:32:47 2009 +0000
+++ b/drivers/video/aty/atyfb_base.c    Mon Nov 23 23:17:38 2009 +0100
@@ -26,7 +26,7 @@
  *                        Anthony Tong <atong@xxxxxxxx>
  *
  *  Generic LCD support written by Daniel Mantione, ported from 2.4.20 by Alex 
Kern
- *  Many Thanks to Ville Syrjälä for patches and fixing nasting 16 bit color 
bug.
+ *  Many Thanks to Ville Syrjälä for patches and fixing nasting 16 bit color 
bug.
  *
  *  This file is subject to the terms and conditions of the GNU General Public
  *  License. See the file COPYING in the main directory of this archive for
@@ -68,7 +68,7 @@
 #include <linux/backlight.h>
 
 #include <asm/io.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 #include <video/mach64.h>
 #include "atyfb.h"
@@ -80,8 +80,9 @@
 #include "../macmodes.h"
 #endif
 #ifdef __sparc__
-#include <asm/pbm.h>
 #include <asm/fbio.h>
+#include <asm/oplib.h>
+#include <asm/prom.h>
 #endif
 
 #ifdef CONFIG_ADB_PMU
@@ -131,9 +132,10 @@
 #define PRINTKI(fmt, args...)  printk(KERN_INFO "atyfb: " fmt, ## args)
 #define PRINTKE(fmt, args...)   printk(KERN_ERR "atyfb: " fmt, ## args)
 
-#if defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || defined 
(CONFIG_FB_ATY_GENERIC_LCD)
+#if defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || \
+defined (CONFIG_FB_ATY_GENERIC_LCD) || defined(CONFIG_FB_ATY_BACKLIGHT)
 static const u32 lt_lcd_regs[] = {
-       CONFIG_PANEL_LG,
+       CNFG_PANEL_LG,
        LCD_GEN_CNTL_LG,
        DSTN_CONTROL_LG,
        HFB_PITCH_ADDR_LG,
@@ -203,14 +205,6 @@ static void ATIReduceRatio(int *Numerato
      *  The Hardware parameters for each card
      */
 
-struct aty_cmap_regs {
-       u8 windex;
-       u8 lut;
-       u8 mask;
-       u8 rindex;
-       u8 cntl;
-};
-
 struct pci_mmap_map {
        unsigned long voff;
        unsigned long poff;
@@ -240,9 +234,6 @@ static int atyfb_pan_display(struct fb_v
 static int atyfb_pan_display(struct fb_var_screeninfo *var, struct fb_info 
*info);
 static int atyfb_blank(int blank, struct fb_info *info);
 static int atyfb_ioctl(struct fb_info *info, u_int cmd, u_long arg);
-extern void atyfb_fillrect(struct fb_info *info, const struct fb_fillrect 
*rect);
-extern void atyfb_copyarea(struct fb_info *info, const struct fb_copyarea 
*area);
-extern void atyfb_imageblit(struct fb_info *info, const struct fb_image 
*image);
 #ifdef __sparc__
 static int atyfb_mmap(struct fb_info *info, struct vm_area_struct *vma);
 #endif
@@ -252,7 +243,8 @@ static int atyfb_sync(struct fb_info *in
      *  Internal routines
      */
 
-static int aty_init(struct fb_info *info, const char *name);
+static int aty_init(struct fb_info *info);
+
 #ifdef CONFIG_ATARI
 static int store_video_par(char *videopar, unsigned char m64_num);
 #endif
@@ -318,6 +310,12 @@ static int comp_sync __devinitdata = -1;
 static int comp_sync __devinitdata = -1;
 static char *mode;
 
+#ifdef CONFIG_PMAC_BACKLIGHT
+static int backlight __devinitdata = 1;
+#else
+static int backlight __devinitdata = 0;
+#endif
+
 #ifdef CONFIG_PPC
 static int default_vmode __devinitdata = VMODE_CHOOSE;
 static int default_cmode __devinitdata = CMODE_CHOOSE;
@@ -409,7 +407,7 @@ static struct {
        { PCI_CHIP_MACH64LB, "3D RAGE LT PRO (Mach64 LB, AGP)", 236, 75, 100, 
135, ATI_CHIP_264LTPRO },
        { PCI_CHIP_MACH64LD, "3D RAGE LT PRO (Mach64 LD, AGP)", 230, 100, 100, 
135, ATI_CHIP_264LTPRO },
        { PCI_CHIP_MACH64LI, "3D RAGE LT PRO (Mach64 LI, PCI)", 230, 100, 100, 
135, ATI_CHIP_264LTPRO | M64F_G3_PB_1_1 | M64F_G3_PB_1024x768 },
-       { PCI_CHIP_MACH64LP, "3D RAGE LT PRO (Mach64 LP, PCI)", 230, 100, 100, 
135, ATI_CHIP_264LTPRO },
+       { PCI_CHIP_MACH64LP, "3D RAGE LT PRO (Mach64 LP, PCI)", 230, 100, 100, 
135, ATI_CHIP_264LTPRO | M64F_G3_PB_1024x768 },
        { PCI_CHIP_MACH64LQ, "3D RAGE LT PRO (Mach64 LQ, PCI)", 230, 100, 100, 
135, ATI_CHIP_264LTPRO },
 
        { PCI_CHIP_MACH64GM, "3D RAGE XL (Mach64 GM, AGP 2x)", 230, 83, 63, 
135, ATI_CHIP_264XL },
@@ -426,7 +424,6 @@ static struct {
 #endif /* CONFIG_FB_ATY_CT */
 };
 
-/* can not fail */
 static int __devinit correct_chipset(struct atyfb_par *par)
 {
        u8 rev;
@@ -438,6 +435,9 @@ static int __devinit correct_chipset(str
        for (i = ARRAY_SIZE(aty_chips) - 1; i >= 0; i--)
                if (par->pci_id == aty_chips[i].pci_id)
                        break;
+
+       if (i < 0)
+               return -ENODEV;
 
        name = aty_chips[i].name;
        par->pll_limits.pll_max = aty_chips[i].pll;
@@ -446,7 +446,7 @@ static int __devinit correct_chipset(str
        par->pll_limits.ecp_max = aty_chips[i].ecp_max;
        par->features = aty_chips[i].features;
 
-       chip_id = aty_ld_le32(CONFIG_CHIP_ID, par);
+       chip_id = aty_ld_le32(CNFG_CHIP_ID, par);
        type = chip_id & CFG_CHIP_TYPE;
        rev = (chip_id & CFG_CHIP_REV) >> 24;
 
@@ -543,8 +543,6 @@ static char ram_off[] __devinitdata = "O
 #endif /* CONFIG_FB_ATY_CT */
 
 
-static u32 pseudo_palette[17];
-
 #ifdef CONFIG_FB_ATY_GX
 static char *aty_gx_ram[8] __devinitdata = {
        ram_dram, ram_vram, ram_vram, ram_dram,
@@ -631,7 +629,7 @@ static void aty_get_crtc(const struct at
                    crtc->lcd_index = aty_ld_le32(LCD_INDEX, par);
                    aty_st_le32(LCD_INDEX, crtc->lcd_index, par);
                }
-               crtc->lcd_config_panel = aty_ld_lcd(CONFIG_PANEL, par);
+               crtc->lcd_config_panel = aty_ld_lcd(CNFG_PANEL, par);
                crtc->lcd_gen_cntl = aty_ld_lcd(LCD_GEN_CNTL, par);
 
 
@@ -678,7 +676,7 @@ static void aty_set_crtc(const struct at
                aty_st_le32(CRTC_GEN_CNTL, crtc->gen_cntl & ~(CRTC_EXT_DISP_EN 
| CRTC_EN), par);
 
                /* update non-shadow registers first */
-               aty_st_lcd(CONFIG_PANEL, crtc->lcd_config_panel, par);
+               aty_st_lcd(CNFG_PANEL, crtc->lcd_config_panel, par);
                aty_st_lcd(LCD_GEN_CNTL, crtc->lcd_gen_cntl &
                        ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN), par);
 
@@ -860,7 +858,7 @@ static int aty_var_to_crtc(const struct 
                if (!M64_HAS(MOBIL_BUS))
                        crtc->lcd_index |= CRTC2_DISPLAY_DIS;
 
-               crtc->lcd_config_panel = aty_ld_lcd(CONFIG_PANEL, par) | 0x4000;
+               crtc->lcd_config_panel = aty_ld_lcd(CNFG_PANEL, par) | 0x4000;
                crtc->lcd_gen_cntl = aty_ld_lcd(LCD_GEN_CNTL, par) & 
~CRTC_RW_SELECT;
 
                crtc->lcd_gen_cntl &=
@@ -1498,10 +1496,6 @@ static int atyfb_check_var(struct fb_var
        else
                info->var.accel_flags = 0;
 
-#if 0 /* fbmon is not done. uncomment for 2.5.x -brad */
-       if (!fbmon_valid_timings(pixclock, htotal, vtotal, info))
-               return -EINVAL;
-#endif
        aty_crtc_to_var(&crtc, var);
        var->pixclock = par->pll_ops->pll_to_var(info, &pll);
        return 0;
@@ -1535,7 +1529,7 @@ static int atyfb_open(struct fb_info *in
        return (0);
 }
 
-static irqreturn_t aty_irq(int irq, void *dev_id, struct pt_regs *fp)
+static irqreturn_t aty_irq(int irq, void *dev_id, struct pt_regs *regs)
 {
        struct atyfb_par *par = dev_id;
        int handled = 0;
@@ -1921,70 +1915,13 @@ static int atyfb_mmap(struct fb_info *in
                par->mmaped = 1;
        return 0;
 }
-
-static struct {
-       u32 yoffset;
-       u8 r[2][256];
-       u8 g[2][256];
-       u8 b[2][256];
-} atyfb_save;
-
-static void atyfb_save_palette(struct atyfb_par *par, int enter)
-{
-       int i, tmp;
-
-       for (i = 0; i < 256; i++) {
-               tmp = aty_ld_8(DAC_CNTL, par) & 0xfc;
-               if (M64_HAS(EXTRA_BRIGHT))
-                       tmp |= 0x2;
-               aty_st_8(DAC_CNTL, tmp, par);
-               aty_st_8(DAC_MASK, 0xff, par);
-
-               writeb(i, &par->aty_cmap_regs->rindex);
-               atyfb_save.r[enter][i] = readb(&par->aty_cmap_regs->lut);
-               atyfb_save.g[enter][i] = readb(&par->aty_cmap_regs->lut);
-               atyfb_save.b[enter][i] = readb(&par->aty_cmap_regs->lut);
-               writeb(i, &par->aty_cmap_regs->windex);
-               writeb(atyfb_save.r[1 - enter][i],
-                      &par->aty_cmap_regs->lut);
-               writeb(atyfb_save.g[1 - enter][i],
-                      &par->aty_cmap_regs->lut);
-               writeb(atyfb_save.b[1 - enter][i],
-                      &par->aty_cmap_regs->lut);
-       }
-}
-
-static void atyfb_palette(int enter)
-{
-       struct atyfb_par *par;
-       struct fb_info *info;
-       int i;
-
-       for (i = 0; i < FB_MAX; i++) {
-               info = registered_fb[i];
-               if (info && info->fbops == &atyfb_ops) {
-                       par = (struct atyfb_par *) info->par;
-                       
-                       atyfb_save_palette(par, enter);
-                       if (enter) {
-                               atyfb_save.yoffset = info->var.yoffset;
-                               info->var.yoffset = 0;
-                               set_off_pitch(par, info);
-                       } else {
-                               info->var.yoffset = atyfb_save.yoffset;
-                               set_off_pitch(par, info);
-                       }
-                       aty_st_le32(CRTC_OFF_PITCH, par->crtc.off_pitch, par);
-                       break;
-               }
-       }
-}
 #endif /* __sparc__ */
 
 
 
 #if defined(CONFIG_PM) && defined(CONFIG_PCI)
 
+#ifdef CONFIG_PPC_PMAC
 /* Power management routines. Those are used for PowerBook sleep.
  */
 static int aty_power_mgmt(int sleep, struct atyfb_par *par)
@@ -2041,20 +1978,12 @@ static int aty_power_mgmt(int sleep, str
 
        return timeout ? 0 : -EIO;
 }
+#endif /* CONFIG_PPC_PMAC */
 
 static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 {
        struct fb_info *info = pci_get_drvdata(pdev);
        struct atyfb_par *par = (struct atyfb_par *) info->par;
-
-#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
-        */
-       return 0;
-#endif /* CONFIG_PPC_PMAC */
 
        if (state.event == pdev->dev.power.power_state.event)
                return 0;
@@ -2073,8 +2002,15 @@ static int atyfb_pci_suspend(struct pci_
        par->asleep = 1;
        par->lock_blank = 1;
 
+       /* Because we may change PCI D state ourselves, we need to
+        * first save the config space content so the core can
+        * restore it properly on resume.
+        */
+       pci_save_state(pdev);
+
+#ifdef CONFIG_PPC_PMAC
        /* Set chip to "suspend" mode */
-       if (aty_power_mgmt(1, par)) {
+       if (machine_is(powermac) && aty_power_mgmt(1, par)) {
                par->asleep = 0;
                par->lock_blank = 0;
                atyfb_blank(FB_BLANK_UNBLANK, info);
@@ -2082,12 +2018,29 @@ static int atyfb_pci_suspend(struct pci_
                release_console_sem();
                return -EIO;
        }
+#else
+       pci_set_power_state(pdev, pci_choose_state(pdev, state));
+#endif
 
        release_console_sem();
 
        pdev->dev.power.power_state = state;
 
        return 0;
+}
+
+static void aty_resume_chip(struct fb_info *info)
+{
+       struct atyfb_par *par = info->par;
+
+       aty_st_le32(MEM_CNTL, par->mem_cntl, par);
+
+       if (par->pll_ops->resume_pll)
+               par->pll_ops->resume_pll(info, &par->pll);
+
+       if (par->aux_start)
+               aty_st_le32(BUS_CNTL,
+                       aty_ld_le32(BUS_CNTL, par) | BUS_APER_REG_DIS, par);
 }
 
 static int atyfb_pci_resume(struct pci_dev *pdev)
@@ -2100,8 +2053,19 @@ static int atyfb_pci_resume(struct pci_d
 
        acquire_console_sem();
 
-       if (pdev->dev.power.power_state.event == 2)
+       /* PCI state will have been restored by the core, so
+        * we should be in D0 now with our config space fully
+        * restored
+        */
+
+#ifdef CONFIG_PPC_PMAC
+       if (machine_is(powermac) &&
+           pdev->dev.power.power_state.event == PM_EVENT_SUSPEND)
                aty_power_mgmt(0, par);
+#endif
+
+       aty_resume_chip(info);
+
        par->asleep = 0;
 
        /* Restore display */
@@ -2127,15 +2091,13 @@ static int atyfb_pci_resume(struct pci_d
 #ifdef CONFIG_FB_ATY_BACKLIGHT
 #define MAX_LEVEL 0xFF
 
-static struct backlight_properties aty_bl_data;
-
-/* Call with fb_info->bl_mutex held */
 static int aty_bl_get_level_brightness(struct atyfb_par *par, int level)
 {
        struct fb_info *info = pci_get_drvdata(par->pdev);
        int atylevel;
 
        /* Get and convert the value */
+       /* No locking of bl_curve since we read a single value */
        atylevel = info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL;
 
        if (atylevel < 0)
@@ -2146,18 +2108,17 @@ static int aty_bl_get_level_brightness(s
        return atylevel;
 }
 
-/* Call with fb_info->bl_mutex held */
-static int __aty_bl_update_status(struct backlight_device *bd)
-{
-       struct atyfb_par *par = class_get_devdata(&bd->class_dev);
+static int aty_bl_update_status(struct backlight_device *bd)
+{
+       struct atyfb_par *par = bl_get_data(bd);
        unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, par);
        int level;
 
-       if (bd->props->power != FB_BLANK_UNBLANK ||
-           bd->props->fb_blank != FB_BLANK_UNBLANK)
+       if (bd->props.power != FB_BLANK_UNBLANK ||
+           bd->props.fb_blank != FB_BLANK_UNBLANK)
                level = 0;
        else
-               level = bd->props->brightness;
+               level = bd->props.brightness;
 
        reg |= (BLMOD_EN | BIASMOD_EN);
        if (level > 0) {
@@ -2172,44 +2133,15 @@ static int __aty_bl_update_status(struct
        return 0;
 }
 
-static int aty_bl_update_status(struct backlight_device *bd)
-{
-       struct atyfb_par *par = class_get_devdata(&bd->class_dev);
-       struct fb_info *info = pci_get_drvdata(par->pdev);
-       int ret;
-
-       mutex_lock(&info->bl_mutex);
-       ret = __aty_bl_update_status(bd);
-       mutex_unlock(&info->bl_mutex);
-
-       return ret;
-}
-
 static int aty_bl_get_brightness(struct backlight_device *bd)
 {
-       return bd->props->brightness;
-}
-
-static struct backlight_properties aty_bl_data = {
-       .owner    = THIS_MODULE,
+       return bd->props.brightness;
+}
+
+static struct backlight_ops aty_bl_data = {
        .get_brightness = aty_bl_get_brightness,
        .update_status  = aty_bl_update_status,
-       .max_brightness = (FB_BACKLIGHT_LEVELS - 1),
 };
-
-static void aty_bl_set_power(struct fb_info *info, int power)
-{
-       mutex_lock(&info->bl_mutex);
-
-       if (info->bl_dev) {
-               down(&info->bl_dev->sem);
-               info->bl_dev->props->power = power;
-               __aty_bl_update_status(info->bl_dev);
-               up(&info->bl_dev->sem);
-       }
-
-       mutex_unlock(&info->bl_mutex);
-}
 
 static void aty_bl_init(struct atyfb_par *par)
 {
@@ -2224,32 +2156,22 @@ static void aty_bl_init(struct atyfb_par
 
        snprintf(name, sizeof(name), "atybl%d", info->node);
 
-       bd = backlight_device_register(name, par, &aty_bl_data);
+       bd = backlight_device_register(name, info->dev, par, &aty_bl_data);
        if (IS_ERR(bd)) {
                info->bl_dev = NULL;
                printk(KERN_WARNING "aty: Backlight registration failed\n");
                goto error;
        }
 
-       mutex_lock(&info->bl_mutex);
        info->bl_dev = bd;
        fb_bl_default_curve(info, 0,
                0x3F * FB_BACKLIGHT_MAX / MAX_LEVEL,
                0xFF * FB_BACKLIGHT_MAX / MAX_LEVEL);
-       mutex_unlock(&info->bl_mutex);
-
-       down(&bd->sem);
-       bd->props->brightness = aty_bl_data.max_brightness;
-       bd->props->power = FB_BLANK_UNBLANK;
-       bd->props->update_status(bd);
-       up(&bd->sem);
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-       mutex_lock(&pmac_backlight_mutex);
-       if (!pmac_backlight)
-               pmac_backlight = bd;
-       mutex_unlock(&pmac_backlight_mutex);
-#endif
+
+       bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
+       bd->props.brightness = bd->props.max_brightness;
+       bd->props.power = FB_BLANK_UNBLANK;
+       backlight_update_status(bd);
 
        printk("aty: Backlight initialized (%s)\n", name);
 
@@ -2259,30 +2181,10 @@ error:
        return;
 }
 
-static void aty_bl_exit(struct atyfb_par *par)
-{
-       struct fb_info *info = pci_get_drvdata(par->pdev);
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-       mutex_lock(&pmac_backlight_mutex);
-#endif
-
-       mutex_lock(&info->bl_mutex);
-       if (info->bl_dev) {
-#ifdef CONFIG_PMAC_BACKLIGHT
-               if (pmac_backlight == info->bl_dev)
-                       pmac_backlight = NULL;
-#endif
-
-               backlight_device_unregister(info->bl_dev);
-
-               printk("aty: Backlight unloaded\n");
-       }
-       mutex_unlock(&info->bl_mutex);
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-       mutex_unlock(&pmac_backlight_mutex);
-#endif
+static void aty_bl_exit(struct backlight_device *bd)
+{
+       backlight_device_unregister(bd);
+       printk("aty: Backlight unloaded\n");
 }
 
 #endif /* CONFIG_FB_ATY_BACKLIGHT */
@@ -2347,52 +2249,22 @@ static int __devinit atyfb_get_timings_f
 }
 #endif /* defined(__i386__) && defined(CONFIG_FB_ATY_GENERIC_LCD) */
 
-static int __devinit aty_init(struct fb_info *info, const char *name)
+static int __devinit aty_init(struct fb_info *info)
 {
        struct atyfb_par *par = (struct atyfb_par *) info->par;
        const char *ramname = NULL, *xtal;
        int gtb_memsize, has_var = 0;
        struct fb_var_screeninfo var;
-       u8 pll_ref_div;
-       u32 i;
-#if defined(CONFIG_PPC)
-       int sense;
-#endif
+       int ret;
 
        init_waitqueue_head(&par->vblank.wait);
        spin_lock_init(&par->int_lock);
-
-       par->aty_cmap_regs =
-           (struct aty_cmap_regs __iomem *) (par->ati_regbase + 0xc0);
-
-#ifdef CONFIG_PPC_PMAC
-       /* The Apple iBook1 uses non-standard memory frequencies. We detect it
-        * and set the frequency manually. */
-       if (machine_is_compatible("PowerBook2,1")) {
-               par->pll_limits.mclk = 70;
-               par->pll_limits.xclk = 53;
-       }
-#endif
-       if (pll)
-               par->pll_limits.pll_max = pll;
-       if (mclk)
-               par->pll_limits.mclk = mclk;
-       if (xclk)
-               par->pll_limits.xclk = xclk;
-
-       aty_calc_mem_refresh(par, par->pll_limits.xclk);
-       par->pll_per = 1000000/par->pll_limits.pll_max;
-       par->mclk_per = 1000000/par->pll_limits.mclk;
-       par->xclk_per = 1000000/par->pll_limits.xclk;
-
-       par->ref_clk_per = 1000000000000ULL / 14318180;
-       xtal = "14.31818";
 
 #ifdef CONFIG_FB_ATY_GX
        if (!M64_HAS(INTEGRATED)) {
                u32 stat0;
                u8 dac_type, dac_subtype, clk_type;
-               stat0 = aty_ld_le32(CONFIG_STAT0, par);
+               stat0 = aty_ld_le32(CNFG_STAT0, par);
                par->bus_type = (stat0 >> 0) & 0x07;
                par->ram_type = (stat0 >> 3) & 0x07;
                ramname = aty_gx_ram[par->ram_type];
@@ -2414,6 +2286,7 @@ static int __devinit aty_init(struct fb_
                case DAC_IBMRGB514:
                        par->dac_ops = &aty_dac_ibm514;
                        break;
+#ifdef CONFIG_ATARI
                case DAC_ATI68860_B:
                case DAC_ATI68860_C:
                        par->dac_ops = &aty_dac_ati68860b;
@@ -2422,6 +2295,7 @@ static int __devinit aty_init(struct fb_
                case DAC_ATT21C498:
                        par->dac_ops = &aty_dac_att21c498;
                        break;
+#endif
                default:
                        PRINTKI("aty_init: DAC type not implemented yet!\n");
                        par->dac_ops = &aty_dac_unsupported;
@@ -2460,25 +2334,57 @@ static int __devinit aty_init(struct fb_
                par->dac_ops = &aty_dac_ct;
                par->pll_ops = &aty_pll_ct;
                par->bus_type = PCI;
-               par->ram_type = (aty_ld_le32(CONFIG_STAT0, par) & 0x07);
+               par->ram_type = (aty_ld_le32(CNFG_STAT0, par) & 0x07);
                ramname = aty_ct_ram[par->ram_type];
                /* for many chips, the mclk is 67 MHz for SDRAM, 63 MHz 
otherwise */
                if (par->pll_limits.mclk == 67 && par->ram_type < SDRAM)
                        par->pll_limits.mclk = 63;
-       }
-
-       if (M64_HAS(GTB_DSP)
-           && (pll_ref_div = aty_ld_pll_ct(PLL_REF_DIV, par))) {
-               int diff1, diff2;
-               diff1 = 510 * 14 / pll_ref_div - par->pll_limits.pll_max;
-               diff2 = 510 * 29 / pll_ref_div - par->pll_limits.pll_max;
-               if (diff1 < 0)
-                       diff1 = -diff1;
-               if (diff2 < 0)
-                       diff2 = -diff2;
-               if (diff2 < diff1) {
-                       par->ref_clk_per = 1000000000000ULL / 29498928;
-                       xtal = "29.498928";
+               /* Mobility + 32bit memory interface need halved XCLK. */
+               if (M64_HAS(MOBIL_BUS) && par->ram_type == SDRAM32)
+                       par->pll_limits.xclk = (par->pll_limits.xclk + 1) >> 1;
+       }
+#endif
+#ifdef CONFIG_PPC_PMAC
+       /* The Apple iBook1 uses non-standard memory frequencies. We detect it
+        * and set the frequency manually. */
+       if (machine_is_compatible("PowerBook2,1")) {
+               par->pll_limits.mclk = 70;
+               par->pll_limits.xclk = 53;
+       }
+#endif
+
+       /* Allow command line to override clocks. */
+       if (pll)
+               par->pll_limits.pll_max = pll;
+       if (mclk)
+               par->pll_limits.mclk = mclk;
+       if (xclk)
+               par->pll_limits.xclk = xclk;
+
+       aty_calc_mem_refresh(par, par->pll_limits.xclk);
+       par->pll_per = 1000000/par->pll_limits.pll_max;
+       par->mclk_per = 1000000/par->pll_limits.mclk;
+       par->xclk_per = 1000000/par->pll_limits.xclk;
+
+       par->ref_clk_per = 1000000000000ULL / 14318180;
+       xtal = "14.31818";
+
+#ifdef CONFIG_FB_ATY_CT
+       if (M64_HAS(GTB_DSP)) {
+               u8 pll_ref_div = aty_ld_pll_ct(PLL_REF_DIV, par);
+
+               if (pll_ref_div) {
+                       int diff1, diff2;
+                       diff1 = 510 * 14 / pll_ref_div - 
par->pll_limits.pll_max;
+                       diff2 = 510 * 29 / pll_ref_div - 
par->pll_limits.pll_max;
+                       if (diff1 < 0)
+                               diff1 = -diff1;
+                       if (diff2 < 0)
+                               diff2 = -diff2;
+                       if (diff2 < diff1) {
+                               par->ref_clk_per = 1000000000000ULL / 29498928;
+                               xtal = "29.498928";
+                       }
                }
        }
 #endif /* CONFIG_FB_ATY_CT */
@@ -2488,10 +2394,10 @@ static int __devinit aty_init(struct fb_
        if(par->pll_ops->get_pll)
                par->pll_ops->get_pll(info, &saved_pll);
 
-       i = aty_ld_le32(MEM_CNTL, par);
+       par->mem_cntl = aty_ld_le32(MEM_CNTL, par);
        gtb_memsize = M64_HAS(GTB_DSP);
        if (gtb_memsize)
-               switch (i & 0xF) {      /* 0xF used instead of MEM_SIZE_ALIAS */
+               switch (par->mem_cntl & 0xF) {  /* 0xF used instead of 
MEM_SIZE_ALIAS */
                case MEM_SIZE_512K:
                        info->fix.smem_len = 0x80000;
                        break;
@@ -2513,7 +2419,7 @@ static int __devinit aty_init(struct fb_
                default:
                        info->fix.smem_len = 0x80000;
        } else
-               switch (i & MEM_SIZE_ALIAS) {
+               switch (par->mem_cntl & MEM_SIZE_ALIAS) {
                case MEM_SIZE_512K:
                        info->fix.smem_len = 0x80000;
                        break;
@@ -2537,26 +2443,26 @@ static int __devinit aty_init(struct fb_
                }
 
        if (M64_HAS(MAGIC_VRAM_SIZE)) {
-               if (aty_ld_le32(CONFIG_STAT1, par) & 0x40000000)
+               if (aty_ld_le32(CNFG_STAT1, par) & 0x40000000)
                        info->fix.smem_len += 0x400000;
        }
 
        if (vram) {
                info->fix.smem_len = vram * 1024;
-               i = i & ~(gtb_memsize ? 0xF : MEM_SIZE_ALIAS);
+               par->mem_cntl &= ~(gtb_memsize ? 0xF : MEM_SIZE_ALIAS);
                if (info->fix.smem_len <= 0x80000)
-                       i |= MEM_SIZE_512K;
+                       par->mem_cntl |= MEM_SIZE_512K;
                else if (info->fix.smem_len <= 0x100000)
-                       i |= MEM_SIZE_1M;
+                       par->mem_cntl |= MEM_SIZE_1M;
                else if (info->fix.smem_len <= 0x200000)
-                       i |= gtb_memsize ? MEM_SIZE_2M_GTB : MEM_SIZE_2M;
+                       par->mem_cntl |= gtb_memsize ? MEM_SIZE_2M_GTB : 
MEM_SIZE_2M;
                else if (info->fix.smem_len <= 0x400000)
-                       i |= gtb_memsize ? MEM_SIZE_4M_GTB : MEM_SIZE_4M;
+                       par->mem_cntl |= gtb_memsize ? MEM_SIZE_4M_GTB : 
MEM_SIZE_4M;
                else if (info->fix.smem_len <= 0x600000)
-                       i |= gtb_memsize ? MEM_SIZE_6M_GTB : MEM_SIZE_6M;
+                       par->mem_cntl |= gtb_memsize ? MEM_SIZE_6M_GTB : 
MEM_SIZE_6M;
                else
-                       i |= gtb_memsize ? MEM_SIZE_8M_GTB : MEM_SIZE_8M;
-               aty_st_le32(MEM_CNTL, i, par);
+                       par->mem_cntl |= gtb_memsize ? MEM_SIZE_8M_GTB : 
MEM_SIZE_8M;
+               aty_st_le32(MEM_CNTL, par->mem_cntl, par);
        }
 
        /*
@@ -2584,7 +2490,7 @@ static int __devinit aty_init(struct fb_
               info->fix.smem_len == 0x80000 ? 'K' : 'M', ramname, xtal, 
par->pll_limits.pll_max,
               par->pll_limits.mclk, par->pll_limits.xclk);
 
-#if defined(DEBUG) && defined(CONFIG_ATY_CT)
+#if defined(DEBUG) && defined(CONFIG_FB_ATY_CT)
        if (M64_HAS(INTEGRATED)) {
                int i;
                printk("debug atyfb: BUS_CNTL DAC_CNTL MEM_CNTL EXT_MEM_CNTL 
CRTC_GEN_CNTL "
@@ -2602,11 +2508,12 @@ static int __devinit aty_init(struct fb_
 #endif
        if(par->pll_ops->init_pll)
                par->pll_ops->init_pll(info, &par->pll);
+       if (par->pll_ops->resume_pll)
+               par->pll_ops->resume_pll(info, &par->pll);
 
        /*
-        *  Last page of 8 MB (4 MB on ISA) aperture is MMIO
-        *  FIXME: we should use the auxiliary aperture instead so we can access
-        *  the full 8 MB of video RAM on 8 MB boards
+        *  Last page of 8 MB (4 MB on ISA) aperture is MMIO,
+        *  unless the auxiliary register aperture is used.
         */
 
        if (!par->aux_start &&
@@ -2640,7 +2547,7 @@ static int __devinit aty_init(struct fb_
 #endif
 
        info->fbops = &atyfb_ops;
-       info->pseudo_palette = pseudo_palette;
+       info->pseudo_palette = par->pseudo_palette;
        info->flags = FBINFO_DEFAULT           |
                      FBINFO_HWACCEL_IMAGEBLIT |
                      FBINFO_HWACCEL_FILLRECT  |
@@ -2654,7 +2561,7 @@ static int __devinit aty_init(struct fb_
                           | (USE_F32KHZ | TRISTATE_MEM_EN), par);
        } else
 #endif
-       if (M64_HAS(MOBIL_BUS)) {
+       if (M64_HAS(MOBIL_BUS) && backlight) {
 #ifdef CONFIG_FB_ATY_BACKLIGHT
                aty_bl_init (par);
 #endif
@@ -2672,6 +2579,7 @@ static int __devinit aty_init(struct fb_
                                has_var = 1;
                } else {
                        if (default_vmode == VMODE_CHOOSE) {
+                               int sense;
                                if (M64_HAS(G3_PB_1024x768))
                                        /* G3 PowerBook with 1024x768 LCD */
                                        default_vmode = VMODE_1024_768_60;
@@ -2729,14 +2637,11 @@ static int __devinit aty_init(struct fb_
                        var.yres_virtual = var.yres;
        }
 
-       if (atyfb_check_var(&var, info)) {
+       ret = atyfb_check_var(&var, info);
+       if (ret) {
                PRINTKE("can't set default video mode\n");
                goto aty_init_exit;
        }
-
-#ifdef __sparc__
-       atyfb_save_palette(par, 0);
-#endif
 
 #ifdef CONFIG_FB_ATY_CT
        if (!noaccel && M64_HAS(INTEGRATED))
@@ -2744,15 +2649,20 @@ static int __devinit aty_init(struct fb_
 #endif /* CONFIG_FB_ATY_CT */
        info->var = var;
 
-       fb_alloc_cmap(&info->cmap, 256, 0);
-
-       if (register_framebuffer(info) < 0)
+       ret = fb_alloc_cmap(&info->cmap, 256, 0);
+       if (ret < 0)
                goto aty_init_exit;
 
+       ret = register_framebuffer(info);
+       if (ret < 0) {
+               fb_dealloc_cmap(&info->cmap);
+               goto aty_init_exit;
+       }
+
        fb_list = info;
 
        PRINTKI("fb%d: %s frame buffer device on %s\n",
-              info->node, info->fix.id, name);
+               info->node, info->fix.id, par->bus_type == ISA ? "ISA" : "PCI");
        return 0;
 
 aty_init_exit:
@@ -2770,7 +2680,7 @@ aty_init_exit:
            par->mtrr_aper = -1;
        }
 #endif
-       return -1;
+       return ret;
 }
 
 #ifdef CONFIG_ATARI
@@ -2816,10 +2726,7 @@ static int atyfb_blank(int blank, struct
        if (par->lock_blank || par->asleep)
                return 0;
 
-#ifdef CONFIG_FB_ATY_BACKLIGHT
-       if (machine_is(powermac) && blank > FB_BLANK_NORMAL)
-               aty_bl_set_power(info, FB_BLANK_POWERDOWN);
-#elif defined(CONFIG_FB_ATY_GENERIC_LCD)
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
        if (par->lcd_table && blank > FB_BLANK_NORMAL &&
            (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) {
                u32 pm = aty_ld_lcd(POWER_MANAGEMENT, par);
@@ -2829,9 +2736,9 @@ static int atyfb_blank(int blank, struct
 #endif
 
        gen_cntl = aty_ld_le32(CRTC_GEN_CNTL, par);
+       gen_cntl &= ~0x400004c;
        switch (blank) {
-               case FB_BLANK_UNBLANK:
-                       gen_cntl &= ~0x400004c;
+               case FB_BLANK_UNBLANK:
                        break;
                case FB_BLANK_NORMAL:
                        gen_cntl |= 0x4000040;
@@ -2848,10 +2755,7 @@ static int atyfb_blank(int blank, struct
        }
        aty_st_le32(CRTC_GEN_CNTL, gen_cntl, par);
 
-#ifdef CONFIG_FB_ATY_BACKLIGHT
-       if (machine_is(powermac) && blank <= FB_BLANK_NORMAL)
-               aty_bl_set_power(info, FB_BLANK_UNBLANK);
-#elif defined(CONFIG_FB_ATY_GENERIC_LCD)
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
        if (par->lcd_table && blank <= FB_BLANK_NORMAL &&
            (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) {
                u32 pm = aty_ld_lcd(POWER_MANAGEMENT, par);
@@ -2866,17 +2770,10 @@ static void aty_st_pal(u_int regno, u_in
 static void aty_st_pal(u_int regno, u_int red, u_int green, u_int blue,
                       const struct atyfb_par *par)
 {
-#ifdef CONFIG_ATARI
-       out_8(&par->aty_cmap_regs->windex, regno);
-       out_8(&par->aty_cmap_regs->lut, red);
-       out_8(&par->aty_cmap_regs->lut, green);
-       out_8(&par->aty_cmap_regs->lut, blue);
-#else
-       writeb(regno, &par->aty_cmap_regs->windex);
-       writeb(red, &par->aty_cmap_regs->lut);
-       writeb(green, &par->aty_cmap_regs->lut);
-       writeb(blue, &par->aty_cmap_regs->lut);
-#endif
+       aty_st_8(DAC_W_INDEX, regno, par);
+       aty_st_8(DAC_DATA, red, par);
+       aty_st_8(DAC_DATA, green, par);
+       aty_st_8(DAC_DATA, blue, par);
 }
 
     /*
@@ -2962,22 +2859,14 @@ static int atyfb_setcolreg(u_int regno, 
 
 #ifdef __sparc__
 
-extern void (*prom_palette) (int);
-
 static int __devinit atyfb_setup_sparc(struct pci_dev *pdev,
                        struct fb_info *info, unsigned long addr)
 {
-       extern int con_is_present(void);
-
        struct atyfb_par *par = info->par;
-       struct pcidev_cookie *pcp;
+       struct device_node *dp;
        char prop[128];
        int node, len, i, j, ret;
        u32 mem, chip_id;
-
-       /* Do not attach when we have a serial console. */
-       if (!con_is_present())
-               return -ENXIO;
 
        /*
         * Map memory-mapped registers.
@@ -2999,12 +2888,11 @@ static int __devinit atyfb_setup_sparc(s
                /* nothing */ ;
        j = i + 4;
 
-       par->mmap_map = kmalloc(j * sizeof(*par->mmap_map), GFP_ATOMIC);
+       par->mmap_map = kcalloc(j, sizeof(*par->mmap_map), GFP_ATOMIC);
        if (!par->mmap_map) {
                PRINTKE("atyfb_setup_sparc() can't alloc mmap_map\n");
                return -ENOMEM;
        }
-       memset(par->mmap_map, 0, j * sizeof(*par->mmap_map));
 
        for (i = 0, j = 2; i < 6 && pdev->resource[i].start; i++) {
                struct resource *rp = &pdev->resource[i];
@@ -3068,7 +2956,7 @@ static int __devinit atyfb_setup_sparc(s
                 * Fix PROMs idea of MEM_CNTL settings...
                 */
                mem = aty_ld_le32(MEM_CNTL, par);
-               chip_id = aty_ld_le32(CONFIG_CHIP_ID, par);
+               chip_id = aty_ld_le32(CNFG_CHIP_ID, par);
                if (((chip_id & CFG_CHIP_TYPE) == VT_CHIP_ID) && !((chip_id >> 
24) & 1)) {
                        switch (mem & 0x0f) {
                        case 3:
@@ -3086,7 +2974,7 @@ static int __devinit atyfb_setup_sparc(s
                        default:
                                break;
                        }
-                       if ((aty_ld_le32(CONFIG_STAT0, par) & 7) >= SDRAM)
+                       if ((aty_ld_le32(CNFG_STAT0, par) & 7) >= SDRAM)
                                mem &= ~(0x00700000);
                }
                mem &= ~(0xcf80e000);   /* Turn off all undocumented bits. */
@@ -3108,8 +2996,8 @@ static int __devinit atyfb_setup_sparc(s
                        node = 0;
        }
 
-       pcp = pdev->sysdata;
-       if (node == pcp->prom_node->node) {
+       dp = pci_device_to_OF_node(pdev);
+       if (node == dp->node) {
                struct fb_var_screeninfo *var = &default_var;
                unsigned int N, P, Q, M, T, R;
                u32 v_total, h_total;
@@ -3185,7 +3073,7 @@ static int __devinit atyfb_setup_sparc(s
 
 #ifdef __i386__
 #ifdef CONFIG_FB_ATY_GENERIC_LCD
-static void aty_init_lcd(struct atyfb_par *par, u32 bios_base)
+static void __devinit aty_init_lcd(struct atyfb_par *par, u32 bios_base)
 {
        u32 driv_inf_tab, sig;
        u16 lcd_ofs;
@@ -3458,7 +3346,7 @@ static int __devinit init_from_bios(stru
                PRINTKE("no BIOS frequency table found, use parameters\n");
                ret = -ENXIO;
        }
-       iounmap((void* __iomem )bios_base);
+       iounmap((void __iomem *)bios_base);
 
        return ret;
 }
@@ -3483,7 +3371,7 @@ static int __devinit atyfb_setup_generic
 
        info->fix.mmio_start = raddr;
        par->ati_regbase = ioremap(info->fix.mmio_start, 0x1000);
-       if (par->ati_regbase == 0)
+       if (par->ati_regbase == NULL)
                return -ENOMEM;
 
        info->fix.mmio_start += par->aux_start ? 0x400 : 0xc00;
@@ -3530,6 +3418,10 @@ atyfb_setup_generic_fail:
 atyfb_setup_generic_fail:
        iounmap(par->ati_regbase);
        par->ati_regbase = NULL;
+       if (info->screen_base) {
+               iounmap(info->screen_base);
+               info->screen_base = NULL;
+       }
        return ret;
 }
 
@@ -3541,14 +3433,7 @@ static int __devinit atyfb_pci_probe(str
        struct fb_info *info;
        struct resource *rp;
        struct atyfb_par *par;
-       int i, rc = -ENOMEM;
-
-       for (i = ARRAY_SIZE(aty_chips) - 1; i >= 0; i--)
-               if (pdev->device == aty_chips[i].pci_id)
-                       break;
-
-       if (i < 0)
-               return -ENODEV;
+       int rc = -ENOMEM;
 
        /* Enable device in PCI config */
        if (pci_enable_device(pdev)) {
@@ -3579,7 +3464,7 @@ static int __devinit atyfb_pci_probe(str
        par = info->par;
        info->fix = atyfb_fix;
        info->device = &pdev->dev;
-       par->pci_id = aty_chips[i].pci_id;
+       par->pci_id = pdev->device;
        par->res_start = res_start;
        par->res_size = res_size;
        par->irq = pdev->irq;
@@ -3597,13 +3482,11 @@ static int __devinit atyfb_pci_probe(str
        pci_set_drvdata(pdev, info);
 
        /* Init chip & register framebuffer */
-       if (aty_init(info, "PCI"))
+       rc = aty_init(info);
+       if (rc)
                goto err_release_io;
 
 #ifdef __sparc__
-       if (!prom_palette)
-               prom_palette = atyfb_palette;
-
        /*
         * Add /dev/fb mmap values.
         */
@@ -3644,12 +3527,13 @@ err_release_mem:
 
 #ifdef CONFIG_ATARI
 
-static int __devinit atyfb_atari_probe(void)
+static int __init atyfb_atari_probe(void)
 {
        struct atyfb_par *par;
        struct fb_info *info;
        int m64_num;
        u32 clock_r;
+       int num_found = 0;
 
        for (m64_num = 0; m64_num < mach64_count; m64_num++) {
                if (!phys_vmembase[m64_num] || !phys_size[m64_num] ||
@@ -3697,15 +3581,33 @@ static int __devinit atyfb_atari_probe(v
                        break;
                }
 
-               if (aty_init(info, "ISA bus")) {
+               /* Fake pci_id for correct_chipset() */
+               switch (aty_ld_le32(CNFG_CHIP_ID, par) & CFG_CHIP_TYPE) {
+               case 0x00d7:
+                       par->pci_id = PCI_CHIP_MACH64GX;
+                       break;
+               case 0x0057:
+                       par->pci_id = PCI_CHIP_MACH64CX;
+                       break;
+               default:
+                       break;
+               }
+
+               if (correct_chipset(par) || aty_init(info)) {
+                       iounmap(info->screen_base);
+                       iounmap(par->ati_regbase);
                        framebuffer_release(info);
-                       /* This is insufficient! kernel_map has added two large 
chunks!! */
-                       return -ENXIO;
-               }
-       }
+               } else {
+                       num_found++;
+               }
+       }
+
+       return num_found ? 0 : -ENXIO;
 }
 
 #endif /* CONFIG_ATARI */
+
+#ifdef CONFIG_PCI
 
 static void __devexit atyfb_remove(struct fb_info *info)
 {
@@ -3715,12 +3617,12 @@ static void __devexit atyfb_remove(struc
        aty_set_crtc(par, &saved_crtc);
        par->pll_ops->set_pll(info, &saved_pll);
 
+       unregister_framebuffer(info);
+
 #ifdef CONFIG_FB_ATY_BACKLIGHT
        if (M64_HAS(MOBIL_BUS))
-               aty_bl_exit(par);
-#endif
-
-       unregister_framebuffer(info);
+               aty_bl_exit(info->bl_dev);
+#endif
 
 #ifdef CONFIG_MTRR
        if (par->mtrr_reg >= 0) {
@@ -3754,7 +3656,6 @@ static void __devexit atyfb_remove(struc
        framebuffer_release(info);
 }
 
-#ifdef CONFIG_PCI
 
 static void __devexit atyfb_pci_remove(struct pci_dev *pdev)
 {
@@ -3763,17 +3664,61 @@ static void __devexit atyfb_pci_remove(s
        atyfb_remove(info);
 }
 
-/*
- * This driver uses its own matching table. That will be more difficult
- * to fix, so for now, we just match against any ATI ID and let the
- * probe() function find out what's up. That also mean we don't have
- * a module ID table though.
- */
 static struct pci_device_id atyfb_pci_tbl[] = {
-       { PCI_VENDOR_ID_ATI, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-         PCI_BASE_CLASS_DISPLAY << 16, 0xff0000, 0 },
-       { 0, }
+#ifdef CONFIG_FB_ATY_GX
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GX) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64CX) },
+#endif /* CONFIG_FB_ATY_GX */
+
+#ifdef CONFIG_FB_ATY_CT
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64CT) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64ET) },
+
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LT) },
+
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64VT) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GT) },
+
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64VU) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GU) },
+
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LG) },
+
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64VV) },
+
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GV) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GW) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GY) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GZ) },
+
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GB) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GD) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GI) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GP) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GQ) },
+
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LB) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LD) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LI) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LP) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LQ) },
+
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GM) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GN) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GO) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GL) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GR) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GS) },
+
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LM) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LN) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LR) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LS) },
+#endif /* CONFIG_FB_ATY_CT */
+       { }
 };
+
+MODULE_DEVICE_TABLE(pci, atyfb_pci_tbl);
 
 static struct pci_driver atyfb_driver = {
        .name           = "atyfb",
@@ -3789,7 +3734,7 @@ static struct pci_driver atyfb_driver = 
 #endif /* CONFIG_PCI */
 
 #ifndef MODULE
-static int __devinit atyfb_setup(char *options)
+static int __init atyfb_setup(char *options)
 {
        char *this_opt;
 
@@ -3813,6 +3758,8 @@ static int __devinit atyfb_setup(char *o
                        xclk = simple_strtoul(this_opt+5, NULL, 0);
                else if (!strncmp(this_opt, "comp_sync:", 10))
                        comp_sync = simple_strtoul(this_opt+10, NULL, 0);
+               else if (!strncmp(this_opt, "backlight:", 10))
+                       backlight = simple_strtoul(this_opt+10, NULL, 0);
 #ifdef CONFIG_PPC
                else if (!strncmp(this_opt, "vmode:", 6)) {
                        unsigned int vmode =
@@ -3861,8 +3808,9 @@ static int __devinit atyfb_setup(char *o
 }
 #endif  /*  MODULE  */
 
-static int __devinit atyfb_init(void)
-{
+static int __init atyfb_init(void)
+{
+    int err1 = 1, err2 = 1;
 #ifndef MODULE
     char *option = NULL;
 
@@ -3872,12 +3820,13 @@ static int __devinit atyfb_init(void)
 #endif
 
 #ifdef CONFIG_PCI
-    pci_register_driver(&atyfb_driver);
+    err1 = pci_register_driver(&atyfb_driver);
 #endif
 #ifdef CONFIG_ATARI
-    atyfb_atari_probe();
-#endif
-    return 0;
+    err2 = atyfb_atari_probe();
+#endif
+
+    return (err1 && err2) ? -ENODEV : 0;
 }
 
 static void __exit atyfb_exit(void)
diff -r 1db1bb63824b -r 0659978a1911 drivers/video/aty/mach64_accel.c
--- a/drivers/video/aty/mach64_accel.c  Mon Nov 23 07:32:47 2009 +0000
+++ b/drivers/video/aty/mach64_accel.c  Mon Nov 23 23:17:38 2009 +0100
@@ -3,7 +3,6 @@
  *  ATI Mach64 Hardware Acceleration
  */
 
-#include <linux/sched.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <video/mach64.h>
diff -r 1db1bb63824b -r 0659978a1911 drivers/video/aty/mach64_ct.c
--- a/drivers/video/aty/mach64_ct.c     Mon Nov 23 07:32:47 2009 +0000
+++ b/drivers/video/aty/mach64_ct.c     Mon Nov 23 23:17:38 2009 +0100
@@ -8,6 +8,9 @@
 #include <asm/io.h>
 #include <video/mach64.h>
 #include "atyfb.h"
+#ifdef CONFIG_PPC
+#include <asm/machdep.h>
+#endif
 
 #undef DEBUG
 
@@ -27,7 +30,7 @@ u8 aty_ld_pll_ct(int offset, const struc
        return res;
 }
 
-void aty_st_pll_ct(int offset, u8 val, const struct atyfb_par *par)
+static void aty_st_pll_ct(int offset, u8 val, const struct atyfb_par *par)
 {
        /* write addr byte */
        aty_st_8(CLOCK_CNTL_ADDR, ((offset << 2) & PLL_ADDR) | PLL_WR_EN, par);
@@ -197,7 +200,7 @@ static int aty_dsp_gt(const struct fb_in
        pll->dsp_config = (dsp_precision << 20) | (pll->dsp_loop_latency << 16) 
| dsp_xclks;
 #ifdef DEBUG
        printk("atyfb(%s): dsp_config 0x%08x, dsp_on_off 0x%08x\n",
-               __FUNCTION__, pll->dsp_config, pll->dsp_on_off);
+               __func__, pll->dsp_config, pll->dsp_on_off);
 #endif
        return 0;
 }
@@ -225,7 +228,7 @@ static int aty_valid_pll_ct(const struct
                (par->ref_clk_per * pll->pll_ref_div);
 #ifdef DEBUG
        printk("atyfb(%s): pllvclk=%d MHz, vclk=%d MHz\n",
-               __FUNCTION__, pllvclk, pllvclk / pll->vclk_post_div_real);
+               __func__, pllvclk, pllvclk / pll->vclk_post_div_real);
 #endif
        pll->pll_vclk_cntl = 0x03; /* VCLK = PLL_VCLK/VCLKx_POST */
 
@@ -269,7 +272,7 @@ static u32 aty_pll_to_var_ct(const struc
        }
 #endif
 #ifdef DEBUG
-       printk("atyfb(%s): calculated 0x%08X(%i)\n", __FUNCTION__, ret, ret);
+       printk("atyfb(%s): calculated 0x%08X(%i)\n", __func__, ret, ret);
 #endif
        return ret;
 }
@@ -284,11 +287,11 @@ void aty_set_pll_ct(const struct fb_info
 #ifdef DEBUG
        printk("atyfb(%s): about to program:\n"
                "pll_ext_cntl=0x%02x pll_gen_cntl=0x%02x 
pll_vclk_cntl=0x%02x\n",
-               __FUNCTION__,
+               __func__,
                pll->ct.pll_ext_cntl, pll->ct.pll_gen_cntl, 
pll->ct.pll_vclk_cntl);
 
        printk("atyfb(%s): setting clock %lu for FeedBackDivider %i, 
ReferenceDivider %i, PostDivider %i(%i)\n",
-               __FUNCTION__,
+               __func__,
                par->clk_wr_offset, pll->ct.vclk_fb_div,
                pll->ct.pll_ref_div, pll->ct.vclk_post_div, 
pll->ct.vclk_post_div_real);
 #endif
@@ -370,8 +373,8 @@ void aty_set_pll_ct(const struct fb_info
 #endif
 }
 
-static void __init aty_get_pll_ct(const struct fb_info *info,
-                                 union aty_pll *pll)
+static void __devinit aty_get_pll_ct(const struct fb_info *info,
+                                    union aty_pll *pll)
 {
        struct atyfb_par *par = (struct atyfb_par *) info->par;
        u8 tmp, clock;
@@ -394,12 +397,12 @@ static void __init aty_get_pll_ct(const 
        }
 }
 
-static int __init aty_init_pll_ct(const struct fb_info *info,
-                                union aty_pll *pll)
+static int __devinit aty_init_pll_ct(const struct fb_info *info,
+                                    union aty_pll *pll)
 {
        struct atyfb_par *par = (struct atyfb_par *) info->par;
-       u8 mpost_div, xpost_div, sclk_post_div_real, sclk_fb_div, spll_cntl2;
-       u32 q, i, memcntl, trp;
+       u8 mpost_div, xpost_div, sclk_post_div_real;
+       u32 q, memcntl, trp;
        u32 dsp_config, dsp_on_off, vga_dsp_config, vga_dsp_on_off;
 #ifdef DEBUG
        int pllmclk, pllsclk;
@@ -428,7 +431,7 @@ static int __init aty_init_pll_ct(const 
 
 #ifdef DEBUG
        printk("atyfb(%s): mclk_fb_mult=%d, xclk_post_div=%d\n",
-               __FUNCTION__, pll->ct.mclk_fb_mult, pll->ct.xclk_post_div);
+               __func__, pll->ct.mclk_fb_mult, pll->ct.xclk_post_div);
 #endif
 
        memcntl = aty_ld_le32(MEM_CNTL, par);
@@ -536,11 +539,19 @@ static int __init aty_init_pll_ct(const 
        pll->ct.xclk_post_div_real = postdividers[xpost_div];
        pll->ct.mclk_fb_div = q * pll->ct.xclk_post_div_real / 8;
 
+#ifdef CONFIG_PPC
+       if (machine_is(powermac)) {
+               /* Override PLL_EXT_CNTL & 0x07. */
+               pll->ct.xclk_post_div = xpost_div;
+               pll->ct.xclk_ref_div = 1;
+       }
+#endif
+
 #ifdef DEBUG
        pllmclk = (1000000 * pll->ct.mclk_fb_mult * pll->ct.mclk_fb_div) /
                        (par->ref_clk_per * pll->ct.pll_ref_div);
        printk("atyfb(%s): pllmclk=%d MHz, xclk=%d MHz\n",
-               __FUNCTION__, pllmclk, pllmclk / pll->ct.xclk_post_div_real);
+               __func__, pllmclk, pllmclk / pll->ct.xclk_post_div_real);
 #endif
 
        if (M64_HAS(SDRAM_MAGIC_PLL) && (par->ram_type >= SDRAM))
@@ -575,14 +586,29 @@ static int __init aty_init_pll_ct(const 
                        mpost_div += (q <  32*8);
                }
                sclk_post_div_real = postdividers[mpost_div];
-               sclk_fb_div = q * sclk_post_div_real / 8;
-               spll_cntl2 = mpost_div << 4;
-#ifdef DEBUG
-               pllsclk = (1000000 * 2 * sclk_fb_div) /
+               pll->ct.sclk_fb_div = q * sclk_post_div_real / 8;
+               pll->ct.spll_cntl2 = mpost_div << 4;
+#ifdef DEBUG
+               pllsclk = (1000000 * 2 * pll->ct.sclk_fb_div) /
                        (par->ref_clk_per * pll->ct.pll_ref_div);
                printk("atyfb(%s): use sclk, pllsclk=%d MHz, sclk=mclk=%d 
MHz\n",
-                       __FUNCTION__, pllsclk, pllsclk / sclk_post_div_real);
-#endif
+                       __func__, pllsclk, pllsclk / sclk_post_div_real);
+#endif
+       }
+
+       /* Disable the extra precision pixel clock controls since we do not use 
them. */
+       pll->ct.ext_vpll_cntl = aty_ld_pll_ct(EXT_VPLL_CNTL, par);
+       pll->ct.ext_vpll_cntl &= ~(EXT_VPLL_EN | EXT_VPLL_VGA_EN | 
EXT_VPLL_INSYNC);
+
+       return 0;
+}
+
+static void aty_resume_pll_ct(const struct fb_info *info,
+                             union aty_pll *pll)
+{
+       struct atyfb_par *par = info->par;
+
+       if (par->mclk_per != par->xclk_per) {
                /*
                * This disables the sclk, crashes the computer as reported:
                * aty_st_pll_ct(SPLL_CNTL2, 3, info);
@@ -590,26 +616,20 @@ static int __init aty_init_pll_ct(const 
                * So it seems the sclk must be enabled before it is used;
                * so PLL_GEN_CNTL must be programmed *after* the sclk.
                */
-               aty_st_pll_ct(SCLK_FB_DIV, sclk_fb_div, par);
-               aty_st_pll_ct(SPLL_CNTL2, spll_cntl2, par);
+               aty_st_pll_ct(SCLK_FB_DIV, pll->ct.sclk_fb_div, par);
+               aty_st_pll_ct(SPLL_CNTL2, pll->ct.spll_cntl2, par);
                /*
-                * The sclk has been started. However, I believe the first clock
-                * ticks it generates are not very stable. Hope this primitive 
loop
-                * helps for Rage Mobilities that sometimes crash when
-                * we switch to sclk. (Daniel Mantione, 13-05-2003)
+                * SCLK has been started. Wait for the PLL to lock. 5 ms
+                * should be enough according to mach64 programmer's guide.
                 */
-               for (i=0;i<=0x1ffff;i++);
+               mdelay(5);
        }
 
        aty_st_pll_ct(PLL_REF_DIV, pll->ct.pll_ref_div, par);
        aty_st_pll_ct(PLL_GEN_CNTL, pll->ct.pll_gen_cntl, par);
        aty_st_pll_ct(MCLK_FB_DIV, pll->ct.mclk_fb_div, par);
        aty_st_pll_ct(PLL_EXT_CNTL, pll->ct.pll_ext_cntl, par);
-       /* Disable the extra precision pixel clock controls since we do not use 
them. */
-       aty_st_pll_ct(EXT_VPLL_CNTL, aty_ld_pll_ct(EXT_VPLL_CNTL, par) &
-               ~(EXT_VPLL_EN | EXT_VPLL_VGA_EN | EXT_VPLL_INSYNC), par);
-
-       return 0;
+       aty_st_pll_ct(EXT_VPLL_CNTL, pll->ct.ext_vpll_cntl, par);
 }
 
 static int dummy(void)
@@ -626,5 +646,6 @@ const struct aty_pll_ops aty_pll_ct = {
        .pll_to_var     = aty_pll_to_var_ct,
        .set_pll        = aty_set_pll_ct,
        .get_pll        = aty_get_pll_ct,
-       .init_pll       = aty_init_pll_ct
+       .init_pll       = aty_init_pll_ct,
+       .resume_pll     = aty_resume_pll_ct,
 };
diff -r 1db1bb63824b -r 0659978a1911 drivers/video/aty/mach64_cursor.c
--- a/drivers/video/aty/mach64_cursor.c Mon Nov 23 07:32:47 2009 +0000
+++ b/drivers/video/aty/mach64_cursor.c Mon Nov 23 23:17:38 2009 +0100
@@ -8,10 +8,8 @@
 #include <linux/string.h>
 
 #include <asm/io.h>
-#include <asm/uaccess.h>
-
-#ifdef __sparc__
-#include <asm/pbm.h>
+
+#ifdef __sparc__
 #include <asm/fbio.h>
 #endif
 
diff -r 1db1bb63824b -r 0659978a1911 drivers/video/aty/mach64_gx.c
--- a/drivers/video/aty/mach64_gx.c     Mon Nov 23 07:32:47 2009 +0000
+++ b/drivers/video/aty/mach64_gx.c     Mon Nov 23 23:17:38 2009 +0100
@@ -5,7 +5,6 @@
 
 #include <linux/delay.h>
 #include <linux/fb.h>
-#include <linux/sched.h>
 
 #include <asm/io.h>
 
diff -r 1db1bb63824b -r 0659978a1911 drivers/video/aty/radeon_accel.c
--- a/drivers/video/aty/radeon_accel.c  Mon Nov 23 07:32:47 2009 +0000
+++ b/drivers/video/aty/radeon_accel.c  Mon Nov 23 23:17:38 2009 +0100
@@ -55,6 +55,10 @@ static void radeonfb_prim_fillrect(struc
        OUTREG(DP_WRITE_MSK, 0xffffffff);
        OUTREG(DP_CNTL, (DST_X_LEFT_TO_RIGHT | DST_Y_TOP_TO_BOTTOM));
 
+       radeon_fifo_wait(2);
+       OUTREG(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL);
+       OUTREG(WAIT_UNTIL, (WAIT_2D_IDLECLEAN | WAIT_DMA_GUI_IDLE));
+
        radeon_fifo_wait(2);  
        OUTREG(DST_Y_X, (region->dy << 16) | region->dx);
        OUTREG(DST_WIDTH_HEIGHT, (region->width << 16) | region->height);
@@ -116,6 +120,10 @@ static void radeonfb_prim_copyarea(struc
        OUTREG(DP_CNTL, (xdir>=0 ? DST_X_LEFT_TO_RIGHT : 0)
                        | (ydir>=0 ? DST_Y_TOP_TO_BOTTOM : 0));
 
+       radeon_fifo_wait(2);
+       OUTREG(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL);
+       OUTREG(WAIT_UNTIL, (WAIT_2D_IDLECLEAN | WAIT_DMA_GUI_IDLE));
+
        radeon_fifo_wait(3);
        OUTREG(SRC_Y_X, (sy << 16) | sx);
        OUTREG(DST_Y_X, (dy << 16) | dx);
@@ -203,9 +211,7 @@ void radeonfb_engine_reset(struct radeon
        host_path_cntl = INREG(HOST_PATH_CNTL);
        rbbm_soft_reset = INREG(RBBM_SOFT_RESET);
 
-       if (rinfo->family == CHIP_FAMILY_R300 ||
-           rinfo->family == CHIP_FAMILY_R350 ||
-           rinfo->family == CHIP_FAMILY_RV350) {
+       if (IS_R300_VARIANT(rinfo)) {
                u32 tmp;
 
                OUTREG(RBBM_SOFT_RESET, (rbbm_soft_reset |
@@ -241,9 +247,7 @@ void radeonfb_engine_reset(struct radeon
        INREG(HOST_PATH_CNTL);
        OUTREG(HOST_PATH_CNTL, host_path_cntl);
 
-       if (rinfo->family != CHIP_FAMILY_R300 ||
-           rinfo->family != CHIP_FAMILY_R350 ||
-           rinfo->family != CHIP_FAMILY_RV350)
+       if (!IS_R300_VARIANT(rinfo))
                OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset);
 
        OUTREG(CLOCK_CNTL_INDEX, clock_cntl_index);
@@ -260,10 +264,18 @@ void radeonfb_engine_init (struct radeon
        radeonfb_engine_reset(rinfo);
 
        radeon_fifo_wait (1);
-       if ((rinfo->family != CHIP_FAMILY_R300) &&
-           (rinfo->family != CHIP_FAMILY_R350) &&
-           (rinfo->family != CHIP_FAMILY_RV350))
+       if (IS_R300_VARIANT(rinfo)) {
+               OUTREG(RB2D_DSTCACHE_MODE, INREG(RB2D_DSTCACHE_MODE) |
+                      RB2D_DC_AUTOFLUSH_ENABLE |
+                      RB2D_DC_DC_DISABLE_IGNORE_PE);
+       } else {
+               /* This needs to be double checked with ATI. Latest X driver
+                * completely "forgets" to set this register on < r3xx, and
+                * we used to just write 0 there... I'll keep the 0 and update
+                * that when we have sorted things out on X side.
+                */
                OUTREG(RB2D_DSTCACHE_MODE, 0);
+       }
 
        radeon_fifo_wait (3);
        /* We re-read MC_FB_LOCATION from card as it can have been
diff -r 1db1bb63824b -r 0659978a1911 drivers/video/aty/radeon_backlight.c
--- a/drivers/video/aty/radeon_backlight.c      Mon Nov 23 07:32:47 2009 +0000
+++ b/drivers/video/aty/radeon_backlight.c      Mon Nov 23 23:17:38 2009 +0100
@@ -19,8 +19,6 @@
 
 #define MAX_RADEON_LEVEL 0xFF
 
-static struct backlight_properties radeon_bl_data;
-
 struct radeon_bl_privdata {
        struct radeonfb_info *rinfo;
        uint8_t negative;
@@ -29,16 +27,12 @@ static int radeon_bl_get_level_brightnes
 static int radeon_bl_get_level_brightness(struct radeon_bl_privdata *pdata,
                int level)
 {
-       struct fb_info *info = pdata->rinfo->info;
        int rlevel;
 
-       mutex_lock(&info->bl_mutex);
-
        /* Get and convert the value */
+       /* No locking of bl_curve since we read a single value */
        rlevel = pdata->rinfo->info->bl_curve[level] *
                 FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL;
-
-       mutex_unlock(&info->bl_mutex);
 
        if (rlevel < 0)
                rlevel = 0;
@@ -53,7 +47,7 @@ static int radeon_bl_get_level_brightnes
 
 static int radeon_bl_update_status(struct backlight_device *bd)
 {
-       struct radeon_bl_privdata *pdata = class_get_devdata(&bd->class_dev);
+       struct radeon_bl_privdata *pdata = bl_get_data(bd);
        struct radeonfb_info *rinfo = pdata->rinfo;
        u32 lvds_gen_cntl, tmpPixclksCntl;
        int level;
@@ -65,11 +59,11 @@ static int radeon_bl_update_status(struc
         * backlight. This provides some greater power saving and the display
         * is useless without backlight anyway.
         */
-        if (bd->props->power != FB_BLANK_UNBLANK ||
-           bd->props->fb_blank != FB_BLANK_UNBLANK)
+        if (bd->props.power != FB_BLANK_UNBLANK ||
+           bd->props.fb_blank != FB_BLANK_UNBLANK)
                level = 0;
        else
-               level = bd->props->brightness;
+               level = bd->props.brightness;
 
        del_timer_sync(&rinfo->lvds_timer);
        radeon_engine_idle();
@@ -130,14 +124,12 @@ static int radeon_bl_update_status(struc
 
 static int radeon_bl_get_brightness(struct backlight_device *bd)
 {
-       return bd->props->brightness;
-}
-
-static struct backlight_properties radeon_bl_data = {
-       .owner          = THIS_MODULE,
+       return bd->props.brightness;
+}
+
+static struct backlight_ops radeon_bl_data = {
        .get_brightness = radeon_bl_get_brightness,
        .update_status  = radeon_bl_update_status,
-       .max_brightness = (FB_BACKLIGHT_LEVELS - 1),
 };
 
 void radeonfb_bl_init(struct radeonfb_info *rinfo)
@@ -163,7 +155,7 @@ void radeonfb_bl_init(struct radeonfb_in
 
        snprintf(name, sizeof(name), "radeonbl%d", rinfo->info->node);
 
-       bd = backlight_device_register(name, pdata, &radeon_bl_data);
+       bd = backlight_device_register(name, rinfo->info->dev, pdata, 
&radeon_bl_data);
        if (IS_ERR(bd)) {
                rinfo->info->bl_dev = NULL;
                printk("radeonfb: Backlight registration failed\n");
@@ -188,25 +180,15 @@ void radeonfb_bl_init(struct radeonfb_in
                machine_is_compatible("PowerBook6,5");
 #endif
 
-       mutex_lock(&rinfo->info->bl_mutex);
        rinfo->info->bl_dev = bd;
        fb_bl_default_curve(rinfo->info, 0,
                 63 * FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL,
                217 * FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL);
-       mutex_unlock(&rinfo->info->bl_mutex);
-
-       down(&bd->sem);
-       bd->props->brightness = radeon_bl_data.max_brightness;
-       bd->props->power = FB_BLANK_UNBLANK;
-       bd->props->update_status(bd);
-       up(&bd->sem);
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-       mutex_lock(&pmac_backlight_mutex);
-       if (!pmac_backlight)
-               pmac_backlight = bd;
-       mutex_unlock(&pmac_backlight_mutex);
-#endif
+
+       bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
+       bd->props.brightness = bd->props.max_brightness;
+       bd->props.power = FB_BLANK_UNBLANK;
+       backlight_update_status(bd);
 
        printk("radeonfb: Backlight initialized (%s)\n", name);
 
@@ -219,29 +201,16 @@ error:
 
 void radeonfb_bl_exit(struct radeonfb_info *rinfo)
 {
-#ifdef CONFIG_PMAC_BACKLIGHT
-       mutex_lock(&pmac_backlight_mutex);
-#endif
-
-       mutex_lock(&rinfo->info->bl_mutex);
-       if (rinfo->info->bl_dev) {
+       struct backlight_device *bd = rinfo->info->bl_dev;
+
+       if (bd) {
                struct radeon_bl_privdata *pdata;
 
-#ifdef CONFIG_PMAC_BACKLIGHT
-               if (pmac_backlight == rinfo->info->bl_dev)
-                       pmac_backlight = NULL;
-#endif
-
-               pdata = class_get_devdata(&rinfo->info->bl_dev->class_dev);
-               backlight_device_unregister(rinfo->info->bl_dev);
+               pdata = bl_get_data(bd);
+               backlight_device_unregister(bd);
                kfree(pdata);
                rinfo->info->bl_dev = NULL;
 
                printk("radeonfb: Backlight unloaded\n");
        }
-       mutex_unlock(&rinfo->info->bl_mutex);
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-       mutex_unlock(&pmac_backlight_mutex);
-#endif
-}
+}
diff -r 1db1bb63824b -r 0659978a1911 drivers/video/aty/radeon_base.c
--- a/drivers/video/aty/radeon_base.c   Mon Nov 23 07:32:47 2009 +0000
+++ b/drivers/video/aty/radeon_base.c   Mon Nov 23 23:17:38 2009 +0100
@@ -52,11 +52,14 @@
 
 #define RADEON_VERSION "0.2.0"
 
+#include "radeonfb.h"
+
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
+#include <linux/ctype.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
@@ -69,7 +72,7 @@
 #include <linux/device.h>
 
 #include <asm/io.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 #ifdef CONFIG_PPC_OF
 
@@ -91,7 +94,6 @@
 
 #include "../edid.h" // MOVE THAT TO include/video
 #include "ati_ids.h"
-#include "radeonfb.h"              
 
 #define MAX_MAPPED_VRAM        (2048*2048*4)
 #define MIN_MAPPED_VRAM        (1024*768*1)
@@ -100,6 +102,9 @@
        { PCI_VENDOR_ID_ATI, id, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (flags) | 
(CHIP_FAMILY_##family) }
 
 static struct pci_device_id radeonfb_pci_table[] = {
+        /* Radeon Xpress 200m */
+       CHIP_DEF(PCI_CHIP_RS480_5955,   RS480,  CHIP_HAS_CRTC2 | CHIP_IS_IGP | 
CHIP_IS_MOBILITY),
+       CHIP_DEF(PCI_CHIP_RS482_5975,   RS480,  CHIP_HAS_CRTC2 | CHIP_IS_IGP | 
CHIP_IS_MOBILITY),
        /* Mobility M6 */
        CHIP_DEF(PCI_CHIP_RADEON_LY,    RV100,  CHIP_HAS_CRTC2 | 
CHIP_IS_MOBILITY),
        CHIP_DEF(PCI_CHIP_RADEON_LZ,    RV100,  CHIP_HAS_CRTC2 | 
CHIP_IS_MOBILITY),
@@ -142,6 +147,8 @@ static struct pci_device_id radeonfb_pci
        /* 9000/Pro */
        CHIP_DEF(PCI_CHIP_RV250_If,     RV250,  CHIP_HAS_CRTC2),
        CHIP_DEF(PCI_CHIP_RV250_Ig,     RV250,  CHIP_HAS_CRTC2),
+
+       CHIP_DEF(PCI_CHIP_RC410_5A62,   RC410,  CHIP_HAS_CRTC2 | CHIP_IS_IGP | 
CHIP_IS_MOBILITY),
        /* Mobility 9100 IGP (U3) */
        CHIP_DEF(PCI_CHIP_RS300_5835,   RS300,  CHIP_HAS_CRTC2 | CHIP_IS_IGP | 
CHIP_IS_MOBILITY),
        CHIP_DEF(PCI_CHIP_RS350_7835,   RS300,  CHIP_HAS_CRTC2 | CHIP_IS_IGP | 
CHIP_IS_MOBILITY),
@@ -197,6 +204,7 @@ static struct pci_device_id radeonfb_pci
        CHIP_DEF(PCI_CHIP_RV380_3154,   RV380,  CHIP_HAS_CRTC2 | 
CHIP_IS_MOBILITY),
        CHIP_DEF(PCI_CHIP_RV370_5B60,   RV380,  CHIP_HAS_CRTC2),
        CHIP_DEF(PCI_CHIP_RV370_5B62,   RV380,  CHIP_HAS_CRTC2),
+       CHIP_DEF(PCI_CHIP_RV370_5B63,   RV380,  CHIP_HAS_CRTC2),
        CHIP_DEF(PCI_CHIP_RV370_5B64,   RV380,  CHIP_HAS_CRTC2),
        CHIP_DEF(PCI_CHIP_RV370_5B65,   RV380,  CHIP_HAS_CRTC2),
        CHIP_DEF(PCI_CHIP_RV370_5460,   RV380,  CHIP_HAS_CRTC2 | 
CHIP_IS_MOBILITY),
@@ -268,6 +276,11 @@ static int nomtrr = 0;
 #endif
 static int force_sleep;
 static int ignore_devlist;
+#ifdef CONFIG_PMAC_BACKLIGHT
+static int backlight = 1;
+#else
+static int backlight = 0;
+#endif
 
 /*
  * prototypes
@@ -405,7 +418,7 @@ static int  __devinit radeon_find_mem_vb
 }
 #endif
 
-#ifdef CONFIG_PPC_OF
+#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC)
 /*
  * Read XTAL (ref clock), SCLK and MCLK from Open Firmware device
  * tree. Hopefully, ATI OF driver is kind enough to fill these
@@ -413,11 +426,11 @@ static int __devinit radeon_read_xtal_OF
 static int __devinit radeon_read_xtal_OF (struct radeonfb_info *rinfo)
 {
        struct device_node *dp = rinfo->of_node;
-       u32 *val;
+       const u32 *val;
 
        if (dp == NULL)
                return -ENODEV;
-       val = (u32 *) get_property(dp, "ATY,RefCLK", NULL);
+       val = of_get_property(dp, "ATY,RefCLK", NULL);
        if (!val || !*val) {
                printk(KERN_WARNING "radeonfb: No ATY,RefCLK property !\n");
                return -EINVAL;
@@ -425,17 +438,17 @@ static int __devinit radeon_read_xtal_OF
 
        rinfo->pll.ref_clk = (*val) / 10;
 
-       val = (u32 *) get_property(dp, "ATY,SCLK", NULL);
+       val = of_get_property(dp, "ATY,SCLK", NULL);
        if (val && *val)
                rinfo->pll.sclk = (*val) / 10;
 
-       val = (u32 *) get_property(dp, "ATY,MCLK", NULL);
+       val = of_get_property(dp, "ATY,MCLK", NULL);
        if (val && *val)
                rinfo->pll.mclk = (*val) / 10;
 
                return 0;
 }
-#endif /* CONFIG_PPC_OF */
+#endif /* CONFIG_PPC_OF || CONFIG_SPARC */
 
 /*
  * Read PLL infos from chip registers
@@ -640,7 +653,7 @@ static void __devinit radeon_get_pllinfo
        rinfo->pll.ref_div = INPLL(PPLL_REF_DIV) & PPLL_REF_DIV_MASK;
 
 
-#ifdef CONFIG_PPC_OF
+#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC)
        /*
         * Retrieve PLL infos from Open Firmware first
         */
@@ -648,7 +661,7 @@ static void __devinit radeon_get_pllinfo
                        printk(KERN_INFO "radeonfb: Retrieved PLL infos from 
Open Firmware\n");
                goto found;
        }
-#endif /* CONFIG_PPC_OF */
+#endif /* CONFIG_PPC_OF || CONFIG_SPARC */
 
        /*
         * Check out if we have an X86 which gave us some PLL informations
@@ -1026,8 +1039,7 @@ int radeon_screen_blank(struct radeonfb_
                break;
        }
 
-       /* let fbcon do a soft blank for us */
-       return (blank == FB_BLANK_NORMAL) ? -EINVAL : 0;
+       return 0;
 }
 
 static int radeonfb_blank (int blank, struct fb_info *info)
@@ -1274,10 +1286,10 @@ static void radeon_write_pll_regs(struct
        radeon_pll_errata_after_data(rinfo);
 
        /* Set PPLL ref. div */
-       if (rinfo->family == CHIP_FAMILY_R300 ||
+       if (IS_R300_VARIANT(rinfo) ||
            rinfo->family == CHIP_FAMILY_RS300 ||
-           rinfo->family == CHIP_FAMILY_R350 ||
-           rinfo->family == CHIP_FAMILY_RV350) {
+           rinfo->family == CHIP_FAMILY_RS400 ||
+           rinfo->family == CHIP_FAMILY_RS480) {
                if (mode->ppll_ref_div & R300_PPLL_REF_DIV_ACC_MASK) {
                        /* When restoring console mode, use saved PPLL_REF_DIV
                         * setting.
@@ -1448,10 +1460,7 @@ static void radeon_calc_pll_regs(struct 
                /* Not all chip revs have the same format for this register,
                 * extract the source selection
                 */
-               if (rinfo->family == CHIP_FAMILY_R200 ||
-                   rinfo->family == CHIP_FAMILY_R300 ||
-                   rinfo->family == CHIP_FAMILY_R350 ||
-                   rinfo->family == CHIP_FAMILY_RV350) {
+               if (rinfo->family == CHIP_FAMILY_R200 || 
IS_R300_VARIANT(rinfo)) {
                        source = (fp2_gen_cntl >> 10) & 0x3;
                        /* sourced from transform unit, check for transform unit
                         * own source
@@ -1477,7 +1486,7 @@ static void radeon_calc_pll_regs(struct 
                freq = rinfo->pll.ppll_max;
        if (freq*12 < rinfo->pll.ppll_min)
                freq = rinfo->pll.ppll_min / 12;
-       RTRACE("freq = %lu, PLL min = %u, PLL max = %u\n",
+       pr_debug("freq = %lu, PLL min = %u, PLL max = %u\n",
               freq, rinfo->pll.ppll_min, rinfo->pll.ppll_max);
 
        for (post_div = &post_divs[0]; post_div->divider; ++post_div) {
@@ -1498,7 +1507,7 @@ static void radeon_calc_pll_regs(struct 
                post_div = &post_divs[post_div->bitvalue];
                pll_output_freq = post_div->divider * freq;
        }
-       RTRACE("ref_div = %d, ref_clk = %d, output_freq = %d\n",
+       pr_debug("ref_div = %d, ref_clk = %d, output_freq = %d\n",
               rinfo->pll.ref_div, rinfo->pll.ref_clk,
               pll_output_freq);
 
@@ -1508,7 +1517,7 @@ static void radeon_calc_pll_regs(struct 
                post_div = &post_divs[post_div->bitvalue];
                pll_output_freq = post_div->divider * freq;
        }
-       RTRACE("ref_div = %d, ref_clk = %d, output_freq = %d\n",
+       pr_debug("ref_div = %d, ref_clk = %d, output_freq = %d\n",
               rinfo->pll.ref_div, rinfo->pll.ref_clk,
               pll_output_freq);
 
@@ -1517,9 +1526,9 @@ static void radeon_calc_pll_regs(struct 
        regs->ppll_ref_div = rinfo->pll.ref_div;
        regs->ppll_div_3 = fb_div | (post_div->bitvalue << 16);
 
-       RTRACE("post div = 0x%x\n", post_div->bitvalue);
-       RTRACE("fb_div = 0x%x\n", fb_div);
-       RTRACE("ppll_div_3 = 0x%x\n", regs->ppll_div_3);
+       pr_debug("post div = 0x%x\n", post_div->bitvalue);
+       pr_debug("fb_div = 0x%x\n", fb_div);
+       pr_debug("ppll_div_3 = 0x%x\n", regs->ppll_div_3);
 }
 
 static int radeonfb_set_par(struct fb_info *info)
@@ -1591,9 +1600,9 @@ static int radeonfb_set_par(struct fb_in
        dotClock = 1000000000 / pixClock;
        freq = dotClock / 10; /* x100 */
 
-       RTRACE("hStart = %d, hEnd = %d, hTotal = %d\n",
+       pr_debug("hStart = %d, hEnd = %d, hTotal = %d\n",
                hSyncStart, hSyncEnd, hTotal);
-       RTRACE("vStart = %d, vEnd = %d, vTotal = %d\n",
+       pr_debug("vStart = %d, vEnd = %d, vTotal = %d\n",
                vSyncStart, vSyncEnd, vTotal);
 
        hsync_wid = (hSyncEnd - hSyncStart) / 8;
@@ -1702,16 +1711,16 @@ static int radeonfb_set_par(struct fb_in
                newmode->surf_info[i] = 0;
        }
 
-       RTRACE("h_total_disp = 0x%x\t   hsync_strt_wid = 0x%x\n",
+       pr_debug("h_total_disp = 0x%x\t   hsync_strt_wid = 0x%x\n",
                newmode->crtc_h_total_disp, newmode->crtc_h_sync_strt_wid);
-       RTRACE("v_total_disp = 0x%x\t   vsync_strt_wid = 0x%x\n",
+       pr_debug("v_total_disp = 0x%x\t   vsync_strt_wid = 0x%x\n",
                newmode->crtc_v_total_disp, newmode->crtc_v_sync_strt_wid);
 
        rinfo->bpp = mode->bits_per_pixel;
        rinfo->depth = depth;
 
-       RTRACE("pixclock = %lu\n", (unsigned long)pixClock);
-       RTRACE("freq = %lu\n", (unsigned long)freq);
+       pr_debug("pixclock = %lu\n", (unsigned long)pixClock);
+       pr_debug("freq = %lu\n", (unsigned long)freq);
 
        /* We use PPLL_DIV_3 */
        newmode->clk_cntl_index = 0x300;
@@ -1927,8 +1936,8 @@ static void fixup_memory_mappings(struct
        OUTREG(CRTC_GEN_CNTL, save_crtc_gen_cntl | CRTC_DISP_REQ_EN_B);
        mdelay(100);
 
-       aper_base = INREG(CONFIG_APER_0_BASE);
-       aper_size = INREG(CONFIG_APER_SIZE);
+       aper_base = INREG(CNFG_APER_0_BASE);
+       aper_size = INREG(CNFG_APER_SIZE);
 
 #ifdef SET_MC_FB_FROM_APERTURE
        /* Set framebuffer to be at the same address as set in PCI BAR */
@@ -1975,7 +1984,7 @@ static void fixup_memory_mappings(struct
        if (rinfo->has_CRTC2)
                OUTREG(CRTC2_GEN_CNTL, save_crtc2_gen_cntl);    
 
-       RTRACE("aper_base: %08x MC_FB_LOC to: %08x, MC_AGP_LOC to: %08x\n",
+       pr_debug("aper_base: %08x MC_FB_LOC to: %08x, MC_AGP_LOC to: %08x\n",
                aper_base,
                ((aper_base + aper_size - 1) & 0xffff0000) | (aper_base >> 16),
                0xffff0000 | (agp_base >> 16));
@@ -1990,7 +1999,10 @@ static void radeon_identify_vram(struct 
        /* framebuffer size */
         if ((rinfo->family == CHIP_FAMILY_RS100) ||
             (rinfo->family == CHIP_FAMILY_RS200) ||
-            (rinfo->family == CHIP_FAMILY_RS300)) {
+            (rinfo->family == CHIP_FAMILY_RS300) ||
+            (rinfo->family == CHIP_FAMILY_RC410) ||
+            (rinfo->family == CHIP_FAMILY_RS400) ||
+           (rinfo->family == CHIP_FAMILY_RS480) ) {
           u32 tom = INREG(NB_TOM);
           tmp = ((((tom >> 16) - (tom & 0xffff) + 1) << 6) * 1024);
 
@@ -2012,11 +2024,11 @@ static void radeon_identify_vram(struct 
                      ~CRTC_H_CUTOFF_ACTIVE_EN);
           }
         } else {
-          tmp = INREG(CONFIG_MEMSIZE);
+          tmp = INREG(CNFG_MEMSIZE);
         }
 
        /* mem size is bits [28:0], mask off the rest */
-       rinfo->video_ram = tmp & CONFIG_MEMSIZE_MASK;
+       rinfo->video_ram = tmp & CNFG_MEMSIZE_MASK;
 
        /*
         * Hack to get around some busted production M6's
@@ -2070,7 +2082,7 @@ static void radeon_identify_vram(struct 
         * ToDo: identify these cases
         */
 
-       RTRACE("radeonfb (%s): Found %ldk of %s %d bits wide videoram\n",
+       pr_debug("radeonfb (%s): Found %ldk of %s %d bits wide videoram\n",
               pci_name(rinfo->pdev),
               rinfo->video_ram / 1024,
               rinfo->vram_ddr ? "DDR" : "SDRAM",
@@ -2119,7 +2131,6 @@ static struct bin_attribute edid1_attr =
 static struct bin_attribute edid1_attr = {
        .attr   = {
                .name   = "edid1",
-               .owner  = THIS_MODULE,
                .mode   = 0444,
        },
        .size   = EDID_LENGTH,
@@ -2129,7 +2140,6 @@ static struct bin_attribute edid2_attr =
 static struct bin_attribute edid2_attr = {
        .attr   = {
                .name   = "edid2",
-               .owner  = THIS_MODULE,
                .mode   = 0444,
        },
        .size   = EDID_LENGTH,
@@ -2143,8 +2153,10 @@ static int __devinit radeonfb_pci_regist
        struct fb_info *info;
        struct radeonfb_info *rinfo;
        int ret;
-
-       RTRACE("radeonfb_pci_register BEGIN\n");
+       unsigned char c1, c2;
+       int err = 0;
+
+       pr_debug("radeonfb_pci_register BEGIN\n");
        
        /* Enable device in PCI config */
        ret = pci_enable_device(pdev);
@@ -2170,9 +2182,15 @@ static int __devinit radeonfb_pci_regist
        rinfo->lvds_timer.function = radeon_lvds_timer_func;
        rinfo->lvds_timer.data = (unsigned long)rinfo;
 
-       strcpy(rinfo->name, "ATI Radeon XX ");
-       rinfo->name[11] = ent->device >> 8;
-       rinfo->name[12] = ent->device & 0xFF;
+       c1 = ent->device >> 8;
+       c2 = ent->device & 0xff;
+       if (isprint(c1) && isprint(c2))
+               snprintf(rinfo->name, sizeof(rinfo->name),
+                        "ATI Radeon %x \"%c%c\"", ent->device & 0xffff, c1, 
c2);
+       else
+               snprintf(rinfo->name, sizeof(rinfo->name),
+                        "ATI Radeon %x", ent->device & 0xffff);
+
        rinfo->family = ent->driver_data & CHIP_FAMILY_MASK;
        rinfo->chipset = pdev->device;
        rinfo->has_CRTC2 = (ent->driver_data & CHIP_HAS_CRTC2) != 0;
@@ -2214,7 +2232,7 @@ static int __devinit radeonfb_pci_regist
         */
        rinfo->errata = 0;
        if (rinfo->family == CHIP_FAMILY_R300 &&
-           (INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK)
+           (INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK)
            == CFG_ATI_REV_A11)
                rinfo->errata |= CHIP_ERRATA_R300_CG;
 
@@ -2227,7 +2245,7 @@ static int __devinit radeonfb_pci_regist
            rinfo->family == CHIP_FAMILY_RS200)
                rinfo->errata |= CHIP_ERRATA_PLL_DELAY;
 
-#ifdef CONFIG_PPC_OF
+#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC)
        /* On PPC, we obtain the OF device-node pointer to the firmware
         * data for this chip
         */
@@ -2236,6 +2254,8 @@ static int __devinit radeonfb_pci_regist
                printk(KERN_WARNING "radeonfb (%s): Cannot match card to OF 
node !\n",
                       pci_name(rinfo->pdev));
 
+#endif /* CONFIG_PPC_OF || CONFIG_SPARC */
+#ifdef CONFIG_PPC_OF
        /* On PPC, the firmware sets up a memory mapping that tends
         * to cause lockups when enabling the engine. We reconfigure
         * the card internal memory mappings properly
@@ -2251,8 +2271,8 @@ static int __devinit radeonfb_pci_regist
        do {
                rinfo->fb_base = ioremap (rinfo->fb_base_phys,
                                          rinfo->mapped_vram);
-       } while (   rinfo->fb_base == 0 &&
-                 ((rinfo->mapped_vram /=2) >= MIN_MAPPED_VRAM) );
+       } while (rinfo->fb_base == NULL &&
+                ((rinfo->mapped_vram /= 2) >= MIN_MAPPED_VRAM));
 
        if (rinfo->fb_base == NULL) {
                printk (KERN_ERR "radeonfb (%s): cannot map FB\n",
@@ -2261,7 +2281,7 @@ static int __devinit radeonfb_pci_regist
                goto err_unmap_rom;
        }
 
-       RTRACE("radeonfb (%s): mapped %ldk videoram\n", pci_name(rinfo->pdev),
+       pr_debug("radeonfb (%s): mapped %ldk videoram\n", pci_name(rinfo->pdev),
               rinfo->mapped_vram/1024);
 
        /*
@@ -2314,9 +2334,14 @@ static int __devinit radeonfb_pci_regist
 
        /* Register some sysfs stuff (should be done better) */
        if (rinfo->mon1_EDID)
-               sysfs_create_bin_file(&rinfo->pdev->dev.kobj, &edid1_attr);
+               err |= sysfs_create_bin_file(&rinfo->pdev->dev.kobj,
+                                               &edid1_attr);
        if (rinfo->mon2_EDID)
-               sysfs_create_bin_file(&rinfo->pdev->dev.kobj, &edid2_attr);
+               err |= sysfs_create_bin_file(&rinfo->pdev->dev.kobj,
+                                               &edid2_attr);
+       if (err)
+               printk(KERN_WARNING "%s() Creating sysfs files failed, 
continuing\n",
+                          __func__);
 
        /* save current mode regs before we switch into the new one
         * so we can restore this upon __exit
@@ -2349,13 +2374,14 @@ static int __devinit radeonfb_pci_regist
                                                 MTRR_TYPE_WRCOMB, 1);
 #endif
 
-       radeonfb_bl_init(rinfo);
+       if (backlight)
+               radeonfb_bl_init(rinfo);
 
        printk ("radeonfb (%s): %s\n", pci_name(rinfo->pdev), rinfo->name);
 
        if (rinfo->bios_seg)
                radeon_unmap_ROM(rinfo, pdev);
-       RTRACE("radeonfb_pci_register END\n");
+       pr_debug("radeonfb_pci_register END\n");
 
        return 0;
 err_unmap_fb:
@@ -2393,7 +2419,6 @@ static void __devexit radeonfb_pci_unreg
         if (!rinfo)
                 return;
 
-       radeonfb_bl_exit(rinfo);
        radeonfb_pm_exit(rinfo);
 
        if (rinfo->mon1_EDID)
@@ -2419,6 +2444,8 @@ static void __devexit radeonfb_pci_unreg
 #endif
 
         unregister_framebuffer(info);
+
+        radeonfb_bl_exit(rinfo);
 
         iounmap(rinfo->mmio_base);
         iounmap(rinfo->fb_base);
@@ -2469,6 +2496,8 @@ static int __init radeonfb_setup (char *
                        force_dfp = 1;
                } else if (!strncmp(this_opt, "panel_yres:", 11)) {
                        panel_yres = simple_strtoul((this_opt+11), NULL, 0);
+               } else if (!strncmp(this_opt, "backlight:", 10)) {
+                       backlight = simple_strtoul(this_opt+10, NULL, 0);
 #ifdef CONFIG_MTRR
                } else if (!strncmp(this_opt, "nomtrr", 6)) {
                        nomtrr = 1;
diff -r 1db1bb63824b -r 0659978a1911 drivers/video/aty/radeon_i2c.c
--- a/drivers/video/aty/radeon_i2c.c    Mon Nov 23 07:32:47 2009 +0000
+++ b/drivers/video/aty/radeon_i2c.c    Mon Nov 23 23:17:38 2009 +0100
@@ -1,8 +1,8 @@
+#include "radeonfb.h"
+
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
 #include <linux/delay.h>
-#include <linux/pci.h>
 #include <linux/fb.h>
 
 
@@ -13,7 +13,6 @@
 #include <asm/io.h>
 
 #include <video/radeon.h>
-#include "radeonfb.h"
 #include "../edid.h"
 
 #define RADEON_DDC     0x50
@@ -72,16 +71,16 @@ static int radeon_setup_i2c_bus(struct r
 {
        int rc;
 
-       strcpy(chan->adapter.name, name);
+       snprintf(chan->adapter.name, sizeof(chan->adapter.name),
+                "radeonfb %s", name);
        chan->adapter.owner             = THIS_MODULE;
-       chan->adapter.id                = I2C_HW_B_RADEON;
        chan->adapter.algo_data         = &chan->algo;
        chan->adapter.dev.parent        = &chan->rinfo->pdev->dev;
        chan->algo.setsda               = radeon_gpio_setsda;
        chan->algo.setscl               = radeon_gpio_setscl;
        chan->algo.getsda               = radeon_gpio_getsda;
        chan->algo.getscl               = radeon_gpio_getscl;
-       chan->algo.udelay               = 40;
+       chan->algo.udelay               = 10;
        chan->algo.timeout              = 20;
        chan->algo.data                 = chan; 
        
@@ -122,22 +121,21 @@ void radeon_delete_i2c_busses(struct rad
 void radeon_delete_i2c_busses(struct radeonfb_info *rinfo)
 {
        if (rinfo->i2c[0].rinfo)
-               i2c_bit_del_bus(&rinfo->i2c[0].adapter);
+               i2c_del_adapter(&rinfo->i2c[0].adapter);
        rinfo->i2c[0].rinfo = NULL;
 
        if (rinfo->i2c[1].rinfo)
-               i2c_bit_del_bus(&rinfo->i2c[1].adapter);
+               i2c_del_adapter(&rinfo->i2c[1].adapter);
        rinfo->i2c[1].rinfo = NULL;
 
        if (rinfo->i2c[2].rinfo)
-               i2c_bit_del_bus(&rinfo->i2c[2].adapter);
+               i2c_del_adapter(&rinfo->i2c[2].adapter);
        rinfo->i2c[2].rinfo = NULL;
 
        if (rinfo->i2c[3].rinfo)
-               i2c_bit_del_bus(&rinfo->i2c[3].adapter);
+               i2c_del_adapter(&rinfo->i2c[3].adapter);
        rinfo->i2c[3].rinfo = NULL;
 }
-
 
 static u8 *radeon_do_probe_i2c_edid(struct radeon_i2c_chan *chan)
 {
@@ -169,8 +167,8 @@ static u8 *radeon_do_probe_i2c_edid(stru
        return NULL;
 }
 
-
-int radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int conn, u8 
**out_edid)
+int radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int conn,
+                              u8 **out_edid)
 {
        u32 reg = rinfo->i2c[conn-1].ddc_reg;
        u8 *edid = NULL;
@@ -244,21 +242,21 @@ int radeon_probe_i2c_connector(struct ra
        if (out_edid)
                *out_edid = edid;
        if (!edid) {
-               RTRACE("radeonfb: I2C (port %d) ... not found\n", conn);
+               pr_debug("radeonfb: I2C (port %d) ... not found\n", conn);
                return MT_NONE;
        }
        if (edid[0x14] & 0x80) {
                /* Fix detection using BIOS tables */
                if (rinfo->is_mobility /*&& conn == ddc_dvi*/ &&
                    (INREG(LVDS_GEN_CNTL) & LVDS_ON)) {
-                       RTRACE("radeonfb: I2C (port %d) ... found LVDS 
panel\n", conn);
+                       pr_debug("radeonfb: I2C (port %d) ... found LVDS 
panel\n", conn);
                        return MT_LCD;
                } else {
-                       RTRACE("radeonfb: I2C (port %d) ... found TMDS 
panel\n", conn);
+                       pr_debug("radeonfb: I2C (port %d) ... found TMDS 
panel\n", conn);
                        return MT_DFP;
                }
        }
-               RTRACE("radeonfb: I2C (port %d) ... found CRT display\n", conn);
+       pr_debug("radeonfb: I2C (port %d) ... found CRT display\n", conn);
        return MT_CRT;
 }
 
diff -r 1db1bb63824b -r 0659978a1911 drivers/video/aty/radeon_monitor.c
--- a/drivers/video/aty/radeon_monitor.c        Mon Nov 23 07:32:47 2009 +0000
+++ b/drivers/video/aty/radeon_monitor.c        Mon Nov 23 23:17:38 2009 +0100
@@ -52,7 +52,7 @@ static char *radeon_get_mon_name(int typ
 }
 
 
-#ifdef CONFIG_PPC_OF
+#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC)
 /*
  * Try to find monitor informations & EDID data out of the Open Firmware
  * device-tree. This also contains some "hacks" to work around a few machine
@@ -64,16 +64,16 @@ static int __devinit radeon_parse_montyp
 {
         static char *propnames[] = { "DFP,EDID", "LCD,EDID", "EDID",
                                     "EDID1", "EDID2",  NULL };
-       u8 *pedid = NULL;
-       u8 *pmt = NULL;
+       const u8 *pedid = NULL;
+       const u8 *pmt = NULL;
        u8 *tmp;
         int i, mt = MT_NONE;  
        
-       RTRACE("analyzing OF properties...\n");
-       pmt = (u8 *)get_property(dp, "display-type", NULL);
+       pr_debug("analyzing OF properties...\n");
+       pmt = of_get_property(dp, "display-type", NULL);
        if (!pmt)
                return MT_NONE;
-       RTRACE("display-type: %s\n", pmt);
+       pr_debug("display-type: %s\n", pmt);
        /* OF says "LCD" for DFP as well, we discriminate from the caller of 
this
         * function
         */
@@ -89,7 +89,7 @@ static int __devinit radeon_parse_montyp
        }
 
        for (i = 0; propnames[i] != NULL; ++i) {
-               pedid = (u8 *)get_property(dp, propnames[i], NULL);
+               pedid = of_get_property(dp, propnames[i], NULL);
                if (pedid != NULL)
                        break;
        }
@@ -98,16 +98,16 @@ static int __devinit radeon_parse_montyp
         * single-head cards have hdno == -1 and skip this step
         */
        if (pedid == NULL && dp->parent && (hdno != -1))
-               pedid = get_property(dp->parent, (hdno == 0) ? "EDID1" : 
"EDID2", NULL);
+               pedid = of_get_property(dp->parent,
+                               (hdno == 0) ? "EDID1" : "EDID2", NULL);
        if (pedid == NULL && dp->parent && (hdno == 0))
-               pedid = get_property(dp->parent, "EDID", NULL);
+               pedid = of_get_property(dp->parent, "EDID", NULL);
        if (pedid == NULL)
                return mt;
 
-       tmp = (u8 *)kmalloc(EDID_LENGTH, GFP_KERNEL);
+       tmp = kmemdup(pedid, EDID_LENGTH, GFP_KERNEL);
        if (!tmp)
                return mt;
-       memcpy(tmp, pedid, EDID_LENGTH);
        *out_EDID = tmp;
        return mt;
 }
@@ -117,25 +117,25 @@ static int __devinit radeon_probe_OF_hea
 {
         struct device_node *dp;
 
-       RTRACE("radeon_probe_OF_head\n");
+       pr_debug("radeon_probe_OF_head\n");
 
         dp = rinfo->of_node;
         while (dp == NULL)
                return MT_NONE;
 
        if (rinfo->has_CRTC2) {
-               char *pname;
+               const char *pname;
                int len, second = 0;
 
                dp = dp->child;
                do {
                        if (!dp)
                                return MT_NONE;
-                       pname = (char *)get_property(dp, "name", NULL);
+                       pname = of_get_property(dp, "name", NULL);
                        if (!pname)
                                return MT_NONE;
                        len = strlen(pname);
-                       RTRACE("head: %s (letter: %c, head_no: %d)\n",
+                       pr_debug("head: %s (letter: %c, head_no: %d)\n",
                               pname, pname[len-1], head_no);
                        if (pname[len-1] == 'A' && head_no == 0) {
                                int mt = radeon_parse_montype_prop(dp, 
out_EDID, 0);
@@ -157,7 +157,7 @@ static int __devinit radeon_probe_OF_hea
        }
         return MT_NONE;
 }
-#endif /* CONFIG_PPC_OF */
+#endif /* CONFIG_PPC_OF || CONFIG_SPARC */
 
 
 static int __devinit radeon_get_panel_info_BIOS(struct radeonfb_info *rinfo)
@@ -185,7 +185,7 @@ static int __devinit radeon_get_panel_in
                rinfo->panel_info.xres, rinfo->panel_info.yres);
 
        rinfo->panel_info.pwr_delay = BIOS_IN16(tmp + 44);
-       RTRACE("BIOS provided panel power delay: %d\n", 
rinfo->panel_info.pwr_delay);
+       pr_debug("BIOS provided panel power delay: %d\n", 
rinfo->panel_info.pwr_delay);
        if (rinfo->panel_info.pwr_delay > 2000 || rinfo->panel_info.pwr_delay 
<= 0)
                rinfo->panel_info.pwr_delay = 2000;
 
@@ -199,16 +199,16 @@ static int __devinit radeon_get_panel_in
            rinfo->panel_info.fbk_divider > 3) {
                rinfo->panel_info.use_bios_dividers = 1;
                printk(KERN_INFO "radeondb: BIOS provided dividers will be 
used\n");
-               RTRACE("ref_divider = %x\n", rinfo->panel_info.ref_divider);
-               RTRACE("post_divider = %x\n", rinfo->panel_info.post_divider);
-               RTRACE("fbk_divider = %x\n", rinfo->panel_info.fbk_divider);
-       }
-       RTRACE("Scanning BIOS table ...\n");
+               pr_debug("ref_divider = %x\n", rinfo->panel_info.ref_divider);
+               pr_debug("post_divider = %x\n", rinfo->panel_info.post_divider);
+               pr_debug("fbk_divider = %x\n", rinfo->panel_info.fbk_divider);
+       }
+       pr_debug("Scanning BIOS table ...\n");
        for(i=0; i<32; i++) {
                tmp0 = BIOS_IN16(tmp+64+i*2);
                if (tmp0 == 0)
                        break;
-               RTRACE(" %d x %d\n", BIOS_IN16(tmp0), BIOS_IN16(tmp0+2));
+               pr_debug(" %d x %d\n", BIOS_IN16(tmp0), BIOS_IN16(tmp0+2));
                if ((BIOS_IN16(tmp0) == rinfo->panel_info.xres) &&
                    (BIOS_IN16(tmp0+2) == rinfo->panel_info.yres)) {
                        rinfo->panel_info.hblank = (BIOS_IN16(tmp0+17) - 
BIOS_IN16(tmp0+19)) * 8;
@@ -227,19 +227,19 @@ static int __devinit radeon_get_panel_in
                        /* Mark panel infos valid */
                        rinfo->panel_info.valid = 1;
 
-                       RTRACE("Found panel in BIOS table:\n");
-                       RTRACE("  hblank: %d\n", rinfo->panel_info.hblank);
-                       RTRACE("  hOver_plus: %d\n", 
rinfo->panel_info.hOver_plus);
-                       RTRACE("  hSync_width: %d\n", 
rinfo->panel_info.hSync_width);
-                       RTRACE("  vblank: %d\n", rinfo->panel_info.vblank);
-                       RTRACE("  vOver_plus: %d\n", 
rinfo->panel_info.vOver_plus);
-                       RTRACE("  vSync_width: %d\n", 
rinfo->panel_info.vSync_width);
-                       RTRACE("  clock: %d\n", rinfo->panel_info.clock);
+                       pr_debug("Found panel in BIOS table:\n");
+                       pr_debug("  hblank: %d\n", rinfo->panel_info.hblank);
+                       pr_debug("  hOver_plus: %d\n", 
rinfo->panel_info.hOver_plus);
+                       pr_debug("  hSync_width: %d\n", 
rinfo->panel_info.hSync_width);
+                       pr_debug("  vblank: %d\n", rinfo->panel_info.vblank);
+                       pr_debug("  vOver_plus: %d\n", 
rinfo->panel_info.vOver_plus);
+                       pr_debug("  vSync_width: %d\n", 
rinfo->panel_info.vSync_width);
+                       pr_debug("  clock: %d\n", rinfo->panel_info.clock);
                                
                        return 1;
                }
        }
-       RTRACE("Didn't find panel in BIOS table !\n");
+       pr_debug("Didn't find panel in BIOS table !\n");
 
        return 0;
 }
@@ -252,11 +252,13 @@ static void __devinit radeon_parse_conne
 {
        int offset, chips, connectors, tmp, i, conn, type;
 
+#ifdef DEBUG
        static char* __conn_type_table[16] = {
                "NONE", "Proprietary", "CRT", "DVI-I", "DVI-D", "Unknown", 
"Unknown",
                "Unknown", "Unknown", "Unknown", "Unknown", "Unknown", 
"Unknown",
                "Unknown", "Unknown", "Unknown"
        };
+#endif
 
        if (!rinfo->bios_seg)
                return;
@@ -271,18 +273,18 @@ static void __devinit radeon_parse_conne
         * DEBUG is enabled
         */
        chips = BIOS_IN8(offset++) >> 4;
-       RTRACE("%d chips in connector info\n", chips);
+       pr_debug("%d chips in connector info\n", chips);
        for (i = 0; i < chips; i++) {
                tmp = BIOS_IN8(offset++);
                connectors = tmp & 0x0f;
-               RTRACE(" - chip %d has %d connectors\n", tmp >> 4, connectors);
+               pr_debug(" - chip %d has %d connectors\n", tmp >> 4, 
connectors);
                for (conn = 0; ; conn++) {
                        tmp = BIOS_IN16(offset);
                        if (tmp == 0)
                                break;
                        offset += 2;
                        type = (tmp >> 12) & 0x0f;
-                       RTRACE("  * connector %d of type %d (%s) : %04x\n",
+                       pr_debug("  * connector %d of type %d (%s) : %04x\n",
                               conn, type, __conn_type_table[type], tmp);
                }
        }
@@ -449,7 +451,7 @@ void __devinit radeon_probe_screens(stru
                 * a layout for each card ?
                 */
 
-               RTRACE("Using specified monitor layout: %s", monitor_layout);
+               pr_debug("Using specified monitor layout: %s", monitor_layout);
 #ifdef CONFIG_FB_RADEON_I2C
                if (!ignore_edid) {
                        if (rinfo->mon1_type != MT_NONE)
@@ -479,9 +481,9 @@ void __devinit radeon_probe_screens(stru
                 * Auto-detecting display type (well... trying to ...)
                 */
                
-               RTRACE("Starting monitor auto detection...\n");
-
-#if DEBUG && defined(CONFIG_FB_RADEON_I2C)
+               pr_debug("Starting monitor auto detection...\n");
+
+#if defined(DEBUG) && defined(CONFIG_FB_RADEON_I2C)
                {
                        u8 *EDIDs[4] = { NULL, NULL, NULL, NULL };
                        int mon_types[4] = {MT_NONE, MT_NONE, MT_NONE, MT_NONE};
@@ -496,11 +498,11 @@ void __devinit radeon_probe_screens(stru
                 * Old single head cards
                 */
                if (!rinfo->has_CRTC2) {
-#ifdef CONFIG_PPC_OF
+#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC)
                        if (rinfo->mon1_type == MT_NONE)
                                rinfo->mon1_type = radeon_probe_OF_head(rinfo, 
0,
                                                                        
&rinfo->mon1_EDID);
-#endif /* CONFIG_PPC_OF */
+#endif /* CONFIG_PPC_OF || CONFIG_SPARC */
 #ifdef CONFIG_FB_RADEON_I2C
                        if (rinfo->mon1_type == MT_NONE)
                                rinfo->mon1_type =
@@ -545,11 +547,11 @@ void __devinit radeon_probe_screens(stru
                /*
                 * Probe primary head (DVI or laptop internal panel)
                 */
-#ifdef CONFIG_PPC_OF
+#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC)
                if (rinfo->mon1_type == MT_NONE)
                        rinfo->mon1_type = radeon_probe_OF_head(rinfo, 0,
                                                                
&rinfo->mon1_EDID);
-#endif /* CONFIG_PPC_OF */
+#endif /* CONFIG_PPC_OF || CONFIG_SPARC */
 #ifdef CONFIG_FB_RADEON_I2C
                if (rinfo->mon1_type == MT_NONE)
                        rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, 
ddc_dvi,
@@ -573,11 +575,11 @@ void __devinit radeon_probe_screens(stru
                /*
                 * Probe secondary head (mostly VGA, can be DVI)
                 */
-#ifdef CONFIG_PPC_OF
+#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC)
                if (rinfo->mon2_type == MT_NONE)
                        rinfo->mon2_type = radeon_probe_OF_head(rinfo, 1,
                                                                
&rinfo->mon2_EDID);
-#endif /* CONFIG_PPC_OF */
+#endif /* CONFIG_PPC_OF || defined(CONFIG_SPARC) */
 #ifdef CONFIG_FB_RADEON_I2C
                if (rinfo->mon2_type == MT_NONE)
                        rinfo->mon2_type = radeon_probe_i2c_connector(rinfo, 
ddc_vga,
@@ -756,7 +758,7 @@ void __devinit radeon_check_modes(struct
        if (!rinfo->panel_info.use_bios_dividers && rinfo->mon1_type != MT_CRT
            && rinfo->mon1_EDID) {
                struct fb_var_screeninfo var;
-               RTRACE("Parsing EDID data for panel info\n");
+               pr_debug("Parsing EDID data for panel info\n");
                if (fb_parse_edid(rinfo->mon1_EDID, &var) == 0) {
                        if (var.xres >= rinfo->panel_info.xres &&
                            var.yres >= rinfo->panel_info.yres)
@@ -776,7 +778,7 @@ void __devinit radeon_check_modes(struct
        if (rinfo->mon1_type != MT_CRT && rinfo->panel_info.valid) {
                struct fb_var_screeninfo *var = &info->var;
 
-               RTRACE("Setting up default mode based on panel info\n");
+               pr_debug("Setting up default mode based on panel info\n");
                var->xres = rinfo->panel_info.xres;
                var->yres = rinfo->panel_info.yres;
                var->xres_virtual = rinfo->panel_info.xres;
@@ -824,7 +826,7 @@ void __devinit radeon_check_modes(struct
                int                     dbsize;
                char                    modename[32];
 
-               RTRACE("Guessing panel info...\n");
+               pr_debug("Guessing panel info...\n");
                if (rinfo->panel_info.xres == 0 || rinfo->panel_info.yres == 0) 
{
                        u32 tmp = INREG(FP_HORZ_STRETCH) & HORZ_PANEL_SIZE;
                        rinfo->panel_info.xres = ((tmp >> HORZ_PANEL_SHIFT) + 
1) * 8;
diff -r 1db1bb63824b -r 0659978a1911 drivers/video/aty/radeon_pm.c
--- a/drivers/video/aty/radeon_pm.c     Mon Nov 23 07:32:47 2009 +0000
+++ b/drivers/video/aty/radeon_pm.c     Mon Nov 23 23:17:38 2009 +0100
@@ -27,8 +27,6 @@
 
 #include "ati_ids.h"
 
-static void radeon_reinitialize_M10(struct radeonfb_info *rinfo);
-
 /*
  * Workarounds for bugs in PC laptops:
  * - enable D2 sleep in some IBM Thinkpads
@@ -39,6 +37,8 @@ static void radeon_reinitialize_M10(stru
  */
 
 #if defined(CONFIG_PM) && defined(CONFIG_X86)
+static void radeon_reinitialize_M10(struct radeonfb_info *rinfo);
+
 struct radeon_device_id {
         const char *ident;                     /* (arbitrary) Name */
         const unsigned short subsystem_vendor; /* Subsystem Vendor ID */
@@ -86,6 +86,9 @@ static struct radeon_device_id radeon_wo
        BUGFIX("Samsung P35",
               PCI_VENDOR_ID_SAMSUNG, 0xc00c,
               radeon_pm_off, radeon_reinitialize_M10),
+       BUGFIX("Acer Aspire 2010",
+              PCI_VENDOR_ID_AI, 0x0061,
+              radeon_pm_off, radeon_reinitialize_M10),
        { .ident = NULL }
 };
 
@@ -330,7 +333,7 @@ static void radeon_pm_enable_dynamic_mod
        if (!rinfo->has_CRTC2) {
                 tmp = INPLL(pllSCLK_CNTL);
 
-               if ((INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) > 
CFG_ATI_REV_A13)
+               if ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) > CFG_ATI_REV_A13)
                     tmp &= ~(SCLK_CNTL__FORCE_CP       | SCLK_CNTL__FORCE_RB);
                 tmp &= ~(SCLK_CNTL__FORCE_HDP          | 
SCLK_CNTL__FORCE_DISP1 |
                         SCLK_CNTL__FORCE_TOP           | SCLK_CNTL__FORCE_SE   
|
@@ -465,9 +468,9 @@ static void radeon_pm_enable_dynamic_mod
 
        /*RAGE_6::A11 A12 A12N1 A13, RV250::A11 A12, R300*/
        if ((rinfo->family == CHIP_FAMILY_RV250 &&
-            ((INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) ||
+            ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) ||
            ((rinfo->family == CHIP_FAMILY_RV100) &&
-            ((INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) <= CFG_ATI_REV_A13))) {
+            ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) <= CFG_ATI_REV_A13))) {
                tmp |= SCLK_CNTL__FORCE_CP;
                tmp |= SCLK_CNTL__FORCE_VIP;
        }
@@ -483,7 +486,7 @@ static void radeon_pm_enable_dynamic_mod
                /* RV200::A11 A12 RV250::A11 A12 */
                if (((rinfo->family == CHIP_FAMILY_RV200) ||
                     (rinfo->family == CHIP_FAMILY_RV250)) &&
-                   ((INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) < 
CFG_ATI_REV_A13))
+                   ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) < 
CFG_ATI_REV_A13))
                        tmp |= SCLK_MORE_CNTL__FORCEON;
 
                OUTPLL(pllSCLK_MORE_CNTL, tmp);
@@ -494,7 +497,7 @@ static void radeon_pm_enable_dynamic_mod
        /* RV200::A11 A12, RV250::A11 A12 */
        if (((rinfo->family == CHIP_FAMILY_RV200) ||
             (rinfo->family == CHIP_FAMILY_RV250)) &&
-           ((INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) {
+           ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) {
                tmp = INPLL(pllPLL_PWRMGT_CNTL);
                tmp |= PLL_PWRMGT_CNTL__TCL_BYPASS_DISABLE;
                OUTPLL(pllPLL_PWRMGT_CNTL, tmp);
@@ -699,7 +702,7 @@ static void radeon_pm_restore_regs(struc
        OUTREG(DISPLAY_BASE_ADDR, rinfo->save_regs[31]);
        OUTREG(MC_AGP_LOCATION, rinfo->save_regs[32]);
        OUTREG(CRTC2_DISPLAY_BASE_ADDR, rinfo->save_regs[33]);
-       OUTREG(CONFIG_MEMSIZE, rinfo->video_ram);
+       OUTREG(CNFG_MEMSIZE, rinfo->video_ram);
 
        OUTREG(DISP_MISC_CNTL, rinfo->save_regs[9]);
        OUTREG(DISP_PWR_MAN, rinfo->save_regs[10]);
@@ -1259,7 +1262,7 @@ static void radeon_pm_full_reset_sdram(s
        /* This is the code for the Aluminium PowerBooks M10 / iBooks M11 */
        if (rinfo->family == CHIP_FAMILY_RV350) {
                u32 sdram_mode_reg = rinfo->save_regs[35];
-               static u32 default_mrtable[] =
+               static const u32 default_mrtable[] =
                        { 0x21320032,
                          0x21321000, 0xa1321000, 0x21321000, 0xffffffff,
                          0x21320032, 0xa1320032, 0x21320032, 0xffffffff,
@@ -1268,7 +1271,7 @@ static void radeon_pm_full_reset_sdram(s
                          0x21320032, 0xa1320032, 0x21320032, 0xffffffff,
                          0x31320032 };
 
-               u32 *mrtable = default_mrtable;
+               const u32 *mrtable = default_mrtable;
                int i, mrtable_size = ARRAY_SIZE(default_mrtable);
 
                mdelay(30);
@@ -1287,7 +1290,7 @@ static void radeon_pm_full_reset_sdram(s
                if (rinfo->of_node != NULL) {
                        int size;
 
-                       mrtable = (u32 *)get_property(rinfo->of_node, 
"ATY,MRT", &size);
+                       mrtable = of_get_property(rinfo->of_node, "ATY,MRT", 
&size);
                        if (mrtable)
                                mrtable_size = size >> 2;
                        else
@@ -1720,7 +1723,7 @@ static void radeon_reinitialize_M10(stru
        OUTREG(CRTC2_DISPLAY_BASE_ADDR, rinfo->save_regs[33]);
        OUTREG(MC_FB_LOCATION, rinfo->save_regs[30]);
        OUTREG(OV0_BASE_ADDR, rinfo->save_regs[80]);
-       OUTREG(CONFIG_MEMSIZE, rinfo->video_ram);
+       OUTREG(CNFG_MEMSIZE, rinfo->video_ram);
        OUTREG(BUS_CNTL, rinfo->save_regs[36]);
        OUTREG(BUS_CNTL1, rinfo->save_regs[14]);
        OUTREG(MPP_TB_CONFIG, rinfo->save_regs[37]);
@@ -1958,7 +1961,7 @@ static void radeon_pm_m9p_reconfigure_mc
        OUTMC(rinfo, ixMC_CHP_IO_CNTL_B1, rinfo->save_regs[68] /*0x141555ff*/);
        OUTMC(rinfo, ixMC_IMP_CNTL_0, rinfo->save_regs[71] /*0x00009249*/);
        OUTREG(MC_IND_INDEX, 0);
-       OUTREG(CONFIG_MEMSIZE, rinfo->video_ram);
+       OUTREG(CNFG_MEMSIZE, rinfo->video_ram);
 
        mdelay(20);
 }
@@ -2358,7 +2361,7 @@ static void radeon_reinitialize_QW(struc
        OUTMC(rinfo, ixMC_IMP_CNTL_0, 0x00009249);
        OUTREG(MC_IND_INDEX, 0);
 
-       OUTREG(CONFIG_MEMSIZE, rinfo->video_ram);
+       OUTREG(CNFG_MEMSIZE, rinfo->video_ram);
 
        radeon_pm_full_reset_sdram(rinfo);
 
@@ -2504,11 +2507,28 @@ static void radeon_reinitialize_QW(struc
 
 #endif /* CONFIG_PPC_OF */
 
+static void radeonfb_whack_power_state(struct radeonfb_info *rinfo, 
pci_power_t state)
+{
+       u16 pwr_cmd;
+
+       for (;;) {
+               pci_read_config_word(rinfo->pdev,
+                                    rinfo->pm_reg+PCI_PM_CTRL,
+                                    &pwr_cmd);
+               if (pwr_cmd & 2)
+                       break;
+               pwr_cmd = (pwr_cmd & ~PCI_PM_CTRL_STATE_MASK) | 2;
+               pci_write_config_word(rinfo->pdev,
+                                     rinfo->pm_reg+PCI_PM_CTRL,
+                                     pwr_cmd);
+               msleep(500);
+       }
+       rinfo->pdev->current_state = state;
+}
+
 static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend)
 {
-       u16 pwr_cmd;
        u32 tmp;
-       int i;
 
        if (!rinfo->pm_reg)
                return;
@@ -2554,31 +2574,18 @@ static void radeon_set_suspend(struct ra
                        }
                }
 
-               for (i = 0; i < 64; ++i)
-                       pci_read_config_dword(rinfo->pdev, i * 4,
-                                             &rinfo->cfg_save[i]);
-
-               /* Switch PCI power managment to D2. */
+               /* Switch PCI power management to D2. */
                pci_disable_device(rinfo->pdev);
-               for (;;) {
-                       pci_read_config_word(
-                               rinfo->pdev, rinfo->pm_reg+PCI_PM_CTRL,
-                               &pwr_cmd);
-                       if (pwr_cmd & 2)
-                               break;                  
-                       pci_write_config_word(
-                               rinfo->pdev, rinfo->pm_reg+PCI_PM_CTRL,
-                               (pwr_cmd & ~PCI_PM_CTRL_STATE_MASK) | 2);
-                       mdelay(500);
-               }
+               pci_save_state(rinfo->pdev);
+               /* The chip seems to need us to whack the PM register
+                * repeatedly until it sticks. We do that -prior- to
+                * calling pci_set_power_state()
+                */
+               radeonfb_whack_power_state(rinfo, PCI_D2);
+               pci_set_power_state(rinfo->pdev, PCI_D2);
        } else {
                printk(KERN_DEBUG "radeonfb (%s): switching to D0 state...\n",
                       pci_name(rinfo->pdev));
-
-               /* Switch back PCI powermanagment to D0 */
-               mdelay(200);
-               pci_write_config_word(rinfo->pdev, rinfo->pm_reg+PCI_PM_CTRL, 
0);
-               mdelay(500);
 
                if (rinfo->family <= CHIP_FAMILY_RV250) {
                        /* Reset the SDRAM controller  */
@@ -2595,50 +2602,23 @@ static void radeon_set_suspend(struct ra
        }
 }
 
-static int radeon_restore_pci_cfg(struct radeonfb_info *rinfo)
-{
-       int i;
-       static u32 radeon_cfg_after_resume[64];
-
-       for (i = 0; i < 64; ++i)
-               pci_read_config_dword(rinfo->pdev, i * 4,
-                                     &radeon_cfg_after_resume[i]);
-
-       if (radeon_cfg_after_resume[PCI_BASE_ADDRESS_0/4]
-           == rinfo->cfg_save[PCI_BASE_ADDRESS_0/4])
-               return 0;       /* assume everything is ok */
-
-       for (i = PCI_BASE_ADDRESS_0/4; i < 64; ++i) {
-               if (radeon_cfg_after_resume[i] != rinfo->cfg_save[i])
-                       pci_write_config_dword(rinfo->pdev, i * 4,
-                                              rinfo->cfg_save[i]);
-       }
-       pci_write_config_word(rinfo->pdev, PCI_CACHE_LINE_SIZE,
-                             rinfo->cfg_save[PCI_CACHE_LINE_SIZE/4]);
-       pci_write_config_word(rinfo->pdev, PCI_COMMAND,
-                             rinfo->cfg_save[PCI_COMMAND/4]);
-       return 1;
-}
-
-
-int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
 {
         struct fb_info *info = pci_get_drvdata(pdev);
         struct radeonfb_info *rinfo = info->par;
-       int i;
-
-       if (state.event == pdev->dev.power.power_state.event)
+
+       if (mesg.event == pdev->dev.power.power_state.event)
                return 0;
 
-       printk(KERN_DEBUG "radeonfb (%s): suspending to state: %d...\n",
-              pci_name(pdev), state.event);
+       printk(KERN_DEBUG "radeonfb (%s): suspending for event: %d...\n",
+              pci_name(pdev), mesg.event);
 
        /* For suspend-to-disk, we cheat here. We don't suspend anything and
         * let fbcon continue drawing until we are all set. That shouldn't
         * really cause any problem at this point, provided that the wakeup
         * code knows that any state in memory may not match the HW
         */
-       if (state.event == PM_EVENT_FREEZE)
+       if (mesg.event == PM_EVENT_FREEZE)
                goto done;
 
        acquire_console_sem();
@@ -2667,6 +2647,11 @@ int radeonfb_pci_suspend(struct pci_dev 
         */
        pmac_suspend_agp_for_card(pdev);
 #endif /* CONFIG_PPC_PMAC */
+
+       /* It's unclear whether or when the generic code will do that, so let's
+        * do it ourselves. We save state before we do any power management
+        */
+       pci_save_state(pdev);
 
        /* If we support wakeup from poweroff, we save all regs we can 
including cfg
         * space
@@ -2692,9 +2677,6 @@ int radeonfb_pci_suspend(struct pci_dev 
                        mdelay(20);
                        OUTREG(LVDS_GEN_CNTL, INREG(LVDS_GEN_CNTL) & 
~(LVDS_DIGON));
                }
-               // FIXME: Use PCI layer
-               for (i = 0; i < 64; ++i)
-                       pci_read_config_dword(pdev, i * 4, &rinfo->cfg_save[i]);
                pci_disable_device(pdev);
        }
        /* If we support D2, we go to it (should be fixed later with a flag 
forcing
@@ -2706,9 +2688,16 @@ int radeonfb_pci_suspend(struct pci_dev 
        release_console_sem();
 
  done:
-       pdev->dev.power.power_state = state;
+       pdev->dev.power.power_state = mesg;
 
        return 0;
+}
+
+static int radeon_check_power_loss(struct radeonfb_info *rinfo)
+{
+       return rinfo->save_regs[4] != INPLL(CLK_PIN_CNTL) ||
+              rinfo->save_regs[2] != INPLL(MCLK_CNTL) ||
+              rinfo->save_regs[3] != INPLL(SCLK_CNTL);
 }
 
 int radeonfb_pci_resume(struct pci_dev *pdev)
@@ -2729,20 +2718,13 @@ int radeonfb_pci_resume(struct pci_dev *
        printk(KERN_DEBUG "radeonfb (%s): resuming from state: %d...\n",
               pci_name(pdev), pdev->dev.power.power_state.event);
 
-
-       if (pci_enable_device(pdev)) {
-               rc = -ENODEV;
-               printk(KERN_ERR "radeonfb (%s): can't enable PCI device !\n",
-                      pci_name(pdev));
-               goto bail;
-       }
-       pci_set_master(pdev);
-
+       /* PCI state will have been restored by the core, so
+        * we should be in D0 now with our config space fully
+        * restored
+        */
        if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
-               /* Wakeup chip. Check from config space if we were powered off
-                * (todo: additionally, check CLK_PIN_CNTL too)
-                */
-               if ((rinfo->pm_mode & radeon_pm_off) && 
radeon_restore_pci_cfg(rinfo)) {
+               /* Wakeup chip */
+               if ((rinfo->pm_mode & radeon_pm_off) && 
radeon_check_power_loss(rinfo)) {
                        if (rinfo->reinit_func != NULL)
                                rinfo->reinit_func(rinfo);
                        else {
@@ -2801,12 +2783,13 @@ int radeonfb_pci_resume(struct pci_dev *
        return rc;
 }
 
-#ifdef CONFIG_PPC_OF
+#ifdef CONFIG_PPC_OF__disabled
 static void radeonfb_early_resume(void *data)
 {
         struct radeonfb_info *rinfo = data;
 
        rinfo->no_schedule = 1;
+       pci_restore_state(rinfo->pdev);
        radeonfb_pci_resume(rinfo->pdev);
        rinfo->no_schedule = 0;
 }
@@ -2820,11 +2803,15 @@ void radeonfb_pm_init(struct radeonfb_in
        rinfo->pm_reg = pci_find_capability(rinfo->pdev, PCI_CAP_ID_PM);
 
        /* Enable/Disable dynamic clocks: TODO add sysfs access */
-       rinfo->dynclk = dynclk;
-       if (dynclk == 1) {
+       if (rinfo->family == CHIP_FAMILY_RS480)
+               rinfo->dynclk = -1;
+       else
+               rinfo->dynclk = dynclk;
+
+       if (rinfo->dynclk == 1) {
                radeon_pm_enable_dynamic_mode(rinfo);
                printk("radeonfb: Dynamic Clock Power Management enabled\n");
-       } else if (dynclk == 0) {
+       } else if (rinfo->dynclk == 0) {
                radeon_pm_disable_dynamic_mode(rinfo);
                printk("radeonfb: Dynamic Clock Power Management disabled\n");
        }
@@ -2869,7 +2856,14 @@ void radeonfb_pm_init(struct radeonfb_in
                 */
                if (rinfo->pm_mode != radeon_pm_none) {
                        pmac_call_feature(PMAC_FTR_DEVICE_CAN_WAKE, 
rinfo->of_node, 0, 1);
+#if 0 /* Disable the early video resume hack for now as it's causing problems, 
among
+       * others we now rely on the PCI core restoring the config space for us, 
which
+       * isn't the case with that hack, and that code path causes various 
things to
+       * be called with interrupts off while they shouldn't. I'm leaving the 
code in
+       * as it can be useful for debugging purposes
+       */
                        pmac_set_early_video_resume(radeonfb_early_resume, 
rinfo);
+#endif
                }
 
 #if 0
diff -r 1db1bb63824b -r 0659978a1911 drivers/video/aty/radeonfb.h
--- a/drivers/video/aty/radeonfb.h      Mon Nov 23 07:32:47 2009 +0000
+++ b/drivers/video/aty/radeonfb.h      Mon Nov 23 23:17:38 2009 +0100
@@ -1,5 +1,9 @@
 #ifndef __RADEONFB_H__
 #define __RADEONFB_H__
+
+#ifdef CONFIG_FB_RADEON_DEBUG
+#define DEBUG          1
+#endif
 
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -16,7 +20,7 @@
 
 #include <asm/io.h>
 
-#ifdef CONFIG_PPC_OF
+#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC)
 #include <asm/prom.h>
 #endif
 
@@ -48,6 +52,9 @@ enum radeon_family {
        CHIP_FAMILY_RV350,
        CHIP_FAMILY_RV380,    /* RV370/RV380/M22/M24 */
        CHIP_FAMILY_R420,     /* R420/R423/M18 */
+       CHIP_FAMILY_RC410,
+       CHIP_FAMILY_RS400,
+       CHIP_FAMILY_RS480,
        CHIP_FAMILY_LAST,
 };
 
@@ -64,7 +71,9 @@ enum radeon_family {
                                ((rinfo)->family == CHIP_FAMILY_RV350) || \
                                ((rinfo)->family == CHIP_FAMILY_R350)  || \
                                ((rinfo)->family == CHIP_FAMILY_RV380) || \
-                               ((rinfo)->family == CHIP_FAMILY_R420))
+                               ((rinfo)->family == CHIP_FAMILY_R420)  || \
+                               ((rinfo)->family == CHIP_FAMILY_RC410) || \
+                               ((rinfo)->family == CHIP_FAMILY_RS480))
 
 /*
  * Chip flags
@@ -281,7 +290,7 @@ struct radeonfb_info {
        struct radeon_regs      state;
        struct radeon_regs      init_state;
 
-       char                    name[DEVICE_NAME_SIZE];
+       char                    name[50];
 
        unsigned long           mmio_base_phys;
        unsigned long           fb_base_phys;
@@ -292,14 +301,14 @@ struct radeonfb_info {
        unsigned long           fb_local_base;
 
        struct pci_dev          *pdev;
-#ifdef CONFIG_PPC_OF
+#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC)
        struct device_node      *of_node;
 #endif
 
        void __iomem            *bios_seg;
        int                     fp_bios_start;
 
-       u32                     pseudo_palette[17];
+       u32                     pseudo_palette[16];
        struct { u8 red, green, blue, pad; }
                                palette[256];
 
@@ -352,28 +361,10 @@ struct radeonfb_info {
 #ifdef CONFIG_FB_RADEON_I2C
        struct radeon_i2c_chan  i2c[4];
 #endif
-
-       u32                     cfg_save[64];
 };
 
 
 #define PRIMARY_MONITOR(rinfo) (rinfo->mon1_type)
-
-
-/*
- * Debugging stuffs
- */
-#ifdef CONFIG_FB_RADEON_DEBUG
-#define DEBUG          1
-#else
-#define DEBUG          0
-#endif
-
-#if DEBUG
-#define RTRACE         printk
-#else
-#define RTRACE         if(0) printk
-#endif
 
 
 /*
@@ -541,22 +532,6 @@ static inline u32 radeon_get_dstbpp(u16 
 /*
  * 2D Engine helper routines
  */
-static inline void radeon_engine_flush (struct radeonfb_info *rinfo)
-{
-       int i;
-
-       /* initiate flush */
-       OUTREGP(RB2D_DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL,
-               ~RB2D_DC_FLUSH_ALL);
-
-       for (i=0; i < 2000000; i++) {
-               if (!(INREG(RB2D_DSTCACHE_CTLSTAT) & RB2D_DC_BUSY))
-                       return;
-               udelay(1);
-       }
-       printk(KERN_ERR "radeonfb: Flush Timeout !\n");
-}
-
 
 static inline void _radeon_fifo_wait(struct radeonfb_info *rinfo, int entries)
 {
@@ -568,6 +543,28 @@ static inline void _radeon_fifo_wait(str
                udelay(1);
        }
        printk(KERN_ERR "radeonfb: FIFO Timeout !\n");
+}
+
+static inline void radeon_engine_flush (struct radeonfb_info *rinfo)
+{
+       int i;
+
+       /* Initiate flush */
+       OUTREGP(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL,
+               ~RB2D_DC_FLUSH_ALL);
+
+       /* Ensure FIFO is empty, ie, make sure the flush commands
+        * has reached the cache
+        */
+       _radeon_fifo_wait (rinfo, 64);
+
+       /* Wait for the flush to complete */
+       for (i=0; i < 2000000; i++) {
+               if (!(INREG(DSTCACHE_CTLSTAT) & RB2D_DC_BUSY))
+                       return;
+               udelay(1);
+       }
+       printk(KERN_ERR "radeonfb: Flush Timeout !\n");
 }
 
 
diff -r 1db1bb63824b -r 0659978a1911 include/linux/radeonfb.h
--- a/include/linux/radeonfb.h  Mon Nov 23 07:32:47 2009 +0000
+++ b/include/linux/radeonfb.h  Mon Nov 23 23:17:38 2009 +0100
@@ -2,7 +2,7 @@
 #define __LINUX_RADEONFB_H__
 
 #include <asm/ioctl.h>
-#include <asm/types.h>
+#include <linux/types.h>
 
 #define ATY_RADEON_LCD_ON      0x00000001
 #define ATY_RADEON_CRT_ON      0x00000002
diff -r 1db1bb63824b -r 0659978a1911 include/video/aty128.h
--- a/include/video/aty128.h    Mon Nov 23 07:32:47 2009 +0000
+++ b/include/video/aty128.h    Mon Nov 23 23:17:38 2009 +0100
@@ -21,9 +21,9 @@
 #define I2C_CNTL_1                             0x0094
 #define PALETTE_INDEX                          0x00b0
 #define PALETTE_DATA                           0x00b4
-#define CONFIG_CNTL                            0x00e0
+#define CNFG_CNTL                              0x00e0
 #define GEN_RESET_CNTL                         0x00f0
-#define CONFIG_MEMSIZE                         0x00f8
+#define CNFG_MEMSIZE                           0x00f8
 #define MEM_CNTL                               0x0140
 #define MEM_POWER_MISC                         0x015c
 #define AGP_BASE                               0x0170
diff -r 1db1bb63824b -r 0659978a1911 include/video/mach64.h
--- a/include/video/mach64.h    Mon Nov 23 07:32:47 2009 +0000
+++ b/include/video/mach64.h    Mon Nov 23 23:17:38 2009 +0100
@@ -103,7 +103,7 @@
 #define CUR_HORZ_VERT_OFF      0x0070  /* Dword offset 0_1C */
 #define CUR2_HORZ_VERT_OFF     0x0070  /* Dword offset 0_1C */
 
-#define CONFIG_PANEL_LG                0x0074  /* Dword offset 0_1D (LG) */
+#define CNFG_PANEL_LG          0x0074  /* Dword offset 0_1D (LG) */
 
 /* General I/O Control */
 #define GP_IO                  0x0078  /* Dword offset 0_1E */
@@ -146,8 +146,8 @@
 #define CLOCK_SEL_CNTL         0x0090  /* Dword offset 0_24 */
 
 /* Configuration */
-#define CONFIG_STAT1           0x0094  /* Dword offset 0_25 */
-#define CONFIG_STAT2           0x0098  /* Dword offset 0_26 */
+#define CNFG_STAT1             0x0094  /* Dword offset 0_25 */
+#define CNFG_STAT2             0x0098  /* Dword offset 0_26 */
 
 /* Bus Control */
 #define BUS_CNTL               0x00A0  /* Dword offset 0_28 */
@@ -190,9 +190,9 @@
 #define POWER_MANAGEMENT_LG    0x00D8  /* Dword offset 0_36 (LG) */
 
 /* Configuration */
-#define CONFIG_CNTL            0x00DC  /* Dword offset 0_37 (CT, ET, VT) */
-#define CONFIG_CHIP_ID         0x00E0  /* Dword offset 0_38 */
-#define CONFIG_STAT0           0x00E4  /* Dword offset 0_39 */
+#define CNFG_CNTL              0x00DC  /* Dword offset 0_37 (CT, ET, VT) */
+#define CNFG_CHIP_ID           0x00E0  /* Dword offset 0_38 */
+#define CNFG_STAT0             0x00E4  /* Dword offset 0_39 */
 
 /* Test and Debug */
 #define CRC_SIG                        0x00E8  /* Dword offset 0_3A */
@@ -851,17 +851,17 @@
 #define PLL_YCLK_CNTL          0x29
 #define PM_DYN_CLK_CNTL                0x2A
 
-/* CONFIG_CNTL register constants */
+/* CNFG_CNTL register constants */
 #define APERTURE_4M_ENABLE     1
 #define APERTURE_8M_ENABLE     2
 #define VGA_APERTURE_ENABLE    4
 
-/* CONFIG_STAT0 register constants (GX, CX) */
+/* CNFG_STAT0 register constants (GX, CX) */
 #define CFG_BUS_TYPE           0x00000007
 #define CFG_MEM_TYPE           0x00000038
 #define CFG_INIT_DAC_TYPE      0x00000e00
 
-/* CONFIG_STAT0 register constants (CT, ET, VT) */
+/* CNFG_STAT0 register constants (CT, ET, VT) */
 #define CFG_MEM_TYPE_xT                0x00000007
 
 #define ISA                    0
@@ -885,6 +885,7 @@
 #define SDRAM                  4
 #define SGRAM                  5
 #define WRAM                   6
+#define SDRAM32                        6
 
 #define DAC_INTERNAL           0x00
 #define DAC_IBMRGB514          0x01
@@ -941,7 +942,7 @@
 #define PCI_ATI_VENDOR_ID      0x1002
 
 
-/* CONFIG_CHIP_ID register constants */
+/* CNFG_CHIP_ID register constants */
 #define CFG_CHIP_TYPE          0x0000FFFF
 #define CFG_CHIP_CLASS         0x00FF0000
 #define CFG_CHIP_REV           0xFF000000
@@ -950,7 +951,7 @@
 #define CFG_CHIP_MINOR         0xC0000000
 
 
-/* Chip IDs read from CONFIG_CHIP_ID */
+/* Chip IDs read from CNFG_CHIP_ID */
 
 /* mach64GX family */
 #define GX_CHIP_ID     0xD7    /* mach64GX (ATI888GX00) */
@@ -1253,7 +1254,7 @@
 #define CRTC2_DISPLAY_DIS      0x00000400
 
 /* LCD register indices */
-#define CONFIG_PANEL           0x00
+#define CNFG_PANEL             0x00
 #define LCD_GEN_CNTL           0x01
 #define DSTN_CONTROL           0x02
 #define HFB_PITCH_ADDR         0x03
diff -r 1db1bb63824b -r 0659978a1911 include/video/radeon.h
--- a/include/video/radeon.h    Mon Nov 23 07:32:47 2009 +0000
+++ b/include/video/radeon.h    Mon Nov 23 23:17:38 2009 +0100
@@ -11,13 +11,13 @@
 #define HI_STAT                                0x004C  
 #define BUS_CNTL1                              0x0034
 #define I2C_CNTL_1                            0x0094  
-#define CONFIG_CNTL                            0x00E0  
-#define CONFIG_MEMSIZE                         0x00F8  
-#define CONFIG_APER_0_BASE                     0x0100  
-#define CONFIG_APER_1_BASE                     0x0104  
-#define CONFIG_APER_SIZE                       0x0108  
-#define CONFIG_REG_1_BASE                      0x010C  
-#define CONFIG_REG_APER_SIZE                   0x0110  
+#define CNFG_CNTL                              0x00E0
+#define CNFG_MEMSIZE                           0x00F8
+#define CNFG_APER_0_BASE                       0x0100
+#define CNFG_APER_1_BASE                       0x0104
+#define CNFG_APER_SIZE                         0x0108
+#define CNFG_REG_1_BASE                        0x010C
+#define CNFG_REG_APER_SIZE                     0x0110
 #define PAD_AGPINPUT_DELAY                     0x0164  
 #define PAD_CTLR_STRENGTH                      0x0168  
 #define PAD_CTLR_UPDATE                        0x016C
@@ -386,7 +386,7 @@
 #define SC_BOTTOM_RIGHT                        0x16F0  
 #define SRC_SC_BOTTOM_RIGHT                    0x16F4  
 #define RB2D_DSTCACHE_MODE                    0x3428
-#define RB2D_DSTCACHE_CTLSTAT                 0x342C
+#define RB2D_DSTCACHE_CTLSTAT_broken          0x342C /* do not use */
 #define LVDS_GEN_CNTL                         0x02d0
 #define LVDS_PLL_CNTL                         0x02d4
 #define FP2_GEN_CNTL                           0x0288
@@ -509,7 +509,7 @@
 /* CLOCK_CNTL_INDEX bit constants */
 #define PLL_WR_EN                                  0x00000080
 
-/* CONFIG_CNTL bit constants */
+/* CNFG_CNTL bit constants */
 #define CFG_VGA_RAM_EN                             0x00000100
 #define CFG_ATI_REV_ID_MASK                       (0xf << 16)
 #define CFG_ATI_REV_A11                                   (0 << 16)
@@ -527,10 +527,14 @@
 
 
 /* DSTCACHE_CTLSTAT bit constants */
-#define RB2D_DC_FLUSH                             (3 << 0)
-#define RB2D_DC_FLUSH_ALL                         0xf
+#define RB2D_DC_FLUSH_2D                          (1 << 0)
+#define RB2D_DC_FREE_2D                                   (1 << 2)
+#define RB2D_DC_FLUSH_ALL                         (RB2D_DC_FLUSH_2D | 
RB2D_DC_FREE_2D)
 #define RB2D_DC_BUSY                              (1 << 31)
 
+/* DSTCACHE_MODE bits constants */
+#define RB2D_DC_AUTOFLUSH_ENABLE                   (1 << 8)
+#define RB2D_DC_DC_DISABLE_IGNORE_PE               (1 << 17)
 
 /* CRTC_GEN_CNTL bit constants */
 #define CRTC_DBL_SCAN_EN                           0x00000001
@@ -740,6 +744,10 @@
 #define SOFT_RESET_E2                             (1 <<  5)
 #define SOFT_RESET_RB                             (1 <<  6)
 #define SOFT_RESET_HDP                            (1 <<  7)
+
+/* WAIT_UNTIL bit constants */
+#define WAIT_DMA_GUI_IDLE                         (1 << 9)
+#define WAIT_2D_IDLECLEAN                         (1 << 16)
 
 /* SURFACE_CNTL bit consants */
 #define SURF_TRANSLATION_DIS                      (1 << 8)
@@ -972,7 +980,7 @@
 
 /* masks */
 
-#define CONFIG_MEMSIZE_MASK            0x1f000000
+#define CNFG_MEMSIZE_MASK              0x1f000000
 #define MEM_CFG_TYPE                   0x40000000
 #define DST_OFFSET_MASK                        0x003fffff
 #define DST_PITCH_MASK                 0x3fc00000

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.