init.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Pistachio platform setup
  3. *
  4. * Copyright (C) 2014 Google, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/kernel.h>
  12. #include <linux/of_address.h>
  13. #include <linux/of_fdt.h>
  14. #include <linux/of_platform.h>
  15. #include <asm/cacheflush.h>
  16. #include <asm/dma-coherence.h>
  17. #include <asm/fw/fw.h>
  18. #include <asm/mips-boards/generic.h>
  19. #include <asm/mips-cm.h>
  20. #include <asm/mips-cpc.h>
  21. #include <asm/prom.h>
  22. #include <asm/smp-ops.h>
  23. #include <asm/traps.h>
  24. const char *get_system_type(void)
  25. {
  26. return "IMG Pistachio SoC";
  27. }
  28. static void __init plat_setup_iocoherency(void)
  29. {
  30. /*
  31. * Kernel has been configured with software coherency
  32. * but we might choose to turn it off and use hardware
  33. * coherency instead.
  34. */
  35. if (mips_cm_numiocu() != 0) {
  36. /* Nothing special needs to be done to enable coherency */
  37. pr_info("CMP IOCU detected\n");
  38. hw_coherentio = 1;
  39. if (coherentio == 0)
  40. pr_info("Hardware DMA cache coherency disabled\n");
  41. else
  42. pr_info("Hardware DMA cache coherency enabled\n");
  43. } else {
  44. if (coherentio == 1)
  45. pr_info("Hardware DMA cache coherency unsupported, but enabled from command line!\n");
  46. else
  47. pr_info("Software DMA cache coherency enabled\n");
  48. }
  49. }
  50. void __init plat_mem_setup(void)
  51. {
  52. if (fw_arg0 != -2)
  53. panic("Device-tree not present");
  54. __dt_setup_arch((void *)fw_arg1);
  55. strlcpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
  56. plat_setup_iocoherency();
  57. }
  58. #define DEFAULT_CPC_BASE_ADDR 0x1bde0000
  59. phys_addr_t mips_cpc_default_phys_base(void)
  60. {
  61. return DEFAULT_CPC_BASE_ADDR;
  62. }
  63. static void __init mips_nmi_setup(void)
  64. {
  65. void *base;
  66. extern char except_vec_nmi;
  67. base = cpu_has_veic ?
  68. (void *)(CAC_BASE + 0xa80) :
  69. (void *)(CAC_BASE + 0x380);
  70. memcpy(base, &except_vec_nmi, 0x80);
  71. flush_icache_range((unsigned long)base,
  72. (unsigned long)base + 0x80);
  73. }
  74. static void __init mips_ejtag_setup(void)
  75. {
  76. void *base;
  77. extern char except_vec_ejtag_debug;
  78. base = cpu_has_veic ?
  79. (void *)(CAC_BASE + 0xa00) :
  80. (void *)(CAC_BASE + 0x300);
  81. memcpy(base, &except_vec_ejtag_debug, 0x80);
  82. flush_icache_range((unsigned long)base,
  83. (unsigned long)base + 0x80);
  84. }
  85. void __init prom_init(void)
  86. {
  87. board_nmi_handler_setup = mips_nmi_setup;
  88. board_ejtag_handler_setup = mips_ejtag_setup;
  89. mips_cm_probe();
  90. mips_cpc_probe();
  91. register_cps_smp_ops();
  92. }
  93. void __init prom_free_prom_memory(void)
  94. {
  95. }
  96. void __init device_tree_init(void)
  97. {
  98. if (!initial_boot_params)
  99. return;
  100. unflatten_and_copy_device_tree();
  101. }
  102. static int __init plat_of_setup(void)
  103. {
  104. if (!of_have_populated_dt())
  105. panic("Device tree not present");
  106. if (of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL))
  107. panic("Failed to populate DT");
  108. return 0;
  109. }
  110. arch_initcall(plat_of_setup);