Allow using control register (in addition to data register) for all output signals.
Signed-off-by: Ondrej Zary linux@rainbow-software.org
--- a/rayer_spi.c 2013-03-16 23:13:02.000000000 +0100 +++ b/rayer_spi.c 2013-03-16 23:13:09.000000000 +0100 @@ -58,6 +58,9 @@ struct rayer_pinout { int sck_inverted; int mosi_inverted; int miso_inverted; + int cs_reg; + int sck_reg; + int mosi_reg; void (*preinit)(void *); int (*shutdown)(void *); }; @@ -136,33 +139,33 @@ struct rayer_pinout *pinout = NULL; static uint16_t lpt_iobase;
/* Cached value of last byte sent. */ -static uint8_t lpt_outbyte; +static uint8_t lpt_outbyte[3];
static void rayer_bitbang_set_cs(int val) { if (pinout->cs_inverted) val = !val; - lpt_outbyte &= ~(1 << pinout->cs_bit); - lpt_outbyte |= (val << pinout->cs_bit); - OUTB(lpt_outbyte, lpt_iobase); + lpt_outbyte[pinout->cs_reg] &= ~(1 << pinout->cs_bit); + lpt_outbyte[pinout->cs_reg] |= (val << pinout->cs_bit); + OUTB(lpt_outbyte[pinout->cs_reg], lpt_iobase + pinout->cs_reg); }
static void rayer_bitbang_set_sck(int val) { if (pinout->sck_inverted) val = !val; - lpt_outbyte &= ~(1 << pinout->sck_bit); - lpt_outbyte |= (val << pinout->sck_bit); - OUTB(lpt_outbyte, lpt_iobase); + lpt_outbyte[pinout->sck_reg] &= ~(1 << pinout->sck_bit); + lpt_outbyte[pinout->sck_reg] |= (val << pinout->sck_bit); + OUTB(lpt_outbyte[pinout->sck_reg], lpt_iobase + pinout->sck_reg); }
static void rayer_bitbang_set_mosi(int val) { if (pinout->mosi_inverted) val = !val; - lpt_outbyte &= ~(1 << pinout->mosi_bit); - lpt_outbyte |= (val << pinout->mosi_bit); - OUTB(lpt_outbyte, lpt_iobase); + lpt_outbyte[pinout->mosi_reg] &= ~(1 << pinout->mosi_bit); + lpt_outbyte[pinout->mosi_reg] |= (val << pinout->mosi_bit); + OUTB(lpt_outbyte[pinout->mosi_reg], lpt_iobase + pinout->mosi_reg); }
static int rayer_bitbang_get_miso(void) @@ -245,7 +248,8 @@ int rayer_spi_init(void) return 1;
/* Get the initial value before writing to any line. */ - lpt_outbyte = INB(lpt_iobase); + lpt_outbyte[0] = INB(lpt_iobase); + lpt_outbyte[2] = INB(lpt_iobase + 2);
if (pinout->shutdown) register_shutdown(pinout->shutdown, (void*)pinout); @@ -261,15 +265,15 @@ int rayer_spi_init(void) static void dlc5b_preinit(void * data) { msg_pdbg("dlc5b_preinit\n"); /* Assert pin 6 to receive MISO. */ - lpt_outbyte |= (1<<4); - OUTB(lpt_outbyte, lpt_iobase); + lpt_outbyte[0] |= (1<<4); + OUTB(lpt_outbyte[0], lpt_iobase); }
static int dlc5b_shutdown(void * data) { msg_pdbg("dlc5b_shutdown\n"); /* De-assert pin 6 to force MISO low. */ - lpt_outbyte &= ~(1<<4); - OUTB(lpt_outbyte, lpt_iobase); + lpt_outbyte[0] &= ~(1<<4); + OUTB(lpt_outbyte[0], lpt_iobase); return 0; }
@@ -289,15 +293,15 @@ static int byteblaster_shutdown(void * d static void stk200_preinit(void *data) { msg_pdbg("stk200_init\n"); /* Assert #EN signals, set LED signal. */ - lpt_outbyte = (1 << 6) ; - OUTB(lpt_outbyte, lpt_iobase); + lpt_outbyte[0] = (1 << 6) ; + OUTB(lpt_outbyte[0], 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); + lpt_outbyte[0] = (1 << 2) | (1 << 3); + OUTB(lpt_outbyte[0], lpt_iobase); return 0; }