atyfb: Fix XCLK frequency on Apple iBook1
[sfrench/cifs-2.6.git] / drivers / video / aty / atyfb_base.c
index d7627fc4f11ee82d094a763e8225a2e26172c974..2fbff63174333b08909c87d438ab0e1ac708efad 100644 (file)
@@ -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
@@ -2289,29 +2290,6 @@ static int __devinit aty_init(struct fb_info *info)
        init_waitqueue_head(&par->vblank.wait);
        spin_lock_init(&par->int_lock);
 
-#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;
@@ -2338,6 +2316,7 @@ static int __devinit aty_init(struct fb_info *info)
                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;
@@ -2346,6 +2325,7 @@ static int __devinit aty_init(struct fb_info *info)
                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;
@@ -2389,8 +2369,37 @@ static int __devinit aty_init(struct fb_info *info)
                /* 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;
+               /* 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);
 
@@ -2899,7 +2908,7 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev,
                        struct fb_info *info, unsigned long addr)
 {
        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;
@@ -3037,8 +3046,8 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev,
                        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;