powerpc/5xxx: Add common mpc5xxx_get_bus_frequency() function
authorWolfgang Denk <wd@denx.de>
Wed, 17 Jun 2009 06:30:22 +0000 (00:30 -0600)
committerGrant Likely <grant.likely@secretlab.ca>
Wed, 17 Jun 2009 06:30:22 +0000 (00:30 -0600)
So far, MPC512x used mpc512x_find_ips_freq() to get the bus frequency,
while MPC52xx used mpc52xx_find_ipb_freq().  Despite the different
clock names (IPS vs. IPB) the code was identical.

Use common code for both processor families.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
15 files changed:
arch/powerpc/include/asm/mpc512x.h [deleted file]
arch/powerpc/include/asm/mpc52xx.h
arch/powerpc/include/asm/mpc5xxx.h [new file with mode: 0644]
arch/powerpc/platforms/512x/clock.c
arch/powerpc/platforms/512x/mpc512x.h
arch/powerpc/platforms/512x/mpc512x_shared.c
arch/powerpc/platforms/52xx/mpc52xx_common.c
arch/powerpc/sysdev/Makefile
arch/powerpc/sysdev/mpc5xxx_clocks.c [new file with mode: 0644]
drivers/ata/pata_mpc52xx.c
drivers/i2c/busses/i2c-mpc.c
drivers/net/fec_mpc52xx.c
drivers/net/fec_mpc52xx_phy.c
drivers/serial/mpc52xx_uart.c
drivers/watchdog/mpc5200_wdt.c

diff --git a/arch/powerpc/include/asm/mpc512x.h b/arch/powerpc/include/asm/mpc512x.h
deleted file mode 100644 (file)
index c48a165..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
- *
- * Author: John Rigby, <jrigby@freescale.com>, Friday Apr 13 2007
- *
- * Description:
- * MPC5121 Prototypes and definitions
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- */
-
-#ifndef __ASM_POWERPC_MPC512x_H__
-#define __ASM_POWERPC_MPC512x_H__
-
-extern unsigned long mpc512x_find_ips_freq(struct device_node *node);
-
-#endif /* __ASM_POWERPC_MPC512x_H__ */
-
index 52e049cd9e687c09b2b95eb5b71082cecca5bfb9..1b4f697abbddf0268e18506029da422eef214156 100644 (file)
@@ -16,6 +16,7 @@
 #ifndef __ASSEMBLY__
 #include <asm/types.h>
 #include <asm/prom.h>
+#include <asm/mpc5xxx.h>
 #endif /* __ASSEMBLY__ */
 
 #include <linux/suspend.h>
