From 2822888c810eaf2d68271f4dac4a0ad639221fd3 Mon Sep 17 00:00:00 2001 From: Carl-Daniel Hailfinger Date: Wed, 15 Sep 2010 00:17:37 +0000 Subject: SPI bitbanging: request/release bus SPI bitbanging on devices which speak SPI natively has a dual-use problem: We need to shut down normal SPI operations to do the bitbanging ourselves. Once we're done, it makes a lot of sense to reenable "normal" SPI operations again. Add request_bus/release_bus functions to struct bitbang_spi_master. Add a bitbang shutdown function (not used yet). Change MCP SPI and Intel NIC SPI to use the new request/release bus infrastructure. Cosmetic changes to a few error messages (80 column limit). There are multiple possible strategies for bus request/release: - Request at the start of a SPI command, release immediately afterwards. - Request at the start of a SPI multicommand, release once all commands of the multicommand are done. - Request on programmer init, release on shutdown. Each strategy has its own advantages. For now, we will stay with the first strategy which worked fine so far. Corresponding to flashrom svn r1171. Signed-off-by: Carl-Daniel Hailfinger Acked-by: Uwe Hermann --- programmer.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'programmer.h') diff --git a/programmer.h b/programmer.h index 0d8e161..6407695 100644 --- a/programmer.h +++ b/programmer.h @@ -131,6 +131,8 @@ struct bitbang_spi_master { void (*set_sck) (int val); void (*set_mosi) (int val); int (*get_miso) (void); + void (*request_bus) (void); + void (*release_bus) (void); }; #if CONFIG_INTERNAL == 1 @@ -443,6 +445,7 @@ int mcp6x_spi_init(int want_spi); /* bitbang_spi.c */ int bitbang_spi_init(const struct bitbang_spi_master *master, int halfperiod); +int bitbang_spi_shutdown(const struct bitbang_spi_master *master); int bitbang_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); int bitbang_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); int bitbang_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len); -- cgit v1.1