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