Angel Pons has uploaded this change for review.

View Change

mcp6x_spi.c: Implement `set_sck_set_mosi` and `set_sck_get_miso`

Change-Id: Ie86cc9d4df6c7f0609c30ff00d6f2d77fbb8b836
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
---
M mcp6x_spi.c
1 file changed, 20 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/66/49266/1
diff --git a/mcp6x_spi.c b/mcp6x_spi.c
index b53d07b..4f82095 100644
--- a/mcp6x_spi.c
+++ b/mcp6x_spi.c
@@ -87,11 +87,31 @@
return (mcp_gpiostate >> MCP6X_SPI_MISO) & 0x1;
}

+static void mcp6x_bitbang_set_sck_set_mosi(int sck, int mosi)
+{
+ mcp_gpiostate &= ~(1 << MCP6X_SPI_SCK);
+ mcp_gpiostate &= ~(1 << MCP6X_SPI_MOSI);
+ mcp_gpiostate |= (sck << MCP6X_SPI_SCK);
+ mcp_gpiostate |= (mosi << MCP6X_SPI_MOSI);
+ mmio_writeb(mcp_gpiostate, mcp6x_spibar + 0x530);
+}
+
+static int mcp6x_bitbang_set_sck_get_miso(int sck)
+{
+ mcp_gpiostate = mmio_readb(mcp6x_spibar + 0x530);
+ mcp_gpiostate &= ~(1 << MCP6X_SPI_SCK);
+ mcp_gpiostate |= (sck << MCP6X_SPI_SCK);
+ mmio_writeb(mcp_gpiostate, mcp6x_spibar + 0x530);
+ return (mcp_gpiostate >> MCP6X_SPI_MISO) & 0x1;
+}
+
static const struct bitbang_spi_master bitbang_spi_master_mcp6x = {
.set_cs = mcp6x_bitbang_set_cs,
.set_sck = mcp6x_bitbang_set_sck,
.set_mosi = mcp6x_bitbang_set_mosi,
.get_miso = mcp6x_bitbang_get_miso,
+ .set_sck_set_mosi = mcp6x_bitbang_set_sck_set_mosi,
+ .set_sck_get_miso = mcp6x_bitbang_set_sck_get_miso,
.request_bus = mcp6x_request_spibus,
.release_bus = mcp6x_release_spibus,
.half_period = 0,

To view, visit change 49266. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie86cc9d4df6c7f0609c30ff00d6f2d77fbb8b836
Gerrit-Change-Number: 49266
Gerrit-PatchSet: 1
Gerrit-Owner: Angel Pons <th3fanbus@gmail.com>
Gerrit-MessageType: newchange