summaryrefslogtreecommitdiffstats
path: root/spi.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2011-12-18 15:01:24 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2011-12-18 15:01:24 +0000
commit8a3c60cdd0e5632173567923ae1927763e31e857 (patch)
tree3a5514d022392cf4d8fa368f9f02653da21a93ca /spi.c
parent63fd9026f1e82b67a65072fda862ba7af35839e1 (diff)
downloadast2050-flashrom-8a3c60cdd0e5632173567923ae1927763e31e857.zip
ast2050-flashrom-8a3c60cdd0e5632173567923ae1927763e31e857.tar.gz
Add struct flashctx * parameter to all functions accessing flash chips
All programmer access function prototypes except init have been made static and moved to the respective file. A few internal functions in flash chip drivers had chipaddr parameters which are no longer needed. The lines touched by flashctx changes have been adjusted to 80 columns except in header files. Corresponding to flashrom svn r1474. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Diffstat (limited to 'spi.c')
-rw-r--r--spi.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/spi.c b/spi.c
index 2eeb1af..02c83f7 100644
--- a/spi.c
+++ b/spi.c
@@ -42,8 +42,9 @@ const struct spi_programmer spi_programmer_none = {
const struct spi_programmer *spi_programmer = &spi_programmer_none;
-int spi_send_command(unsigned int writecnt, unsigned int readcnt,
- const unsigned char *writearr, unsigned char *readarr)
+int spi_send_command(struct flashctx *flash, unsigned int writecnt,
+ unsigned int readcnt, const unsigned char *writearr,
+ unsigned char *readarr)
{
if (!spi_programmer->command) {
msg_perr("%s called, but SPI is unsupported on this "
@@ -52,11 +53,11 @@ int spi_send_command(unsigned int writecnt, unsigned int readcnt,
return 1;
}
- return spi_programmer->command(writecnt, readcnt,
- writearr, readarr);
+ return spi_programmer->command(flash, writecnt, readcnt, writearr,
+ readarr);
}
-int spi_send_multicommand(struct spi_command *cmds)
+int spi_send_multicommand(struct flashctx *flash, struct spi_command *cmds)
{
if (!spi_programmer->multicommand) {
msg_perr("%s called, but SPI is unsupported on this "
@@ -65,11 +66,13 @@ int spi_send_multicommand(struct spi_command *cmds)
return 1;
}
- return spi_programmer->multicommand(cmds);
+ return spi_programmer->multicommand(flash, cmds);
}
-int default_spi_send_command(unsigned int writecnt, unsigned int readcnt,
- const unsigned char *writearr, unsigned char *readarr)
+int default_spi_send_command(struct flashctx *flash, unsigned int writecnt,
+ unsigned int readcnt,
+ const unsigned char *writearr,
+ unsigned char *readarr)
{
struct spi_command cmd[] = {
{
@@ -84,20 +87,22 @@ int default_spi_send_command(unsigned int writecnt, unsigned int readcnt,
.readarr = NULL,
}};
- return spi_send_multicommand(cmd);
+ return spi_send_multicommand(flash, cmd);
}
-int default_spi_send_multicommand(struct spi_command *cmds)
+int default_spi_send_multicommand(struct flashctx *flash,
+ struct spi_command *cmds)
{
int result = 0;
for (; (cmds->writecnt || cmds->readcnt) && !result; cmds++) {
- result = spi_send_command(cmds->writecnt, cmds->readcnt,
+ result = spi_send_command(flash, cmds->writecnt, cmds->readcnt,
cmds->writearr, cmds->readarr);
}
return result;
}
-int default_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
+int default_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start,
+ unsigned int len)
{
unsigned int max_data = spi_programmer->max_data_read;
if (max_data == MAX_DATA_UNSPECIFIED) {
@@ -109,7 +114,8 @@ int default_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, u
return spi_read_chunked(flash, buf, start, len, max_data);
}
-int default_spi_write_256(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
+int default_spi_write_256(struct flashctx *flash, uint8_t *buf,
+ unsigned int start, unsigned int len)
{
unsigned int max_data = spi_programmer->max_data_write;
if (max_data == MAX_DATA_UNSPECIFIED) {
@@ -121,7 +127,8 @@ int default_spi_write_256(struct flashctx *flash, uint8_t *buf, unsigned int sta
return spi_write_chunked(flash, buf, start, len, max_data);
}
-int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
+int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start,
+ unsigned int len)
{
unsigned int addrbase = 0;
if (!spi_programmer->read) {
@@ -135,7 +142,7 @@ int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsi
* address. Highest possible address with the current SPI implementation
* means 0xffffff, the highest unsigned 24bit number.
*/
- addrbase = spi_get_valid_read_addr();
+ addrbase = spi_get_valid_read_addr(flash);
if (addrbase + flash->total_size * 1024 > (1 << 24)) {
msg_perr("Flash chip size exceeds the allowed access window. ");
msg_perr("Read will probably fail.\n");
@@ -160,7 +167,8 @@ int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsi
* .write_256 = spi_chip_write_1
*/
/* real chunksize is up to 256, logical chunksize is 256 */
-int spi_chip_write_256(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
+int spi_chip_write_256(struct flashctx *flash, uint8_t *buf, unsigned int start,
+ unsigned int len)
{
if (!spi_programmer->write_256) {
msg_perr("%s called, but SPI page write is unsupported on this "
@@ -177,7 +185,7 @@ int spi_chip_write_256(struct flashctx *flash, uint8_t *buf, unsigned int start,
* be the lowest allowed address for all commands which take an address.
* This is a programmer limitation.
*/
-uint32_t spi_get_valid_read_addr(void)
+uint32_t spi_get_valid_read_addr(struct flashctx *flash)
{
switch (spi_programmer->type) {
#if CONFIG_INTERNAL == 1
OpenPOWER on IntegriCloud