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
f5a4a27c
Commit
f5a4a27c
authored
Jan 08, 2015
by
Grzegorz Daniluk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sdb-eeprom: adding erase function for i2c eeprom
parent
d5abb7e8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
sdb-eeprom.c
dev/sdb-eeprom.c
+29
-0
No files found.
dev/sdb-eeprom.c
View file @
f5a4a27c
...
...
@@ -110,6 +110,34 @@ static int sdb_i2c_write(struct sdbfs *fs, int offset, void *buf, int count)
return
count
;
}
static
int
sdb_i2c_erase
(
struct
sdbfs
*
fs
,
int
offset
,
int
count
)
{
int
i
,
busy
;
struct
i2c_params
*
p
=
fs
->
drvdata
;
for
(
i
=
0
;
i
<
count
;
i
++
)
{
mi2c_start
(
p
->
ifnum
);
if
(
mi2c_put_byte
(
p
->
ifnum
,
p
->
addr
<<
1
)
<
0
)
{
mi2c_stop
(
p
->
ifnum
);
return
-
1
;
}
mi2c_put_byte
(
p
->
ifnum
,
(
offset
>>
8
)
&
0xff
);
mi2c_put_byte
(
p
->
ifnum
,
offset
&
0xff
);
mi2c_put_byte
(
p
->
ifnum
,
0xff
);
offset
++
;
mi2c_stop
(
p
->
ifnum
);
do
{
/* wait until the chip becomes ready */
mi2c_start
(
p
->
ifnum
);
busy
=
mi2c_put_byte
(
p
->
ifnum
,
p
->
addr
<<
1
);
mi2c_stop
(
p
->
ifnum
);
}
while
(
busy
);
}
return
count
;
}
/*
* A trivial dumper, just to show what's up in there
*/
...
...
@@ -186,6 +214,7 @@ void eeprom_init(int chosen_i2cif, int chosen_i2c_addr)
wrc_sdb
.
drvdata
=
&
i2c_params
;
wrc_sdb
.
read
=
sdb_i2c_read
;
wrc_sdb
.
write
=
sdb_i2c_write
;
wrc_sdb
.
erase
=
sdb_i2c_erase
;
goto
found_exit
;
}
if
(
i
==
ARRAY_SIZE
(
entry_points
))
{
...
...
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