Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spec-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.
fmc-projects
spec
spec-sw
Commits
a7b37736
Commit
a7b37736
authored
12 years ago
by
Alessandro Rubini
Browse files
Options
Downloads
Patches
Plain Diff
fmc-write-eeprom: tlv added
parent
c88f2e02
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
kernel/fmc-write-eeprom.c
+42
-5
42 additions, 5 deletions
kernel/fmc-write-eeprom.c
with
42 additions
and
5 deletions
kernel/fmc-write-eeprom.c
+
42
−
5
View file @
a7b37736
...
...
@@ -12,6 +12,7 @@
#include
<linux/firmware.h>
#include
<linux/init.h>
#include
<linux/fmc.h>
#include
<asm/unaligned.h>
/*
* This module uses the firmware loader to program the whole or part
...
...
@@ -21,10 +22,40 @@
static
char
*
fwe_file
;
module_param_named
(
file
,
fwe_file
,
charp
,
444
);
static
int
fwe_run_tlv
(
struct
fmc_device
*
fmc
,
const
struct
firmware
*
fw
)
static
int
fwe_run_tlv
(
struct
fmc_device
*
fmc
,
const
struct
firmware
*
fw
,
int
write
)
{
dev_err
(
fmc
->
hwdev
,
"not implemented yet
\n
"
);
return
-
EOPNOTSUPP
;
const
uint8_t
*
p
=
fw
->
data
;
int
len
=
fw
->
size
;
uint16_t
thislen
,
thisaddr
;
int
err
;
/* format is: 'w' addr16 len16 data... */
while
(
len
>
5
)
{
thisaddr
=
get_unaligned_le16
(
p
+
1
);
thislen
=
get_unaligned_le16
(
p
+
3
);
if
(
p
[
0
]
!=
'w'
||
thislen
+
5
>
len
)
{
dev_err
(
fmc
->
hwdev
,
"invalid tlv at offset %i
\n
"
,
p
-
fw
->
data
);
return
-
EINVAL
;
}
err
=
0
;
if
(
write
)
{
dev_info
(
fmc
->
hwdev
,
"write %i bytes at 0x%04x
\n
"
,
thislen
,
thisaddr
);
err
=
fmc
->
op
->
write_ee
(
fmc
,
thisaddr
,
p
+
5
,
thislen
);
}
if
(
err
<
0
)
{
dev_err
(
fmc
->
hwdev
,
"write failure @0x%04x
\n
"
,
thisaddr
);
return
err
;
}
p
+=
5
+
thislen
;
len
-=
5
+
thislen
;
}
if
(
write
)
dev_info
(
fmc
->
hwdev
,
"write_eeprom: success
\n
"
);
return
0
;
}
static
int
fwe_run_bin
(
struct
fmc_device
*
fmc
,
const
struct
firmware
*
fw
)
...
...
@@ -37,17 +68,23 @@ static int fwe_run_bin(struct fmc_device *fmc, const struct firmware *fw)
dev_info
(
fmc
->
hwdev
,
"write_eeprom: error %i
\n
"
,
ret
);
return
ret
;
}
dev_info
(
fmc
->
hwdev
,
"write_eeprom: success
\n
"
);
return
0
;
}
static
int
fwe_run
(
struct
fmc_device
*
fmc
,
const
struct
firmware
*
fw
)
{
char
*
last4
=
fwe_file
+
strlen
(
fwe_file
)
-
4
;
int
err
;
if
(
!
strcmp
(
last4
,
".tlv"
))
return
fwe_run_tlv
(
fmc
,
fw
);
if
(
!
strcmp
(
last4
,
".bin"
))
return
fwe_run_bin
(
fmc
,
fw
);
if
(
!
strcmp
(
last4
,
".tlv"
))
{
err
=
fwe_run_tlv
(
fmc
,
fw
,
0
);
if
(
!
err
)
err
=
fwe_run_tlv
(
fmc
,
fw
,
1
);
return
err
;
}
dev_err
(
fmc
->
hwdev
,
"invalid file name
\"
%s
\"\n
"
,
fwe_file
);
return
-
EINVAL
;
}
...
...
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