init.c 2.9 KB

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