Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Stefan Roese | 7360640 | 2015-10-20 15:14:47 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015 Stefan Roese <sr@denx.de> |
Stefan Roese | 7360640 | 2015-10-20 15:14:47 +0200 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <i2c.h> |
| 8 | #include <miiphy.h> |
| 9 | #include <netdev.h> |
| 10 | #include <asm/io.h> |
| 11 | #include <asm/arch/cpu.h> |
| 12 | #include <asm/arch/soc.h> |
| 13 | |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 14 | #include "../drivers/ddr/marvell/a38x/ddr3_init.h" |
Stefan Roese | 7360640 | 2015-10-20 15:14:47 +0200 | [diff] [blame] | 15 | #include <../serdes/a38x/high_speed_env_spec.h> |
| 16 | |
| 17 | DECLARE_GLOBAL_DATA_PTR; |
| 18 | |
Stefan Roese | 7360640 | 2015-10-20 15:14:47 +0200 | [diff] [blame] | 19 | /* |
| 20 | * Those values and defines are taken from the Marvell U-Boot version |
| 21 | * "u-boot-2013.01-15t1-clearfog" |
| 22 | */ |
| 23 | #define BOARD_GPP_OUT_ENA_LOW 0xffffffff |
| 24 | #define BOARD_GPP_OUT_ENA_MID 0xffffffff |
| 25 | |
| 26 | #define BOARD_GPP_OUT_VAL_LOW 0x0 |
| 27 | #define BOARD_GPP_OUT_VAL_MID 0x0 |
| 28 | #define BOARD_GPP_POL_LOW 0x0 |
| 29 | #define BOARD_GPP_POL_MID 0x0 |
| 30 | |
Stefan Roese | 7360640 | 2015-10-20 15:14:47 +0200 | [diff] [blame] | 31 | static struct serdes_map board_serdes_map[] = { |
| 32 | {SATA0, SERDES_SPEED_3_GBPS, SERDES_DEFAULT_MODE, 0, 0}, |
| 33 | {SGMII1, SERDES_SPEED_1_25_GBPS, SERDES_DEFAULT_MODE, 0, 0}, |
| 34 | {PEX1, SERDES_SPEED_5_GBPS, PEX_ROOT_COMPLEX_X1, 0, 0}, |
| 35 | {USB3_HOST1, SERDES_SPEED_5_GBPS, SERDES_DEFAULT_MODE, 0, 0}, |
| 36 | {PEX2, SERDES_SPEED_5_GBPS, PEX_ROOT_COMPLEX_X1, 0, 0}, |
| 37 | {SGMII2, SERDES_SPEED_1_25_GBPS, SERDES_DEFAULT_MODE, 0, 0}, |
| 38 | }; |
| 39 | |
| 40 | int hws_board_topology_load(struct serdes_map **serdes_map_array, u8 *count) |
| 41 | { |
| 42 | *serdes_map_array = board_serdes_map; |
| 43 | *count = ARRAY_SIZE(board_serdes_map); |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | /* |
| 48 | * Define the DDR layout / topology here in the board file. This will |
| 49 | * be used by the DDR3 init code in the SPL U-Boot version to configure |
| 50 | * the DDR3 controller. |
| 51 | */ |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 52 | static struct mv_ddr_topology_map board_topology_map = { |
| 53 | DEBUG_LEVEL_ERROR, |
Stefan Roese | 7360640 | 2015-10-20 15:14:47 +0200 | [diff] [blame] | 54 | 0x1, /* active interfaces */ |
| 55 | /* cs_mask, mirror, dqs_swap, ck_swap X PUPs */ |
| 56 | { { { {0x1, 0, 0, 0}, |
| 57 | {0x1, 0, 0, 0}, |
| 58 | {0x1, 0, 0, 0}, |
| 59 | {0x1, 0, 0, 0}, |
| 60 | {0x1, 0, 0, 0} }, |
| 61 | SPEED_BIN_DDR_1600K, /* speed_bin */ |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 62 | MV_DDR_DEV_WIDTH_16BIT, /* memory_width */ |
| 63 | MV_DDR_DIE_CAP_4GBIT, /* mem_size */ |
Chris Packham | 4bf81db | 2018-12-03 14:26:49 +1300 | [diff] [blame] | 64 | MV_DDR_FREQ_800, /* frequency */ |
Chris Packham | dd092bd | 2017-11-29 10:38:34 +1300 | [diff] [blame] | 65 | 0, 0, /* cas_wl cas_l */ |
Chris Packham | 3a09e13 | 2018-05-10 13:28:30 +1200 | [diff] [blame] | 66 | MV_DDR_TEMP_LOW, /* temperature */ |
| 67 | MV_DDR_TIM_DEFAULT} }, /* timing */ |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 68 | BUS_MASK_32BIT, /* Busses mask */ |
| 69 | MV_DDR_CFG_DEFAULT, /* ddr configuration data source */ |
| 70 | { {0} }, /* raw spd data */ |
Baruch Siach | 43b76ce | 2020-01-20 14:20:07 +0200 | [diff] [blame^] | 71 | {0}, /* timing parameters */ |
| 72 | { {0} }, /* electrical configuration */ |
| 73 | {0,}, /* electrical parameters */ |
| 74 | 0x3, /* clock enable mask */ |
Stefan Roese | 7360640 | 2015-10-20 15:14:47 +0200 | [diff] [blame] | 75 | }; |
| 76 | |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 77 | struct mv_ddr_topology_map *mv_ddr_topology_map_get(void) |
Stefan Roese | 7360640 | 2015-10-20 15:14:47 +0200 | [diff] [blame] | 78 | { |
| 79 | /* Return the board topology as defined in the board code */ |
| 80 | return &board_topology_map; |
| 81 | } |
| 82 | |
| 83 | int board_early_init_f(void) |
| 84 | { |
| 85 | /* Configure MPP */ |
| 86 | writel(0x11111111, MVEBU_MPP_BASE + 0x00); |
| 87 | writel(0x11111111, MVEBU_MPP_BASE + 0x04); |
| 88 | writel(0x10400011, MVEBU_MPP_BASE + 0x08); |
| 89 | writel(0x22043333, MVEBU_MPP_BASE + 0x0c); |
| 90 | writel(0x44400002, MVEBU_MPP_BASE + 0x10); |
| 91 | writel(0x41144004, MVEBU_MPP_BASE + 0x14); |
| 92 | writel(0x40333333, MVEBU_MPP_BASE + 0x18); |
| 93 | writel(0x00004444, MVEBU_MPP_BASE + 0x1c); |
| 94 | |
| 95 | /* Set GPP Out value */ |
| 96 | writel(BOARD_GPP_OUT_VAL_LOW, MVEBU_GPIO0_BASE + 0x00); |
| 97 | writel(BOARD_GPP_OUT_VAL_MID, MVEBU_GPIO1_BASE + 0x00); |
| 98 | |
| 99 | /* Set GPP Polarity */ |
| 100 | writel(BOARD_GPP_POL_LOW, MVEBU_GPIO0_BASE + 0x0c); |
| 101 | writel(BOARD_GPP_POL_MID, MVEBU_GPIO1_BASE + 0x0c); |
| 102 | |
| 103 | /* Set GPP Out Enable */ |
| 104 | writel(BOARD_GPP_OUT_ENA_LOW, MVEBU_GPIO0_BASE + 0x04); |
| 105 | writel(BOARD_GPP_OUT_ENA_MID, MVEBU_GPIO1_BASE + 0x04); |
| 106 | |
| 107 | return 0; |
| 108 | } |
| 109 | |
| 110 | int board_init(void) |
| 111 | { |
Stefan Roese | 7360640 | 2015-10-20 15:14:47 +0200 | [diff] [blame] | 112 | /* Address of boot parameters */ |
| 113 | gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100; |
| 114 | |
| 115 | /* Toggle GPIO41 to reset onboard switch and phy */ |
| 116 | clrbits_le32(MVEBU_GPIO1_BASE + 0x0, BIT(9)); |
| 117 | clrbits_le32(MVEBU_GPIO1_BASE + 0x4, BIT(9)); |
Patrick Wildt | b6bce29 | 2017-05-09 13:54:44 +0200 | [diff] [blame] | 118 | /* GPIO 19 on ClearFog rev 2.1 controls the uSOM onboard phy reset */ |
| 119 | clrbits_le32(MVEBU_GPIO0_BASE + 0x0, BIT(19)); |
| 120 | clrbits_le32(MVEBU_GPIO0_BASE + 0x4, BIT(19)); |
Stefan Roese | 7360640 | 2015-10-20 15:14:47 +0200 | [diff] [blame] | 121 | mdelay(1); |
| 122 | setbits_le32(MVEBU_GPIO1_BASE + 0x0, BIT(9)); |
Patrick Wildt | b6bce29 | 2017-05-09 13:54:44 +0200 | [diff] [blame] | 123 | setbits_le32(MVEBU_GPIO0_BASE + 0x0, BIT(19)); |
Stefan Roese | 7360640 | 2015-10-20 15:14:47 +0200 | [diff] [blame] | 124 | mdelay(10); |
| 125 | |
Stefan Roese | 7360640 | 2015-10-20 15:14:47 +0200 | [diff] [blame] | 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | int checkboard(void) |
| 130 | { |
| 131 | puts("Board: SolidRun ClearFog\n"); |
| 132 | |
| 133 | return 0; |
| 134 | } |
| 135 | |
| 136 | int board_eth_init(bd_t *bis) |
| 137 | { |
| 138 | cpu_eth_init(bis); /* Built in controller(s) come first */ |
| 139 | return pci_eth_init(bis); |
| 140 | } |