Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wrpc-sw
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
hdl-core-lib
wr-cores
wrpc-sw
Commits
bc6b72e0
Commit
bc6b72e0
authored
12 years ago
by
Grzegorz Daniluk
Browse files
Options
Downloads
Patches
Plain Diff
check FMC EEPROM presence before doing anything on it
parent
03dd3536
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
dev/eeprom.c
+20
-1
20 additions, 1 deletion
dev/eeprom.c
include/eeprom.h
+2
-0
2 additions, 0 deletions
include/eeprom.h
shell/cmd_calib.c
+1
-1
1 addition, 1 deletion
shell/cmd_calib.c
shell/shell.c
+3
-3
3 additions, 3 deletions
shell/shell.c
with
26 additions
and
5 deletions
dev/eeprom.c
+
20
−
1
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
);
...
...
This diff is collapsed.
Click to expand it.
include/eeprom.h
+
2
−
0
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
);
...
...
This diff is collapsed.
Click to expand it.
shell/cmd_calib.c
+
1
−
1
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
;
...
...
This diff is collapsed.
Click to expand it.
shell/shell.c
+
3
−
3
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
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment