bitbang_spi: Move API into its own header file

We're going to extent it for multi-i/o.

Change-Id: Ifead97d7a8f848b82a4d21c557f5d364066d5d6a
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/81
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/bitbang_spi.c b/bitbang_spi.c
index c43fa2f..1c2c178 100644
--- a/bitbang_spi.c
+++ b/bitbang_spi.c
@@ -20,6 +20,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "spi.h"
+#include "bitbang_spi.h"
 
 struct bitbang_spi_master_data {
 	const struct bitbang_spi_master *mst;
diff --git a/developerbox_spi.c b/developerbox_spi.c
index 3a9059e..4efa309 100644
--- a/developerbox_spi.c
+++ b/developerbox_spi.c
@@ -34,6 +34,7 @@
 #include <stdlib.h>
 #include <libusb.h>
 #include "programmer.h"
+#include "bitbang_spi.h"
 #include "spi.h"
 
 /* Bit positions for each pin. */
diff --git a/include/bitbang_spi.h b/include/bitbang_spi.h
new file mode 100644
index 0000000..b321651
--- /dev/null
+++ b/include/bitbang_spi.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the flashrom project.
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 __BITBANG_SPI_H__
+#define __BITBANG_SPI_H__ 1
+
+struct bitbang_spi_master {
+	/* Note that CS# is active low, so val=0 means the chip is active. */
+	void (*set_cs) (int val, void *data);
+	void (*set_sck) (int val, void *data);
+	void (*set_mosi) (int val, void *data);
+	int (*get_miso) (void *data);
+	void (*request_bus) (void *data);
+	void (*release_bus) (void *data);
+	/* optional functions to optimize xfers */
+	void (*set_sck_set_mosi) (int sck, int mosi, void *data);
+	int (*set_sck_get_miso) (int sck, void *data);
+	/* Length of half a clock period in usecs. */
+	unsigned int half_period;
+};
+
+int register_spi_bitbang_master(const struct bitbang_spi_master *, void *data);
+
+#endif				/* !__BITBANG_SPI_H__ */
diff --git a/include/programmer.h b/include/programmer.h
index fb19c00..0f724ec 100644
--- a/include/programmer.h
+++ b/include/programmer.h
@@ -106,21 +106,6 @@
 int programmer_init(struct flashprog_programmer *);
 int programmer_shutdown(struct flashprog_programmer *);
 
-struct bitbang_spi_master {
-	/* Note that CS# is active low, so val=0 means the chip is active. */
-	void (*set_cs) (int val, void *spi_data);
-	void (*set_sck) (int val, void *spi_data);
-	void (*set_mosi) (int val, void *spi_data);
-	int (*get_miso) (void *spi_data);
-	void (*request_bus) (void *spi_data);
-	void (*release_bus) (void *spi_data);
-	/* optional functions to optimize xfers */
-	void (*set_sck_set_mosi) (int sck, int mosi, void *spi_data);
-	int (*set_sck_get_miso) (int sck, void *spi_data);
-	/* Length of half a clock period in usecs. */
-	unsigned int half_period;
-};
-
 struct pci_dev;
 struct pci_filter;
 
@@ -281,10 +266,6 @@
 extern enum chipbustype internal_buses_supported;
 #endif
 
-/* bitbang_spi.c */
-int register_spi_bitbang_master(const struct bitbang_spi_master *master, void *spi_data);
-
-
 /* flashprog.c */
 // FIXME: These need to be local, not global
 extern bool programmer_may_write;
diff --git a/linux_gpio2_spi.c b/linux_gpio2_spi.c
index ef162b8..24cf33d 100644
--- a/linux_gpio2_spi.c
+++ b/linux_gpio2_spi.c
@@ -23,6 +23,7 @@
 #include <errno.h>
 #include <gpiod.h>
 #include "programmer.h"
+#include "bitbang_spi.h"
 #include "spi.h"
 #include "flash.h"
 
diff --git a/linux_gpio_spi.c b/linux_gpio_spi.c
index 8ce5b07..647f813 100644
--- a/linux_gpio_spi.c
+++ b/linux_gpio_spi.c
@@ -20,6 +20,7 @@
 #include <errno.h>
 #include <gpiod.h>
 #include "programmer.h"
+#include "bitbang_spi.h"
 #include "spi.h"
 #include "flash.h"
 
diff --git a/mcp6x_spi.c b/mcp6x_spi.c
index 2e5d1de..cdaa7fd 100644
--- a/mcp6x_spi.c
+++ b/mcp6x_spi.c
@@ -23,6 +23,7 @@
 #include <ctype.h>
 #include "flash.h"
 #include "programmer.h"
+#include "bitbang_spi.h"
 #include "hwaccess_physmap.h"
 #include "platform/pci.h"
 
diff --git a/nicintel_spi.c b/nicintel_spi.c
index 1de3fd0..ccb0c5d 100644
--- a/nicintel_spi.c
+++ b/nicintel_spi.c
@@ -34,6 +34,7 @@
 #include <unistd.h>
 #include "flash.h"
 #include "programmer.h"
+#include "bitbang_spi.h"
 #include "hwaccess_physmap.h"
 #include "platform/pci.h"
 
diff --git a/ogp_spi.c b/ogp_spi.c
index 5eeda98..ad04a7d 100644
--- a/ogp_spi.c
+++ b/ogp_spi.c
@@ -18,6 +18,7 @@
 #include <string.h>
 #include "flash.h"
 #include "programmer.h"
+#include "bitbang_spi.h"
 #include "hwaccess_physmap.h"
 #include "platform/pci.h"
 
diff --git a/pony_spi.c b/pony_spi.c
index 1b1f939..a09021d 100644
--- a/pony_spi.c
+++ b/pony_spi.c
@@ -42,6 +42,7 @@
 
 #include "flash.h"
 #include "programmer.h"
+#include "bitbang_spi.h"
 
 enum pony_type {
 	TYPE_SI_PROG,
diff --git a/rayer_spi.c b/rayer_spi.c
index f8bac35..30577ac 100644
--- a/rayer_spi.c
+++ b/rayer_spi.c
@@ -28,6 +28,7 @@
 #include <string.h>
 #include "flash.h"
 #include "programmer.h"
+#include "bitbang_spi.h"
 #include "hwaccess_x86_io.h"
 
 /* We have two sets of pins, out and in. The numbers for both sets are