prom.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
  7. */
  8. #include <linux/init.h>
  9. #include <linux/bootmem.h>
  10. #include <linux/smp.h>
  11. #include <asm/bootinfo.h>
  12. #include <asm/bmips.h>
  13. #include <asm/smp-ops.h>
  14. #include <asm/mipsregs.h>
  15. #include <bcm63xx_board.h>
  16. #include <bcm63xx_cpu.h>
  17. #include <bcm63xx_io.h>
  18. #include <bcm63xx_regs.h>
  19. #include <bcm63xx_gpio.h>
  20. void __init prom_init(void)
  21. {
  22. u32 reg, mask;
  23. bcm63xx_cpu_init();
  24. /* stop any running watchdog */
  25. bcm_wdt_writel(WDT_STOP_1, WDT_CTL_REG);
  26. bcm_wdt_writel(WDT_STOP_2, WDT_CTL_REG);
  27. /* disable all hardware blocks clock for now */
  28. if (BCMCPU_IS_3368())
  29. mask = CKCTL_3368_ALL_SAFE_EN;
  30. else if (BCMCPU_IS_6328())
  31. mask = CKCTL_6328_ALL_SAFE_EN;
  32. else if (BCMCPU_IS_6338())
  33. mask = CKCTL_6338_ALL_SAFE_EN;
  34. else if (BCMCPU_IS_6345())
  35. mask = CKCTL_6345_ALL_SAFE_EN;
  36. else if (BCMCPU_IS_6348())
  37. mask = CKCTL_6348_ALL_SAFE_EN;
  38. else if (BCMCPU_IS_6358())
  39. mask = CKCTL_6358_ALL_SAFE_EN;
  40. else if (BCMCPU_IS_6362())
  41. mask = CKCTL_6362_ALL_SAFE_EN;
  42. else if (BCMCPU_IS_6368())
  43. mask = CKCTL_6368_ALL_SAFE_EN;
  44. else
  45. mask = 0;
  46. reg = bcm_perf_readl(PERF_CKCTL_REG);
  47. reg &= ~mask;
  48. bcm_perf_writel(reg, PERF_CKCTL_REG);
  49. /* register gpiochip */
  50. bcm63xx_gpio_init();
  51. /* do low level board init */
  52. board_prom_init();
  53. if (IS_ENABLED(CONFIG_CPU_BMIPS4350) && IS_ENABLED(CONFIG_SMP)) {
  54. /* set up SMP */
  55. register_smp_ops(&bmips_smp_ops);
  56. /*
  57. * BCM6328 might not have its second CPU enabled, while BCM6358
  58. * needs special handling for its shared TLB, so disable SMP
  59. * for now.
  60. */
  61. if (BCMCPU_IS_6328()) {
  62. reg = bcm_readl(BCM_6328_OTP_BASE +
  63. OTP_USER_BITS_6328_REG(3));
  64. if (reg & OTP_6328_REG3_TP1_DISABLED)
  65. bmips_smp_enabled = 0;
  66. } else if (BCMCPU_IS_6358()) {
  67. bmips_smp_enabled = 0;
  68. }
  69. if (!bmips_smp_enabled)
  70. return;
  71. /*
  72. * The bootloader has set up the CPU1 reset vector at
  73. * 0xa000_0200.
  74. * This conflicts with the special interrupt vector (IV).
  75. * The bootloader has also set up CPU1 to respond to the wrong
  76. * IPI interrupt.
  77. * Here we will start up CPU1 in the background and ask it to
  78. * reconfigure itself then go back to sleep.
  79. */
  80. memcpy((void *)0xa0000200, &bmips_smp_movevec, 0x20);
  81. __sync();
  82. set_c0_cause(C_SW0);
  83. cpumask_set_cpu(1, &bmips_booted_mask);
  84. /*
  85. * FIXME: we really should have some sort of hazard barrier here
  86. */
  87. }
  88. }
  89. void __init prom_free_prom_memory(void)
  90. {
  91. }