[PATCH] powerpc: Remove device_node addrs/n_addr
[pandora-kernel.git] / arch / powerpc / platforms / powermac / feature.c
index 0d7fa00..b1f8969 100644 (file)
@@ -1445,20 +1445,55 @@ static long g5_i2s_enable(struct device_node *node, long param, long value)
        /* Very crude implementation for now */
        struct macio_chip *macio = &macio_chips[0];
        unsigned long flags;
-
-       if (value == 0)
-               return 0; /* don't disable yet */
+       int cell;
+       u32 fcrs[3][3] = {
+               { 0,
+                 K2_FCR1_I2S0_CELL_ENABLE |
+                 K2_FCR1_I2S0_CLK_ENABLE_BIT | K2_FCR1_I2S0_ENABLE,
+                 KL3_I2S0_CLK18_ENABLE
+               },
+               { KL0_SCC_A_INTF_ENABLE,
+                 K2_FCR1_I2S1_CELL_ENABLE |
+                 K2_FCR1_I2S1_CLK_ENABLE_BIT | K2_FCR1_I2S1_ENABLE,
+                 KL3_I2S1_CLK18_ENABLE
+               },
+               { KL0_SCC_B_INTF_ENABLE,
+                 SH_FCR1_I2S2_CELL_ENABLE |
+                 SH_FCR1_I2S2_CLK_ENABLE_BIT | SH_FCR1_I2S2_ENABLE,
+                 SH_FCR3_I2S2_CLK18_ENABLE
+               },
+       };
+
+       if (macio->type != macio_keylargo2 /* && macio->type != macio_shasta*/)
+               return -ENODEV;
+       if (strncmp(node->name, "i2s-", 4))
+               return -ENODEV;
+       cell = node->name[4] - 'a';
+       switch(cell) {
+       case 0:
+       case 1:
+               break;
+#if 0
+       case 2:
+               if (macio->type == macio_shasta)
+                       break;
+#endif
+       default:
+               return -ENODEV;
+       }
 
        LOCK(flags);
-       MACIO_BIS(KEYLARGO_FCR3, KL3_CLK45_ENABLE | KL3_CLK49_ENABLE |
-                 KL3_I2S0_CLK18_ENABLE);
-       udelay(10);
-       MACIO_BIS(KEYLARGO_FCR1, K2_FCR1_I2S0_CELL_ENABLE |
-                 K2_FCR1_I2S0_CLK_ENABLE_BIT | K2_FCR1_I2S0_ENABLE);
+       if (value) {
+               MACIO_BIC(KEYLARGO_FCR0, fcrs[cell][0]);
+               MACIO_BIS(KEYLARGO_FCR1, fcrs[cell][1]);
+               MACIO_BIS(KEYLARGO_FCR3, fcrs[cell][2]);
+       } else {
+               MACIO_BIC(KEYLARGO_FCR3, fcrs[cell][2]);
+               MACIO_BIC(KEYLARGO_FCR1, fcrs[cell][1]);
+               MACIO_BIS(KEYLARGO_FCR0, fcrs[cell][0]);
+       }
        udelay(10);
-       MACIO_BIC(KEYLARGO_FCR1, K2_FCR1_I2S0_RESET);
        UNLOCK(flags);
-       udelay(10);
 
        return 0;
 }
@@ -1650,11 +1685,19 @@ void pmac_tweak_clock_spreading(int enable)
         */
 
        if (macio->type == macio_intrepid) {
-               if (enable)
-                       UN_OUT(UNI_N_CLOCK_SPREADING, 2);
-               else
-                       UN_OUT(UNI_N_CLOCK_SPREADING, 0);
-               mdelay(40);
+               struct device_node *clock =
+                       of_find_node_by_path("/uni-n@f8000000/hw-clock");
+               if (clock && get_property(clock, "platform-do-clockspreading",
+                                         NULL)) {
+                       printk(KERN_INFO "%sabling clock spreading on Intrepid"
+                              " ASIC\n", enable ? "En" : "Dis");
+                       if (enable)
+                               UN_OUT(UNI_N_CLOCK_SPREADING, 2);
+                       else
+                               UN_OUT(UNI_N_CLOCK_SPREADING, 0);
+                       mdelay(40);
+               }
+               of_node_put(clock);
        }
 
        while (machine_is_compatible("PowerBook5,2") ||
@@ -1724,6 +1767,9 @@ void pmac_tweak_clock_spreading(int enable)
                        pmac_low_i2c_close(ui2c);
                        break;
                }
+               printk(KERN_INFO "%sabling clock spreading on i2c clock chip\n",
+                      enable ? "En" : "Dis");
+
                pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_stdsub);
                rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_write, 0x80, buffer, 9);
                DBG("write result: %d,", rc);
