prom.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. *
  4. * Copyright (C) 2010 John Crispin <john@phrozen.org>
  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 struct is filled by the soc specific detection code and holds
  21. * information about the specific soc type, revision and name
  22. */
  23. static struct ltq_soc_info soc_info;
  24. /*
  25. * These structs are used to override vsmp_init_secondary()
  26. */
  27. #if defined(CONFIG_MIPS_MT_SMP)
  28. extern const struct plat_smp_ops vsmp_smp_ops;
  29. static struct plat_smp_ops lantiq_smp_ops;
  30. #endif
  31. const char *get_system_type(void)
  32. {
  33. return soc_info.sys_type;
  34. }
  35. int ltq_soc_type(void)
  36. {
  37. return soc_info.type;
  38. }
  39. static void __init prom_init_cmdline(void)
  40. {
  41. int argc = fw_arg0;
  42. char **argv = (char **) KSEG1ADDR(fw_arg1);
  43. int i;
  44. arcs_cmdline[0] = '\0';
  45. for (i = 0; i < argc; i++) {
  46. char *p = (char *) KSEG1ADDR(argv[i]);
  47. if (CPHYSADDR(p) && *p) {
  48. strlcat(arcs_cmdline, p, sizeof(arcs_cmdline));
  49. strlcat(arcs_cmdline, " ", sizeof(arcs_cmdline));
  50. }
  51. }
  52. }
  53. void __init plat_mem_setup(void)
  54. {
  55. void *dtb;
  56. ioport_resource.start = IOPORT_RESOURCE_START;
  57. ioport_resource.end = IOPORT_RESOURCE_END;
  58. iomem_resource.start = IOMEM_RESOURCE_START;
  59. iomem_resource.end = IOMEM_RESOURCE_END;
  60. set_io_port_base((unsigned long) KSEG1);
  61. dtb = get_fdt();
  62. if (dtb == NULL)
  63. panic("no dtb found");
  64. /*
  65. * Load the devicetree. This causes the chosen node to be
  66. * parsed resulting in our memory appearing
  67. */
  68. __dt_setup_arch(dtb);
  69. }
  70. #if defined(CONFIG_MIPS_MT_SMP)
  71. static void lantiq_init_secondary(void)
  72. {
  73. /*
  74. * MIPS CPU startup function vsmp_init_secondary() will only
  75. * enable some of the interrupts for the second CPU/VPE.
  76. */
  77. set_c0_status(ST0_IM);
  78. }
  79. #endif
  80. void __init prom_init(void)
  81. {
  82. /* call the soc specific detetcion code and get it to fill soc_info */
  83. ltq_soc_detect(&soc_info);
  84. snprintf(soc_info.sys_type, LTQ_SYS_TYPE_LEN - 1, "%s rev %s",
  85. soc_info.name, soc_info.rev_type);
  86. soc_info.sys_type[LTQ_SYS_TYPE_LEN - 1] = '\0';
  87. pr_info("SoC: %s\n", soc_info.sys_type);
  88. prom_init_cmdline();
  89. #if defined(CONFIG_MIPS_MT_SMP)
  90. lantiq_smp_ops = vsmp_smp_ops;
  91. if (cpu_has_mipsmt)
  92. lantiq_smp_ops.init_secondary = lantiq_init_secondary;
  93. register_smp_ops(&lantiq_smp_ops);
  94. #endif
  95. }