diff options
Diffstat (limited to 'wbsio_spi.c')
-rw-r--r-- | wbsio_spi.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/wbsio_spi.c b/wbsio_spi.c index 632ff72ae..9f33b18de 100644 --- a/wbsio_spi.c +++ b/wbsio_spi.c @@ -14,14 +14,13 @@ * GNU General Public License for more details. */ -#if defined(__i386__) || defined(__x86_64__) - #include <stdlib.h> #include "flash.h" #include "chipdrivers.h" #include "programmer.h" -#include "hwaccess.h" +#include "hwaccess_physmap.h" +#include "hwaccess_x86_io.h" #include "spi.h" #define WBSIO_PORT1 0x2e @@ -156,7 +155,7 @@ static int wbsio_spi_send_command(const struct flashctx *flash, unsigned int wri OUTB(writearr[0], data->spibase); OUTB(mode, data->spibase + 1); - programmer_delay(10); + default_delay(10); if (!readcnt) return 0; @@ -177,23 +176,25 @@ static int wbsio_spi_read(struct flashctx *flash, uint8_t *buf, return 0; } -static struct spi_master spi_master_wbsio = { - .max_data_read = MAX_DATA_UNSPECIFIED, - .max_data_write = MAX_DATA_UNSPECIFIED, - .command = wbsio_spi_send_command, - .multicommand = default_spi_send_multicommand, - .read = wbsio_spi_read, - .write_256 = spi_chip_write_1, - .write_aai = spi_chip_write_1, -}; - static int wbsio_spi_shutdown(void *data) { free(data); return 0; } -int wbsio_check_for_spi(void) +static const struct spi_master spi_master_wbsio = { + .max_data_read = MAX_DATA_UNSPECIFIED, + .max_data_write = MAX_DATA_UNSPECIFIED, + .command = wbsio_spi_send_command, + .map_flash_region = physmap, + .unmap_flash_region = physunmap, + .read = wbsio_spi_read, + .write_256 = spi_chip_write_1, + .write_aai = spi_chip_write_1, + .shutdown = wbsio_spi_shutdown, +}; + +int wbsio_check_for_spi(struct board_cfg *cfg) { uint16_t wbsio_spibase = 0; @@ -207,18 +208,12 @@ int wbsio_check_for_spi(void) "1024 kB!\n", __func__); max_rom_decode.spi = 1024 * 1024; - struct wbsio_spi_data * data = calloc(1, sizeof(struct wbsio_spi_data)); + struct wbsio_spi_data *data = calloc(1, sizeof(*data)); if (!data) { msg_perr("Unable to allocate space for extra SPI master data.\n"); return SPI_GENERIC_ERROR; } data->spibase = wbsio_spibase; - register_shutdown(wbsio_spi_shutdown, data); - spi_master_wbsio.data = data; - register_spi_master(&spi_master_wbsio); - - return 0; + return register_spi_master(&spi_master_wbsio, data); } - -#endif /* defined(__i386__) || defined(__x86_64__) */ |