summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2018-03-27 16:28:52 -0700
committerJulius Werner <jwerner@chromium.org>2018-04-03 00:34:52 +0000
commit4783db2cf18c31ab48b219dabe1e04bf7f311d52 (patch)
treed68c3a022c55adc6ed0c7530983185325ac252d9 /src/include
parentffeee420912eecf525564bb35b095b6bfa5d0de6 (diff)
spi: Add helper functions for bit-banging
Sometimes when bringing up a new board it can take a while until you have all the peripheral drivers ready. For those cases it is nice to be able to bitbang certain protocols so that you can already get further in the boot flow while those drivers are still being worked on. We already have this support for I2C, but it would be nice to have something for SPI as well, since without SPI you're not going to boot very far. This patch adds a couple of helper functions that platforms can use to implement bit-banging SPI with minimal effort. It also adds a proof of concept implementation using the RK3399. Change-Id: Ie3551f51cc9a9f8bf3a47fd5cea6d9c064da8a62 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/25394 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/spi_bitbang.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/include/spi_bitbang.h b/src/include/spi_bitbang.h
new file mode 100644
index 0000000000..710fefb1bf
--- /dev/null
+++ b/src/include/spi_bitbang.h
@@ -0,0 +1,32 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2018 Google LLC
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+#ifndef _SPI_BITBANG_H_
+#define _SPI_BITBANG_H_
+
+#include <types.h>
+
+struct spi_bitbang_ops {
+ int (*get_miso)(const struct spi_bitbang_ops *ops);
+ void (*set_mosi)(const struct spi_bitbang_ops *ops, int value);
+ void (*set_clk)(const struct spi_bitbang_ops *ops, int value);
+ void (*set_cs)(const struct spi_bitbang_ops *ops, int value);
+};
+
+int spi_bitbang_claim_bus(const struct spi_bitbang_ops *ops);
+void spi_bitbang_release_bus(const struct spi_bitbang_ops *ops);
+int spi_bitbang_xfer(const struct spi_bitbang_ops *ops, const void *dout,
+ size_t bytes_out, void *din, size_t bytes_in);
+
+#endif /* _SPI_BITBANG_H_ */