wsp.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright 2008-2011, IBM Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/of.h>
  11. #include <linux/of_device.h>
  12. #include <linux/smp.h>
  13. #include <linux/delay.h>
  14. #include <linux/time.h>
  15. #include <linux/of_address.h>
  16. #include <asm/scom.h>
  17. #include "wsp.h"
  18. #include "ics.h"
  19. #define WSP_SOC_COMPATIBLE "ibm,wsp-soc"
  20. #define PBIC_COMPATIBLE "ibm,wsp-pbic"
  21. #define COPRO_COMPATIBLE "ibm,wsp-coprocessor"
  22. static int __init wsp_probe_buses(void)
  23. {
  24. static __initdata struct of_device_id bus_ids[] = {
  25. /*
  26. * every node in between needs to be here or you won't
  27. * find it
  28. */
  29. { .compatible = WSP_SOC_COMPATIBLE, },
  30. { .compatible = PBIC_COMPATIBLE, },
  31. { .compatible = COPRO_COMPATIBLE, },
  32. {},
  33. };
  34. of_platform_bus_probe(NULL, bus_ids, NULL);
  35. return 0;
  36. }
  37. void __init wsp_setup_arch(void)
  38. {
  39. /* init to some ~sane value until calibrate_delay() runs */
  40. loops_per_jiffy = 50000000;
  41. scom_init_wsp();
  42. /* Setup SMP callback */
  43. #ifdef CONFIG_SMP
  44. a2_setup_smp();
  45. #endif
  46. #ifdef CONFIG_PCI
  47. wsp_setup_pci();
  48. #endif
  49. }
  50. void __init wsp_setup_irq(void)
  51. {
  52. wsp_init_irq();
  53. opb_pic_init();
  54. }
  55. int __init wsp_probe_devices(void)
  56. {
  57. struct device_node *np;
  58. /* Our RTC is a ds1500. It seems to be programatically compatible
  59. * with the ds1511 for which we have a driver so let's use that
  60. */
  61. np = of_find_compatible_node(NULL, NULL, "dallas,ds1500");
  62. if (np != NULL) {
  63. struct resource res;
  64. if (of_address_to_resource(np, 0, &res) == 0)
  65. platform_device_register_simple("ds1511", 0, &res, 1);
  66. }
  67. wsp_probe_buses();
  68. return 0;
  69. }
  70. void wsp_halt(void)
  71. {
  72. u64 val;
  73. scom_map_t m;
  74. struct device_node *dn;
  75. struct device_node *mine;
  76. struct device_node *me;
  77. int rc;
  78. me = of_get_cpu_node(smp_processor_id(), NULL);
  79. mine = scom_find_parent(me);
  80. /* This will halt all the A2s but not power off the chip */
  81. for_each_node_with_property(dn, "scom-controller") {
  82. if (dn == mine)
  83. continue;
  84. m = scom_map(dn, 0, 1);
  85. /* read-modify-write it so the HW probe does not get
  86. * confused */
  87. rc = scom_read(m, 0, &val);
  88. if (rc == 0)
  89. scom_write(m, 0, val | 1);
  90. scom_unmap(m);
  91. }
  92. m = scom_map(mine, 0, 1);
  93. rc = scom_read(m, 0, &val);
  94. if (rc == 0)
  95. scom_write(m, 0, val | 1);
  96. /* should never return */
  97. scom_unmap(m);
  98. }