Pull platform-drivers into test branch
[powerpc.git] / drivers / video / aty / aty128fb.c
index c64a717..2e976ff 100644 (file)
@@ -455,7 +455,10 @@ static void do_wait_for_fifo(u16 entries, struct aty128fb_par *par);
 static void wait_for_fifo(u16 entries, struct aty128fb_par *par);
 static void wait_for_idle(struct aty128fb_par *par);
 static u32 depth_to_dst(u32 depth);
+
+#ifdef CONFIG_FB_ATY128_BACKLIGHT
 static void aty128_bl_set_power(struct fb_info *info, int power);
+#endif
 
 #define BIOS_IN8(v)    (readb(bios + (v)))
 #define BIOS_IN16(v)   (readb(bios + (v)) | \
@@ -1330,6 +1333,8 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
        if (vclk * 12 < c.ppll_min)
                vclk = c.ppll_min/12;
 
+       pll->post_divider = -1;
+
        /* now, find an acceptable divider */
        for (i = 0; i < sizeof(post_dividers); i++) {
                output_freq = post_dividers[i] * vclk;
@@ -1339,6 +1344,9 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
                }
        }
 
+       if (pll->post_divider < 0)
+               return -EINVAL;
+
        /* calculate feedback divider */
        n = c.ref_divider * output_freq;
        d = c.ref_clk;
@@ -1798,10 +1806,14 @@ static struct backlight_properties aty128_bl_data = {
 static void aty128_bl_set_power(struct fb_info *info, int power)
 {
        mutex_lock(&info->bl_mutex);
-       up(&info->bl_dev->sem);
-       info->bl_dev->props->power = power;
-       __aty128_bl_update_status(info->bl_dev);
-       down(&info->bl_dev->sem);
+
+       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);
 }
 
@@ -1822,10 +1834,10 @@ static void aty128_bl_init(struct aty128fb_par *par)
 
        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("aty128: Backlight registration failed\n");
+               printk(KERN_WARNING "aty128: Backlight registration failed\n");
                goto error;
        }
 
@@ -1836,11 +1848,11 @@ static void aty128_bl_init(struct aty128fb_par *par)
                219 * FB_BACKLIGHT_MAX / MAX_LEVEL);
        mutex_unlock(&info->bl_mutex);
 
-       up(&bd->sem);
+       down(&bd->sem);
        bd->props->brightness = aty128_bl_data.max_brightness;
        bd->props->power = FB_BLANK_UNBLANK;
        bd->props->update_status(bd);
-       down(&bd->sem);
+       up(&bd->sem);
 
 #ifdef CONFIG_PMAC_BACKLIGHT
        mutex_lock(&pmac_backlight_mutex);
@@ -1910,9 +1922,6 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i
        u8 chip_rev;
        u32 dac;
 
-       if (!par->vram_size)    /* may have already been probed */
-               par->vram_size = aty_ld_le32(CONFIG_MEMSIZE) & 0x03FFFFFF;
-
        /* Get the chip revision */
        chip_rev = (aty_ld_le32(CONFIG_CNTL) >> 16) & 0x1F;
 
@@ -2025,9 +2034,6 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i
 
        aty128_init_engine(par);
 
-       if (register_framebuffer(info) < 0)
-               return 0;
-
        par->pm_reg = pci_find_capability(pdev, PCI_CAP_ID_PM);
        par->pdev = pdev;
        par->asleep = 0;
@@ -2037,6 +2043,9 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i
        aty128_bl_init(par);
 #endif
 
+       if (register_framebuffer(info) < 0)
+               return 0;
+
        printk(KERN_INFO "fb%d: %s frame buffer device on %s\n",
               info->node, info->fix.id, video_card);
 
@@ -2086,7 +2095,6 @@ static int __devinit aty128_probe(struct pci_dev *pdev, const struct pci_device_
        par = info->par;
 
        info->pseudo_palette = par->pseudo_palette;
-       info->fix = aty128fb_fix;
 
        /* Virtualize mmio region */
        info->fix.mmio_start = reg_addr;