wsp.c 2.4 KB

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