init.c 2.7 KB

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