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