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
7
Merge Requests
7
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
8b0d60e5
Commit
8b0d60e5
authored
Jul 17, 2012
by
Grzegorz Daniluk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell: sfp add/erase/show commands for handling SFP DB in eeprom
parent
4300100f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
235 additions
and
157 deletions
+235
-157
eeprom.c
dev/eeprom.c
+147
-148
i2c.c
dev/i2c.c
+15
-0
eeprom.h
include/eeprom.h
+14
-5
cmd_sfp.c
shell/cmd_sfp.c
+59
-4
No files found.
dev/eeprom.c
View file @
8b0d60e5
This diff is collapsed.
Click to expand it.
dev/i2c.c
View file @
8b0d60e5
...
@@ -97,3 +97,18 @@ void mi2c_init(uint8_t i2cif)
...
@@ -97,3 +97,18 @@ void mi2c_init(uint8_t i2cif)
M_SCL_OUT
(
i2cif
,
1
);
M_SCL_OUT
(
i2cif
,
1
);
M_SDA_OUT
(
i2cif
,
1
);
M_SDA_OUT
(
i2cif
,
1
);
}
}
//void mi2c_scan(uint8_t i2cif)
//{
// int i;
//
// //for(i=0;i<0x80;i++)
// for(i=0x50;i<0x51;i++)
// {
// mi2c_start(i2cif);
// if(!mi2c_put_byte(i2cif, i<<1)) mprintf("found : %x\n", i);
// mi2c_stop(i2cif);
//
// }
// mprintf("Nothing more found...\n");
//}
include/eeprom.h
View file @
8b0d60e5
...
@@ -2,20 +2,29 @@
...
@@ -2,20 +2,29 @@
#define __EEPROM_H
#define __EEPROM_H
#define SFP_SECTION_PATTERN 0xdeadbeef
#define SFP_SECTION_PATTERN 0xdeadbeef
#define SFPINFO_MAX 4
#define SFPS_MAX 4
#define EE_BASE_SFP 4*1024
#define EE_BASE_INIT 4*1024+SFPS_MAX*29
__attribute__
((
packed
))
struct
s_sfpinfo
#define EE_RET_I2CERR -1
#define EE_RET_DBFULL -2
#define EE_RET_CHKSUM -3
#define EE_RET_POSERR -4
struct
s_sfpinfo
{
{
char
pn
[
16
];
char
pn
[
16
];
int32_t
alpha
;
int32_t
alpha
;
int32_t
deltaTx
;
int32_t
dTx
;
int32_t
deltaRx
;
int32_t
dRx
;
};
uint8_t
chksum
;
}
__attribute__
((
__packed__
));
int
eeprom_read
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint32_t
offset
,
uint8_t
*
buf
,
size_t
size
);
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
);
int
eeprom_write
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint32_t
offset
,
uint8_t
*
buf
,
size_t
size
);
int32_t
eeprom_sfpdb_erase
(
uint8_t
i2cif
,
uint8_t
i2c_addr
);
int32_t
eeprom_sfp_section
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
size_t
size
,
uint16_t
*
section_sz
);
int32_t
eeprom_sfp_section
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
size_t
size
,
uint16_t
*
section_sz
);
int8_t
eeprom_get_sfpinfo
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint32_t
offset
,
struct
s_sfpinfo
*
sfpinfo
,
uint16_t
section_sz
);
int8_t
eeprom_get_sfpinfo
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint32_t
offset
,
struct
s_sfpinfo
*
sfpinfo
,
uint16_t
section_sz
);
int8_t
access_eeprom
(
char
*
sfp_pn
,
int32_t
*
alpha
,
int32_t
*
deltaTx
,
int32_t
*
deltaRx
);
int8_t
access_eeprom
(
char
*
sfp_pn
,
int32_t
*
alpha
,
int32_t
*
deltaTx
,
int32_t
*
deltaRx
);
...
...
shell/cmd_sfp.c
View file @
8b0d60e5
...
@@ -6,15 +6,21 @@
...
@@ -6,15 +6,21 @@
Subcommands:
Subcommands:
add vendor_type delta_tx delta_rx alpha - adds an SFP to the database, with given alpha/delta_rx/delta_rx values
add vendor_type delta_tx delta_rx alpha - adds an SFP to the database, with given alpha/delta_rx/delta_rx values
show - shows the SFP database
show - shows the SFP database
erase - cleans the SFP database
detect - detects the transceiver type
detect - detects the transceiver type
*/
*/
#include "shell.h"
#include "shell.h"
#include "eeprom.h"
#include "syscon.h"
#include "sfp.h"
#include "sfp.h"
int
cmd_sfp
(
const
char
*
args
[])
int
cmd_sfp
(
const
char
*
args
[])
{
{
int8_t
sfpcount
=
1
,
i
,
temp
;
struct
s_sfpinfo
sfp
;
if
(
args
[
0
]
&&
!
strcasecmp
(
args
[
0
],
"detect"
))
if
(
args
[
0
]
&&
!
strcasecmp
(
args
[
0
],
"detect"
))
{
{
char
pn
[
17
];
char
pn
[
17
];
...
@@ -25,11 +31,60 @@ int cmd_sfp(const char *args[])
...
@@ -25,11 +31,60 @@ int cmd_sfp(const char *args[])
pn
[
16
]
=
0
;
pn
[
16
]
=
0
;
mprintf
(
"%s
\n
"
,
pn
);
mprintf
(
"%s
\n
"
,
pn
);
return
0
;
return
0
;
}
else
if
(
args
[
3
]
&&
!
strcasecmp
(
args
[
0
],
"add"
))
}
// else if (!strcasecmp(args[0], "i2cscan"))
// {
// mi2c_scan(WRPC_FMC_I2C);
// return 0;
// }
else
if
(
!
strcasecmp
(
args
[
0
],
"erase"
))
{
{
if
(
eeprom_sfpdb_erase
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
)
==
EE_RET_I2CERR
)
mprintf
(
"Could not erase DB
\n
"
);
}
else
if
(
args
[
4
]
&&
!
strcasecmp
(
args
[
0
],
"add"
))
{
if
(
strlen
(
args
[
1
]
)
>
16
)
temp
=
16
;
else
temp
=
strlen
(
args
[
1
]
);
for
(
i
=
0
;
i
<
temp
;
++
i
)
sfp
.
pn
[
i
]
=
args
[
1
][
i
];
while
(
i
<
16
)
sfp
.
pn
[
i
++
]
=
' '
;
//padding
sfp
.
dTx
=
atoi
(
args
[
2
]);
sfp
.
dRx
=
atoi
(
args
[
3
]);
sfp
.
alpha
=
atoi
(
args
[
4
]);
temp
=
eeprom_get_sfp
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
&
sfp
,
1
,
0
);
if
(
temp
==
EE_RET_DBFULL
)
mprintf
(
"SFP DB is full
\n
"
);
else
if
(
temp
==
EE_RET_I2CERR
)
mprintf
(
"I2C error
\n
"
);
else
mprintf
(
"%d SFPs in DB
\n
"
,
temp
);
}
else
if
(
args
[
0
]
&&
!
strcasecmp
(
args
[
0
],
"show"
))
{
for
(
i
=
0
;
i
<
sfpcount
;
++
i
)
{
temp
=
eeprom_get_sfp
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
&
sfp
,
0
,
i
);
if
(
!
i
)
{
sfpcount
=
temp
;
//only in first round valid sfpcount is returned from eeprom_get_sfp
if
(
sfpcount
==
0
||
sfpcount
==
0xFF
)
{
mprintf
(
"SFP database empty...
\n
"
);
return
0
;
}
else
if
(
sfpcount
==
-
1
)
{
mprintf
(
"SFP database corrupted...
\n
"
);
return
0
;
}
}
mprintf
(
"%d: PN:"
,
i
+
1
);
for
(
temp
=
0
;
temp
<
16
;
++
temp
)
mprintf
(
"%c"
,
sfp
.
pn
[
temp
]);
mprintf
(
" dTx: %d, dRx: %d, alpha: %d
\n
"
,
sfp
.
dTx
,
sfp
.
dRx
,
sfp
.
alpha
);
}
}
}
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