mpc512x_shared.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (C) 2007,2008 Freescale Semiconductor, Inc. All rights reserved.
  3. *
  4. * Author: John Rigby <jrigby@freescale.com>
  5. *
  6. * Description:
  7. * MPC512x Shared code
  8. *
  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
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/io.h>
  16. #include <linux/irq.h>
  17. #include <linux/of_platform.h>
  18. #include <asm/machdep.h>
  19. #include <asm/ipic.h>
  20. #include <asm/prom.h>
  21. #include <asm/time.h>
  22. #include "mpc512x.h"
  23. unsigned long
  24. mpc512x_find_ips_freq(struct device_node *node)
  25. {
  26. struct device_node *np;
  27. const unsigned int *p_ips_freq = NULL;
  28. of_node_get(node);
  29. while (node) {
  30. p_ips_freq = of_get_property(node, "bus-frequency", NULL);
  31. if (p_ips_freq)
  32. break;
  33. np = of_get_parent(node);
  34. of_node_put(node);
  35. node = np;
  36. }
  37. if (node)
  38. of_node_put(node);
  39. return p_ips_freq ? *p_ips_freq : 0;
  40. }
  41. EXPORT_SYMBOL(mpc512x_find_ips_freq);
  42. void __init mpc512x_init_IRQ(void)
  43. {
  44. struct device_node *np;
  45. np = of_find_compatible_node(NULL, NULL, "fsl,mpc5121-ipic");
  46. if (!np)
  47. return;
  48. ipic_init(np, 0);
  49. of_node_put(np);
  50. /*
  51. * Initialize the default interrupt mapping priorities,
  52. * in case the boot rom changed something on us.
  53. */
  54. ipic_set_default_priority();
  55. }
  56. /*
  57. * Nodes to do bus probe on, soc and localbus
  58. */
  59. static struct of_device_id __initdata of_bus_ids[] = {
  60. { .compatible = "fsl,mpc5121-immr", },
  61. { .compatible = "fsl,mpc5121-localbus", },
  62. {},
  63. };
  64. void __init mpc512x_declare_of_platform_devices(void)
  65. {
  66. if (of_platform_bus_probe(NULL, of_bus_ids, NULL))
  67. printk(KERN_ERR __FILE__ ": "
  68. "Error while probing of_platform bus\n");
  69. }