@@ -268,7 +269,6 @@ struct mpc52xx_intr {
 #ifndef __ASSEMBLY__
 
 /* mpc52xx_common.c */
-extern unsigned int mpc52xx_find_ipb_freq(struct device_node *node);
 extern void mpc5200_setup_xlb_arbiter(void);
 extern void mpc52xx_declare_of_platform_devices(void);
 extern void mpc52xx_map_common_devices(void);
diff --git a/arch/powerpc/include/asm/mpc5xxx.h b/arch/powerpc/include/asm/mpc5xxx.h
new file mode 100644 (file)
index 0000000..5ce9c5f
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * Author: John Rigby, <jrigby@freescale.com>, Friday Apr 13 2007
+ *
+ * Description:
+ * MPC5xxx Prototypes and definitions
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#ifndef __ASM_POWERPC_MPC5xxx_H__
+#define __ASM_POWERPC_MPC5xxx_H__
+
+extern unsigned long mpc5xxx_get_bus_frequency(struct device_node *node);
+
+#endif /* __ASM_POWERPC_MPC5xxx_H__ */
+
index 1bcff94eb924b054575ac58aba4a6713c0a6d0f9..f4c4c6f807d772e497c59a044b68e805168580d6 100644 (file)
@@ -24,7 +24,7 @@
 #include <linux/io.h>
 
 #include <linux/of_platform.h>
-#include <asm/mpc512x.h>
+#include <asm/mpc5xxx.h>
 #include <asm/clk_interface.h>
 
 #undef CLK_DEBUG
index 9c03693cb0097ae1c6a5dd7ece523ad36fbaddd5..22a5352407e0ae0c64ed5bd00177cc211156e792 100644 (file)
@@ -11,7 +11,6 @@
 
 #ifndef __MPC512X_H__
 #define __MPC512X_H__
-extern unsigned long mpc512x_find_ips_freq(struct device_node *node);
 extern void __init mpc512x_init_IRQ(void);
 void __init mpc512x_declare_of_platform_devices(void);
 #endif                         /* __MPC512X_H__ */
index d8cd579f3191b8955e897f7be21d0912105763ae..434d683df5a0e927931660fb55a328ffc40301e4 100644 (file)
 
 #include "mpc512x.h"
 
-unsigned long
-mpc512x_find_ips_freq(struct device_node *node)
-{
-       struct device_node *np;
-       const unsigned int *p_ips_freq = NULL;
-
-       of_node_get(node);
-       while (node) {
-               p_ips_freq = of_get_property(node, "bus-frequency", NULL);
-               if (p_ips_freq)
-                       break;
-
-               np = of_get_parent(node);
-               of_node_put(node);
-               node = np;
-       }
-       if (node)
-               of_node_put(node);
-
-       return p_ips_freq ? *p_ips_freq : 0;
-}
-EXPORT_SYMBOL(mpc512x_find_ips_freq);
-
 void __init mpc512x_init_IRQ(void)
 {
        struct device_node *np;
index 8e3dd5a0f228d67fc305731ebddf12fbe2f80b39..a46bad0c2339732555dacd4806a75bf7dcc15c19 100644 (file)
@@ -47,36 +47,6 @@ static DEFINE_SPINLOCK(mpc52xx_lock);
 static struct mpc52xx_gpt __iomem *mpc52xx_wdt;
 static struct mpc52xx_cdm __iomem *mpc52xx_cdm;
 
-/**
- *     mpc52xx_find_ipb_freq - Find the IPB bus frequency for a device
- *     @node:  device node
- *
- *     Returns IPB bus frequency, or 0 if the bus frequency cannot be found.
- */
-unsigned int
-mpc52xx_find_ipb_freq(struct device_node *node)
-{
-       struct device_node *np;
-       const unsigned int *p_ipb_freq = NULL;
-
-       of_node_get(node);
-       while (node) {
-               p_ipb_freq = of_get_property(node, "bus-frequency", NULL);
-               if (p_ipb_freq)
-                       break;
-
-               np = of_get_parent(node);
-               of_node_put(node);
-               node = np;
-       }
-       if (node)
-               of_node_put(node);
-
-       return p_ipb_freq ? *p_ipb_freq : 0;
-}
-EXPORT_SYMBOL(mpc52xx_find_ipb_freq);
-
-
 /*
  * Configure the XLB arbiter settings to match what Linux expects.
  */
@@ -221,7 +191,7 @@ unsigned int mpc52xx_get_xtal_freq(struct device_node *node)
        if (!mpc52xx_cdm)
                return 0;
 
-       freq = mpc52xx_find_ipb_freq(node);
+       freq = mpc5xxx_get_bus_frequency(node);
        if (!freq)
                return 0;
 
index d073bfdd222a7d8225fe04366bc8b9c28087c43e..9d4b17462f1308815b29a18368fbb14b37d9e9e6 100644 (file)
@@ -50,6 +50,9 @@ obj-$(CONFIG_PPC_DCR)         += dcr.o
 obj-$(CONFIG_8xx)              += mpc8xx_pic.o cpm1.o
 obj-$(CONFIG_UCODE_PATCH)      += micropatch.o
 
+obj-$(CONFIG_PPC_MPC512x)      += mpc5xxx_clocks.o
+obj-$(CONFIG_PPC_MPC52xx)      += mpc5xxx_clocks.o
+
 ifeq ($(CONFIG_SUSPEND),y)
 obj-$(CONFIG_6xx)              += 6xx-suspend.o
 endif
diff --git a/arch/powerpc/sysdev/mpc5xxx_clocks.c b/arch/powerpc/sysdev/mpc5xxx_clocks.c
new file mode 100644 (file)
index 0000000..34e12f9
--- /dev/null
@@ -0,0 +1,33 @@
+/**
+ *     mpc5xxx_get_bus_frequency - Find the bus frequency for a device
+ *     @node:  device node
+ *
+ *     Returns bus frequency (IPS on MPC512x, IPB on MPC52xx),
+ *     or 0 if the bus frequency cannot be found.
+ */
+
+#include <linux/kernel.h>
+#include <linux/of_platform.h>
+
+unsigned int
+mpc5xxx_get_bus_frequency(struct device_node *node)
+{
+       struct device_node *np;
+       const unsigned int *p_bus_freq = NULL;
+
+       of_node_get(node);
+       while (node) {
+               p_bus_freq = of_get_property(node, "bus-frequency", NULL);
+               if (p_bus_freq)
+                       break;
+
+               np = of_get_parent(node);
+               of_node_put(node);
+               node = np;
+       }
+       if (node)
+               of_node_put(node);
+
+       return p_bus_freq ? *p_bus_freq : 0;
+}
+EXPORT_SYMBOL(mpc5xxx_get_bus_frequency);
index 68d27bc70d06c8722038fe8d459755425fa293bd..2bc2dbe30e8fe6d4635cf90f986ad866926c0feb 100644 (file)
@@ -694,7 +694,7 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match)
        struct bcom_task *dmatsk = NULL;
 
        /* Get ipb frequency */
-       ipb_freq = mpc52xx_find_ipb_freq(op->node);
+       ipb_freq = mpc5xxx_get_bus_frequency(op->node);
        if (!ipb_freq) {
                dev_err(&op->dev, "could not determine IPB bus frequency\n");
                return -ENODEV;
index dd778d7ae047a35d7626e083dacf34e1d72d0552..d325e86e3103dc1059c754e51e7ee269c5cc1c8f 100644 (file)
@@ -197,7 +197,7 @@ int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler)
                return -EINVAL;
 
        /* Determine divider value */
-       divider = mpc52xx_find_ipb_freq(node) / clock;
+       divider = mpc5xxx_get_bus_frequency(node) / clock;
 
        /*
         * We want to choose an FDR/DFSR that generates an I2C bus speed that
index 8bbe7f6179949c30b167d82cb2236394af9332c4..5ddf03325d1634f8ba91176c20c0d96f649f6ff5 100644 (file)
@@ -1006,7 +1006,7 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
        priv->phy_addr = FEC5200_PHYADDR_NONE;
        priv->speed = 100;
        priv->duplex = DUPLEX_HALF;
-       priv->phy_speed = ((mpc52xx_find_ipb_freq(op->node) >> 20) / 5) << 1;
+       priv->phy_speed = ((mpc5xxx_get_bus_frequency(op->node) >> 20) / 5) << 1;
 
        /* the 7-wire property means don't use MII mode */
        if (of_find_property(op->node, "fsl,7-wire-mode", NULL))
index dd9bfa42ac348b3039c56d90dd6cab9f0c61fa50..176e9b8d7101fc6bbf6869a8cbb25a1a2be58c06 100644 (file)
@@ -120,7 +120,7 @@ static int mpc52xx_fec_mdio_probe(struct of_device *of,
 
        /* set MII speed */
        out_be32(&priv->regs->mii_speed,
-               ((mpc52xx_find_ipb_freq(of->node) >> 20) / 5) << 1);
+               ((mpc5xxx_get_bus_frequency(of->node) >> 20) / 5) << 1);
 
        err = mdiobus_register(bus);
        if (err)
index b3feb6198d57171b30edcf4d3a51cada259af29b..abbd146c50d97ae1c55c34c94d26b025a53179c8 100644 (file)
@@ -76,7 +76,6 @@
 #include <linux/of_platform.h>
 
 #include <asm/mpc52xx.h>
-#include <asm/mpc512x.h>
 #include <asm/mpc52xx_psc.h>
 
 #if defined(CONFIG_SERIAL_MPC52xx_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
@@ -254,7 +253,7 @@ static unsigned long mpc52xx_getuartclk(void *p)
         * but the generic serial code assumes 16
         * so return ipb freq / 2
         */
-       return mpc52xx_find_ipb_freq(p) / 2;
+       return mpc5xxx_get_bus_frequency(p) / 2;
 }
 
 static struct psc_ops mpc52xx_psc_ops = {
@@ -391,7 +390,7 @@ static void mpc512x_psc_cw_restore_ints(struct uart_port *port)
 
 static unsigned long mpc512x_getuartclk(void *p)
 {
-       return mpc512x_find_ips_freq(p);
+       return mpc5xxx_get_bus_frequency(p);
 }
 
 static struct psc_ops mpc512x_psc_ops = {
index 465fe36adad4db1ea03c35921aef1bd83a65ee8e..fa9c47ce0ae7b3d32a9c4a34a3747c2df08ae7d6 100644 (file)
@@ -188,7 +188,7 @@ static int mpc5200_wdt_probe(struct of_device *op,
        if (!wdt)
                return -ENOMEM;
 
-       wdt->ipb_freq = mpc52xx_find_ipb_freq(op->node);
+       wdt->ipb_freq = mpc5xxx_get_bus_frequency(op->node);
 
        err = of_address_to_resource(op->node, 0, &wdt->mem);
        if (err)