Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Prabhakar Kushwaha | e60476a | 2015-03-20 19:28:26 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2015 Freescale Semiconductor, Inc. |
Prabhakar Kushwaha | e60476a | 2015-03-20 19:28:26 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
Prabhakar Kushwaha | e60476a | 2015-03-20 19:28:26 -0700 | [diff] [blame] | 6 | #include <asm/io.h> |
| 7 | #include <asm/arch/fsl_serdes.h> |
Bogdan Purcareata | 33a8991 | 2017-05-24 16:40:21 +0000 | [diff] [blame] | 8 | #include <fsl-mc/fsl_mc.h> |
Prabhakar Kushwaha | e60476a | 2015-03-20 19:28:26 -0700 | [diff] [blame] | 9 | |
Pratiyush Mohan Srivastava | 30677de | 2016-01-20 12:29:03 +0530 | [diff] [blame] | 10 | #define MC_BOOT_ENV_VAR "mcinitcmd" |
Prabhakar Kushwaha | e60476a | 2015-03-20 19:28:26 -0700 | [diff] [blame] | 11 | |
Bogdan Purcareata | 33a8991 | 2017-05-24 16:40:21 +0000 | [diff] [blame] | 12 | #if defined(CONFIG_RESET_PHY_R) |
| 13 | void reset_phy(void) |
| 14 | { |
| 15 | mc_env_boot(); |
| 16 | } |
| 17 | #endif /* CONFIG_RESET_PHY_R */ |
Ioana Ciornei | 020ed9c | 2020-05-18 14:48:36 +0300 | [diff] [blame] | 18 | |
Ioana Ciornei | 6bd026d | 2023-02-15 17:31:18 +0200 | [diff] [blame] | 19 | #if defined(CONFIG_MULTI_DTB_FIT) |
Ioana Ciornei | 020ed9c | 2020-05-18 14:48:36 +0300 | [diff] [blame] | 20 | |
Ioana Ciornei | 6bd026d | 2023-02-15 17:31:18 +0200 | [diff] [blame] | 21 | /* Structure to hold SERDES protocols supported (network interfaces are |
| 22 | * described in the DTS). |
Ioana Ciornei | 020ed9c | 2020-05-18 14:48:36 +0300 | [diff] [blame] | 23 | * |
| 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 | */ |
| 32 | static 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 | |
| 46 | static 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 | |
| 61 | static 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 | |
| 79 | int board_fit_config_name_match(const char *name) |
| 80 | { |
Tom Rini | 6cc0454 | 2022-10-28 20:27:13 -0400 | [diff] [blame] | 81 | struct ccsr_gur *gur = (void *)(CFG_SYS_FSL_GUTS_ADDR); |
Ioana Ciornei | 020ed9c | 2020-05-18 14:48:36 +0300 | [diff] [blame] | 82 | 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 |