Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Kumar Gala | bd29be8 | 2010-06-01 10:29:11 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2010-2011 Freescale Semiconductor, Inc. |
Kumar Gala | bd29be8 | 2010-06-01 10:29:11 -0500 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <asm/fsl_serdes.h> |
| 8 | #include <asm/processor.h> |
| 9 | #include <asm/io.h> |
| 10 | #include "fsl_corenet_serdes.h" |
| 11 | |
| 12 | static u8 serdes_cfg_tbl[][SRDS_MAX_LANES] = { |
| 13 | [0x2] = {NONE, NONE, PCIE1, PCIE1, SRIO1, SRIO1, SRIO1, SRIO1, |
| 14 | NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, |
| 15 | SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, NONE, NONE, }, |
| 16 | [0x5] = {NONE, NONE, PCIE1, PCIE3, PCIE2, PCIE2, PCIE2, PCIE2, |
| 17 | NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, |
| 18 | SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, NONE, NONE, }, |
| 19 | [0x8] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2, |
| 20 | PCIE2, PCIE2, PCIE2, NONE, NONE, NONE, NONE, SATA1, |
| 21 | SATA2, NONE, NONE, NONE, NONE, }, |
Mingkai Hu | 4a75bb3 | 2011-04-15 15:18:03 +0800 | [diff] [blame] | 22 | [0x9] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2, |
Kumar Gala | e9f9839 | 2011-07-21 00:20:20 -0500 | [diff] [blame] | 23 | PCIE2, PCIE2, PCIE2, NONE, NONE, XAUI_FM1, XAUI_FM1, |
| 24 | XAUI_FM1, XAUI_FM1, NONE, NONE, NONE, NONE, }, |
Kumar Gala | bd29be8 | 2010-06-01 10:29:11 -0500 | [diff] [blame] | 25 | [0xa] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2, |
| 26 | PCIE2, PCIE2, PCIE2, NONE, NONE, PCIE3, PCIE3, PCIE3, |
| 27 | PCIE3, NONE, NONE, NONE, NONE, }, |
| 28 | [0xf] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, SRIO2, |
| 29 | SRIO2, SRIO1, SRIO1, NONE, NONE, PCIE3, SGMII_FM1_DTSEC5, |
| 30 | SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, NONE, NONE, }, |
| 31 | [0x14] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2, |
| 32 | PCIE2, SRIO1, SRIO1, NONE, NONE, AURORA, |
| 33 | SGMII_FM1_DTSEC5, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, |
| 34 | NONE, NONE, NONE, }, |
| 35 | [0x16] = {NONE, NONE, PCIE1, PCIE3, PCIE2, PCIE2, SGMII_FM1_DTSEC3, |
| 36 | SGMII_FM1_DTSEC4, NONE, NONE, NONE, NONE, SATA1, SATA2, NONE, |
| 37 | NONE, NONE, NONE, }, |
Mingkai Hu | 4a75bb3 | 2011-04-15 15:18:03 +0800 | [diff] [blame] | 38 | [0x17] = {NONE, NONE, PCIE1, PCIE3, PCIE2, PCIE2, SGMII_FM1_DTSEC3, |
Kumar Gala | e9f9839 | 2011-07-21 00:20:20 -0500 | [diff] [blame] | 39 | SGMII_FM1_DTSEC4, NONE, NONE, XAUI_FM1, XAUI_FM1, XAUI_FM1, |
| 40 | XAUI_FM1, NONE, NONE, NONE, NONE, }, |
Mingkai Hu | 4a75bb3 | 2011-04-15 15:18:03 +0800 | [diff] [blame] | 41 | [0x19] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, PCIE2, |
| 42 | PCIE2, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, |
| 43 | NONE, NONE, SATA1, SATA2, NONE, NONE, NONE, NONE, }, |
Kumar Gala | bd29be8 | 2010-06-01 10:29:11 -0500 | [diff] [blame] | 44 | [0x1a] = {NONE, NONE, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, SRIO2, |
| 45 | SRIO2, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, |
| 46 | NONE, NONE, SATA1, SATA2, NONE, NONE, NONE, NONE, }, |
| 47 | [0x1c] = {NONE, NONE, PCIE1, SGMII_FM1_DTSEC2, PCIE2, PCIE2, |
| 48 | SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4, NONE, NONE, AURORA, |
| 49 | SGMII_FM1_DTSEC5, NONE, NONE, NONE, NONE, NONE, NONE, }, |
| 50 | }; |
| 51 | |
| 52 | enum srds_prtcl serdes_get_prtcl(int cfg, int lane) |
| 53 | { |
Kumar Gala | e9f9839 | 2011-07-21 00:20:20 -0500 | [diff] [blame] | 54 | enum srds_prtcl prtcl; |
| 55 | u32 svr = get_svr(); |
| 56 | u32 ver = SVR_SOC_VER(svr); |
| 57 | |
Kumar Gala | bd29be8 | 2010-06-01 10:29:11 -0500 | [diff] [blame] | 58 | if (!serdes_lane_enabled(lane)) |
| 59 | return NONE; |
| 60 | |
Kumar Gala | e9f9839 | 2011-07-21 00:20:20 -0500 | [diff] [blame] | 61 | prtcl = serdes_cfg_tbl[cfg][lane]; |
| 62 | |
| 63 | /* P2040[e] does not support XAUI */ |
York Sun | 8cb6548 | 2012-07-06 17:10:33 -0500 | [diff] [blame] | 64 | if (ver == SVR_P2040 && prtcl == XAUI_FM1) |
Kumar Gala | e9f9839 | 2011-07-21 00:20:20 -0500 | [diff] [blame] | 65 | prtcl = NONE; |
| 66 | |
| 67 | return prtcl; |
Kumar Gala | bd29be8 | 2010-06-01 10:29:11 -0500 | [diff] [blame] | 68 | } |
Mingkai Hu | 4a75bb3 | 2011-04-15 15:18:03 +0800 | [diff] [blame] | 69 | |
| 70 | int is_serdes_prtcl_valid(u32 prtcl) |
| 71 | { |
| 72 | int i; |
Kumar Gala | e9f9839 | 2011-07-21 00:20:20 -0500 | [diff] [blame] | 73 | u32 svr = get_svr(); |
| 74 | u32 ver = SVR_SOC_VER(svr); |
Mingkai Hu | 4a75bb3 | 2011-04-15 15:18:03 +0800 | [diff] [blame] | 75 | |
Axel Lin | ab95b09 | 2013-05-26 15:00:30 +0800 | [diff] [blame] | 76 | if (prtcl >= ARRAY_SIZE(serdes_cfg_tbl)) |
Mingkai Hu | 4a75bb3 | 2011-04-15 15:18:03 +0800 | [diff] [blame] | 77 | return 0; |
| 78 | |
Kumar Gala | e9f9839 | 2011-07-21 00:20:20 -0500 | [diff] [blame] | 79 | /* P2040[e] does not support XAUI */ |
York Sun | 8cb6548 | 2012-07-06 17:10:33 -0500 | [diff] [blame] | 80 | if (ver == SVR_P2040 && prtcl == XAUI_FM1) |
Kumar Gala | e9f9839 | 2011-07-21 00:20:20 -0500 | [diff] [blame] | 81 | return 0; |
| 82 | |
Mingkai Hu | 4a75bb3 | 2011-04-15 15:18:03 +0800 | [diff] [blame] | 83 | for (i = 0; i < SRDS_MAX_LANES; i++) { |
| 84 | if (serdes_cfg_tbl[prtcl][i] != NONE) |
| 85 | return 1; |
| 86 | } |
| 87 | |
| 88 | return 0; |
| 89 | } |