mpc5121_ads.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
  3. *
  4. * Author: John Rigby, <jrigby@freescale.com>, Thur Mar 29 2007
  5. *
  6. * Description:
  7. * MPC5121 ADS board setup
  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. */
  15. #include <linux/kernel.h>
  16. #include <linux/io.h>
  17. #include <linux/irq.h>
  18. #include <linux/of_platform.h>
  19. #include <asm/machdep.h>
  20. #include <asm/ipic.h>
  21. #include <asm/prom.h>
  22. #include <asm/time.h>
  23. /**
  24. * mpc512x_find_ips_freq - Find the IPS bus frequency for a device
  25. * @node: device node
  26. *
  27. * Returns IPS bus frequency, or 0 if the bus frequency cannot be found.
  28. */
  29. unsigned long
  30. mpc512x_find_ips_freq(struct device_node *node)
  31. {
  32. struct device_node *np;
  33. const unsigned int *p_ips_freq = NULL;
  34. of_node_get(node);
  35. while (node) {
  36. p_ips_freq = of_get_property(node, "bus-frequency", NULL);
  37. if (p_ips_freq)
  38. break;
  39. np = of_get_parent(node);
  40. of_node_put(node);
  41. node = np;
  42. }
  43. if (node)
  44. of_node_put(node);
  45. return p_ips_freq ? *p_ips_freq : 0;
  46. }
  47. EXPORT_SYMBOL(mpc512x_find_ips_freq);
  48. static struct of_device_id __initdata of_bus_ids[] = {
  49. { .name = "soc", },
  50. { .name = "localbus", },
  51. {},
  52. };
  53. static void __init mpc5121_ads_declare_of_platform_devices(void)
  54. {
  55. /* Find every child of the SOC node and add it to of_platform */
  56. if (of_platform_bus_probe(NULL, of_bus_ids, NULL))
  57. printk(KERN_ERR __FILE__ ": "
  58. "Error while probing of_platform bus\n");
  59. }
  60. static void __init mpc5121_ads_init_IRQ(void)
  61. {
  62. struct device_node *np;
  63. np = of_find_compatible_node(NULL, NULL, "fsl,ipic");
  64. if (!np)
  65. return;
  66. ipic_init(np, 0);
  67. of_node_put(np);
  68. /*
  69. * Initialize the default interrupt mapping priorities,
  70. * in case the boot rom changed something on us.
  71. */
  72. ipic_set_default_priority();
  73. }
  74. /*
  75. * Called very early, MMU is off, device-tree isn't unflattened
  76. */
  77. static int __init mpc5121_ads_probe(void)
  78. {
  79. unsigned long root = of_get_flat_dt_root();
  80. return of_flat_dt_is_compatible(root, "fsl,mpc5121ads");
  81. }
  82. define_machine(mpc5121_ads) {
  83. .name = "MPC5121 ADS",
  84. .probe = mpc5121_ads_probe,
  85. .init = mpc5121_ads_declare_of_platform_devices,
  86. .init_IRQ = mpc5121_ads_init_IRQ,
  87. .get_irq = ipic_get_irq,
  88. .calibrate_decr = generic_calibrate_decr,
  89. };