Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
[firefly-linux-kernel-4.4.55.git] / arch / powerpc / platforms / 85xx / mpc85xx_mds.c
index a23a3ff634c55fdd3d949a8a2a77a8405b5b2de8..f33662b46b8d31052028c4ff779b5a4d8fc064d1 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) Freescale Semicondutor, Inc. 2006-2010. All rights reserved.
+ * Copyright (C) 2006-2010, 2012 Freescale Semicondutor, Inc.
+ * All rights reserved.
  *
  * Author: Andy Fleming <afleming@freescale.com>
  *
 #include <asm/qe_ic.h>
 #include <asm/mpic.h>
 #include <asm/swiotlb.h>
+#include <asm/fsl_guts.h>
+#include "smp.h"
+
+#include "mpc85xx.h"
 
 #undef DEBUG
 #ifdef DEBUG
@@ -153,30 +158,7 @@ static int mpc8568_mds_phy_fixups(struct phy_device *phydev)
  * Setup the architecture
  *
  */
-#ifdef CONFIG_SMP
-extern void __init mpc85xx_smp_init(void);
-#endif
-
 #ifdef CONFIG_QUICC_ENGINE
-static struct of_device_id mpc85xx_qe_ids[] __initdata = {
-       { .type = "qe", },
-       { .compatible = "fsl,qe", },
-       { },
-};
-
-static void __init mpc85xx_publish_qe_devices(void)
-{
-       struct device_node *np;
-
-       np = of_find_compatible_node(NULL, NULL, "fsl,qe");
-       if (!of_device_is_available(np)) {
-               of_node_put(np);
-               return;
-       }
-
-       of_platform_bus_probe(NULL, mpc85xx_qe_ids, NULL);
-}
-
 static void __init mpc85xx_mds_reset_ucc_phys(void)
 {
        struct device_node *np;
@@ -288,34 +270,27 @@ static void __init mpc85xx_mds_qe_init(void)
        mpc85xx_mds_reset_ucc_phys();
 
        if (machine_is(p1021_mds)) {
-#define MPC85xx_PMUXCR_OFFSET           0x60
-#define MPC85xx_PMUXCR_QE0              0x00008000
-#define MPC85xx_PMUXCR_QE3              0x00001000
-#define MPC85xx_PMUXCR_QE9              0x00000040
-#define MPC85xx_PMUXCR_QE12             0x00000008
-               static __be32 __iomem *pmuxcr;
 
-               np = of_find_node_by_name(NULL, "global-utilities");
+               struct ccsr_guts_85xx __iomem *guts;
 
+               np = of_find_node_by_name(NULL, "global-utilities");
                if (np) {
-                       pmuxcr = of_iomap(np, 0) + MPC85xx_PMUXCR_OFFSET;
-
-                       if (!pmuxcr)
-                               printk(KERN_EMERG "Error: Alternate function"
-                                       " signal multiplex control register not"
-                                       " mapped!\n");
-                       else
+                       guts = of_iomap(np, 0);
+                       if (!guts)
+                               pr_err("mpc85xx-rdb: could not map global utilities register\n");
+                       else{
                        /* P1021 has pins muxed for QE and other functions. To
                         * enable QE UEC mode, we need to set bit QE0 for UCC1
                         * in Eth mode, QE0 and QE3 for UCC5 in Eth mode, QE9
                         * and QE12 for QE MII management signals in PMUXCR
                         * register.
                         */
-                               setbits32(pmuxcr, MPC85xx_PMUXCR_QE0 |
-                                                 MPC85xx_PMUXCR_QE3 |
-                                                 MPC85xx_PMUXCR_QE9 |
-                                                 MPC85xx_PMUXCR_QE12);
-
+                               setbits32(&guts->pmuxcr, MPC85xx_PMUXCR_QE(0) |
+                                                 MPC85xx_PMUXCR_QE(3) |
+                                                 MPC85xx_PMUXCR_QE(9) |
+                                                 MPC85xx_PMUXCR_QE(12));
+                               iounmap(guts);
+                       }
                        of_node_put(np);
                }
 
@@ -347,7 +322,6 @@ static void __init mpc85xx_mds_qeic_init(void)
        of_node_put(np);
 }
 #else
-static void __init mpc85xx_publish_qe_devices(void) { }
 static void __init mpc85xx_mds_qe_init(void) { }
 static void __init mpc85xx_mds_qeic_init(void) { }
 #endif /* CONFIG_QUICC_ENGINE */
@@ -381,9 +355,7 @@ static void __init mpc85xx_mds_setup_arch(void)
        }
 #endif
 
-#ifdef CONFIG_SMP
        mpc85xx_smp_init();
-#endif
 
        mpc85xx_mds_qe_init();
 
@@ -429,24 +401,11 @@ machine_arch_initcall(mpc8568_mds, board_fixups);
 machine_arch_initcall(mpc8569_mds, board_fixups);
 
 static struct of_device_id mpc85xx_ids[] = {
-       { .type = "soc", },
-       { .compatible = "soc", },
-       { .compatible = "simple-bus", },
-       { .compatible = "gianfar", },
-       { .compatible = "fsl,rapidio-delta", },
        { .compatible = "fsl,mpc8548-guts", },
        { .compatible = "gpio-leds", },
        {},
 };
 
-static struct of_device_id p1021_ids[] = {
-       { .type = "soc", },
-       { .compatible = "soc", },
-       { .compatible = "simple-bus", },
-       { .compatible = "gianfar", },
-       {},
-};
-
 static int __init mpc85xx_publish_devices(void)
 {
        if (machine_is(mpc8568_mds))
@@ -454,23 +413,15 @@ static int __init mpc85xx_publish_devices(void)
        if (machine_is(mpc8569_mds))
                simple_gpiochip_init("fsl,mpc8569mds-bcsr-gpio");
 
+       mpc85xx_common_publish_devices();
        of_platform_bus_probe(NULL, mpc85xx_ids, NULL);
-       mpc85xx_publish_qe_devices();
-
-       return 0;
-}
-
-static int __init p1021_publish_devices(void)
-{
-       of_platform_bus_probe(NULL, p1021_ids, NULL);
-       mpc85xx_publish_qe_devices();
 
        return 0;
 }
 
 machine_device_initcall(mpc8568_mds, mpc85xx_publish_devices);
 machine_device_initcall(mpc8569_mds, mpc85xx_publish_devices);
-machine_device_initcall(p1021_mds, p1021_publish_devices);
+machine_device_initcall(p1021_mds, mpc85xx_common_publish_devices);
 
 machine_arch_initcall(mpc8568_mds, swiotlb_setup_bus_notifier);
 machine_arch_initcall(mpc8569_mds, swiotlb_setup_bus_notifier);
@@ -478,26 +429,10 @@ machine_arch_initcall(p1021_mds, swiotlb_setup_bus_notifier);
 
 static void __init mpc85xx_mds_pic_init(void)
 {
-       struct mpic *mpic;
-       struct resource r;
-       struct device_node *np = NULL;
-
-       np = of_find_node_by_type(NULL, "open-pic");
-       if (!np)
-               return;
-
-       if (of_address_to_resource(np, 0, &r)) {
-               printk(KERN_ERR "Failed to map mpic register space\n");
-               of_node_put(np);
-               return;
-       }
-
-       mpic = mpic_alloc(np, r.start,
-                       MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
-                       MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
+       struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
+                       MPIC_SINGLE_DEST_CPU,
                        0, 256, " OpenPIC  ");
        BUG_ON(mpic == NULL);
-       of_node_put(np);
 
        mpic_init(mpic);
        mpc85xx_mds_qeic_init();