mpc512x_shared.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 <asm/mpc5121.h>
  23. #include "mpc512x.h"
  24. static struct mpc512x_reset_module __iomem *reset_module_base;
  25. static void __init mpc512x_restart_init(void)
  26. {
  27. struct device_node *np;
  28. np = of_find_compatible_node(NULL, NULL, "fsl,mpc5121-reset");
  29. if (!np)
  30. return;
  31. reset_module_base = of_iomap(np, 0);
  32. of_node_put(np);
  33. }
  34. void mpc512x_restart(char *cmd)
  35. {
  36. if (reset_module_base) {
  37. /* Enable software reset "RSTE" */
  38. out_be32(&reset_module_base->rpr, 0x52535445);
  39. /* Set software hard reset */
  40. out_be32(&reset_module_base->rcr, 0x2);
  41. } else {
  42. pr_err("Restart module not mapped.\n");
  43. }
  44. for (;;)
  45. ;
  46. }
  47. void __init mpc512x_init_IRQ(void)
  48. {
  49. struct device_node *np;
  50. np = of_find_compatible_node(NULL, NULL, "fsl,mpc5121-ipic");
  51. if (!np)
  52. return;
  53. ipic_init(np, 0);
  54. of_node_put(np);
  55. /*
  56. * Initialize the default interrupt mapping priorities,
  57. * in case the boot rom changed something on us.
  58. */
  59. ipic_set_default_priority();
  60. }
  61. /*
  62. * Nodes to do bus probe on, soc and localbus
  63. */
  64. static struct of_device_id __initdata of_bus_ids[] = {
  65. { .compatible = "fsl,mpc5121-immr", },
  66. { .compatible = "fsl,mpc5121-localbus", },
  67. {},
  68. };
  69. void __init mpc512x_declare_of_platform_devices(void)
  70. {
  71. struct device_node *np;
  72. if (of_platform_bus_probe(NULL, of_bus_ids, NULL))
  73. printk(KERN_ERR __FILE__ ": "
  74. "Error while probing of_platform bus\n");
  75. np = of_find_compatible_node(NULL, NULL, "fsl,mpc5121-nfc");
  76. if (np) {
  77. of_platform_device_create(np, NULL, NULL);
  78. of_node_put(np);
  79. }
  80. }
  81. void __init mpc512x_init(void)
  82. {
  83. mpc512x_declare_of_platform_devices();
  84. mpc5121_clk_init();
  85. mpc512x_restart_init();
  86. }