Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
6bb6cab6
Commit
6bb6cab6
authored
Feb 16, 2024
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
phy_calibration: reformatting, handle link down
Restart rx fsm when link is lost
parent
8304358d
Pipeline
#5132
passed with stage
in 3 minutes and 40 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
175 additions
and
184 deletions
+175
-184
phy_calibration.c
boards/ertm14/phy_calibration.c
+175
-184
No files found.
boards/ertm14/phy_calibration.c
View file @
6bb6cab6
...
@@ -551,14 +551,12 @@ static int rx_fsm_update(struct wrc_lpdc_state *lpdc)
...
@@ -551,14 +551,12 @@ static int rx_fsm_update(struct wrc_lpdc_state *lpdc)
uint16_t
lpc_stat
=
mdio_lpdc_read
(
lpdc
,
LPDC_MDIO_STAT
);
uint16_t
lpc_stat
=
mdio_lpdc_read
(
lpdc
,
LPDC_MDIO_STAT
);
int
early_link_up
=
lpc_stat
&
LPDC_MDIO_STAT_LINK_UP
;
int
early_link_up
=
lpc_stat
&
LPDC_MDIO_STAT_LINK_UP
;
if
(
fsm_tx
->
state
!=
TX_SETUP_DONE
)
if
(
fsm_tx
->
state
!=
TX_SETUP_DONE
)
{
{
fsm
->
state
=
RX_SETUP_STATE_INIT
;
fsm
->
state
=
RX_SETUP_STATE_INIT
;
return
0
;
return
0
;
}
}
switch
(
fsm
->
state
)
switch
(
fsm
->
state
)
{
{
case
RX_SETUP_STATE_INIT
:
case
RX_SETUP_STATE_INIT
:
{
{
mdio_lpdc_set_bits
(
lpdc
,
LPDC_MDIO_CTRL
,
LPDC_MDIO_CTRL_RX_SW_RESET
);
mdio_lpdc_set_bits
(
lpdc
,
LPDC_MDIO_CTRL
,
LPDC_MDIO_CTRL_RX_SW_RESET
);
...
@@ -605,7 +603,7 @@ static int rx_fsm_update(struct wrc_lpdc_state *lpdc)
...
@@ -605,7 +603,7 @@ static int rx_fsm_update(struct wrc_lpdc_state *lpdc)
ctrl2 |= 4;
ctrl2 |= 4;
pp_printf("RXRATE = 4\n");
pp_printf("RXRATE = 4\n");
mdio_lpdc_write( lpdc, LPDC_MDIO_CTRL2, ctrl2 );
mdio_lpdc_write( lpdc, LPDC_MDIO_CTRL2, ctrl2 );
s
timer_delay_ms(2000);
timer_delay_ms(2000);
}*/
}*/
...
@@ -639,12 +637,10 @@ s timer_delay_ms(2000);
...
@@ -639,12 +637,10 @@ s timer_delay_ms(2000);
case
RX_SETUP_STATE_WAIT_RX_RESET_DONE
:
case
RX_SETUP_STATE_WAIT_RX_RESET_DONE
:
{
{
uint16_t
ctrl2
=
mdio_lpdc_read
(
lpdc
,
LPDC_MDIO_CTRL2
);
uint16_t
ctrl2
=
mdio_lpdc_read
(
lpdc
,
LPDC_MDIO_CTRL2
);
if
(
(
lpc_stat
&
LPDC_MDIO_STAT_RX_RST_DONE
)
&&
(
ctrl2
&
LPDC_MDIO_CTRL2_RX_CDR_LOCKED
)
)
if
(
(
lpc_stat
&
LPDC_MDIO_STAT_RX_RST_DONE
)
&&
(
ctrl2
&
LPDC_MDIO_CTRL2_RX_CDR_LOCKED
)
)
{
{
mdio_lpdc_clear_bits
(
lpdc
,
LPDC_MDIO_CTRL2
,
LPDC_MDIO_CTRL2_RX_GEARBOX_PLL_RESET
);
mdio_lpdc_clear_bits
(
lpdc
,
LPDC_MDIO_CTRL2
,
LPDC_MDIO_CTRL2_RX_GEARBOX_PLL_RESET
);
fsm
->
state
=
RX_SETUP_STATE_WAIT_GEARBOX_PLL_LOCKED
;
fsm
->
state
=
RX_SETUP_STATE_WAIT_GEARBOX_PLL_LOCKED
;
}
else
if
(
tmo_expired
(
&
fsm
->
link_timeout
))
}
else
if
(
tmo_expired
(
&
fsm
->
link_timeout
))
{
{
phy_dbg
(
"[lpdc] timeout waiting for rx reset done
\n
"
);
phy_dbg
(
"[lpdc] timeout waiting for rx reset done
\n
"
);
fsm
->
state
=
RX_SETUP_STATE_RESET_PCS
;
fsm
->
state
=
RX_SETUP_STATE_RESET_PCS
;
}
}
...
@@ -654,11 +650,9 @@ s timer_delay_ms(2000);
...
@@ -654,11 +650,9 @@ s timer_delay_ms(2000);
case
RX_SETUP_STATE_WAIT_GEARBOX_PLL_LOCKED
:
case
RX_SETUP_STATE_WAIT_GEARBOX_PLL_LOCKED
:
{
{
uint16_t
ctrl2
=
mdio_lpdc_read
(
lpdc
,
LPDC_MDIO_CTRL2
);
uint16_t
ctrl2
=
mdio_lpdc_read
(
lpdc
,
LPDC_MDIO_CTRL2
);
if
(
ctrl2
&
LPDC_MDIO_CTRL2_RX_GEARBOX_PLL_LOCKED
)
if
(
ctrl2
&
LPDC_MDIO_CTRL2_RX_GEARBOX_PLL_LOCKED
)
{
{
fsm
->
state
=
RX_SETUP_STATE_BUILD_COMMA_HISTOGRAM
;
fsm
->
state
=
RX_SETUP_STATE_BUILD_COMMA_HISTOGRAM
;
}
else
if
(
tmo_expired
(
&
fsm
->
link_timeout
))
}
else
if
(
tmo_expired
(
&
fsm
->
link_timeout
))
{
{
phy_dbg
(
"[lpdc] timeout waiting for rx gearbox PLL
\n
"
);
phy_dbg
(
"[lpdc] timeout waiting for rx gearbox PLL
\n
"
);
fsm
->
state
=
RX_SETUP_STATE_RESET_PCS
;
fsm
->
state
=
RX_SETUP_STATE_RESET_PCS
;
}
}
...
@@ -682,8 +676,7 @@ s timer_delay_ms(2000);
...
@@ -682,8 +676,7 @@ s timer_delay_ms(2000);
pattern[0] = 0x01ff;
pattern[0] = 0x01ff;
pp_printf("latched pattern: ");
pp_printf("latched pattern: ");
for(i=LPDC_NUM_PATTERN_WORDS-1; i>=0; i--)
for(i=LPDC_NUM_PATTERN_WORDS-1; i>=0; i--) {
{
if(i==LPDC_NUM_PATTERN_WORDS-1) // pattern is 120 bits
if(i==LPDC_NUM_PATTERN_WORDS-1) // pattern is 120 bits
pp_printf("%02x", pattern[i] & 0xff);
pp_printf("%02x", pattern[i] & 0xff);
else
else
...
@@ -697,8 +690,7 @@ s timer_delay_ms(2000);
...
@@ -697,8 +690,7 @@ s timer_delay_ms(2000);
int
comma_pos
;
int
comma_pos
;
int
status
=
check_histogram_threshold_hit
(
&
fsm
->
comma_hist
,
50
,
10
,
4
,
LPDC_TARGET_COMMA_POS
,
&
comma_pos
);
int
status
=
check_histogram_threshold_hit
(
&
fsm
->
comma_hist
,
50
,
10
,
4
,
LPDC_TARGET_COMMA_POS
,
&
comma_pos
);
switch
(
status
)
switch
(
status
)
{
{
case
LPDC_HIST_COMMA_POS_OUT_OF_RANGE
:
case
LPDC_HIST_COMMA_POS_OUT_OF_RANGE
:
#ifdef LPDC_EXTRA_DEBUG
#ifdef LPDC_EXTRA_DEBUG
pp_printf
(
"[lpdc] Comma @ %d (miss)
\n
"
,
comma_pos
);
pp_printf
(
"[lpdc] Comma @ %d (miss)
\n
"
,
comma_pos
);
...
@@ -711,8 +703,7 @@ s timer_delay_ms(2000);
...
@@ -711,8 +703,7 @@ s timer_delay_ms(2000);
#ifdef LPDC_EXTRA_DEBUG
#ifdef LPDC_EXTRA_DEBUG
pp_printf
(
"Comma @ %d (hit)
\n
"
,
comma_pos
);
pp_printf
(
"Comma @ %d (hit)
\n
"
,
comma_pos
);
pp_printf
(
"latched pattern: "
);
pp_printf
(
"latched pattern: "
);
for
(
i
=
LPDC_NUM_PATTERN_WORDS
-
1
;
i
>=
0
;
i
--
)
for
(
i
=
LPDC_NUM_PATTERN_WORDS
-
1
;
i
>=
0
;
i
--
)
{
{
if
(
i
==
LPDC_NUM_PATTERN_WORDS
-
1
)
// pattern is 120 bits
if
(
i
==
LPDC_NUM_PATTERN_WORDS
-
1
)
// pattern is 120 bits
pp_printf
(
"%02x"
,
pattern
[
i
]
&
0xff
);
pp_printf
(
"%02x"
,
pattern
[
i
]
&
0xff
);
else
else
...
@@ -733,8 +724,7 @@ s timer_delay_ms(2000);
...
@@ -733,8 +724,7 @@ s timer_delay_ms(2000);
int
i
;
int
i
;
#ifdef LPDC_EXTRA_DEBUG
#ifdef LPDC_EXTRA_DEBUG
pp_printf
(
"Too wide: "
);
pp_printf
(
"Too wide: "
);
for
(
i
=
0
;
i
<
LPDC_NUM_COMMA_POSITIONS
;
i
++
)
for
(
i
=
0
;
i
<
LPDC_NUM_COMMA_POSITIONS
;
i
++
)
{
{
if
(
fsm
->
comma_hist
.
bins
[
i
])
if
(
fsm
->
comma_hist
.
bins
[
i
])
pp_printf
(
"%-2d:%-4d "
,
i
,
fsm
->
comma_hist
.
bins
[
i
]);
pp_printf
(
"%-2d:%-4d "
,
i
,
fsm
->
comma_hist
.
bins
[
i
]);
}
}
...
@@ -748,8 +738,7 @@ s timer_delay_ms(2000);
...
@@ -748,8 +738,7 @@ s timer_delay_ms(2000);
break
;
break
;
}
}
if
(
!
early_link_up
)
if
(
!
early_link_up
)
{
{
fsm
->
state
=
RX_SETUP_STATE_INIT
;
fsm
->
state
=
RX_SETUP_STATE_INIT
;
}
}
break
;
break
;
...
@@ -780,13 +769,15 @@ s timer_delay_ms(2000);
...
@@ -780,13 +769,15 @@ s timer_delay_ms(2000);
}
}
case
RX_SETUP_DONE
:
case
RX_SETUP_DONE
:
if
(
!
early_link_up
)
fsm
->
state
=
RX_SETUP_STATE_INIT
;
break
;
break
;
default
:
default
:
break
;
break
;
}
}
return
0
;
return
0
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment