blob: 8b63811946885e15bc624e8b8c298d2d950eb76a [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stefan Roese0299c902015-10-20 15:14:47 +02002/*
3 * Copyright (C) 2015 Stefan Roese <sr@denx.de>
Stefan Roese0299c902015-10-20 15:14:47 +02004 */
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 Packham2b4ffbf2018-05-10 13:28:29 +120014#include "../drivers/ddr/marvell/a38x/ddr3_init.h"
Stefan Roese0299c902015-10-20 15:14:47 +020015#include <../serdes/a38x/high_speed_env_spec.h>
16
17DECLARE_GLOBAL_DATA_PTR;
18
Stefan Roese0299c902015-10-20 15:14:47 +020019/*
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 Roese0299c902015-10-20 15:14:47 +020031static 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
40int 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 Packham2b4ffbf2018-05-10 13:28:29 +120052static struct mv_ddr_topology_map board_topology_map = {
53 DEBUG_LEVEL_ERROR,
Stefan Roese0299c902015-10-20 15:14:47 +020054 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 Packham2b4ffbf2018-05-10 13:28:29 +120062 MV_DDR_DEV_WIDTH_16BIT, /* memory_width */
63 MV_DDR_DIE_CAP_4GBIT, /* mem_size */
Chris Packhamebb1a592018-12-03 14:26:49 +130064 MV_DDR_FREQ_800, /* frequency */
Chris Packham01c541e2017-11-29 10:38:34 +130065 0, 0, /* cas_wl cas_l */
Chris Packhame6f61622018-05-10 13:28:30 +120066 MV_DDR_TEMP_LOW, /* temperature */
67 MV_DDR_TIM_DEFAULT} }, /* timing */
Chris Packham2b4ffbf2018-05-10 13:28:29 +120068 BUS_MASK_32BIT, /* Busses mask */
69 MV_DDR_CFG_DEFAULT, /* ddr configuration data source */
70 { {0} }, /* raw spd data */
Baruch Siach66646fa2020-01-20 14:20:07 +020071 {0}, /* timing parameters */
72 { {0} }, /* electrical configuration */
73 {0,}, /* electrical parameters */
74 0x3, /* clock enable mask */
Stefan Roese0299c902015-10-20 15:14:47 +020075};
76
Chris Packham2b4ffbf2018-05-10 13:28:29 +120077struct mv_ddr_topology_map *mv_ddr_topology_map_get(void)
Stefan Roese0299c902015-10-20 15:14:47 +020078{
79 /* Return the board topology as defined in the board code */
80 return &board_topology_map;
81}
82
83int 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
110int board_init(void)
111{
Stefan Roese0299c902015-10-20 15:14:47 +0200112 /* 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 Wildtfb9765d2017-05-09 13:54:44 +0200118 /* 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 Roese0299c902015-10-20 15:14:47 +0200121 mdelay(1);
122 setbits_le32(MVEBU_GPIO1_BASE + 0x0, BIT(9));
Patrick Wildtfb9765d2017-05-09 13:54:44 +0200123 setbits_le32(MVEBU_GPIO0_BASE + 0x0, BIT(19));
Stefan Roese0299c902015-10-20 15:14:47 +0200124 mdelay(10);
125
Stefan Roese0299c902015-10-20 15:14:47 +0200126 return 0;
127}
128
129int checkboard(void)
130{
131 puts("Board: SolidRun ClearFog\n");
132
133 return 0;
134}
135
136int 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}