Update flashrom to use flashctx struct for flash chip access
Corresponds to r1473 and r1474 from upstream.
For all operations which access hardware, the struct flashctx (flash
context) is now used. Flashctx is similar in structure to flashchip, but
with a few additions. Flashchip is still used for non hardware
operations, such as listing the supported flash chips.
BUG=none
BRANCH=none
TEST=tested correct read/write for auron_paine
Change-Id: I043913d4aa30f47985f96209e2c0a52c98119764
Signed-off-by: Souvik Ghosh <souvikghosh@google.com>
Reviewed-on: https://chromium-review.googlesource.com/353740
Reviewed-by: David Hendricks <dhendrix@chromium.org>
diff --git a/programmer.c b/programmer.c
index eb92e1b..a1b8ccc 100644
--- a/programmer.c
+++ b/programmer.c
@@ -1,7 +1,7 @@
/*
* This file is part of the flashrom project.
*
- * Copyright (C) 2009,2010 Carl-Daniel Hailfinger
+ * Copyright (C) 2009,2010,2011 Carl-Daniel Hailfinger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -53,61 +53,61 @@
}
/* No-op chip_writeb() for drivers not supporting addr/data pair accesses */
-uint8_t noop_chip_readb(const chipaddr addr)
+uint8_t noop_chip_readb(const struct flashctx *flash, const chipaddr addr)
{
return 0xff;
}
/* No-op chip_writeb() for drivers not supporting addr/data pair accesses */
-void noop_chip_writeb(uint8_t val, chipaddr addr)
+void noop_chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr)
{
}
/* Little-endian fallback for drivers not supporting 16 bit accesses */
-void fallback_chip_writew(uint16_t val, chipaddr addr)
+void fallback_chip_writew(const struct flashctx *flash, uint16_t val, chipaddr addr)
{
- chip_writeb(val & 0xff, addr);
- chip_writeb((val >> 8) & 0xff, addr + 1);
+ chip_writeb(flash, val & 0xff, addr);
+ chip_writeb(flash, (val >> 8) & 0xff, addr + 1);
}
/* Little-endian fallback for drivers not supporting 16 bit accesses */
-uint16_t fallback_chip_readw(const chipaddr addr)
+uint16_t fallback_chip_readw(const struct flashctx *flash, const chipaddr addr)
{
uint16_t val;
- val = chip_readb(addr);
- val |= chip_readb(addr + 1) << 8;
+ val = chip_readb(flash, addr);
+ val |= chip_readb(flash, addr + 1) << 8;
return val;
}
/* Little-endian fallback for drivers not supporting 32 bit accesses */
-void fallback_chip_writel(uint32_t val, chipaddr addr)
+void fallback_chip_writel(const struct flashctx *flash, uint32_t val, chipaddr addr)
{
- chip_writew(val & 0xffff, addr);
- chip_writew((val >> 16) & 0xffff, addr + 2);
+ chip_writew(flash, val & 0xffff, addr);
+ chip_writew(flash, (val >> 16) & 0xffff, addr + 2);
}
/* Little-endian fallback for drivers not supporting 32 bit accesses */
-uint32_t fallback_chip_readl(const chipaddr addr)
+uint32_t fallback_chip_readl(const struct flashctx *flash, const chipaddr addr)
{
uint32_t val;
- val = chip_readw(addr);
- val |= chip_readw(addr + 2) << 16;
+ val = chip_readw(flash, addr);
+ val |= chip_readw(flash, addr + 2) << 16;
return val;
}
-void fallback_chip_writen(uint8_t *buf, chipaddr addr, size_t len)
+void fallback_chip_writen(const struct flashctx *flash, uint8_t *buf, chipaddr addr, size_t len)
{
size_t i;
for (i = 0; i < len; i++)
- chip_writeb(buf[i], addr + i);
+ chip_writeb(flash, buf[i], addr + i);
return;
}
-void fallback_chip_readn(uint8_t *buf, chipaddr addr, size_t len)
+void fallback_chip_readn(const struct flashctx *flash, uint8_t *buf, chipaddr addr, size_t len)
{
size_t i;
for (i = 0; i < len; i++)
- buf[i] = chip_readb(addr + i);
+ buf[i] = chip_readb(flash, addr + i);
return;
}