blob: 0e6ad5f37e18069818d462a6bc0dd24bbd7dd767 [file] [log] [blame]
Michael Walle4ceb5c62020-10-15 23:08:57 +02001// SPDX-License-Identifier: GPL-2.0+
2
3#include <common.h>
4#include <asm/io.h>
5#include <asm/spl.h>
Michael Walle805b2422021-01-08 00:08:59 +01006#include <asm/arch-fsl-layerscape/fsl_serdes.h>
7#include <asm/arch-fsl-layerscape/soc.h>
Michael Walle4ceb5c62020-10-15 23:08:57 +02008
9#define DCFG_RCWSR25 0x160
10#define GPINFO_HW_VARIANT_MASK 0xff
11
Michael Walle805b2422021-01-08 00:08:59 +010012#define SERDES_LNDGCR0 0x1ea08c0
13#define LNDGCR0_PROTS_MASK GENMASK(11, 7)
14#define LNDGCR0_PROTS_SATA (0x2 << 7)
15#define SERDES_LNDGCR1 0x1ea08c4
16#define LNDGCR1_RDAT_INV BIT(31)
17
18/*
19 * On this board the SMARC PCIe lane D might be switched to SATA mode. This
20 * makes sense if this lane is connected to a Mini PCI slot and a mSATA card
21 * is plugged in. In this case, the RX pair is swapped and we need to invert
22 * the received data.
23 */
24static void fixup_sata_rx_polarity(void)
25{
26 u32 prot = in_le32(SERDES_LNDGCR0) & LNDGCR0_PROTS_MASK;
27 u32 tmp;
28
29 if (prot == LNDGCR0_PROTS_SATA) {
30 tmp = in_le32(SERDES_LNDGCR1);
31 tmp |= LNDGCR1_RDAT_INV;
32 out_le32(SERDES_LNDGCR1, tmp);
33 }
34}
35
Michael Walle4ceb5c62020-10-15 23:08:57 +020036int sl28_variant(void)
37{
38 return in_le32(DCFG_BASE + DCFG_RCWSR25) & GPINFO_HW_VARIANT_MASK;
39}
40
41int board_fit_config_name_match(const char *name)
42{
43 int variant = sl28_variant();
44
45 switch (variant) {
Michael Walle4029d352021-01-08 00:08:57 +010046 case 1:
47 return strcmp(name, "fsl-ls1028a-kontron-sl28-var1");
Michael Walleb4630102021-01-08 00:08:58 +010048 case 2:
49 return strcmp(name, "fsl-ls1028a-kontron-sl28-var2");
Michael Walle4ceb5c62020-10-15 23:08:57 +020050 case 3:
51 return strcmp(name, "fsl-ls1028a-kontron-sl28-var3");
52 case 4:
53 return strcmp(name, "fsl-ls1028a-kontron-sl28-var4");
54 default:
55 return strcmp(name, "fsl-ls1028a-kontron-sl28");
56 }
57}
58
59void board_boot_order(u32 *spl_boot_list)
60{
61 spl_boot_list[0] = BOOT_DEVICE_SPI;
62}
Michael Walle805b2422021-01-08 00:08:59 +010063
64int board_early_init_f(void)
65{
66 fixup_sata_rx_polarity();
67 fsl_lsch3_early_init_f();
68
69 return 0;
70}