init.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * Pistachio platform setup
  3. *
  4. * Copyright (C) 2014 Google, Inc.
  5. * Copyright (C) 2016 Imagination Technologies
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms and conditions of the GNU General Public License,
  9. * version 2, as published by the Free Software Foundation.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/io.h>
  13. #include <linux/kernel.h>
  14. #include <linux/of_address.h>
  15. #include <linux/of_fdt.h>
  16. #include <asm/cacheflush.h>
  17. #include <asm/dma-coherence.h>
  18. #include <asm/fw/fw.h>
  19. #include <asm/mips-boards/generic.h>
  20. #include <asm/mips-cm.h>
  21. #include <asm/mips-cpc.h>
  22. #include <asm/prom.h>
  23. #include <asm/smp-ops.h>
  24. #include <asm/traps.h>
  25. /*
  26. * Core revision register decoding
  27. * Bits 23 to 20: Major rev
  28. * Bits 15 to 8: Minor rev
  29. * Bits 7 to 0: Maintenance rev
  30. */
  31. #define PISTACHIO_CORE_REV_REG 0xB81483D0
  32. #define PISTACHIO_CORE_REV_A1 0x00100006
  33. #define PISTACHIO_CORE_REV_B0 0x00100106
  34. const char *get_system_type(void)
  35. {
  36. u32 core_rev;
  37. const char *sys_type;
  38. core_rev = __raw_readl((const void *)PISTACHIO_CORE_REV_REG);
  39. switch (core_rev) {
  40. case PISTACHIO_CORE_REV_B0:
  41. sys_type = "IMG Pistachio SoC (B0)";
  42. break;
  43. case PISTACHIO_CORE_REV_A1:
  44. sys_type = "IMG Pistachio SoC (A1)";
  45. break;
  46. default:
  47. sys_type = "IMG Pistachio SoC";
  48. break;
  49. }
  50. return sys_type;
  51. }
  52. static void __init plat_setup_iocoherency(void)
  53. {
  54. /*
  55. * Kernel has been configured with software coherency
  56. * but we might choose to turn it off and use hardware
  57. * coherency instead.
  58. */
  59. if (mips_cm_numiocu() != 0) {
  60. /* Nothing special needs to be done to enable coherency */
  61. pr_info("CMP IOCU detected\n");
  62. hw_coherentio = 1;
  63. if (coherentio == 0)
  64. pr_info("Hardware DMA cache coherency disabled\n");
  65. else
  66. pr_info("Hardware DMA cache coherency enabled\n");
  67. } else {
  68. if (coherentio == 1)
  69. pr_info("Hardware DMA cache coherency unsupported, but enabled from command line!\n");
  70. else
  71. pr_info("Software DMA cache coherency enabled\n");
  72. }
  73. }
  74. void __init *plat_get_fdt(void)
  75. {
  76. if (fw_arg0 != -2)
  77. panic("Device-tree not present");
  78. return (void *)fw_arg1;
  79. }
  80. void __init plat_mem_setup(void)
  81. {
  82. __dt_setup_arch(plat_get_fdt());
  83. plat_setup_iocoherency();
  84. }
  85. #define DEFAULT_CPC_BASE_ADDR 0x1bde0000
  86. #define DEFAULT_CDMM_BASE_ADDR 0x1bdd0000
  87. phys_addr_t mips_cpc_default_phys_base(void)
  88. {
  89. return DEFAULT_CPC_BASE_ADDR;
  90. }
  91. phys_addr_t mips_cdmm_phys_base(void)
  92. {
  93. return DEFAULT_CDMM_BASE_ADDR;
  94. }
  95. static void __init mips_nmi_setup(void)
  96. {
  97. void *base;
  98. extern char except_vec_nmi;
  99. base = cpu_has_veic ?
  100. (void *)(CAC_BASE + 0xa80) :
  101. (void *)(CAC_BASE + 0x380);
  102. memcpy(base, &except_vec_nmi, 0x80);
  103. flush_icache_range((unsigned long)base,
  104. (unsigned long)base + 0x80);
  105. }
  106. static void __init mips_ejtag_setup(void)
  107. {
  108. void *base;
  109. extern char except_vec_ejtag_debug;
  110. base = cpu_has_veic ?
  111. (void *)(CAC_BASE + 0xa00) :
  112. (void *)(CAC_BASE + 0x300);
  113. memcpy(base, &except_vec_ejtag_debug, 0x80);
  114. flush_icache_range((unsigned long)base,
  115. (unsigned long)base + 0x80);
  116. }
  117. void __init prom_init(void)
  118. {
  119. board_nmi_handler_setup = mips_nmi_setup;
  120. board_ejtag_handler_setup = mips_ejtag_setup;
  121. mips_cm_probe();
  122. mips_cpc_probe();
  123. register_cps_smp_ops();
  124. pr_info("SoC Type: %s\n", get_system_type());
  125. }
  126. void __init prom_free_prom_memory(void)
  127. {
  128. }
  129. void __init device_tree_init(void)
  130. {
  131. if (!initial_boot_params)
  132. return;
  133. unflatten_and_copy_device_tree();
  134. }