Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Wolfgang Denk and committed by
Grant Likely
87c441e5 c155ee10

+51 -70
+5 -5
arch/powerpc/include/asm/mpc512x.h arch/powerpc/include/asm/mpc5xxx.h
··· 4 4 * Author: John Rigby, <jrigby@freescale.com>, Friday Apr 13 2007 5 5 * 6 6 * Description: 7 - * MPC5121 Prototypes and definitions 7 + * MPC5xxx Prototypes and definitions 8 8 * 9 9 * This is free software; you can redistribute it and/or modify it 10 10 * under the terms of the GNU General Public License as published by ··· 13 13 * 14 14 */ 15 15 16 - #ifndef __ASM_POWERPC_MPC512x_H__ 17 - #define __ASM_POWERPC_MPC512x_H__ 16 + #ifndef __ASM_POWERPC_MPC5xxx_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
+1 -1
arch/powerpc/include/asm/mpc52xx.h
··· 16 16 #ifndef __ASSEMBLY__ 17 17 #include <asm/types.h> 18 18 #include <asm/prom.h> 19 + #include <asm/mpc5xxx.h> 19 20 #endif /* __ASSEMBLY__ */ 20 21 21 22 #include <linux/suspend.h> ··· 269 268 #ifndef __ASSEMBLY__ 270 269 271 270 /* mpc52xx_common.c */ 272 - extern unsigned int mpc52xx_find_ipb_freq(struct device_node *node); 273 271 extern void mpc5200_setup_xlb_arbiter(void); 274 272 extern void mpc52xx_declare_of_platform_devices(void); 275 273 extern void mpc52xx_map_common_devices(void);
+1 -1
arch/powerpc/platforms/512x/clock.c
··· 24 24 #include <linux/io.h> 25 25 26 26 #include <linux/of_platform.h> 27 - #include <asm/mpc512x.h> 27 + #include <asm/mpc5xxx.h> 28 28 #include <asm/clk_interface.h> 29 29 30 30 #undef CLK_DEBUG
-1
arch/powerpc/platforms/512x/mpc512x.h
··· 11 11 12 12 #ifndef __MPC512X_H__ 13 13 #define __MPC512X_H__ 14 - extern unsigned long mpc512x_find_ips_freq(struct device_node *node); 15 14 extern void __init mpc512x_init_IRQ(void); 16 15 void __init mpc512x_declare_of_platform_devices(void); 17 16 #endif /* __MPC512X_H__ */
-23
arch/powerpc/platforms/512x/mpc512x_shared.c
··· 24 24 25 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 27 void __init mpc512x_init_IRQ(void) 51 28 { 52 29 struct device_node *np;
+1 -31
arch/powerpc/platforms/52xx/mpc52xx_common.c
··· 47 47 static struct mpc52xx_gpt __iomem *mpc52xx_wdt; 48 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 51 * Configure the XLB arbiter settings to match what Linux expects. 82 52 */ ··· 191 221 if (!mpc52xx_cdm) 192 222 return 0; 193 223 194 - freq = mpc52xx_find_ipb_freq(node); 224 + freq = mpc5xxx_get_bus_frequency(node); 195 225 if (!freq) 196 226 return 0; 197 227
+3
arch/powerpc/sysdev/Makefile
··· 50 50 obj-$(CONFIG_8xx) += mpc8xx_pic.o cpm1.o 51 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 56 ifeq ($(CONFIG_SUSPEND),y) 54 57 obj-$(CONFIG_6xx) += 6xx-suspend.o 55 58 endif
+33
arch/powerpc/sysdev/mpc5xxx_clocks.c
··· 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);
+1 -1
drivers/ata/pata_mpc52xx.c
··· 694 694 struct bcom_task *dmatsk = NULL; 695 695 696 696 /* Get ipb frequency */ 697 - ipb_freq = mpc52xx_find_ipb_freq(op->node); 697 + ipb_freq = mpc5xxx_get_bus_frequency(op->node); 698 698 if (!ipb_freq) { 699 699 dev_err(&op->dev, "could not determine IPB bus frequency\n"); 700 700 return -ENODEV;
+1 -1
drivers/i2c/busses/i2c-mpc.c
··· 197 197 return -EINVAL; 198 198 199 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 203 * We want to choose an FDR/DFSR that generates an I2C bus speed that
+1 -1
drivers/net/fec_mpc52xx.c
··· 1006 1006 priv->phy_addr = FEC5200_PHYADDR_NONE; 1007 1007 priv->speed = 100; 1008 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 1011 /* the 7-wire property means don't use MII mode */ 1012 1012 if (of_find_property(op->node, "fsl,7-wire-mode", NULL))
+1 -1
drivers/net/fec_mpc52xx_phy.c
··· 120 120 121 121 /* set MII speed */ 122 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 125 err = mdiobus_register(bus); 126 126 if (err)
+2 -3
drivers/serial/mpc52xx_uart.c
··· 76 76 #include <linux/of_platform.h> 77 77 78 78 #include <asm/mpc52xx.h> 79 - #include <asm/mpc512x.h> 80 79 #include <asm/mpc52xx_psc.h> 81 80 82 81 #if defined(CONFIG_SERIAL_MPC52xx_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) ··· 253 254 * but the generic serial code assumes 16 254 255 * so return ipb freq / 2 255 256 */ 256 - return mpc52xx_find_ipb_freq(p) / 2; 257 + return mpc5xxx_get_bus_frequency(p) / 2; 257 258 } 258 259 259 260 static struct psc_ops mpc52xx_psc_ops = { ··· 390 391 391 392 static unsigned long mpc512x_getuartclk(void *p) 392 393 { 393 - return mpc512x_find_ips_freq(p); 394 + return mpc5xxx_get_bus_frequency(p); 394 395 } 395 396 396 397 static struct psc_ops mpc512x_psc_ops = {
+1 -1
drivers/watchdog/mpc5200_wdt.c
··· 188 188 if (!wdt) 189 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 193 err = of_address_to_resource(op->node, 0, &wdt->mem); 194 194 if (err)