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
4
Merge Requests
4
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
59978129
Commit
59978129
authored
Nov 18, 2014
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'simplify-eeprom-calls'
parents
9db373ba
9e0d9fe8
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
59 additions
and
64 deletions
+59
-64
eeprom.c
dev/eeprom.c
+17
-13
rxts_calibrator.c
dev/rxts_calibrator.c
+3
-3
sdb-eeprom.c
dev/sdb-eeprom.c
+17
-19
eeprom.h
include/eeprom.h
+10
-14
cmd_calib.c
shell/cmd_calib.c
+3
-4
cmd_init.c
shell/cmd_init.c
+3
-3
cmd_sfp.c
shell/cmd_sfp.c
+4
-5
shell.c
shell/shell.c
+1
-2
wrc_main.c
wrc_main.c
+1
-1
No files found.
dev/eeprom.c
View file @
59978129
...
@@ -58,14 +58,20 @@
...
@@ -58,14 +58,20 @@
uint8_t
has_eeprom
=
0
;
uint8_t
has_eeprom
=
0
;
uint8_t
eeprom_present
(
uint8_t
i2cif
,
uint8_t
i2c_addr
)
static
int
i2cif
,
i2c_addr
;
/* globals, using the names we always used */
void
eeprom_init
(
int
chosen_i2cif
,
int
chosen_i2c_addr
)
{
{
/* Save these to globals, they are never passed any more */
i2cif
=
chosen_i2cif
;
i2c_addr
=
chosen_i2c_addr
;
has_eeprom
=
1
;
has_eeprom
=
1
;
if
(
!
mi2c_devprobe
(
i2cif
,
i2c_addr
))
if
(
!
mi2c_devprobe
(
i2cif
,
i2c_addr
))
if
(
!
mi2c_devprobe
(
i2cif
,
i2c_addr
))
if
(
!
mi2c_devprobe
(
i2cif
,
i2c_addr
))
has_eeprom
=
0
;
has_eeprom
=
0
;
return
0
;
return
;
}
}
static
int
eeprom_read
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint32_t
offset
,
static
int
eeprom_read
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint32_t
offset
,
...
@@ -128,7 +134,7 @@ static int eeprom_write(uint8_t i2cif, uint8_t i2c_addr, uint32_t offset,
...
@@ -128,7 +134,7 @@ static int eeprom_write(uint8_t i2cif, uint8_t i2c_addr, uint32_t offset,
return
size
;
return
size
;
}
}
int32_t
eeprom_sfpdb_erase
(
uint8_t
i2cif
,
uint8_t
i2c_addr
)
int32_t
eeprom_sfpdb_erase
(
void
)
{
{
uint8_t
sfpcount
=
0
;
uint8_t
sfpcount
=
0
;
...
@@ -140,7 +146,7 @@ int32_t eeprom_sfpdb_erase(uint8_t i2cif, uint8_t i2c_addr)
...
@@ -140,7 +146,7 @@ int32_t eeprom_sfpdb_erase(uint8_t i2cif, uint8_t i2c_addr)
return
sfpcount
;
return
sfpcount
;
}
}
int
32_t
eeprom_get_sfp
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
struct
s_sfpinfo
*
sfp
,
int
eeprom_get_sfp
(
struct
s_sfpinfo
*
sfp
,
uint8_t
add
,
uint8_t
pos
)
uint8_t
add
,
uint8_t
pos
)
{
{
static
uint8_t
sfpcount
=
0
;
static
uint8_t
sfpcount
=
0
;
...
@@ -195,15 +201,14 @@ int32_t eeprom_get_sfp(uint8_t i2cif, uint8_t i2c_addr, struct s_sfpinfo * sfp,
...
@@ -195,15 +201,14 @@ int32_t eeprom_get_sfp(uint8_t i2cif, uint8_t i2c_addr, struct s_sfpinfo * sfp,
return
sfpcount
;
return
sfpcount
;
}
}
int
8_t
eeprom_match_sfp
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
struct
s_sfpinfo
*
sfp
)
int
eeprom_match_sfp
(
struct
s_sfpinfo
*
sfp
)
{
{
uint8_t
sfpcount
=
1
;
uint8_t
sfpcount
=
1
;
int8_t
i
,
temp
;
int8_t
i
,
temp
;
struct
s_sfpinfo
dbsfp
;
struct
s_sfpinfo
dbsfp
;
for
(
i
=
0
;
i
<
sfpcount
;
++
i
)
{
for
(
i
=
0
;
i
<
sfpcount
;
++
i
)
{
temp
=
eeprom_get_sfp
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
temp
=
eeprom_get_sfp
(
&
dbsfp
,
0
,
i
);
&
dbsfp
,
0
,
i
);
if
(
!
i
)
{
if
(
!
i
)
{
sfpcount
=
temp
;
//only in first round valid sfpcount is returned from eeprom_get_sfp
sfpcount
=
temp
;
//only in first round valid sfpcount is returned from eeprom_get_sfp
if
(
sfpcount
==
0
||
sfpcount
==
0xFF
)
if
(
sfpcount
==
0
||
sfpcount
==
0xFF
)
...
@@ -222,7 +227,7 @@ int8_t eeprom_match_sfp(uint8_t i2cif, uint8_t i2c_addr, struct s_sfpinfo * sfp)
...
@@ -222,7 +227,7 @@ int8_t eeprom_match_sfp(uint8_t i2cif, uint8_t i2c_addr, struct s_sfpinfo * sfp)
return
0
;
return
0
;
}
}
int
8_t
eeprom_phtrans
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint32_t
*
val
,
int
eeprom_phtrans
(
uint32_t
*
val
,
uint8_t
write
)
uint8_t
write
)
{
{
int8_t
ret
;
int8_t
ret
;
...
@@ -249,7 +254,7 @@ int8_t eeprom_phtrans(uint8_t i2cif, uint8_t i2c_addr, uint32_t * val,
...
@@ -249,7 +254,7 @@ int8_t eeprom_phtrans(uint8_t i2cif, uint8_t i2c_addr, uint32_t * val,
}
}
}
}
int
8_t
eeprom_init_erase
(
uint8_t
i2cif
,
uint8_t
i2c_addr
)
int
eeprom_init_erase
(
void
)
{
{
uint16_t
used
=
0
;
uint16_t
used
=
0
;
...
@@ -263,7 +268,7 @@ int8_t eeprom_init_erase(uint8_t i2cif, uint8_t i2c_addr)
...
@@ -263,7 +268,7 @@ int8_t eeprom_init_erase(uint8_t i2cif, uint8_t i2c_addr)
/*
/*
* Appends a new shell command at the end of boot script
* Appends a new shell command at the end of boot script
*/
*/
int
8_t
eeprom_init_add
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
const
char
*
args
[])
int
eeprom_init_add
(
const
char
*
args
[])
{
{
uint8_t
i
=
1
;
uint8_t
i
=
1
;
uint8_t
separator
=
' '
;
uint8_t
separator
=
' '
;
...
@@ -306,7 +311,7 @@ int8_t eeprom_init_add(uint8_t i2cif, uint8_t i2c_addr, const char *args[])
...
@@ -306,7 +311,7 @@ int8_t eeprom_init_add(uint8_t i2cif, uint8_t i2c_addr, const char *args[])
return
0
;
return
0
;
}
}
int
32_t
eeprom_init_show
(
uint8_t
i2cif
,
uint8_t
i2c_addr
)
int
eeprom_init_show
(
void
)
{
{
uint16_t
used
,
i
;
uint16_t
used
,
i
;
uint8_t
byte
;
uint8_t
byte
;
...
@@ -330,8 +335,7 @@ int32_t eeprom_init_show(uint8_t i2cif, uint8_t i2c_addr)
...
@@ -330,8 +335,7 @@ int32_t eeprom_init_show(uint8_t i2cif, uint8_t i2c_addr)
return
0
;
return
0
;
}
}
int8_t
eeprom_init_readcmd
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint8_t
*
buf
,
int
eeprom_init_readcmd
(
uint8_t
*
buf
,
uint8_t
bufsize
,
uint8_t
next
)
uint8_t
bufsize
,
uint8_t
next
)
{
{
static
uint16_t
ptr
;
static
uint16_t
ptr
;
static
uint16_t
used
=
0
;
static
uint16_t
used
=
0
;
...
...
dev/rxts_calibrator.c
View file @
59978129
...
@@ -213,7 +213,7 @@ static int calib_t24p_master(uint32_t *value)
...
@@ -213,7 +213,7 @@ static int calib_t24p_master(uint32_t *value)
{
{
int
rv
;
int
rv
;
rv
=
eeprom_phtrans
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
value
,
0
);
rv
=
eeprom_phtrans
(
value
,
0
);
if
(
rv
<
0
)
{
if
(
rv
<
0
)
{
pp_printf
(
"Error %d while reading EEPROM
\n
"
,
rv
);
pp_printf
(
"Error %d while reading EEPROM
\n
"
,
rv
);
return
rv
;
return
rv
;
...
@@ -241,9 +241,9 @@ static int calib_t24p_slave(uint32_t *value)
...
@@ -241,9 +241,9 @@ static int calib_t24p_slave(uint32_t *value)
* Let's see if we have a matching value in EEPROM:
* Let's see if we have a matching value in EEPROM:
* accept a 200ps difference, otherwise rewrite eeprom
* accept a 200ps difference, otherwise rewrite eeprom
*/
*/
rv
=
eeprom_phtrans
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
&
prev
,
0
/* rd */
);
rv
=
eeprom_phtrans
(
&
prev
,
0
/* rd */
);
if
(
rv
<
0
||
(
prev
<
*
value
-
200
)
||
(
prev
>
*
value
+
200
))
{
if
(
rv
<
0
||
(
prev
<
*
value
-
200
)
||
(
prev
>
*
value
+
200
))
{
rv
=
eeprom_phtrans
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
value
,
1
);
rv
=
eeprom_phtrans
(
value
,
1
);
pp_printf
(
"Wrote new t24p value: %d ps (%s)
\n
"
,
*
value
,
pp_printf
(
"Wrote new t24p value: %d ps (%s)
\n
"
,
*
value
,
rv
<
0
?
"Failed"
:
"Success"
);
rv
<
0
?
"Failed"
:
"Success"
);
}
}
...
...
dev/sdb-eeprom.c
View file @
59978129
...
@@ -138,11 +138,11 @@ static struct sdbfs wrc_sdb = {
...
@@ -138,11 +138,11 @@ static struct sdbfs wrc_sdb = {
uint8_t
has_eeprom
=
0
;
/* modified at init time */
uint8_t
has_eeprom
=
0
;
/* modified at init time */
/*
/*
* Init:
returns 0 for success; it changes has_eeprom
above
* Init:
sets "int has_eeprom"
above
*
*
* This is called by wrc_main, after initializing both w1 and i2c
* This is called by wrc_main, after initializing both w1 and i2c
*/
*/
uint8_t
eeprom_present
(
uint8_t
i2cif
,
uint8_t
i2c_addr
)
void
eeprom_init
(
int
chosen_i2cif
,
int
chosen_
i2c_addr
)
{
{
uint32_t
magic
=
0
;
uint32_t
magic
=
0
;
static
unsigned
entry_points
[]
=
{
0
,
64
,
128
,
256
,
512
,
1024
};
static
unsigned
entry_points
[]
=
{
0
,
64
,
128
,
256
,
512
,
1024
};
...
@@ -169,10 +169,10 @@ uint8_t eeprom_present(uint8_t i2cif, uint8_t i2c_addr)
...
@@ -169,10 +169,10 @@ uint8_t eeprom_present(uint8_t i2cif, uint8_t i2c_addr)
/*
/*
* If w1 failed, look for i2c: start from low offsets.
* If w1 failed, look for i2c: start from low offsets.
*/
*/
i
f
(
!
mi2c_devprobe
(
i2cif
,
i2c_addr
))
i
2c_params
.
ifnum
=
chosen_i2cif
;
return
0
;
i2c_params
.
addr
=
chosen_i2c_addr
;
i
2c_params
.
ifnum
=
i2cif
;
i
f
(
!
mi2c_devprobe
(
i2c_params
.
ifnum
,
i2c_params
.
addr
))
i2c_params
.
addr
=
i2c_addr
;
return
;
/* While looking for the magic number, use sdb-based read function */
/* While looking for the magic number, use sdb-based read function */
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
entry_points
);
i
++
)
{
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
entry_points
);
i
++
)
{
...
@@ -185,7 +185,7 @@ uint8_t eeprom_present(uint8_t i2cif, uint8_t i2c_addr)
...
@@ -185,7 +185,7 @@ uint8_t eeprom_present(uint8_t i2cif, uint8_t i2c_addr)
}
}
if
(
i
==
ARRAY_SIZE
(
entry_points
))
{
if
(
i
==
ARRAY_SIZE
(
entry_points
))
{
pp_printf
(
"No SDB filesystem in i2c eeprom
\n
"
);
pp_printf
(
"No SDB filesystem in i2c eeprom
\n
"
);
return
0
;
return
;
}
}
found_exit:
found_exit:
...
@@ -193,7 +193,7 @@ found_exit:
...
@@ -193,7 +193,7 @@ found_exit:
has_eeprom
=
1
;
has_eeprom
=
1
;
sdbfs_dev_create
(
&
wrc_sdb
);
sdbfs_dev_create
(
&
wrc_sdb
);
eeprom_sdb_list
(
&
wrc_sdb
);
eeprom_sdb_list
(
&
wrc_sdb
);
return
0
;
return
;
}
}
/*
/*
...
@@ -275,7 +275,7 @@ int set_persistent_mac(uint8_t portnum, uint8_t * mac)
...
@@ -275,7 +275,7 @@ int set_persistent_mac(uint8_t portnum, uint8_t * mac)
/* Just a dummy function that writes '0' to sfp count field of the SFP DB */
/* Just a dummy function that writes '0' to sfp count field of the SFP DB */
int32_t
eeprom_sfpdb_erase
(
uint8_t
i2cif
,
uint8_t
i2c_addr
)
int32_t
eeprom_sfpdb_erase
(
void
)
{
{
uint8_t
sfpcount
=
0
;
uint8_t
sfpcount
=
0
;
int
ret
;
int
ret
;
...
@@ -287,7 +287,7 @@ int32_t eeprom_sfpdb_erase(uint8_t i2cif, uint8_t i2c_addr)
...
@@ -287,7 +287,7 @@ int32_t eeprom_sfpdb_erase(uint8_t i2cif, uint8_t i2c_addr)
return
ret
==
1
?
0
:
-
1
;
return
ret
==
1
?
0
:
-
1
;
}
}
int
32_t
eeprom_get_sfp
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
struct
s_sfpinfo
*
sfp
,
int
eeprom_get_sfp
(
struct
s_sfpinfo
*
sfp
,
uint8_t
add
,
uint8_t
pos
)
uint8_t
add
,
uint8_t
pos
)
{
{
static
uint8_t
sfpcount
=
0
;
static
uint8_t
sfpcount
=
0
;
...
@@ -350,15 +350,14 @@ out:
...
@@ -350,15 +350,14 @@ out:
return
0
;
return
0
;
}
}
int
8_t
eeprom_match_sfp
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
struct
s_sfpinfo
*
sfp
)
int
eeprom_match_sfp
(
struct
s_sfpinfo
*
sfp
)
{
{
uint8_t
sfpcount
=
1
;
uint8_t
sfpcount
=
1
;
int8_t
i
,
temp
;
int8_t
i
,
temp
;
struct
s_sfpinfo
dbsfp
;
struct
s_sfpinfo
dbsfp
;
for
(
i
=
0
;
i
<
sfpcount
;
++
i
)
{
for
(
i
=
0
;
i
<
sfpcount
;
++
i
)
{
temp
=
eeprom_get_sfp
(
i2cif
,
i2c_addr
,
temp
=
eeprom_get_sfp
(
&
dbsfp
,
0
,
i
);
&
dbsfp
,
0
,
i
);
if
(
!
i
)
{
if
(
!
i
)
{
// first round: valid sfpcount is returned
// first round: valid sfpcount is returned
sfpcount
=
temp
;
sfpcount
=
temp
;
...
@@ -382,7 +381,7 @@ int8_t eeprom_match_sfp(uint8_t i2cif, uint8_t i2c_addr, struct s_sfpinfo * sfp)
...
@@ -382,7 +381,7 @@ int8_t eeprom_match_sfp(uint8_t i2cif, uint8_t i2c_addr, struct s_sfpinfo * sfp)
* Phase transition ("calibration" file)
* Phase transition ("calibration" file)
*/
*/
#define VALIDITY_BIT 0x80000000
#define VALIDITY_BIT 0x80000000
int
8_t
eeprom_phtrans
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint32_t
*
valp
,
int
eeprom_phtrans
(
uint32_t
*
valp
,
uint8_t
write
)
uint8_t
write
)
{
{
int
ret
=
-
1
;
int
ret
=
-
1
;
...
@@ -421,7 +420,7 @@ out:
...
@@ -421,7 +420,7 @@ out:
* ------------------------------------------------
* ------------------------------------------------
*/
*/
int
8_t
eeprom_init_erase
(
uint8_t
i2cif
,
uint8_t
i2c_addr
)
int
eeprom_init_erase
(
void
)
{
{
uint16_t
used
=
0
;
uint16_t
used
=
0
;
int
ret
;
int
ret
;
...
@@ -436,7 +435,7 @@ int8_t eeprom_init_erase(uint8_t i2cif, uint8_t i2c_addr)
...
@@ -436,7 +435,7 @@ int8_t eeprom_init_erase(uint8_t i2cif, uint8_t i2c_addr)
/*
/*
* Appends a new shell command at the end of boot script
* Appends a new shell command at the end of boot script
*/
*/
int
8_t
eeprom_init_add
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
const
char
*
args
[])
int
eeprom_init_add
(
const
char
*
args
[])
{
{
int
len
,
i
=
1
;
/* args[0] is "add" */
int
len
,
i
=
1
;
/* args[0] is "add" */
uint8_t
separator
=
' '
;
uint8_t
separator
=
' '
;
...
@@ -482,7 +481,7 @@ out:
...
@@ -482,7 +481,7 @@ out:
return
ret
;
return
ret
;
}
}
int
32_t
eeprom_init_show
(
uint8_t
i2cif
,
uint8_t
i2c_addr
)
int
eeprom_init_show
(
void
)
{
{
int
i
,
ret
=
-
1
;
int
i
,
ret
=
-
1
;
uint16_t
used
;
uint16_t
used
;
...
@@ -512,8 +511,7 @@ out:
...
@@ -512,8 +511,7 @@ out:
return
ret
;
return
ret
;
}
}
int8_t
eeprom_init_readcmd
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint8_t
*
buf
,
int
eeprom_init_readcmd
(
uint8_t
*
buf
,
uint8_t
bufsize
,
uint8_t
next
)
uint8_t
bufsize
,
uint8_t
next
)
{
{
int
i
=
0
,
ret
=
-
1
;
int
i
=
0
,
ret
=
-
1
;
uint16_t
used
;
uint16_t
used
;
...
...
include/eeprom.h
View file @
59978129
...
@@ -27,23 +27,19 @@ struct s_sfpinfo {
...
@@ -27,23 +27,19 @@ struct s_sfpinfo {
uint8_t
chksum
;
uint8_t
chksum
;
}
__attribute__
((
__packed__
));
}
__attribute__
((
__packed__
));
uint8_t
eeprom_present
(
uint8_t
i2cif
,
uint8_
t
i2c_addr
);
void
eeprom_init
(
int
i2cif
,
in
t
i2c_addr
);
int
32_t
eeprom_sfpdb_erase
(
uint8_t
i2cif
,
uint8_t
i2c_addr
);
int
eeprom_sfpdb_erase
(
void
);
int
32_t
eeprom_sfp_section
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
size_t
size
,
int
eeprom_match_sfp
(
struct
s_sfpinfo
*
sfp
);
uint16_t
*
section_sz
);
int
eeprom_get_sfp
(
struct
s_sfpinfo
*
sfp
,
int8_t
eeprom_match_sfp
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
struct
s_sfpinfo
*
sfp
);
uint8_t
add
,
uint8_t
pos
);
int
8_t
eeprom_phtrans
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint32_t
*
val
,
int
eeprom_phtrans
(
uint32_t
*
val
,
uint8_t
write
);
uint8_t
write
);
int8_t
eeprom_init_erase
(
uint8_t
i2cif
,
uint8_t
i2c_addr
);
int
eeprom_init_erase
(
void
);
int8_t
eeprom_init_add
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
const
char
*
args
[]);
int
eeprom_init_add
(
const
char
*
args
[]);
int32_t
eeprom_init_show
(
uint8_t
i2cif
,
uint8_t
i2c_addr
);
int
eeprom_init_show
(
void
);
int8_t
eeprom_init_readcmd
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint8_t
*
buf
,
int
eeprom_init_readcmd
(
uint8_t
*
buf
,
uint8_t
bufsize
,
uint8_t
next
);
uint8_t
bufsize
,
uint8_t
next
);
int32_t
eeprom_get_sfp
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
struct
s_sfpinfo
*
sfp
,
uint8_t
add
,
uint8_t
pos
);
#endif
#endif
shell/cmd_calib.c
View file @
59978129
...
@@ -27,9 +27,9 @@ static int cmd_calibration(const char *args[])
...
@@ -27,9 +27,9 @@ static int cmd_calibration(const char *args[])
if
(
args
[
0
]
&&
!
strcasecmp
(
args
[
0
],
"force"
))
{
if
(
args
[
0
]
&&
!
strcasecmp
(
args
[
0
],
"force"
))
{
if
(
measure_t24p
(
&
trans
)
<
0
)
if
(
measure_t24p
(
&
trans
)
<
0
)
return
-
1
;
return
-
1
;
return
eeprom_phtrans
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
&
trans
,
1
);
return
eeprom_phtrans
(
&
trans
,
1
);
}
else
if
(
!
args
[
0
])
{
}
else
if
(
!
args
[
0
])
{
if
(
eeprom_phtrans
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
&
trans
,
0
)
>
0
)
{
if
(
eeprom_phtrans
(
&
trans
,
0
)
>
0
)
{
mprintf
(
"Found phase transition in EEPROM: %dps
\n
"
,
mprintf
(
"Found phase transition in EEPROM: %dps
\n
"
,
trans
);
trans
);
cal_phase_transition
=
trans
;
cal_phase_transition
=
trans
;
...
@@ -39,8 +39,7 @@ static int cmd_calibration(const char *args[])
...
@@ -39,8 +39,7 @@ static int cmd_calibration(const char *args[])
if
(
measure_t24p
(
&
trans
)
<
0
)
if
(
measure_t24p
(
&
trans
)
<
0
)
return
-
1
;
return
-
1
;
cal_phase_transition
=
trans
;
cal_phase_transition
=
trans
;
return
eeprom_phtrans
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
return
eeprom_phtrans
(
&
trans
,
1
);
&
trans
,
1
);
}
}
}
}
...
...
shell/cmd_init.c
View file @
59978129
...
@@ -22,15 +22,15 @@ static int cmd_init(const char *args[])
...
@@ -22,15 +22,15 @@ static int cmd_init(const char *args[])
}
}
if
(
args
[
0
]
&&
!
strcasecmp
(
args
[
0
],
"erase"
))
{
if
(
args
[
0
]
&&
!
strcasecmp
(
args
[
0
],
"erase"
))
{
if
(
eeprom_init_erase
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
)
<
0
)
if
(
eeprom_init_erase
()
<
0
)
mprintf
(
"Could not erase init script
\n
"
);
mprintf
(
"Could not erase init script
\n
"
);
}
else
if
(
args
[
1
]
&&
!
strcasecmp
(
args
[
0
],
"add"
))
{
}
else
if
(
args
[
1
]
&&
!
strcasecmp
(
args
[
0
],
"add"
))
{
if
(
eeprom_init_add
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
args
)
<
0
)
if
(
eeprom_init_add
(
args
)
<
0
)
mprintf
(
"Could not add the command
\n
"
);
mprintf
(
"Could not add the command
\n
"
);
else
else
mprintf
(
"OK.
\n
"
);
mprintf
(
"OK.
\n
"
);
}
else
if
(
args
[
0
]
&&
!
strcasecmp
(
args
[
0
],
"show"
))
{
}
else
if
(
args
[
0
]
&&
!
strcasecmp
(
args
[
0
],
"show"
))
{
eeprom_init_show
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
);
eeprom_init_show
();
}
else
if
(
args
[
0
]
&&
!
strcasecmp
(
args
[
0
],
"boot"
))
{
}
else
if
(
args
[
0
]
&&
!
strcasecmp
(
args
[
0
],
"boot"
))
{
shell_boot_script
();
shell_boot_script
();
}
}
...
...
shell/cmd_sfp.c
View file @
59978129
...
@@ -51,7 +51,7 @@ static int cmd_sfp(const char *args[])
...
@@ -51,7 +51,7 @@ static int cmd_sfp(const char *args[])
// return 0;
// return 0;
// }
// }
else
if
(
!
strcasecmp
(
args
[
0
],
"erase"
))
{
else
if
(
!
strcasecmp
(
args
[
0
],
"erase"
))
{
if
(
eeprom_sfpdb_erase
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
)
==
if
(
eeprom_sfpdb_erase
()
==
EE_RET_I2CERR
)
EE_RET_I2CERR
)
mprintf
(
"Could not erase DB
\n
"
);
mprintf
(
"Could not erase DB
\n
"
);
}
else
if
(
args
[
4
]
&&
!
strcasecmp
(
args
[
0
],
"add"
))
{
}
else
if
(
args
[
4
]
&&
!
strcasecmp
(
args
[
0
],
"add"
))
{
...
@@ -66,7 +66,7 @@ static int cmd_sfp(const char *args[])
...
@@ -66,7 +66,7 @@ static int cmd_sfp(const char *args[])
sfp
.
dTx
=
atoi
(
args
[
2
]);
sfp
.
dTx
=
atoi
(
args
[
2
]);
sfp
.
dRx
=
atoi
(
args
[
3
]);
sfp
.
dRx
=
atoi
(
args
[
3
]);
sfp
.
alpha
=
atoi
(
args
[
4
]);
sfp
.
alpha
=
atoi
(
args
[
4
]);
temp
=
eeprom_get_sfp
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
&
sfp
,
1
,
0
);
temp
=
eeprom_get_sfp
(
&
sfp
,
1
,
0
);
if
(
temp
==
EE_RET_DBFULL
)
if
(
temp
==
EE_RET_DBFULL
)
mprintf
(
"SFP DB is full
\n
"
);
mprintf
(
"SFP DB is full
\n
"
);
else
if
(
temp
==
EE_RET_I2CERR
)
else
if
(
temp
==
EE_RET_I2CERR
)
...
@@ -75,8 +75,7 @@ static int cmd_sfp(const char *args[])
...
@@ -75,8 +75,7 @@ static int cmd_sfp(const char *args[])
mprintf
(
"%d SFPs in DB
\n
"
,
temp
);
mprintf
(
"%d SFPs in DB
\n
"
,
temp
);
}
else
if
(
args
[
0
]
&&
!
strcasecmp
(
args
[
0
],
"show"
))
{
}
else
if
(
args
[
0
]
&&
!
strcasecmp
(
args
[
0
],
"show"
))
{
for
(
i
=
0
;
i
<
sfpcount
;
++
i
)
{
for
(
i
=
0
;
i
<
sfpcount
;
++
i
)
{
temp
=
eeprom_get_sfp
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
temp
=
eeprom_get_sfp
(
&
sfp
,
0
,
i
);
&
sfp
,
0
,
i
);
if
(
!
i
)
{
if
(
!
i
)
{
sfpcount
=
temp
;
//only in first round valid sfpcount is returned from eeprom_get_sfp
sfpcount
=
temp
;
//only in first round valid sfpcount is returned from eeprom_get_sfp
if
(
sfpcount
==
0
||
sfpcount
==
0xFF
)
{
if
(
sfpcount
==
0
||
sfpcount
==
0xFF
)
{
...
@@ -99,7 +98,7 @@ static int cmd_sfp(const char *args[])
...
@@ -99,7 +98,7 @@ static int cmd_sfp(const char *args[])
return
0
;
return
0
;
}
}
strncpy
(
sfp
.
pn
,
pn
,
SFP_PN_LEN
);
strncpy
(
sfp
.
pn
,
pn
,
SFP_PN_LEN
);
if
(
eeprom_match_sfp
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
&
sfp
)
>
0
)
{
if
(
eeprom_match_sfp
(
&
sfp
)
>
0
)
{
mprintf
(
"SFP matched, dTx=%d, dRx=%d, alpha=%d
\n
"
,
mprintf
(
"SFP matched, dTx=%d, dRx=%d, alpha=%d
\n
"
,
sfp
.
dTx
,
sfp
.
dRx
,
sfp
.
alpha
);
sfp
.
dTx
,
sfp
.
dRx
,
sfp
.
alpha
);
sfp_deltaTx
=
sfp
.
dTx
;
sfp_deltaTx
=
sfp
.
dTx
;
...
...
shell/shell.c
View file @
59978129
...
@@ -256,8 +256,7 @@ int shell_boot_script(void)
...
@@ -256,8 +256,7 @@ int shell_boot_script(void)
return
-
1
;
return
-
1
;
while
(
1
)
{
while
(
1
)
{
cmd_len
=
eeprom_init_readcmd
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
cmd_len
=
eeprom_init_readcmd
((
uint8_t
*
)
cmd_buf
,
(
uint8_t
*
)
cmd_buf
,
SH_MAX_LINE_LEN
,
next
);
SH_MAX_LINE_LEN
,
next
);
if
(
cmd_len
<=
0
)
{
if
(
cmd_len
<=
0
)
{
if
(
next
==
0
)
if
(
next
==
0
)
...
...
wrc_main.c
View file @
59978129
...
@@ -60,7 +60,7 @@ static void wrc_initialize()
...
@@ -60,7 +60,7 @@ static void wrc_initialize()
/*initialize I2C bus*/
/*initialize I2C bus*/
mi2c_init
(
WRPC_FMC_I2C
);
mi2c_init
(
WRPC_FMC_I2C
);
/*check if EEPROM is onboard*/
/*check if EEPROM is onboard*/
eeprom_
presen
t
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
);
eeprom_
ini
t
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
);
mac_addr
[
0
]
=
0x08
;
//
mac_addr
[
0
]
=
0x08
;
//
mac_addr
[
1
]
=
0x00
;
// CERN OUI
mac_addr
[
1
]
=
0x00
;
// CERN OUI
...
...
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