diff options
| author | Wolfgang Denk <wd@denx.de> | 2009-06-17 02:30:22 -0400 |
|---|---|---|
| committer | Grant Likely <grant.likely@secretlab.ca> | 2009-06-17 02:30:22 -0400 |
| commit | 87c441e54dfcf9f45593ecaf68e7e18ea53d5e13 (patch) | |
| tree | 6a986caab77412a90ffe8c5d8788bc1216b10ed8 | |
| parent | c155ee10c212254e9cdfe7b3eab4e8c13990c231 (diff) | |
powerpc/5xxx: Add common mpc5xxx_get_bus_frequency() function
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>
| -rw-r--r-- | arch/powerpc/include/asm/mpc52xx.h | 2 | ||||
| -rw-r--r-- | arch/powerpc/include/asm/mpc5xxx.h (renamed from arch/powerpc/include/asm/mpc512x.h) | 10 | ||||
| -rw-r--r-- | arch/powerpc/platforms/512x/clock.c | 2 | ||||
| -rw-r--r-- | arch/powerpc/platforms/512x/mpc512x.h | 1 | ||||
| -rw-r--r-- | arch/powerpc/platforms/512x/mpc512x_shared.c | 23 | ||||
| -rw-r--r-- | arch/powerpc/platforms/52xx/mpc52xx_common.c | 32 | ||||
| -rw-r--r-- | arch/powerpc/sysdev/Makefile | 3 | ||||
| -rw-r--r-- | arch/powerpc/sysdev/mpc5xxx_clocks.c | 33 | ||||
| -rw-r--r-- | drivers/ata/pata_mpc52xx.c | 2 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-mpc.c | 2 | ||||
| -rw-r--r-- | drivers/net/fec_mpc52xx.c | 2 | ||||
| -rw-r--r-- | drivers/net/fec_mpc52xx_phy.c | 2 | ||||
| -rw-r--r-- | drivers/serial/mpc52xx_uart.c | 5 | ||||
| -rw-r--r-- | drivers/watchdog/mpc5200_wdt.c | 2 |
14 files changed, 51 insertions, 70 deletions
diff --git a/arch/powerpc/include/asm/mpc52xx.h b/arch/powerpc/include/asm/mpc52xx.h index 52e049cd9e68..1b4f697abbdd 100644 --- a/arch/powerpc/include/asm/mpc52xx.h +++ b/arch/powerpc/include/asm/mpc52xx.h | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #ifndef __ASSEMBLY__ | 16 | #ifndef __ASSEMBLY__ |
| 17 | #include <asm/types.h> | 17 | #include <asm/types.h> |
| 18 | #include <asm/prom.h> | 18 | #include <asm/prom.h> |
| 19 | #include <asm/mpc5xxx.h> | ||
| 19 | #endif /* __ASSEMBLY__ */ | 20 | #endif /* __ASSEMBLY__ */ |
| 20 | 21 | ||
| 21 | #include <linux/suspend.h> | 22 | #include <linux/suspend.h> |
| @@ -268,7 +269,6 @@ struct mpc52xx_intr { | |||
| 268 | #ifndef __ASSEMBLY__ | 269 | #ifndef __ASSEMBLY__ |
| 269 | 270 | ||
| 270 | /* mpc52xx_common.c */ | 271 | /* mpc52xx_common.c */ |
| 271 | extern unsigned int mpc52xx_find_ipb_freq(struct device_node *node); | ||
| 272 | extern void mpc5200_setup_xlb_arbiter(void); | 272 | extern void mpc5200_setup_xlb_arbiter(void); |
| 273 | extern void mpc52xx_declare_of_platform_devices(void); | 273 | extern void mpc52xx_declare_of_platform_devices(void); |
| 274 | extern void mpc52xx_map_common_devices(void); | 274 | extern void mpc52xx_map_common_devices(void); |
diff --git a/arch/powerpc/include/asm/mpc512x.h b/arch/powerpc/include/asm/mpc5xxx.h index c48a1658eeac..5ce9c5fa434a 100644 --- a/arch/powerpc/include/asm/mpc512x.h +++ b/arch/powerpc/include/asm/mpc5xxx.h | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | * Author: John Rigby, <jrigby@freescale.com>, Friday Apr 13 2007 | 4 | * Author: John Rigby, <jrigby@freescale.com>, Friday Apr 13 2007 |
| 5 | * | 5 | * |
| 6 | * Description: | 6 | * Description: |
| 7 | * MPC5121 Prototypes and definitions | 7 | * MPC5xxx Prototypes and definitions |
| 8 | * | 8 | * |
| 9 | * This is free software; you can redistribute it and/or modify it | 9 | * This is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License as published by | 10 | * under the terms of the GNU General Public License as published by |
| @@ -13,10 +13,10 @@ | |||
| 13 | * | 13 | * |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #ifndef __ASM_POWERPC_MPC512x_H__ | 16 | #ifndef __ASM_POWERPC_MPC5xxx_H__ |
| 17 | #define __ASM_POWERPC_MPC512x_H__ | 17 | #define __ASM_POWERPC_MPC5xxx_H__ |
| 18 | 18 | ||
| 19 | extern unsigned long mpc512x_find_ips_freq(struct device_node *node); | 19 | extern unsigned long mpc5xxx_get_bus_frequency(struct device_node *node); |
| 20 | 20 | ||
| 21 | #endif /* __ASM_POWERPC_MPC512x_H__ */ | 21 | #endif /* __ASM_POWERPC_MPC5xxx_H__ */ |
| 22 | 22 | ||
diff --git a/arch/powerpc/platforms/512x/clock.c b/arch/powerpc/platforms/512x/clock.c index 1bcff94eb924..f4c4c6f807d7 100644 --- a/arch/powerpc/platforms/512x/clock.c +++ b/arch/powerpc/platforms/512x/clock.c | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | #include <linux/io.h> | 24 | #include <linux/io.h> |
| 25 | 25 | ||
| 26 | #include <linux/of_platform.h> | 26 | #include <linux/of_platform.h> |
| 27 | #include <asm/mpc512x.h> | 27 | #include <asm/mpc5xxx.h> |
| 28 | #include <asm/clk_interface.h> | 28 | #include <asm/clk_interface.h> |
| 29 | 29 | ||
| 30 | #undef CLK_DEBUG | 30 | #undef CLK_DEBUG |
diff --git a/arch/powerpc/platforms/512x/mpc512x.h b/arch/powerpc/platforms/512x/mpc512x.h index 9c03693cb009..22a5352407e0 100644 --- a/arch/powerpc/platforms/512x/mpc512x.h +++ b/arch/powerpc/platforms/512x/mpc512x.h | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | 11 | ||
| 12 | #ifndef __MPC512X_H__ | 12 | #ifndef __MPC512X_H__ |
| 13 | #define __MPC512X_H__ | 13 | #define __MPC512X_H__ |
| 14 | extern unsigned long mpc512x_find_ips_freq(struct device_node *node); | ||
| 15 | extern void __init mpc512x_init_IRQ(void); | 14 | extern void __init mpc512x_init_IRQ(void); |
| 16 | void __init mpc512x_declare_of_platform_devices(void); | 15 | void __init mpc512x_declare_of_platform_devices(void); |
| 17 | #endif /* __MPC512X_H__ */ | 16 | #endif /* __MPC512X_H__ */ |
diff --git a/arch/powerpc/platforms/512x/mpc512x_shared.c b/arch/powerpc/platforms/512x/mpc512x_shared.c index d8cd579f3191..434d683df5a0 100644 --- a/arch/powerpc/platforms/512x/mpc512x_shared.c +++ b/arch/powerpc/platforms/512x/mpc512x_shared.c | |||
| @@ -24,29 +24,6 @@ | |||
| 24 | 24 | ||
| 25 | #include "mpc512x.h" | 25 | #include "mpc512x.h" |
| 26 | 26 | ||
| 27 | unsigned long | ||
| 28 | mpc512x_find_ips_freq(struct device_node *node) | ||
| 29 | { | ||
| 30 | struct device_node *np; | ||
| 31 | const unsigned int *p_ips_freq = NULL; | ||
| 32 | |||
| 33 | of_node_get(node); | ||
| 34 | while (node) { | ||
| 35 | p_ips_freq = of_get_property(node, "bus-frequency", NULL); | ||
| 36 | if (p_ips_freq) | ||
| 37 | break; | ||
| 38 | |||
| 39 | np = of_get_parent(node); | ||
| 40 | of_node_put(node); | ||
| 41 | node = np; | ||
| 42 | } | ||
| 43 | if (node) | ||
| 44 | of_node_put(node); | ||
| 45 | |||
| 46 | return p_ips_freq ? *p_ips_freq : 0; | ||
| 47 | } | ||
| 48 | EXPORT_SYMBOL(mpc512x_find_ips_freq); | ||
| 49 | |||
| 50 | void __init mpc512x_init_IRQ(void) | 27 | void __init mpc512x_init_IRQ(void) |
| 51 | { | 28 | { |
| 52 | struct device_node *np; | 29 | struct device_node *np; |
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_common.c b/arch/powerpc/platforms/52xx/mpc52xx_common.c index 8e3dd5a0f228..a46bad0c2339 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_common.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c | |||
| @@ -47,36 +47,6 @@ static DEFINE_SPINLOCK(mpc52xx_lock); | |||
| 47 | static struct mpc52xx_gpt __iomem *mpc52xx_wdt; | 47 | static struct mpc52xx_gpt __iomem *mpc52xx_wdt; |
| 48 | static struct mpc52xx_cdm __iomem *mpc52xx_cdm; | 48 | static struct mpc52xx_cdm __iomem *mpc52xx_cdm; |
| 49 | 49 | ||
| 50 | /** | ||
| 51 | * mpc52xx_find_ipb_freq - Find the IPB bus frequency for a device | ||
| 52 | * @node: device node | ||
| 53 | * | ||
| 54 | * Returns IPB bus frequency, or 0 if the bus frequency cannot be found. | ||
| 55 | */ | ||
| 56 | unsigned int | ||
| 57 | mpc52xx_find_ipb_freq(struct device_node *node) | ||
| 58 | { | ||
| 59 | struct device_node *np; | ||
| 60 | const unsigned int *p_ipb_freq = NULL; | ||
| 61 | |||
| 62 | of_node_get(node); | ||
| 63 | while (node) { | ||
| 64 | p_ipb_freq = of_get_property(node, "bus-frequency", NULL); | ||
| 65 | if (p_ipb_freq) | ||
| 66 | break; | ||
| 67 | |||
| 68 | np = of_get_parent(node); | ||
| 69 | of_node_put(node); | ||
| 70 | node = np; | ||
| 71 | } | ||
| 72 | if (node) | ||
| 73 | of_node_put(node); | ||
| 74 | |||
| 75 | return p_ipb_freq ? *p_ipb_freq : 0; | ||
| 76 | } | ||
| 77 | EXPORT_SYMBOL(mpc52xx_find_ipb_freq); | ||
| 78 | |||
| 79 | |||
| 80 | /* | 50 | /* |
| 81 | * Configure the XLB arbiter settings to match what Linux expects. | 51 | * Configure the XLB arbiter settings to match what Linux expects. |
| 82 | */ | 52 | */ |
| @@ -221,7 +191,7 @@ unsigned int mpc52xx_get_xtal_freq(struct device_node *node) | |||
| 221 | if (!mpc52xx_cdm) | 191 | if (!mpc52xx_cdm) |
| 222 | return 0; | 192 | return 0; |
| 223 | 193 | ||
| 224 | freq = mpc52xx_find_ipb_freq(node); | 194 | freq = mpc5xxx_get_bus_frequency(node); |
| 225 | if (!freq) | 195 | if (!freq) |
| 226 | return 0; | 196 | return 0; |
| 227 | 197 | ||
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile index d073bfdd222a..9d4b17462f13 100644 --- a/arch/powerpc/sysdev/Makefile +++ b/arch/powerpc/sysdev/Makefile | |||
| @@ -50,6 +50,9 @@ obj-$(CONFIG_PPC_DCR) += dcr.o | |||
| 50 | obj-$(CONFIG_8xx) += mpc8xx_pic.o cpm1.o | 50 | obj-$(CONFIG_8xx) += mpc8xx_pic.o cpm1.o |
| 51 | obj-$(CONFIG_UCODE_PATCH) += micropatch.o | 51 | obj-$(CONFIG_UCODE_PATCH) += micropatch.o |
| 52 | 52 | ||
| 53 | obj-$(CONFIG_PPC_MPC512x) += mpc5xxx_clocks.o | ||
| 54 | obj-$(CONFIG_PPC_MPC52xx) += mpc5xxx_clocks.o | ||
| 55 | |||
| 53 | ifeq ($(CONFIG_SUSPEND),y) | 56 | ifeq ($(CONFIG_SUSPEND),y) |
| 54 | obj-$(CONFIG_6xx) += 6xx-suspend.o | 57 | obj-$(CONFIG_6xx) += 6xx-suspend.o |
| 55 | endif | 58 | endif |
diff --git a/arch/powerpc/sysdev/mpc5xxx_clocks.c b/arch/powerpc/sysdev/mpc5xxx_clocks.c new file mode 100644 index 000000000000..34e12f9995fe --- /dev/null +++ b/arch/powerpc/sysdev/mpc5xxx_clocks.c | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | /** | ||
| 2 | * mpc5xxx_get_bus_frequency - Find the bus frequency for a device | ||
| 3 | * @node: device node | ||
| 4 | * | ||
| 5 | * Returns bus frequency (IPS on MPC512x, IPB on MPC52xx), | ||
| 6 | * or 0 if the bus frequency cannot be found. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #include <linux/kernel.h> | ||
| 10 | #include <linux/of_platform.h> | ||
| 11 | |||
| 12 | unsigned int | ||
| 13 | mpc5xxx_get_bus_frequency(struct device_node *node) | ||
| 14 | { | ||
| 15 | struct device_node *np; | ||
| 16 | const unsigned int *p_bus_freq = NULL; | ||
| 17 | |||
| 18 | of_node_get(node); | ||
| 19 | while (node) { | ||
| 20 | p_bus_freq = of_get_property(node, "bus-frequency", NULL); | ||
| 21 | if (p_bus_freq) | ||
| 22 | break; | ||
| 23 | |||
| 24 | np = of_get_parent(node); | ||
| 25 | of_node_put(node); | ||
| 26 | node = np; | ||
| 27 | } | ||
| 28 | if (node) | ||
| 29 | of_node_put(node); | ||
| 30 | |||
| 31 | return p_bus_freq ? *p_bus_freq : 0; | ||
| 32 | } | ||
| 33 | EXPORT_SYMBOL(mpc5xxx_get_bus_frequency); | ||
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c index 68d27bc70d06..2bc2dbe30e8f 100644 --- a/drivers/ata/pata_mpc52xx.c +++ b/drivers/ata/pata_mpc52xx.c | |||
| @@ -694,7 +694,7 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match) | |||
| 694 | struct bcom_task *dmatsk = NULL; | 694 | struct bcom_task *dmatsk = NULL; |
| 695 | 695 | ||
| 696 | /* Get ipb frequency */ | 696 | /* Get ipb frequency */ |
| 697 | ipb_freq = mpc52xx_find_ipb_freq(op->node); | 697 | ipb_freq = mpc5xxx_get_bus_frequency(op->node); |
| 698 | if (!ipb_freq) { | 698 | if (!ipb_freq) { |
| 699 | dev_err(&op->dev, "could not determine IPB bus frequency\n"); | 699 | dev_err(&op->dev, "could not determine IPB bus frequency\n"); |
| 700 | return -ENODEV; | 700 | return -ENODEV; |
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index dd778d7ae047..d325e86e3103 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
| @@ -197,7 +197,7 @@ int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler) | |||
| 197 | return -EINVAL; | 197 | return -EINVAL; |
| 198 | 198 | ||
| 199 | /* Determine divider value */ | 199 | /* Determine divider value */ |
| 200 | divider = mpc52xx_find_ipb_freq(node) / clock; | 200 | divider = mpc5xxx_get_bus_frequency(node) / clock; |
| 201 | 201 | ||
| 202 | /* | 202 | /* |
| 203 | * We want to choose an FDR/DFSR that generates an I2C bus speed that | 203 | * We want to choose an FDR/DFSR that generates an I2C bus speed that |
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c index 8bbe7f617994..5ddf03325d16 100644 --- a/drivers/net/fec_mpc52xx.c +++ b/drivers/net/fec_mpc52xx.c | |||
| @@ -1006,7 +1006,7 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match) | |||
| 1006 | priv->phy_addr = FEC5200_PHYADDR_NONE; | 1006 | priv->phy_addr = FEC5200_PHYADDR_NONE; |
| 1007 | priv->speed = 100; | 1007 | priv->speed = 100; |
| 1008 | priv->duplex = DUPLEX_HALF; | 1008 | priv->duplex = DUPLEX_HALF; |
| 1009 | priv->phy_speed = ((mpc52xx_find_ipb_freq(op->node) >> 20) / 5) << 1; | 1009 | priv->phy_speed = ((mpc5xxx_get_bus_frequency(op->node) >> 20) / 5) << 1; |
| 1010 | 1010 | ||
| 1011 | /* the 7-wire property means don't use MII mode */ | 1011 | /* the 7-wire property means don't use MII mode */ |
| 1012 | if (of_find_property(op->node, "fsl,7-wire-mode", NULL)) | 1012 | if (of_find_property(op->node, "fsl,7-wire-mode", NULL)) |
diff --git a/drivers/net/fec_mpc52xx_phy.c b/drivers/net/fec_mpc52xx_phy.c index dd9bfa42ac34..176e9b8d7101 100644 --- a/drivers/net/fec_mpc52xx_phy.c +++ b/drivers/net/fec_mpc52xx_phy.c | |||
| @@ -120,7 +120,7 @@ static int mpc52xx_fec_mdio_probe(struct of_device *of, | |||
| 120 | 120 | ||
| 121 | /* set MII speed */ | 121 | /* set MII speed */ |
| 122 | out_be32(&priv->regs->mii_speed, | 122 | out_be32(&priv->regs->mii_speed, |
| 123 | ((mpc52xx_find_ipb_freq(of->node) >> 20) / 5) << 1); | 123 | ((mpc5xxx_get_bus_frequency(of->node) >> 20) / 5) << 1); |
| 124 | 124 | ||
| 125 | err = mdiobus_register(bus); | 125 | err = mdiobus_register(bus); |
| 126 | if (err) | 126 | if (err) |
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index b3feb6198d57..abbd146c50d9 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c | |||
| @@ -76,7 +76,6 @@ | |||
| 76 | #include <linux/of_platform.h> | 76 | #include <linux/of_platform.h> |
| 77 | 77 | ||
| 78 | #include <asm/mpc52xx.h> | 78 | #include <asm/mpc52xx.h> |
| 79 | #include <asm/mpc512x.h> | ||
| 80 | #include <asm/mpc52xx_psc.h> | 79 | #include <asm/mpc52xx_psc.h> |
| 81 | 80 | ||
| 82 | #if defined(CONFIG_SERIAL_MPC52xx_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) | 81 | #if defined(CONFIG_SERIAL_MPC52xx_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) |
| @@ -254,7 +253,7 @@ static unsigned long mpc52xx_getuartclk(void *p) | |||
| 254 | * but the generic serial code assumes 16 | 253 | * but the generic serial code assumes 16 |
| 255 | * so return ipb freq / 2 | 254 | * so return ipb freq / 2 |
| 256 | */ | 255 | */ |
| 257 | return mpc52xx_find_ipb_freq(p) / 2; | 256 | return mpc5xxx_get_bus_frequency(p) / 2; |
| 258 | } | 257 | } |
| 259 | 258 | ||
| 260 | static struct psc_ops mpc52xx_psc_ops = { | 259 | static struct psc_ops mpc52xx_psc_ops = { |
| @@ -391,7 +390,7 @@ static void mpc512x_psc_cw_restore_ints(struct uart_port *port) | |||
| 391 | 390 | ||
| 392 | static unsigned long mpc512x_getuartclk(void *p) | 391 | static unsigned long mpc512x_getuartclk(void *p) |
| 393 | { | 392 | { |
| 394 | return mpc512x_find_ips_freq(p); | 393 | return mpc5xxx_get_bus_frequency(p); |
| 395 | } | 394 | } |
| 396 | 395 | ||
| 397 | static struct psc_ops mpc512x_psc_ops = { | 396 | static struct psc_ops mpc512x_psc_ops = { |
diff --git a/drivers/watchdog/mpc5200_wdt.c b/drivers/watchdog/mpc5200_wdt.c index 465fe36adad4..fa9c47ce0ae7 100644 --- a/drivers/watchdog/mpc5200_wdt.c +++ b/drivers/watchdog/mpc5200_wdt.c | |||
| @@ -188,7 +188,7 @@ static int mpc5200_wdt_probe(struct of_device *op, | |||
| 188 | if (!wdt) | 188 | if (!wdt) |
| 189 | return -ENOMEM; | 189 | return -ENOMEM; |
| 190 | 190 | ||
| 191 | wdt->ipb_freq = mpc52xx_find_ipb_freq(op->node); | 191 | wdt->ipb_freq = mpc5xxx_get_bus_frequency(op->node); |
| 192 | 192 | ||
| 193 | err = of_address_to_resource(op->node, 0, &wdt->mem); | 193 | err = of_address_to_resource(op->node, 0, &wdt->mem); |
| 194 | if (err) | 194 | if (err) |
