init.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. #define DEFAULT_CDMM_BASE_ADDR 0x1bdd0000
  60. phys_addr_t mips_cpc_default_phys_base(void)
  61. {
  62. return DEFAULT_CPC_BASE_ADDR;
  63. }
  64. phys_addr_t mips_cdmm_phys_base(void)
  65. {
  66. return DEFAULT_CDMM_BASE_ADDR;
  67. }
  68. static void __init mips_nmi_setup(void)
  69. {
  70. void *base;
  71. extern char except_vec_nmi;
  72. base = cpu_has_veic ?
  73. (void *)(CAC_BASE + 0xa80) :
  74. (void *)(CAC_BASE + 0x380);
  75. memcpy(base, &except_vec_nmi, 0x80);
  76. flush_icache_range((unsigned long)base,
  77. (unsigned long)base + 0x80);
  78. }
  79. static void __init mips_ejtag_setup(void)
  80. {
  81. void *base;
  82. extern char except_vec_ejtag_debug;
  83. base = cpu_has_veic ?
  84. (void *)(CAC_BASE + 0xa00) :
  85. (void *)(CAC_BASE + 0x300);
  86. memcpy(base, &except_vec_ejtag_debug, 0x80);
  87. flush_icache_range((unsigned long)base,
  88. (unsigned long)base + 0x80);
  89. }
  90. void __init prom_init(void)
  91. {
  92. board_nmi_handler_setup = mips_nmi_setup;
  93. board_ejtag_handler_setup = mips_ejtag_setup;
  94. mips_cm_probe();
  95. mips_cpc_probe();
  96. register_cps_smp_ops();
  97. }
  98. void __init prom_free_prom_memory(void)
  99. {
  100. }
  101. void __init device_tree_init(void)
  102. {
  103. if (!initial_boot_params)
  104. return;
  105. unflatten_and_copy_device_tree();
  106. }
  107. static int __init plat_of_setup(void)
  108. {
  109. if (!of_have_populated_dt())
  110. panic("Device tree not present");
  111. if (of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL))
  112. panic("Failed to populate DT");
  113. return 0;
  114. }
  115. arch_initcall(plat_of_setup);