Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
u-boot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
Florian Mayer
u-boot
Commits
7432ed05
Commit
7432ed05
authored
13 years ago
by
Simon Guinot
Committed by
Wolfgang Denk
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
sf: macronix: disable write protection when initializing
Signed-off-by:
Simon Guinot
<
sguinot@lacie.com
>
parent
9445ce08
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
drivers/mtd/spi/macronix.c
+42
-0
42 additions, 0 deletions
drivers/mtd/spi/macronix.c
with
42 additions
and
0 deletions
drivers/mtd/spi/macronix.c
+
42
−
0
View file @
7432ed05
...
...
@@ -117,6 +117,45 @@ static const struct macronix_spi_flash_params macronix_spi_flash_table[] = {
},
};
static
int
macronix_write_status
(
struct
spi_flash
*
flash
,
u8
sr
)
{
u8
cmd
;
int
ret
;
ret
=
spi_flash_cmd_write_enable
(
flash
);
if
(
ret
<
0
)
{
debug
(
"SF: enabling write failed
\n
"
);
return
ret
;
}
cmd
=
CMD_MX25XX_WRSR
;
ret
=
spi_flash_cmd_write
(
flash
->
spi
,
&
cmd
,
1
,
&
sr
,
1
);
if
(
ret
)
{
debug
(
"SF: fail to write status register
\n
"
);
return
ret
;
}
ret
=
spi_flash_cmd_wait_ready
(
flash
,
SPI_FLASH_PROG_TIMEOUT
);
if
(
ret
<
0
)
{
debug
(
"SF: write status register timed out
\n
"
);
return
ret
;
}
return
0
;
}
static
int
macronix_unlock
(
struct
spi_flash
*
flash
)
{
int
ret
;
/* Enable status register writing and clear BP# bits */
ret
=
macronix_write_status
(
flash
,
0
);
if
(
ret
)
debug
(
"SF: fail to disable write protection
\n
"
);
return
ret
;
}
static
int
macronix_erase
(
struct
spi_flash
*
flash
,
u32
offset
,
size_t
len
)
{
return
spi_flash_cmd_erase
(
flash
,
CMD_MX25XX_BE
,
offset
,
len
);
...
...
@@ -157,5 +196,8 @@ struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)
*
params
->
sectors_per_block
;
flash
->
size
=
flash
->
sector_size
*
params
->
nr_blocks
;
/* Clear BP# bits for read-only flash */
macronix_unlock
(
flash
);
return
flash
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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