plat_bl31_setup.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (C) 2018 Marvell International Ltd.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. * https://spdx.org/licenses
  6. */
  7. #include <lib/mmio.h>
  8. #include <armada_common.h>
  9. #include <dram_win.h>
  10. #include <io_addr_dec.h>
  11. #include <marvell_plat_priv.h>
  12. #include <plat_marvell.h>
  13. /* This routine does MPP initialization */
  14. static void marvell_bl31_mpp_init(void)
  15. {
  16. mmio_clrbits_32(MVEBU_NB_GPIO_SEL_REG, 1 << MVEBU_GPIO_TW1_GPIO_EN_OFF);
  17. /* Set hidden GPIO setting for SPI.
  18. * In north_bridge_pin_out_en_high register 13804,
  19. * bit 28 is the one which enables CS, CLK pins to be
  20. * output, need to set it to 1.
  21. * The initial value of this bit is 1, but in UART boot mode
  22. * initialization, this bit is disabled and the SPI CS and CLK pins
  23. * are used for downloading image purpose; so after downloading,
  24. * we should set this bit to 1 again to enable SPI CS and CLK pins.
  25. * And anyway, this bit value should be 1 in all modes,
  26. * so here we does not judge boot mode and set this bit to 1 always.
  27. */
  28. mmio_setbits_32(MVEBU_NB_GPIO_OUTPUT_EN_HIGH_REG,
  29. 1 << MVEBU_GPIO_NB_SPI_PIN_MODE_OFF);
  30. }
  31. /* This function overruns the same function in marvell_bl31_setup.c */
  32. void bl31_plat_arch_setup(void)
  33. {
  34. struct dec_win_config *io_dec_map;
  35. uint32_t dec_win_num;
  36. struct dram_win_map dram_wins_map;
  37. marvell_bl31_plat_arch_setup();
  38. /* MPP init */
  39. marvell_bl31_mpp_init();
  40. /* initialize the timer for delay functionality */
  41. plat_delay_timer_init();
  42. /* CPU address decoder windows initialization. */
  43. cpu_wins_init();
  44. /* fetch CPU-DRAM window mapping information by reading
  45. * CPU-DRAM decode windows (only the enabled ones)
  46. */
  47. dram_win_map_build(&dram_wins_map);
  48. /* Get IO address decoder windows */
  49. if (marvell_get_io_dec_win_conf(&io_dec_map, &dec_win_num)) {
  50. printf("No IO address decoder windows configurations found!\n");
  51. return;
  52. }
  53. /* IO address decoder init */
  54. if (init_io_addr_dec(&dram_wins_map, io_dec_map, dec_win_num)) {
  55. printf("IO address decoder windows initialization failed!\n");
  56. return;
  57. }
  58. }