blob: 0d0d5de15623b0b75c88178f7918065c78e94c9d [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Prabhakar Kushwahae60476a2015-03-20 19:28:26 -07002/*
3 * Copyright 2015 Freescale Semiconductor, Inc.
Prabhakar Kushwahae60476a2015-03-20 19:28:26 -07004 */
5
Prabhakar Kushwahae60476a2015-03-20 19:28:26 -07006#include <asm/io.h>
7#include <asm/arch/fsl_serdes.h>
Bogdan Purcareata33a89912017-05-24 16:40:21 +00008#include <fsl-mc/fsl_mc.h>
Prabhakar Kushwahae60476a2015-03-20 19:28:26 -07009
Pratiyush Mohan Srivastava30677de2016-01-20 12:29:03 +053010#define MC_BOOT_ENV_VAR "mcinitcmd"
Prabhakar Kushwahae60476a2015-03-20 19:28:26 -070011
Bogdan Purcareata33a89912017-05-24 16:40:21 +000012#if defined(CONFIG_RESET_PHY_R)
13void reset_phy(void)
14{
15 mc_env_boot();
16}
17#endif /* CONFIG_RESET_PHY_R */
Ioana Ciornei020ed9c2020-05-18 14:48:36 +030018
Ioana Ciornei6bd026d2023-02-15 17:31:18 +020019#if defined(CONFIG_MULTI_DTB_FIT)
Ioana Ciornei020ed9c2020-05-18 14:48:36 +030020
Ioana Ciornei6bd026d2023-02-15 17:31:18 +020021/* Structure to hold SERDES protocols supported (network interfaces are
22 * described in the DTS).
Ioana Ciornei020ed9c2020-05-18 14:48:36 +030023 *
24 * @serdes_block: the index of the SERDES block
25 * @serdes_protocol: the decimal value of the protocol supported
26 * @dts_needed: DTS notes describing the current configuration are needed
27 *
28 * When dts_needed is true, the board_fit_config_name_match() function
29 * will try to exactly match the current configuration of the block with a DTS
30 * name provided.
31 */
32static struct serdes_configuration {
33 u8 serdes_block;
34 u32 serdes_protocol;
35 bool dts_needed;
36} supported_protocols[] = {
37 /* Serdes block #1 */
38 {1, 42, true},
39
40 /* Serdes block #2 */
41 {2, 65, false},
42};
43
44#define SUPPORTED_SERDES_PROTOCOLS ARRAY_SIZE(supported_protocols)
45
46static bool protocol_supported(u8 serdes_block, u32 protocol)
47{
48 struct serdes_configuration serdes_conf;
49 int i;
50
51 for (i = 0; i < SUPPORTED_SERDES_PROTOCOLS; i++) {
52 serdes_conf = supported_protocols[i];
53 if (serdes_conf.serdes_block == serdes_block &&
54 serdes_conf.serdes_protocol == protocol)
55 return true;
56 }
57
58 return false;
59}
60
61static void get_str_protocol(u8 serdes_block, u32 protocol, char *str)
62{
63 struct serdes_configuration serdes_conf;
64 int i;
65
66 for (i = 0; i < SUPPORTED_SERDES_PROTOCOLS; i++) {
67 serdes_conf = supported_protocols[i];
68 if (serdes_conf.serdes_block == serdes_block &&
69 serdes_conf.serdes_protocol == protocol) {
70 if (serdes_conf.dts_needed == true)
71 sprintf(str, "%u", protocol);
72 else
73 sprintf(str, "x");
74 return;
75 }
76 }
77}
78
79int board_fit_config_name_match(const char *name)
80{
Tom Rini6cc04542022-10-28 20:27:13 -040081 struct ccsr_gur *gur = (void *)(CFG_SYS_FSL_GUTS_ADDR);
Ioana Ciornei020ed9c2020-05-18 14:48:36 +030082 u32 rcw_status = in_le32(&gur->rcwsr[28]);
83 char srds_s1_str[2], srds_s2_str[2];
84 u32 srds_s1, srds_s2;
85 char expected_dts[100];
86
87 srds_s1 = rcw_status & FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_MASK;
88 srds_s1 >>= FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_SHIFT;
89
90 srds_s2 = rcw_status & FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_MASK;
91 srds_s2 >>= FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_SHIFT;
92
93 /* Check for supported protocols. The default DTS will be used
94 * in this case
95 */
96 if (!protocol_supported(1, srds_s1) ||
97 !protocol_supported(2, srds_s2))
98 return -1;
99
100 get_str_protocol(1, srds_s1, srds_s1_str);
101 get_str_protocol(2, srds_s2, srds_s2_str);
102
103 printf("expected_dts %s\n", expected_dts);
104 sprintf(expected_dts, "fsl-ls2080a-qds-%s-%s",
105 srds_s1_str, srds_s2_str);
106
107 if (!strcmp(name, expected_dts))
108 return 0;
109
110 printf("this is not!\n");
111 return -1;
112}
113
114#endif