Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2017 NXP |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 4 | */ |
| 5 | |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 6 | #include <asm/io.h> |
| 7 | #include <asm/arch/fsl_serdes.h> |
Bogdan Purcareata | 33ba939 | 2017-10-05 06:56:53 +0000 | [diff] [blame] | 8 | #include <fsl-mc/fsl_mc.h> |
Bogdan Purcareata | 33ba939 | 2017-10-05 06:56:53 +0000 | [diff] [blame] | 9 | |
| 10 | #if defined(CONFIG_RESET_PHY_R) |
| 11 | void reset_phy(void) |
| 12 | { |
| 13 | mc_env_boot(); |
| 14 | } |
| 15 | #endif /* CONFIG_RESET_PHY_R */ |
Ioana Ciornei | 666a2fb | 2020-05-15 09:56:48 +0300 | [diff] [blame] | 16 | |
Ioana Ciornei | 2ead443 | 2023-02-15 17:31:19 +0200 | [diff] [blame] | 17 | #if defined(CONFIG_MULTI_DTB_FIT) |
Ioana Ciornei | 666a2fb | 2020-05-15 09:56:48 +0300 | [diff] [blame] | 18 | |
Ioana Ciornei | 2ead443 | 2023-02-15 17:31:19 +0200 | [diff] [blame] | 19 | /* Structure to hold SERDES protocols supported (network interfaces are |
| 20 | * described in the DTS). |
Ioana Ciornei | 666a2fb | 2020-05-15 09:56:48 +0300 | [diff] [blame] | 21 | * |
| 22 | * @serdes_block: the index of the SERDES block |
| 23 | * @serdes_protocol: the decimal value of the protocol supported |
| 24 | * @dts_needed: DTS notes describing the current configuration are needed |
| 25 | * |
| 26 | * When dts_needed is true, the board_fit_config_name_match() function |
| 27 | * will try to exactly match the current configuration of the block with a DTS |
| 28 | * name provided. |
| 29 | */ |
| 30 | static struct serdes_configuration { |
| 31 | u8 serdes_block; |
| 32 | u32 serdes_protocol; |
| 33 | bool dts_needed; |
| 34 | } supported_protocols[] = { |
| 35 | /* Serdes block #1 */ |
| 36 | {1, 21, true}, |
| 37 | {1, 29, true}, |
| 38 | }; |
| 39 | |
| 40 | #define SUPPORTED_SERDES_PROTOCOLS ARRAY_SIZE(supported_protocols) |
| 41 | |
| 42 | static bool protocol_supported(u8 serdes_block, u32 protocol) |
| 43 | { |
| 44 | struct serdes_configuration serdes_conf; |
| 45 | int i; |
| 46 | |
| 47 | for (i = 0; i < SUPPORTED_SERDES_PROTOCOLS; i++) { |
| 48 | serdes_conf = supported_protocols[i]; |
| 49 | if (serdes_conf.serdes_block == serdes_block && |
| 50 | serdes_conf.serdes_protocol == protocol) |
| 51 | return true; |
| 52 | } |
| 53 | |
| 54 | return false; |
| 55 | } |
| 56 | |
| 57 | static void get_str_protocol(u8 serdes_block, u32 protocol, char *str) |
| 58 | { |
| 59 | struct serdes_configuration serdes_conf; |
| 60 | int i; |
| 61 | |
| 62 | for (i = 0; i < SUPPORTED_SERDES_PROTOCOLS; i++) { |
| 63 | serdes_conf = supported_protocols[i]; |
| 64 | if (serdes_conf.serdes_block == serdes_block && |
| 65 | serdes_conf.serdes_protocol == protocol) { |
| 66 | if (serdes_conf.dts_needed == true) |
| 67 | sprintf(str, "%u", protocol); |
| 68 | else |
| 69 | sprintf(str, "x"); |
| 70 | return; |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | int board_fit_config_name_match(const char *name) |
| 76 | { |
Tom Rini | 376b88a | 2022-10-28 20:27:13 -0400 | [diff] [blame] | 77 | struct ccsr_gur *gur = (void *)(CFG_SYS_FSL_GUTS_ADDR); |
Ioana Ciornei | 666a2fb | 2020-05-15 09:56:48 +0300 | [diff] [blame] | 78 | char expected_dts[100]; |
| 79 | char srds_s1_str[2]; |
| 80 | u32 srds_s1, cfg; |
| 81 | |
| 82 | cfg = in_le32(&gur->rcwsr[FSL_CHASSIS3_SRDS1_REGSR - 1]) & |
| 83 | FSL_CHASSIS3_SRDS1_PRTCL_MASK; |
| 84 | cfg >>= FSL_CHASSIS3_SRDS1_PRTCL_SHIFT; |
| 85 | srds_s1 = serdes_get_number(FSL_SRDS_1, cfg); |
| 86 | |
| 87 | /* Check for supported protocols. The default DTS will be used |
| 88 | * in this case |
| 89 | */ |
| 90 | if (!protocol_supported(1, srds_s1)) |
| 91 | return -1; |
| 92 | |
| 93 | get_str_protocol(1, srds_s1, srds_s1_str); |
| 94 | |
| 95 | sprintf(expected_dts, "fsl-ls1088a-qds-%s-x", srds_s1_str); |
| 96 | |
| 97 | if (!strcmp(name, expected_dts)) |
| 98 | return 0; |
| 99 | |
| 100 | return -1; |
| 101 | } |
| 102 | #endif |