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
31
Issues
31
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
bc6b72e0
Commit
bc6b72e0
authored
Aug 03, 2012
by
Grzegorz Daniluk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check FMC EEPROM presence before doing anything on it
parent
03dd3536
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
5 deletions
+26
-5
eeprom.c
dev/eeprom.c
+20
-1
eeprom.h
include/eeprom.h
+2
-0
cmd_calib.c
shell/cmd_calib.c
+1
-1
shell.c
shell/shell.c
+3
-3
No files found.
dev/eeprom.c
View file @
bc6b72e0
...
...
@@ -45,12 +45,26 @@
* ------------------------------------------------
*/
uint8_t
has_eeprom
=
0
;
uint8_t
eeprom_present
(
uint8_t
i2cif
,
uint8_t
i2c_addr
)
{
has_eeprom
=
1
;
if
(
!
mi2c_devprobe
(
i2cif
,
i2c_addr
)
)
if
(
!
mi2c_devprobe
(
i2cif
,
i2c_addr
)
)
has_eeprom
=
0
;
return
0
;
}
int
eeprom_read
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint32_t
offset
,
uint8_t
*
buf
,
size_t
size
)
{
int
i
;
unsigned
char
c
;
if
(
!
has_eeprom
)
return
-
1
;
mi2c_start
(
i2cif
);
if
(
mi2c_put_byte
(
i2cif
,
i2c_addr
<<
1
)
<
0
)
{
...
...
@@ -77,6 +91,9 @@ int eeprom_write(uint8_t i2cif, uint8_t i2c_addr, uint32_t offset, uint8_t *buf,
{
int
i
,
busy
;
if
(
!
has_eeprom
)
return
-
1
;
for
(
i
=
0
;
i
<
size
;
i
++
)
{
mi2c_start
(
i2cif
);
...
...
@@ -227,7 +244,9 @@ int8_t eeprom_init_purge(uint8_t i2cif, uint8_t i2c_addr)
uint16_t
used
=
0xffff
,
i
;
uint16_t
pattern
=
0xff
;
eeprom_read
(
i2cif
,
i2c_addr
,
EE_BASE_INIT
,
&
used
,
sizeof
(
used
));
if
(
eeprom_read
(
i2cif
,
i2c_addr
,
EE_BASE_INIT
,
&
used
,
sizeof
(
used
))
!=
sizeof
(
used
)
)
return
EE_RET_I2CERR
;
if
(
used
==
0xffff
)
used
=
0
;
for
(
i
=
0
;
i
<
used
;
++
i
)
eeprom_write
(
i2cif
,
i2c_addr
,
EE_BASE_INIT
+
sizeof
(
used
)
+
i
,
&
pattern
,
1
);
...
...
include/eeprom.h
View file @
bc6b72e0
...
...
@@ -17,6 +17,7 @@ extern int32_t sfp_alpha;
extern
int32_t
sfp_deltaTx
;
extern
int32_t
sfp_deltaRx
;
extern
uint32_t
cal_phase_transition
;
extern
uint8_t
has_eeprom
;
struct
s_sfpinfo
{
...
...
@@ -27,6 +28,7 @@ struct s_sfpinfo
uint8_t
chksum
;
}
__attribute__
((
__packed__
));
uint8_t
eeprom_present
(
uint8_t
i2cif
,
uint8_t
i2c_addr
);
int
eeprom_read
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint32_t
offset
,
uint8_t
*
buf
,
size_t
size
);
int
eeprom_write
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint32_t
offset
,
uint8_t
*
buf
,
size_t
size
);
...
...
shell/cmd_calib.c
View file @
bc6b72e0
...
...
@@ -22,7 +22,7 @@ int cmd_calib(const char *args[])
}
else
if
(
!
args
[
0
]
)
{
if
(
eeprom_phtrans
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
&
trans
,
0
)
)
if
(
eeprom_phtrans
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
&
trans
,
0
)
>
0
)
{
mprintf
(
"Found phase transition in EEPROM: %dps
\n
"
,
trans
);
cal_phase_transition
=
trans
;
...
...
shell/shell.c
View file @
bc6b72e0
...
...
@@ -6,6 +6,7 @@
#include "uart.h"
#include "syscon.h"
#include "shell.h"
#include "eeprom.h"
#define SH_MAX_LINE_LEN 80
#define SH_MAX_ARGS 8
...
...
@@ -274,9 +275,8 @@ int shell_boot_script(void)
uint8_t
next
=
0
;
//first check if EEPROM is really there
if
(
!
mi2c_devprobe
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
)
)
if
(
!
mi2c_devprobe
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
)
)
return
-
1
;
eeprom_present
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
);
if
(
!
has_eeprom
)
return
-
1
;
while
(
1
)
{
...
...
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