@@ -2596,6 +2642,8 @@ found:
  */
 static void __init probe_uninorth(void)
 {
+       u32 *addrp;
+       phys_addr_t address;
        unsigned long actrl;
 
        /* Locate core99 Uni-N */
@@ -2605,20 +2653,23 @@ static void __init probe_uninorth(void)
                uninorth_node = of_find_node_by_name(NULL, "u3");
                uninorth_u3 = 1;
        }
-       if (uninorth_node && uninorth_node->n_addrs > 0) {
-               unsigned long address = uninorth_node->addrs[0].address;
-               uninorth_base = ioremap(address, 0x40000);
-               uninorth_rev = in_be32(UN_REG(UNI_N_VERSION));
-               if (uninorth_u3)
-                       u3_ht = ioremap(address + U3_HT_CONFIG_BASE, 0x1000);
-       } else
-               uninorth_node = NULL;
-
-       if (!uninorth_node)
+       if (uninorth_node == NULL)
                return;
 
-       printk(KERN_INFO "Found %s memory controller & host bridge, revision: %d\n",
-              uninorth_u3 ? "U3" : "UniNorth", uninorth_rev);
+       addrp = (u32 *)get_property(uninorth_node, "reg", NULL);
+       if (addrp == NULL)
+               return;
+       address = of_translate_address(uninorth_node, addrp);
+       if (address == 0)
+               return;
+       uninorth_base = ioremap(address, 0x40000);
+       uninorth_rev = in_be32(UN_REG(UNI_N_VERSION));
+       if (uninorth_u3)
+               u3_ht = ioremap(address + U3_HT_CONFIG_BASE, 0x1000);
+
+       printk(KERN_INFO "Found %s memory controller & host bridge,"
+              " revision: %d\n", uninorth_u3 ? "U3" : "UniNorth",
+              uninorth_rev);
        printk(KERN_INFO "Mapped at 0x%08lx\n", (unsigned long)uninorth_base);
 
        /* Set the arbitrer QAck delay according to what Apple does
@@ -2642,18 +2693,17 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ
 {
        struct device_node*     node;
        int                     i;
-       volatile u32 __iomem *  base;
-       u32*                    revp;
+       volatile u32 __iomem    *base;
+       u32                     *addrp, *revp;
+       phys_addr_t             addr;
+       u64                     size;
 
-       node = find_devices(name);
-       if (!node || !node->n_addrs)
-               return;
-       if (compat)
-               do {
-                       if (device_is_compatible(node, compat))
-                               break;
-                       node = node->next;
-               } while (node);
+       for (node = NULL; (node = of_find_node_by_name(node, name)) != NULL;) {
+               if (!compat)
+                       break;
+               if (device_is_compatible(node, compat))
+                       break;
+       }
        if (!node)
                return;
        for(i=0; i<MAX_MACIO_CHIPS; i++) {
@@ -2662,14 +2712,28 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ
                if (macio_chips[i].of_node == node)
                        return;
        }
+
        if (i >= MAX_MACIO_CHIPS) {
                printk(KERN_ERR "pmac_feature: Please increase MAX_MACIO_CHIPS !\n");
                printk(KERN_ERR "pmac_feature: %s skipped\n", node->full_name);
                return;
        }
-       base = ioremap(node->addrs[0].address, node->addrs[0].size);
+       addrp = of_get_pci_address(node, 0, &size, NULL);
+       if (addrp == NULL) {
+               printk(KERN_ERR "pmac_feature: %s: can't find base !\n",
+                      node->full_name);
+               return;
+       }
+       addr = of_translate_address(node, addrp);
+       if (addr == 0) {
+               printk(KERN_ERR "pmac_feature: %s, can't translate base !\n",
+                      node->full_name);
+               return;
+       }
+       base = ioremap(addr, (unsigned long)size);
        if (!base) {
-               printk(KERN_ERR "pmac_feature: Can't map mac-io chip !\n");
+               printk(KERN_ERR "pmac_feature: %s, can't map mac-io chip !\n",
+                      node->full_name);
                return;
        }
        if (type == macio_keylargo) {
@@ -2931,26 +2995,6 @@ pmac_feature_init(void)
        set_initial_features();
 }
 
-int __init pmac_feature_late_init(void)
-{
-#if 0
-       struct device_node *np;
-
-       /* Request some resources late */
-       if (uninorth_node)
-               request_OF_resource(uninorth_node, 0, NULL);
-       np = find_devices("hammerhead");
-       if (np)
-               request_OF_resource(np, 0, NULL);
-       np = find_devices("interrupt-controller");
-       if (np)
-               request_OF_resource(np, 0, NULL);
-#endif
-       return 0;
-}
-
-device_initcall(pmac_feature_late_init);
-
 #if 0
 static void dump_HT_speeds(char *name, u32 cfg, u32 frq)
 {