prom.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. *
  4. * Copyright (C) 2010 John Crispin <[email protected]>
  5. */
  6. #include <linux/export.h>
  7. #include <linux/clk.h>
  8. #include <linux/memblock.h>
  9. #include <linux/of_fdt.h>
  10. #include <asm/bootinfo.h>
  11. #include <asm/time.h>
  12. #include <asm/prom.h>
  13. #include <lantiq.h>
  14. #include "prom.h"
  15. #include "clk.h"
  16. /* access to the ebu needs to be locked between different drivers */
  17. DEFINE_SPINLOCK(ebu_lock);
  18. EXPORT_SYMBOL_GPL(ebu_lock);
  19. /*
  20. * This is needed by the VPE loader code, just set it to 0 and assume
  21. * that the firmware hardcodes this value to something useful.
  22. */
  23. unsigned long physical_memsize = 0L;
  24. /*
  25. * this struct is filled by the soc specific detection code and holds
  26. * information about the specific soc type, revision and name
  27. */
  28. static struct ltq_soc_info soc_info;
  29. /*
  30. * These structs are used to override vsmp_init_secondary()
  31. */
  32. #if defined(CONFIG_MIPS_MT_SMP)
  33. extern const struct plat_smp_ops vsmp_smp_ops;
  34. static struct plat_smp_ops lantiq_smp_ops;
  35. #endif
  36. const char *get_system_type(void)
  37. {
  38. return soc_info.sys_type;
  39. }
  40. int ltq_soc_type(void)
  41. {
  42. return soc_info.type;
  43. }
  44. static void __init prom_init_cmdline(void)
  45. {
  46. int argc = fw_arg0;
  47. char **argv = (char **) KSEG1ADDR(fw_arg1);
  48. int i;
  49. arcs_cmdline[0] = '\0';
  50. for (i = 0; i < argc; i++) {
  51. char *p = (char *) KSEG1ADDR(argv[i]);
  52. if (CPHYSADDR(p) && *p) {
  53. strlcat(arcs_cmdline, p, sizeof(arcs_cmdline));
  54. strlcat(arcs_cmdline, " ", sizeof(arcs_cmdline));
  55. }
  56. }
  57. }
  58. void __init plat_mem_setup(void)
  59. {
  60. void *dtb;
  61. ioport_resource.start = IOPORT_RESOURCE_START;
  62. ioport_resource.end = IOPORT_RESOURCE_END;
  63. iomem_resource.start = IOMEM_RESOURCE_START;
  64. iomem_resource.end = IOMEM_RESOURCE_END;
  65. set_io_port_base((unsigned long) KSEG1);
  66. dtb = get_fdt();
  67. if (dtb == NULL)
  68. panic("no dtb found");
  69. /*
  70. * Load the devicetree. This causes the chosen node to be
  71. * parsed resulting in our memory appearing
  72. */
  73. __dt_setup_arch(dtb);
  74. }
  75. #if defined(CONFIG_MIPS_MT_SMP)
  76. static void lantiq_init_secondary(void)
  77. {
  78. /*
  79. * MIPS CPU startup function vsmp_init_secondary() will only
  80. * enable some of the interrupts for the second CPU/VPE.
  81. */
  82. set_c0_status(ST0_IM);
  83. }
  84. #endif
  85. void __init prom_init(void)
  86. {
  87. /* call the soc specific detetcion code and get it to fill soc_info */
  88. ltq_soc_detect(&soc_info);
  89. snprintf(soc_info.sys_type, LTQ_SYS_TYPE_LEN - 1, "%s rev %s",
  90. soc_info.name, soc_info.rev_type);
  91. soc_info.sys_type[LTQ_SYS_TYPE_LEN - 1] = '\0';
  92. pr_info("SoC: %s\n", soc_info.sys_type);
  93. prom_init_cmdline();
  94. #if defined(CONFIG_MIPS_MT_SMP)
  95. if (cpu_has_mipsmt) {
  96. lantiq_smp_ops = vsmp_smp_ops;
  97. lantiq_smp_ops.init_secondary = lantiq_init_secondary;
  98. register_smp_ops(&lantiq_smp_ops);
  99. }
  100. #endif
  101. }