summaryrefslogtreecommitdiffstats
path: root/rayer_spi.c
diff options
context:
space:
mode:
authorAnastasia Klimchuk <aklm@chromium.org>2021-03-17 12:11:35 +1100
committerEdward O'Callaghan <quasisec@chromium.org>2021-03-18 01:25:40 +0000
commit5e0a9eadd24934d868952ad818dfa8c698705989 (patch)
treee15734b2c946622e54fc51c4ae6037001bdf73dd /rayer_spi.c
parent51ae724a08636acd5074aa87bedf5f0baece8f51 (diff)
downloadflashrom-5e0a9eadd24934d868952ad818dfa8c698705989.tar.gz
flashrom-5e0a9eadd24934d868952ad818dfa8c698705989.tar.bz2
flashrom-5e0a9eadd24934d868952ad818dfa8c698705989.zip
rayer_spi.c: Remove forward-declarations
Reorder functions to avoid forward-declarations. This was aimed to be done for all spi masters in the earlier patch however this file was missed. BUG=b:140394053 TEST=builds Change-Id: I0e3c82967a169d6a2512ffa17d1e0c78eafb2797 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/51555 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'rayer_spi.c')
-rw-r--r--rayer_spi.c99
1 files changed, 45 insertions, 54 deletions
diff --git a/rayer_spi.c b/rayer_spi.c
index 8e869e66d..cde008f7c 100644
--- a/rayer_spi.c
+++ b/rayer_spi.c
@@ -31,6 +31,11 @@
#include "programmer.h"
#include "hwaccess.h"
+static uint16_t lpt_iobase;
+
+/* Cached value of last byte sent. */
+static uint8_t lpt_outbyte;
+
/* We have two sets of pins, out and in. The numbers for both sets are
* independent and are bitshift values, not real pin numbers.
* Default settings are for the RayeR hardware.
@@ -59,8 +64,20 @@ static const struct rayer_pinout rayer_spipgm = {
.miso_bit = 6,
};
-static void dlc5_preinit(const void *);
-static int dlc5_shutdown(void *);
+static void dlc5_preinit(const void *data) {
+ msg_pdbg("dlc5_preinit\n");
+ /* Assert pin 6 to receive MISO. */
+ lpt_outbyte |= (1<<4);
+ OUTB(lpt_outbyte, lpt_iobase);
+}
+
+static int dlc5_shutdown(void *data) {
+ msg_pdbg("dlc5_shutdown\n");
+ /* De-assert pin 6 to force MISO low. */
+ lpt_outbyte &= ~(1<<4);
+ OUTB(lpt_outbyte, lpt_iobase);
+ return 0;
+}
static const struct rayer_pinout xilinx_dlc5 = {
.cs_bit = 2,
@@ -71,8 +88,18 @@ static const struct rayer_pinout xilinx_dlc5 = {
.shutdown = dlc5_shutdown,
};
-static void byteblaster_preinit(const void *);
-static int byteblaster_shutdown(void *);
+static void byteblaster_preinit(const void *data){
+ msg_pdbg("byteblaster_preinit\n");
+ /* Assert #EN signal. */
+ OUTB(2, lpt_iobase + 2 );
+}
+
+static int byteblaster_shutdown(void *data){
+ msg_pdbg("byteblaster_shutdown\n");
+ /* De-Assert #EN signal. */
+ OUTB(0, lpt_iobase + 2 );
+ return 0;
+}
static const struct rayer_pinout altera_byteblastermv = {
.cs_bit = 1,
@@ -83,8 +110,20 @@ static const struct rayer_pinout altera_byteblastermv = {
.shutdown = byteblaster_shutdown,
};
-static void stk200_preinit(const void *);
-static int stk200_shutdown(void *);
+static void stk200_preinit(const void *data) {
+ msg_pdbg("stk200_init\n");
+ /* Assert #EN signals, set LED signal. */
+ lpt_outbyte = (1 << 6) ;
+ OUTB(lpt_outbyte, lpt_iobase);
+}
+
+static int stk200_shutdown(void *data) {
+ msg_pdbg("stk200_shutdown\n");
+ /* Assert #EN signals, clear LED signal. */
+ lpt_outbyte = (1 << 2) | (1 << 3);
+ OUTB(lpt_outbyte, lpt_iobase);
+ return 0;
+}
static const struct rayer_pinout atmel_stk200 = {
.cs_bit = 7,
@@ -121,11 +160,6 @@ static const struct rayer_programmer rayer_spi_types[] = {
static const struct rayer_pinout *pinout = NULL;
-static uint16_t lpt_iobase;
-
-/* Cached value of last byte sent. */
-static uint8_t lpt_outbyte;
-
static void rayer_bitbang_set_cs(int val)
{
lpt_outbyte &= ~(1 << pinout->cs_bit);
@@ -237,49 +271,6 @@ int rayer_spi_init(void)
return 0;
}
-static void byteblaster_preinit(const void *data){
- msg_pdbg("byteblaster_preinit\n");
- /* Assert #EN signal. */
- OUTB(2, lpt_iobase + 2 );
-}
-
-static int byteblaster_shutdown(void *data){
- msg_pdbg("byteblaster_shutdown\n");
- /* De-Assert #EN signal. */
- OUTB(0, lpt_iobase + 2 );
- return 0;
-}
-
-static void stk200_preinit(const void *data) {
- msg_pdbg("stk200_init\n");
- /* Assert #EN signals, set LED signal. */
- lpt_outbyte = (1 << 6) ;
- OUTB(lpt_outbyte, lpt_iobase);
-}
-
-static int stk200_shutdown(void *data) {
- msg_pdbg("stk200_shutdown\n");
- /* Assert #EN signals, clear LED signal. */
- lpt_outbyte = (1 << 2) | (1 << 3);
- OUTB(lpt_outbyte, lpt_iobase);
- return 0;
-}
-
-static void dlc5_preinit(const void *data) {
- msg_pdbg("dlc5_preinit\n");
- /* Assert pin 6 to receive MISO. */
- lpt_outbyte |= (1<<4);
- OUTB(lpt_outbyte, lpt_iobase);
-}
-
-static int dlc5_shutdown(void *data) {
- msg_pdbg("dlc5_shutdown\n");
- /* De-assert pin 6 to force MISO low. */
- lpt_outbyte &= ~(1<<4);
- OUTB(lpt_outbyte, lpt_iobase);
- return 0;
-}
-
#else
#error PCI port I/O access is not supported on this architecture yet.
#endif