init.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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-cps.h>
  21. #include <asm/prom.h>
  22. #include <asm/smp-ops.h>
  23. #include <asm/traps.h>
  24. /*
  25. * Core revision register decoding
  26. * Bits 23 to 20: Major rev
  27. * Bits 15 to 8: Minor rev
  28. * Bits 7 to 0: Maintenance rev
  29. */
  30. #define PISTACHIO_CORE_REV_REG 0xB81483D0
  31. #define PISTACHIO_CORE_REV_A1 0x00100006
  32. #define PISTACHIO_CORE_REV_B0 0x00100106
  33. const char *get_system_type(void)
  34. {
  35. u32 core_rev;
  36. const char *sys_type;
  37. core_rev = __raw_readl((const void *)PISTACHIO_CORE_REV_REG);
  38. switch (core_rev) {
  39. case PISTACHIO_CORE_REV_B0:
  40. sys_type = "IMG Pistachio SoC (B0)";
  41. break;
  42. case PISTACHIO_CORE_REV_A1:
  43. sys_type = "IMG Pistachio SoC (A1)";
  44. break;
  45. default:
  46. sys_type = "IMG Pistachio SoC";
  47. break;
  48. }
  49. return sys_type;
  50. }
  51. void __init *plat_get_fdt(void)
  52. {
  53. if (fw_arg0 != -2)
  54. panic("Device-tree not present");
  55. return (void *)fw_arg1;
  56. }
  57. void __init plat_mem_setup(void)
  58. {
  59. __dt_setup_arch(plat_get_fdt());
  60. }
  61. #define DEFAULT_CPC_BASE_ADDR 0x1bde0000
  62. #define DEFAULT_CDMM_BASE_ADDR 0x1bdd0000
  63. phys_addr_t mips_cpc_default_phys_base(void)
  64. {
  65. return DEFAULT_CPC_BASE_ADDR;
  66. }
  67. phys_addr_t mips_cdmm_phys_base(void)
  68. {
  69. return DEFAULT_CDMM_BASE_ADDR;
  70. }
  71. static void __init mips_nmi_setup(void)
  72. {
  73. void *base;
  74. extern char except_vec_nmi;
  75. base = cpu_has_veic ?
  76. (void *)(CAC_BASE + 0xa80) :
  77. (void *)(CAC_BASE + 0x380);
  78. memcpy(base, &except_vec_nmi, 0x80);
  79. flush_icache_range((unsigned long)base,
  80. (unsigned long)base + 0x80);
  81. }
  82. static void __init mips_ejtag_setup(void)
  83. {
  84. void *base;
  85. extern char except_vec_ejtag_debug;
  86. base = cpu_has_veic ?
  87. (void *)(CAC_BASE + 0xa00) :
  88. (void *)(CAC_BASE + 0x300);
  89. memcpy(base, &except_vec_ejtag_debug, 0x80);
  90. flush_icache_range((unsigned long)base,
  91. (unsigned long)base + 0x80);
  92. }
  93. void __init prom_init(void)
  94. {
  95. board_nmi_handler_setup = mips_nmi_setup;
  96. board_ejtag_handler_setup = mips_ejtag_setup;
  97. mips_cm_probe();
  98. mips_cpc_probe();
  99. register_cps_smp_ops();
  100. pr_info("SoC Type: %s\n", get_system_type());
  101. }
  102. void __init prom_free_prom_memory(void)
  103. {
  104. }
  105. void __init device_tree_init(void)
  106. {
  107. if (!initial_boot_params)
  108. return;
  109. unflatten_and_copy_device_tree();
  110. }