Daniel Thompson has uploaded this change for review. ( https://review.coreboot.org/26946
Change subject: bitbang_spi: Add functions to optimize xfers
......................................................................
bitbang_spi: Add functions to optimize xfers
On systems where the overhead of getting/setting pins is much greater
than the half period (for example, USB bit banging) it significantly
boosts performance if we can bang more than one bit at the same time.
Add support for setting sck at the same time as mosi or miso activity.
Change-Id: Ic3430a9df34844cdfa82e109456be788eaa1789a
Signed-off-by: Daniel Thompson <daniel.thompson(a)linaro.org>
---
M bitbang_spi.c
M programmer.h
2 files changed, 27 insertions(+), 16 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/46/26946/1
diff --git a/bitbang_spi.c b/bitbang_spi.c
index edbc3e9..2c7a3f1 100644
--- a/bitbang_spi.c
+++ b/bitbang_spi.c
@@ -32,16 +32,6 @@
master->set_sck(val);
}
-static void bitbang_spi_set_mosi(const struct bitbang_spi_master * const master, int val)
-{
- master->set_mosi(val);
-}
-
-static int bitbang_spi_get_miso(const struct bitbang_spi_master * const master)
-{
- return master->get_miso();
-}
-
static void bitbang_spi_request_bus(const struct bitbang_spi_master * const master)
{
if (master->request_bus)
@@ -54,6 +44,26 @@
master->release_bus();
}
+static void bitbang_spi_set_sck_set_mosi(const struct bitbang_spi_master * const master, int sck, int mosi)
+{
+ if (master->set_sck_set_mosi) {
+ master->set_sck_set_mosi(sck, mosi);
+ return;
+ }
+
+ master->set_sck(sck);
+ master->set_mosi(mosi);
+}
+
+static int bitbang_spi_set_sck_get_miso(const struct bitbang_spi_master * const master, int sck)
+{
+ if (master->set_sck_get_miso)
+ return master->set_sck_get_miso(sck);
+
+ master->set_sck(sck);
+ return master->get_miso();
+}
+
static int bitbang_spi_send_command(struct flashctx *flash,
unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr,
@@ -101,8 +111,7 @@
/* Only mess with the bus if we're sure nobody else uses it. */
bitbang_spi_request_bus(master);
bitbang_spi_set_cs(master, 1);
- bitbang_spi_set_sck(master, 0);
- bitbang_spi_set_mosi(master, 0);
+ bitbang_spi_set_sck_set_mosi(master, 0, 0);
/* FIXME: Release SPI bus here and request it again for each command or
* don't release it now and only release it on programmer shutdown?
*/
@@ -117,13 +126,11 @@
int i;
for (i = 7; i >= 0; i--) {
- bitbang_spi_set_mosi(master, (val >> i) & 1);
+ bitbang_spi_set_sck_set_mosi(master, 0, (val >> i) & 1);
programmer_delay(master->half_period);
- bitbang_spi_set_sck(master, 1);
ret <<= 1;
- ret |= bitbang_spi_get_miso(master);
+ ret |= bitbang_spi_set_sck_get_miso(master, 1);
programmer_delay(master->half_period);
- bitbang_spi_set_sck(master, 0);
}
return ret;
}
@@ -147,6 +154,7 @@
for (i = 0; i < readcnt; i++)
readarr[i] = bitbang_spi_rw_byte(master, 0);
+ bitbang_spi_set_sck(master, 0);
programmer_delay(master->half_period);
bitbang_spi_set_cs(master, 1);
programmer_delay(master->half_period);
diff --git a/programmer.h b/programmer.h
index e49f262..7bb51eb 100644
--- a/programmer.h
+++ b/programmer.h
@@ -181,6 +181,9 @@
int (*get_miso) (void);
void (*request_bus) (void);
void (*release_bus) (void);
+ /* optional functions to optimize xfers */
+ void (*set_sck_set_mosi) (int sck, int mosi);
+ int (*set_sck_get_miso) (int sck);
/* Length of half a clock period in usecs. */
unsigned int half_period;
};
--
To view, visit https://review.coreboot.org/26946
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic3430a9df34844cdfa82e109456be788eaa1789a
Gerrit-Change-Number: 26946
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Thompson <daniel.thompson(a)linaro.org>
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/26856 )
Change subject: Add support for AT25DF021A
......................................................................
Patch Set 4:
Build Successful
https://qa.coreboot.org/job/flashrom-customrules/1321/ : SUCCESS
--
To view, visit https://review.coreboot.org/26856
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If4990e6856c8b77567ef4218459cf754b9c6bc57
Gerrit-Change-Number: 26856
Gerrit-PatchSet: 4
Gerrit-Owner: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: Stefan Tauner <stefan.tauner(a)gmx.at>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Comment-Date: Wed, 06 Jun 2018 08:58:07 +0000
Gerrit-HasComments: No
Gerrit-HasLabels: No
David Hendricks has posted comments on this change. ( https://review.coreboot.org/26856 )
Change subject: Add support for AT25DF021A
......................................................................
Patch Set 3: Code-Review+2
Fixed the commit message as per discussion on the github PR.
--
To view, visit https://review.coreboot.org/26856
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If4990e6856c8b77567ef4218459cf754b9c6bc57
Gerrit-Change-Number: 26856
Gerrit-PatchSet: 3
Gerrit-Owner: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: Stefan Tauner <stefan.tauner(a)gmx.at>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Comment-Date: Wed, 06 Jun 2018 05:04:16 +0000
Gerrit-HasComments: No
Gerrit-HasLabels: Yes
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/26856 )
Change subject: Add support for AT25DF021A
......................................................................
Patch Set 3:
Build Successful
https://qa.coreboot.org/job/flashrom-customrules/1320/ : SUCCESS
https://qa.coreboot.org/job/flashrom_gerrit/1092/ : SUCCESS
--
To view, visit https://review.coreboot.org/26856
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If4990e6856c8b77567ef4218459cf754b9c6bc57
Gerrit-Change-Number: 26856
Gerrit-PatchSet: 3
Gerrit-Owner: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Comment-Date: Wed, 06 Jun 2018 05:03:45 +0000
Gerrit-HasComments: No
Gerrit-HasLabels: No