Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 
0003 #include <linux/kernel.h>
0004 #include <linux/export.h>
0005 #include <linux/property.h>
0006 
0007 #include <asm/mpc5xxx.h>
0008 
0009 /**
0010  * mpc5xxx_fwnode_get_bus_frequency - Find the bus frequency for a firmware node
0011  * @fwnode: firmware node
0012  *
0013  * Returns bus frequency (IPS on MPC512x, IPB on MPC52xx),
0014  * or 0 if the bus frequency cannot be found.
0015  */
0016 unsigned long mpc5xxx_fwnode_get_bus_frequency(struct fwnode_handle *fwnode)
0017 {
0018     struct fwnode_handle *parent;
0019     u32 bus_freq;
0020     int ret;
0021 
0022     ret = fwnode_property_read_u32(fwnode, "bus-frequency", &bus_freq);
0023     if (!ret)
0024         return bus_freq;
0025 
0026     fwnode_for_each_parent_node(fwnode, parent) {
0027         ret = fwnode_property_read_u32(parent, "bus-frequency", &bus_freq);
0028         if (!ret)
0029             return bus_freq;
0030     }
0031 
0032     return 0;
0033 }
0034 EXPORT_SYMBOL(mpc5xxx_fwnode_get_bus_frequency);