summaryrefslogtreecommitdiff
path: root/arch/powerpc/cpu/mpc85xx/b4860_serdes.c
blob: 9990202f421af77c459f2810b340af4bfb8c879d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
 * Copyright 2012 Freescale Semiconductor, Inc.
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#include <common.h>
#include <asm/fsl_serdes.h>
#include <asm/processor.h>
#include <asm/io.h>
#include "fsl_corenet2_serdes.h"

struct serdes_config {
	u8 protocol;
	u8 lanes[SRDS_MAX_LANES];
};

static struct serdes_config serdes1_cfg_tbl[] = {
	/* SerDes 1 */
	{0x0D, {CPRI8, CPRI7, CPRI6, CPRI5,
		CPRI4, CPRI3, CPRI2, CPRI1}},
	{0x0E, {CPRI8, CPRI7,	CPRI6, CPRI5,
		CPRI4, CPRI3, CPRI2, CPRI1}},
	{0x12, {CPRI8, CPRI7,	CPRI6, CPRI5,
		CPRI4, CPRI3, CPRI2, CPRI1}},
	{0x2a, {SGMII_FM1_DTSEC5, SGMII_FM1_DTSEC6,
		CPRI6, CPRI5, CPRI4, CPRI3, CPRI2, CPRI1}},
	{0x30, {AURORA, AURORA,
		SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
		CPRI4, CPRI3, CPRI2, CPRI1}},
	{0x32, {AURORA, AURORA,
		SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
		CPRI4, CPRI3, CPRI2, CPRI1}},
	{0x33, {AURORA, AURORA,
		SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
		CPRI4, CPRI3, CPRI2, CPRI1}},
	{0x34, {AURORA, AURORA,
		SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
		CPRI4, CPRI3, CPRI2, CPRI1}},
	{0x3E, {CPRI8, CPRI7,	CPRI6, CPRI5,
		CPRI4, CPRI3, CPRI2, CPRI1}},
	{}
};
static struct serdes_config serdes2_cfg_tbl[] = {
	/* SerDes 2 */
	{0x18, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
		SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
		AURORA, AURORA,	SRIO1, SRIO1}},
	{0x1D, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
		SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
		AURORA, AURORA,	SRIO1, SRIO1}},
	{0x2B, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
		SRIO2, SRIO2,
		AURORA, AURORA, SRIO1, SRIO1}},
	{0x30, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
		SRIO2, SRIO2,
		AURORA, AURORA,
		SRIO1, SRIO1}},
	{0x49, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
		SGMII_FM1_DTSEC3, AURORA,
		SRIO1, SRIO1, SRIO1, SRIO1}},
	{0x4A, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
		SGMII_FM1_DTSEC3, AURORA,
		SRIO1, SRIO1, SRIO1, SRIO1}},
	{0x4C, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
		SGMII_FM1_DTSEC3, AURORA,
		SRIO1, SRIO1, SRIO1, SRIO1}},
	{0x4E, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
		SGMII_FM1_DTSEC3, AURORA,
		SRIO1, SRIO1, SRIO1, SRIO1}},
	{0x84, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
		SRIO2, SRIO2, AURORA, AURORA,
		XFI_FM1_MAC9, XFI_FM1_MAC10}},
	{0x85, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
		SRIO2, SRIO2, AURORA, AURORA,
		XFI_FM1_MAC9, XFI_FM1_MAC10}},
	{0x87, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
		SRIO2, SRIO2,
		SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
		XFI_FM1_MAC9, XFI_FM1_MAC10}},
	{0x93, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
		SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
		XAUI_FM1_MAC10, XAUI_FM1_MAC10,
		XAUI_FM1_MAC10, XAUI_FM1_MAC10}},
	{0x9E, {PCIE1, PCIE1,	PCIE1, PCIE1,
		XAUI_FM1_MAC10, XAUI_FM1_MAC10,
		XAUI_FM1_MAC10, XAUI_FM1_MAC10}},
	{0x9A, {PCIE1, PCIE1,
		SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
		XAUI_FM1_MAC10, XAUI_FM1_MAC10,
		XAUI_FM1_MAC10, XAUI_FM1_MAC10}},
	{0xB2, {PCIE1, PCIE1, PCIE1, PCIE1,
		SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
		XFI_FM1_MAC9, XFI_FM1_MAC10}},
	{0xC3, {XAUI_FM1_MAC9, XAUI_FM1_MAC9,
		XAUI_FM1_MAC9, XAUI_FM1_MAC9,
		SRIO1, SRIO1, SRIO1, SRIO1}},
	{}
};
static struct serdes_config *serdes_cfg_tbl[] = {
	serdes1_cfg_tbl,
	serdes2_cfg_tbl,
};

enum srds_prtcl serdes_get_prtcl(int serdes, int cfg, int lane)
{
	struct serdes_config *ptr;

	if (serdes >= ARRAY_SIZE(serdes_cfg_tbl))
		return 0;

	ptr = serdes_cfg_tbl[serdes];
	while (ptr->protocol) {
		if (ptr->protocol == cfg)
			return ptr->lanes[lane];
		ptr++;
	}

	return 0;
}

int is_serdes_prtcl_valid(int serdes, u32 prtcl)
{
	int i;
	struct serdes_config *ptr;

	if (serdes >= ARRAY_SIZE(serdes_cfg_tbl))
		return 0;

	ptr = serdes_cfg_tbl[serdes];
	while (ptr->protocol) {
		if (ptr->protocol == prtcl)
			break;
		ptr++;
	}

	if (!ptr->protocol)
		return 0;

	for (i = 0; i < SRDS_MAX_LANES; i++) {
		if (ptr->lanes[i] != NONE)
			return 1;
	}

	return 0;
}