blob: 39a24aa69ae87dfeef8b9bbae7b1b55b77bea71c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stefan Roese73606402015-10-20 15:14:47 +02002/*
3 * Copyright (C) 2015 Stefan Roese <sr@denx.de>
Stefan Roese73606402015-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>
Baruch Siach4417ff22020-01-20 14:20:11 +020013#include "../common/tlv_data.h"
Stefan Roese73606402015-10-20 15:14:47 +020014
Chris Packham1a07d212018-05-10 13:28:29 +120015#include "../drivers/ddr/marvell/a38x/ddr3_init.h"
Stefan Roese73606402015-10-20 15:14:47 +020016#include <../serdes/a38x/high_speed_env_spec.h>
17
18DECLARE_GLOBAL_DATA_PTR;
19
Stefan Roese73606402015-10-20 15:14:47 +020020/*
21 * Those values and defines are taken from the Marvell U-Boot version
22 * "u-boot-2013.01-15t1-clearfog"
23 */
24#define BOARD_GPP_OUT_ENA_LOW 0xffffffff
25#define BOARD_GPP_OUT_ENA_MID 0xffffffff
26
27#define BOARD_GPP_OUT_VAL_LOW 0x0
28#define BOARD_GPP_OUT_VAL_MID 0x0
29#define BOARD_GPP_POL_LOW 0x0
30#define BOARD_GPP_POL_MID 0x0
31
Baruch Siach4417ff22020-01-20 14:20:11 +020032static struct tlv_data cf_tlv_data;
33
34static void cf_read_tlv_data(void)
35{
36 static bool read_once;
37
38 if (read_once)
39 return;
40 read_once = true;
41
42 read_tlv_data(&cf_tlv_data);
43}
44
Stefan Roese73606402015-10-20 15:14:47 +020045static struct serdes_map board_serdes_map[] = {
46 {SATA0, SERDES_SPEED_3_GBPS, SERDES_DEFAULT_MODE, 0, 0},
47 {SGMII1, SERDES_SPEED_1_25_GBPS, SERDES_DEFAULT_MODE, 0, 0},
48 {PEX1, SERDES_SPEED_5_GBPS, PEX_ROOT_COMPLEX_X1, 0, 0},
49 {USB3_HOST1, SERDES_SPEED_5_GBPS, SERDES_DEFAULT_MODE, 0, 0},
50 {PEX2, SERDES_SPEED_5_GBPS, PEX_ROOT_COMPLEX_X1, 0, 0},
51 {SGMII2, SERDES_SPEED_1_25_GBPS, SERDES_DEFAULT_MODE, 0, 0},
52};
53
54int hws_board_topology_load(struct serdes_map **serdes_map_array, u8 *count)
55{
56 *serdes_map_array = board_serdes_map;
57 *count = ARRAY_SIZE(board_serdes_map);
58 return 0;
59}
60
61/*
62 * Define the DDR layout / topology here in the board file. This will
63 * be used by the DDR3 init code in the SPL U-Boot version to configure
64 * the DDR3 controller.
65 */
Chris Packham1a07d212018-05-10 13:28:29 +120066static struct mv_ddr_topology_map board_topology_map = {
67 DEBUG_LEVEL_ERROR,
Stefan Roese73606402015-10-20 15:14:47 +020068 0x1, /* active interfaces */
69 /* cs_mask, mirror, dqs_swap, ck_swap X PUPs */
70 { { { {0x1, 0, 0, 0},
71 {0x1, 0, 0, 0},
72 {0x1, 0, 0, 0},
73 {0x1, 0, 0, 0},
74 {0x1, 0, 0, 0} },
75 SPEED_BIN_DDR_1600K, /* speed_bin */
Chris Packham1a07d212018-05-10 13:28:29 +120076 MV_DDR_DEV_WIDTH_16BIT, /* memory_width */
77 MV_DDR_DIE_CAP_4GBIT, /* mem_size */
Chris Packham4bf81db2018-12-03 14:26:49 +130078 MV_DDR_FREQ_800, /* frequency */
Chris Packhamdd092bd2017-11-29 10:38:34 +130079 0, 0, /* cas_wl cas_l */
Chris Packham3a09e132018-05-10 13:28:30 +120080 MV_DDR_TEMP_LOW, /* temperature */
81 MV_DDR_TIM_DEFAULT} }, /* timing */
Chris Packham1a07d212018-05-10 13:28:29 +120082 BUS_MASK_32BIT, /* Busses mask */
83 MV_DDR_CFG_DEFAULT, /* ddr configuration data source */
84 { {0} }, /* raw spd data */
Baruch Siach43b76ce2020-01-20 14:20:07 +020085 {0}, /* timing parameters */
86 { {0} }, /* electrical configuration */
87 {0,}, /* electrical parameters */
88 0x3, /* clock enable mask */
Stefan Roese73606402015-10-20 15:14:47 +020089};
90
Chris Packham1a07d212018-05-10 13:28:29 +120091struct mv_ddr_topology_map *mv_ddr_topology_map_get(void)
Stefan Roese73606402015-10-20 15:14:47 +020092{
Baruch Siach4417ff22020-01-20 14:20:11 +020093 struct if_params *ifp = &board_topology_map.interface_params[0];
94
95 cf_read_tlv_data();
96
97 switch (cf_tlv_data.ram_size) {
98 case 4:
99 default:
100 ifp->memory_size = MV_DDR_DIE_CAP_4GBIT;
101 break;
102 case 8:
103 ifp->memory_size = MV_DDR_DIE_CAP_8GBIT;
104 break;
105 }
106
Stefan Roese73606402015-10-20 15:14:47 +0200107 /* Return the board topology as defined in the board code */
108 return &board_topology_map;
109}
110
111int board_early_init_f(void)
112{
113 /* Configure MPP */
114 writel(0x11111111, MVEBU_MPP_BASE + 0x00);
115 writel(0x11111111, MVEBU_MPP_BASE + 0x04);
116 writel(0x10400011, MVEBU_MPP_BASE + 0x08);
117 writel(0x22043333, MVEBU_MPP_BASE + 0x0c);
118 writel(0x44400002, MVEBU_MPP_BASE + 0x10);
119 writel(0x41144004, MVEBU_MPP_BASE + 0x14);
120 writel(0x40333333, MVEBU_MPP_BASE + 0x18);
121 writel(0x00004444, MVEBU_MPP_BASE + 0x1c);
122
123 /* Set GPP Out value */
124 writel(BOARD_GPP_OUT_VAL_LOW, MVEBU_GPIO0_BASE + 0x00);
125 writel(BOARD_GPP_OUT_VAL_MID, MVEBU_GPIO1_BASE + 0x00);
126
127 /* Set GPP Polarity */
128 writel(BOARD_GPP_POL_LOW, MVEBU_GPIO0_BASE + 0x0c);
129 writel(BOARD_GPP_POL_MID, MVEBU_GPIO1_BASE + 0x0c);
130
131 /* Set GPP Out Enable */
132 writel(BOARD_GPP_OUT_ENA_LOW, MVEBU_GPIO0_BASE + 0x04);
133 writel(BOARD_GPP_OUT_ENA_MID, MVEBU_GPIO1_BASE + 0x04);
134
135 return 0;
136}
137
138int board_init(void)
139{
Stefan Roese73606402015-10-20 15:14:47 +0200140 /* Address of boot parameters */
141 gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
142
143 /* Toggle GPIO41 to reset onboard switch and phy */
144 clrbits_le32(MVEBU_GPIO1_BASE + 0x0, BIT(9));
145 clrbits_le32(MVEBU_GPIO1_BASE + 0x4, BIT(9));
Patrick Wildtb6bce292017-05-09 13:54:44 +0200146 /* GPIO 19 on ClearFog rev 2.1 controls the uSOM onboard phy reset */
147 clrbits_le32(MVEBU_GPIO0_BASE + 0x0, BIT(19));
148 clrbits_le32(MVEBU_GPIO0_BASE + 0x4, BIT(19));
Stefan Roese73606402015-10-20 15:14:47 +0200149 mdelay(1);
150 setbits_le32(MVEBU_GPIO1_BASE + 0x0, BIT(9));
Patrick Wildtb6bce292017-05-09 13:54:44 +0200151 setbits_le32(MVEBU_GPIO0_BASE + 0x0, BIT(19));
Stefan Roese73606402015-10-20 15:14:47 +0200152 mdelay(10);
153
Stefan Roese73606402015-10-20 15:14:47 +0200154 return 0;
155}
156
157int checkboard(void)
158{
159 puts("Board: SolidRun ClearFog\n");
160
161 return 0;
162}
163
164int board_eth_init(bd_t *bis)
165{
166 cpu_eth_init(bis); /* Built in controller(s) come first */
167 return pci_eth_init(bis);
168}