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
e10d4071
Commit
e10d4071
authored
Nov 24, 2016
by
Grzegorz Daniluk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sdb-storage: scan through 128 possible i2c EEPROMs
parent
1c028e8e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
21 deletions
+32
-21
sdb-storage.c
dev/sdb-storage.c
+32
-21
No files found.
dev/sdb-storage.c
View file @
e10d4071
...
@@ -31,6 +31,10 @@
...
@@ -31,6 +31,10 @@
#define SDB_DEV_SFP 0x7366702d
/* sfp- (database) */
#define SDB_DEV_SFP 0x7366702d
/* sfp- (database) */
#define SDB_DEV_CALIB 0x63616c69
/* cali (bration) */
#define SDB_DEV_CALIB 0x63616c69
/* cali (bration) */
/* constants for scanning I2C EEPROMs */
#define EEPROM_START_ADR 0
#define EEPROM_STOP_ADR 127
/* Functions for Flash access */
/* Functions for Flash access */
static
int
sdb_flash_read
(
struct
sdbfs
*
fs
,
int
offset
,
void
*
buf
,
int
count
)
static
int
sdb_flash_read
(
struct
sdbfs
*
fs
,
int
offset
,
void
*
buf
,
int
count
)
{
{
...
@@ -252,28 +256,35 @@ void storage_init(int chosen_i2cif, int chosen_i2c_addr)
...
@@ -252,28 +256,35 @@ void storage_init(int chosen_i2cif, int chosen_i2c_addr)
* 3. If w1 failed, look for i2c: start from low offsets.
* 3. If w1 failed, look for i2c: start from low offsets.
*/
*/
i2c_params
.
ifnum
=
chosen_i2cif
;
i2c_params
.
ifnum
=
chosen_i2cif
;
i2c_params
.
addr
=
chosen_i2c_addr
;
i2c_params
.
addr
=
EEPROM_START_ADR
;
if
(
!
mi2c_devprobe
(
i2c_params
.
ifnum
,
i2c_params
.
addr
))
while
(
i2c_params
.
addr
<=
EEPROM_STOP_ADR
)
{
return
;
/* First, we check if I2C EEPROM is there */
if
(
!
mi2c_devprobe
(
i2c_params
.
ifnum
,
i2c_params
.
addr
))
{
/* While looking for the magic number, use sdb-based read function */
i2c_params
.
addr
++
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
entry_points_eeprom
);
i
++
)
{
continue
;
sdb_i2c_read
(
&
wrc_sdb
,
entry_points_eeprom
[
i
],
(
void
*
)
&
magic
,
}
sizeof
(
magic
));
/* While looking for the magic number, use sdb-based read function */
if
(
magic
==
SDB_MAGIC
)
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
entry_points_eeprom
);
i
++
)
{
break
;
sdb_i2c_read
(
&
wrc_sdb
,
entry_points_eeprom
[
i
],
(
void
*
)
&
magic
,
}
sizeof
(
magic
));
if
(
magic
==
SDB_MAGIC
)
{
if
(
magic
==
SDB_MAGIC
)
pp_printf
(
"sdbfs: found at %i in I2C
\n
"
,
entry_points_eeprom
[
i
]);
break
;
wrc_sdb
.
drvdata
=
&
i2c_params
;
}
wrc_sdb
.
blocksize
=
1
;
if
(
magic
==
SDB_MAGIC
)
{
wrc_sdb
.
entrypoint
=
entry_points_eeprom
[
i
];
pp_printf
(
"sdbfs: found at %i in I2C(0x%2X)
\n
"
,
wrc_sdb
.
read
=
sdb_i2c_read
;
entry_points_eeprom
[
i
],
i2c_params
.
addr
);
wrc_sdb
.
write
=
sdb_i2c_write
;
wrc_sdb
.
drvdata
=
&
i2c_params
;
wrc_sdb
.
erase
=
sdb_i2c_erase
;
wrc_sdb
.
blocksize
=
1
;
goto
found_exit
;
wrc_sdb
.
entrypoint
=
entry_points_eeprom
[
i
];
wrc_sdb
.
read
=
sdb_i2c_read
;
wrc_sdb
.
write
=
sdb_i2c_write
;
wrc_sdb
.
erase
=
sdb_i2c_erase
;
goto
found_exit
;
}
i2c_params
.
addr
++
;
}
}
if
(
i
==
ARRAY_SIZE
(
entry_points_eeprom
))
{
if
(
i2c_params
.
addr
==
EEPROM_STOP_ADR
)
{
pp_printf
(
"No SDB filesystem in i2c eeprom
\n
"
);
pp_printf
(
"No SDB filesystem in i2c eeprom
\n
"
);
return
;
return
;
}
}
...
...
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