1
2
3
4
5
6
7#include <common.h>
8#include <spl.h>
9#include <asm/io.h>
10#include <asm/arch/cpu.h>
11#include <asm/arch/soc.h>
12
13#include "high_speed_env_spec.h"
14#include "sys_env_lib.h"
15
16u8 selectors_serdes_rev1_map[LAST_SERDES_TYPE][MAX_SERDES_LANES] = {
17
18 {0x1, 0x1, NA, NA, NA, NA},
19 {NA, 0x2, 0x1, NA, 0x1, NA},
20 {NA, NA, 0x2, NA, NA, 0x1},
21 {NA, NA, NA, 0x1, NA, NA},
22 {0x2, 0x3, NA, NA, NA, NA},
23 {NA, NA, 0x3, NA, 0x2, NA},
24 {NA, NA, NA, NA, 0x6, 0x2},
25 {NA, NA, NA, 0x3, NA, NA},
26 {0x3, 0x4, NA, NA, NA, NA},
27 {NA, 0x5, 0x4, NA, 0x3, NA},
28 {NA, NA, NA, 0x4, NA, 0x3},
29 {NA, 0x7, NA, NA, NA, NA},
30 {NA, 0x6, NA, NA, 0x4, NA},
31 {NA, NA, NA, 0x5, NA, 0x4},
32 {NA, NA, NA, 0x6, 0x5, 0x5},
33 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
34};
35
36int hws_serdes_seq_init(void)
37{
38 DEBUG_INIT_FULL_S("\n### serdes_seq_init ###\n");
39
40 if (hws_serdes_seq_db_init() != MV_OK) {
41 printf("hws_serdes_seq_init: Error: Serdes initialization fail\n");
42 return MV_FAIL;
43 }
44
45 return MV_OK;
46}
47
48int serdes_power_up_ctrl_ext(u32 serdes_num, int serdes_power_up,
49 enum serdes_type serdes_type,
50 enum serdes_speed baud_rate,
51 enum serdes_mode serdes_mode,
52 enum ref_clock ref_clock)
53{
54 return MV_NOT_SUPPORTED;
55}
56
57u32 hws_serdes_silicon_ref_clock_get(void)
58{
59 DEBUG_INIT_FULL_S("\n### hws_serdes_silicon_ref_clock_get ###\n");
60
61 return REF_CLOCK_25MHZ;
62}
63
64u32 hws_serdes_get_max_lane(void)
65{
66 switch (sys_env_device_id_get()) {
67 case MV_6811:
68 return 4;
69 case MV_6810:
70 return 5;
71 case MV_6820:
72 case MV_6828:
73 return 6;
74 default:
75 printf("%s: Device ID Error, using 4 SerDes lanes\n",
76 __func__);
77 return 4;
78 }
79 return 6;
80}
81
82int hws_is_serdes_active(u8 lane_num)
83{
84 int ret = 1;
85
86
87 if (lane_num > 6)
88 ret = 0;
89
90
91 if (sys_env_device_id_get() == MV_6810 && lane_num == 4) {
92 printf("%s: Error: Lane#4 on Device 6810 is not Active.\n",
93 __func__);
94 return 0;
95 }
96
97
98
99
100
101 if (sys_env_device_id_get() == MV_6810 && lane_num == 5)
102 return 1;
103
104 if (lane_num >= hws_serdes_get_max_lane())
105 ret = 0;
106
107 return ret;
108}
109
110int hws_get_ext_base_addr(u32 serdes_num, u32 base_addr, u32 unit_base_offset,
111 u32 *unit_base_reg, u32 *unit_offset)
112{
113 *unit_base_reg = base_addr;
114 *unit_offset = unit_base_offset;
115
116 return MV_OK;
117}
118
119
120
121
122
123
124
125
126
127
128
129
130u32 hws_serdes_get_phy_selector_val(int serdes_num,
131 enum serdes_type serdes_type)
132{
133 if (serdes_type >= LAST_SERDES_TYPE)
134 return 0xff;
135
136 if (hws_ctrl_serdes_rev_get() == MV_SERDES_REV_1_2) {
137 return selectors_serdes_rev1_map
138 [serdes_type][serdes_num];
139 } else
140 return selectors_serdes_rev2_map
141 [serdes_type][serdes_num];
142}
143
144u32 hws_get_physical_serdes_num(u32 serdes_num)
145{
146 if ((serdes_num == 4) && (sys_env_device_id_get() == MV_6810)) {
147
148
149
150
151 return 5;
152 } else {
153 return serdes_num;
154 }
155}
156