anyio: refactor: unification of functions arguments in hostmot2 access interface

factor out common board structure initialisations to function

Signed-off-by: Michael Geszkiewicz <micges@wp.pl>
This commit is contained in:
Michael Geszkiewicz 2015-03-09 00:05:39 +01:00
parent 2e72e502db
commit 3106d0df2b
17 changed files with 92 additions and 104 deletions

View file

@ -311,7 +311,7 @@ void anyio_dev_print_hm2_info(board_t *board, int xml_flag) {
if (board == NULL) {
return;
}
hm2_read_idrom(&(board->llio));
hm2_read_idrom(&(board->llio.hm2));
hm2_print_pin_file(&(board->llio), xml_flag);
}
@ -319,7 +319,7 @@ void anyio_dev_print_sserial_info(board_t *board) {
if (board == NULL) {
return;
}
hm2_read_idrom(&(board->llio));
hm2_read_idrom(&(board->llio.hm2));
sserial_module_init(&(board->llio));
}

View file

@ -22,6 +22,7 @@
#include <windows.h>
#endif
#include <stdio.h>
#include <string.h>
#include "types.h"
#include "common.h"
#include "eeprom.h"
@ -105,6 +106,12 @@ void show_formatted_size(u32 size) {
}
}
void board_init_struct(board_t *board) {
memset(board, 0, sizeof(board_t));
board->llio.board = board;
board->llio.hm2.llio = &(board->llio);
}
void show_board_info(board_t *board) {
int i;

View file

@ -42,6 +42,7 @@ void *unmap_memory(tagPhysStruct_t *phys);
void sleep_ns(u64 nanoseconds);
void show_formatted_size(u32 size);
void board_init_struct(board_t *board);
void show_board_info(board_t *board);
#endif

View file

@ -109,7 +109,7 @@ static void write_boot(llio_t *self) {
}
int start_programming(llio_t *self, u32 start_address, int fsize) {
board_t *board = self->private;
board_t *board = self->board;
u32 sec_addr;
int esectors, sector, max_sectors;
struct timeval tv1, tv2;
@ -150,7 +150,7 @@ int start_programming(llio_t *self, u32 start_address, int fsize) {
}
int eeprom_write(llio_t *self, char *bitfile_name, u32 start_address) {
board_t *board = self->private;
board_t *board = self->board;
int bytesread, i;
u32 eeprom_addr;
char part_name[32];
@ -225,7 +225,7 @@ int eeprom_write(llio_t *self, char *bitfile_name, u32 start_address) {
}
int eeprom_verify(llio_t *self, char *bitfile_name, u32 start_address) {
board_t *board = self->private;
board_t *board = self->board;
int bytesread, i, bindex;
u32 eeprom_addr;
char part_name[32];
@ -298,7 +298,7 @@ int eeprom_verify(llio_t *self, char *bitfile_name, u32 start_address) {
}
void eeprom_init(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
switch (board->flash) {
case BOARD_FLASH_NONE:
@ -316,7 +316,7 @@ void eeprom_init(llio_t *self) {
}
void eeprom_cleanup(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
switch (board->flash) {
case BOARD_FLASH_NONE:

View file

@ -92,49 +92,49 @@ static u8 recv_byte_hm2(llio_t *self) {
static u16 GPIO_reg_val;
static void set_cs_high_gpio(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
GPIO_reg_val = GPIO_reg_val | 0x2;
pci_write_word(board->dev, XIO2001_GPIO_DATA_REG, GPIO_reg_val);
}
static void set_cs_low_gpio(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
GPIO_reg_val = GPIO_reg_val & (~ 0x2);
pci_write_word(board->dev, XIO2001_GPIO_DATA_REG, GPIO_reg_val);
}
static void set_din_high_gpio(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
GPIO_reg_val = GPIO_reg_val | 0x8;
pci_write_word(board->dev, XIO2001_GPIO_DATA_REG, GPIO_reg_val);
}
static void set_din_low_gpio(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
GPIO_reg_val = GPIO_reg_val & (~0x8);
pci_write_word(board->dev, XIO2001_GPIO_DATA_REG, GPIO_reg_val);
}
static void set_clock_high_gpio(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
GPIO_reg_val = GPIO_reg_val | 0x10;
pci_write_word(board->dev, XIO2001_GPIO_DATA_REG, GPIO_reg_val);
}
static void set_clock_low_gpio(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
GPIO_reg_val = GPIO_reg_val & (~ 0x10);
pci_write_word(board->dev, XIO2001_GPIO_DATA_REG, GPIO_reg_val);
}
static int get_bit_gpio(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
u16 data;
data = pci_read_word(board->dev, XIO2001_GPIO_DATA_REG);
@ -157,7 +157,7 @@ static void suffix_gpio(llio_t *self) {
}
static void init_gpio(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
pci_write_word(board->dev, XIO2001_GPIO_ADDR_REG, 0x001B);
pci_write_word(board->dev, XIO2001_SBAD_STAT_REG, 0x0000);
@ -166,7 +166,7 @@ static void init_gpio(llio_t *self) {
}
static void restore_gpio(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
GPIO_reg_val = 0x0003;
pci_write_word(board->dev, XIO2001_GPIO_DATA_REG, GPIO_reg_val);
@ -206,7 +206,7 @@ static u8 recv_byte_gpio(llio_t *self) {
// spi access via io ports like on 3x20
static void wait_for_data_io(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
u32 i = 0;
u8 data = 0;
@ -219,13 +219,13 @@ static void wait_for_data_io(llio_t *self) {
}
static void set_cs_high_io(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
outb(1, board->data_base_addr + IO_SPI_CS_OFFSET);
}
static void set_cs_low_io(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
outb(0, board->data_base_addr + IO_SPI_CS_OFFSET);
}
@ -239,13 +239,13 @@ static void suffix_io(llio_t *self) {
}
static void send_byte_io(llio_t *self, u8 byte) {
board_t *board = self->private;
board_t *board = self->board;
outb(byte, board->data_base_addr + IO_SPI_SREG_OFFSET);
}
static u8 recv_byte_io(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
outb(0, board->data_base_addr + IO_SPI_SREG_OFFSET);
wait_for_data_io(self);
@ -255,7 +255,7 @@ static u8 recv_byte_io(llio_t *self) {
// spi access via epp on board 7i43 with EPPIO firmware
void wait_for_data_epp(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
u32 i = 0;
u8 data = 0;
@ -269,14 +269,14 @@ void wait_for_data_epp(llio_t *self) {
}
static void set_cs_high_epp(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
epp_addr8(board, EPP_SPI_CS_REG);
epp_write8(board, 1);
}
static void set_cs_low_epp(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
epp_addr8(board, EPP_SPI_CS_REG);
epp_write8(board, 0);
@ -291,14 +291,14 @@ static void suffix_epp(llio_t *self) {
}
static void send_byte_epp(llio_t *self, u8 byte) {
board_t *board = self->private;
board_t *board = self->board;
epp_addr8(board, EPP_SPI_SREG_REG);
epp_write8(board, byte);
}
static u8 recv_byte_epp(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
epp_addr8(board, EPP_SPI_SREG_REG);
epp_write8(board, 0);
@ -428,7 +428,7 @@ int local_verify_flash(llio_t *self, char *bitfile_name, u32 start_address) {
}
void open_spi_access_local(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
switch (board->flash) {
case BOARD_FLASH_NONE:
@ -476,7 +476,7 @@ void open_spi_access_local(llio_t *self) {
};
void close_spi_access_local(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
switch (board->flash) {
case BOARD_FLASH_NONE:

View file

@ -25,17 +25,17 @@
double seconds_per_tsdiv_clock;
static void enable_encoder_pins(llio_t *llio) {
static void enable_encoder_pins(hostmot2_t *hm2) {
int i;
for (i = 0; i < HM2_MAX_PINS; i++) {
if (llio->hm2.pins[i].gtag == HM2_GTAG_NONE) {
if (hm2->pins[i].gtag == HM2_GTAG_NONE) {
break;
}
if ((llio->hm2.pins[i].sec_tag == HM2_GTAG_MUXED_ENCODER_SEL)) {
hm2_set_pin_source(llio, i, HM2_PIN_SOURCE_IS_SECONDARY);
if (llio->hm2.pins[i].sec_pin & HM2_PIN_OUTPUT) {
hm2_set_pin_direction(llio, i, HM2_PIN_DIR_IS_OUTPUT);
if ((hm2->pins[i].sec_tag == HM2_GTAG_MUXED_ENCODER_SEL)) {
hm2_set_pin_source(hm2, i, HM2_PIN_SOURCE_IS_SECONDARY);
if (hm2->pins[i].sec_pin & HM2_PIN_OUTPUT) {
hm2_set_pin_direction(hm2, i, HM2_PIN_DIR_IS_OUTPUT);
}
}
}
@ -64,7 +64,7 @@ int encoder_init(encoder_module_t *enc, board_t *board, int instance, int delay)
enc->instance = instance;
enc->instance_stride = (md->strides & 0xF0) == 0 ? board->llio.hm2.idrom.instance_stride0 : board->llio.hm2.idrom.instance_stride1;
enable_encoder_pins(&(enc->board->llio));
enable_encoder_pins(&(enc->board->llio.hm2));
if (md->clock_tag == HM2_CLOCK_LOW_TAG) {
clock = (enc->board->llio.hm2.idrom.clock_low / 1e6 * delay) - 2;

View file

@ -139,7 +139,7 @@ static inline void epp_write32(board_t *board, u32 data) {
int epp_read(llio_t *self, u32 addr, void *buffer, int size) {
int bytes_remaining = size;
board_t *board = self->private;
board_t *board = self->board;
epp_addr16(board, addr | EPP_ADDR_AUTOINCREMENT);
@ -165,7 +165,7 @@ int epp_read(llio_t *self, u32 addr, void *buffer, int size) {
int epp_write(llio_t *self, u32 addr, void *buffer, int size) {
int bytes_remaining = size;
board_t *board = self->private;
board_t *board = self->board;
epp_addr16(board, addr | EPP_ADDR_AUTOINCREMENT);
@ -190,7 +190,7 @@ int epp_write(llio_t *self, u32 addr, void *buffer, int size) {
}
int epp_program_fpga(llio_t *self, char *bitfile_name) {
board_t *board = self->private;
board_t *board = self->board;
int bindex, bytesread;
char part_name[32];
struct stat file_stat;
@ -246,7 +246,7 @@ int epp_program_fpga(llio_t *self, char *bitfile_name) {
// return 0 if the board has been reset, -errno if not
int epp_reset(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
u8 byte;
@ -343,6 +343,8 @@ void epp_boards_scan(board_access_t *access) {
u16 epp_addr = 0, epp_hi_addr = 0;
u32 hm2_cookie, eppio_cookie;
board_init_struct(board);
if (access->address == 0) {
access->dev_addr = "0x378";
access->dev_hi_addr = "0x778";
@ -389,7 +391,6 @@ void epp_boards_scan(board_access_t *access) {
epp_clear_timeout(board);
board->epp_wide = 1;
board->llio.private = board;
epp_read(&(board->llio), 0, &eppio_cookie, 4);
epp_read(&(board->llio), HM2_COOKIE_REG, &hm2_cookie, 4);
@ -428,7 +429,6 @@ void epp_boards_scan(board_access_t *access) {
board->llio.write = &epp_write;
board->llio.write_flash = &local_write_flash;
board->llio.verify_flash = &local_verify_flash;
board->llio.private = board;
board->open = &epp_board_open;
board->close = &epp_board_close;
@ -452,7 +452,6 @@ void epp_boards_scan(board_access_t *access) {
board->llio.write = &epp_write;
board->llio.program_fpga = &epp_program_fpga;
board->llio.reset = &epp_reset;
board->llio.private = board;
board->open = &epp_board_open;
board->close = &epp_board_close;
@ -477,7 +476,6 @@ void epp_boards_scan(board_access_t *access) {
board->llio.program_fpga = &epp_program_fpga;
board->llio.write_flash = &local_write_flash;
board->llio.verify_flash = &local_verify_flash;
board->llio.private = board;
board->open = &epp_board_open;
board->close = &epp_board_close;
@ -498,7 +496,6 @@ void epp_boards_scan(board_access_t *access) {
board->llio.num_leds = 2;
board->llio.program_fpga = &epp_program_fpga;
board->llio.reset = &epp_reset;
board->llio.private = board;
board->open = &epp_board_open;
board->close = &epp_board_close;

View file

@ -147,6 +147,8 @@ static int eth_scan_one_addr(board_access_t *access) {
char buff[20];
board_t *board = &boards[boards_count];
board_init_struct(board);
eth_socket_blocking();
LBP16_INIT_PACKET4(packet2, CMD_READ_BOARD_INFO_ADDR16_INCR(8), 0);
memset(buff, 0, sizeof(buff));
@ -171,7 +173,6 @@ static int eth_scan_one_addr(board_access_t *access) {
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->llio.private = board;
board->open = &eth_board_open;
board->close = &eth_board_close;
@ -197,7 +198,6 @@ static int eth_scan_one_addr(board_access_t *access) {
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->llio.private = board;
board->open = &eth_board_open;
board->close = &eth_board_close;
@ -222,7 +222,6 @@ static int eth_scan_one_addr(board_access_t *access) {
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->llio.private = board;
board->open = &eth_board_open;
board->close = &eth_board_close;
@ -247,7 +246,6 @@ static int eth_scan_one_addr(board_access_t *access) {
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->llio.private = board;
board->open = &eth_board_open;
board->close = &eth_board_close;
@ -272,7 +270,6 @@ static int eth_scan_one_addr(board_access_t *access) {
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->llio.private = board;
board->open = &eth_board_open;
board->close = &eth_board_close;
@ -296,7 +293,6 @@ static int eth_scan_one_addr(board_access_t *access) {
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->llio.private = board;
board->open = &eth_board_open;
board->close = &eth_board_close;

View file

@ -158,7 +158,7 @@ int main(int argc, char *argv[]) {
board->open(board); // open board for communication
board->print_info(board); // print what card it is
hm2_read_idrom(&(board->llio)); // read hostmot2 idrom
hm2_read_idrom(&(board->llio.hm2)); // read hostmot2 idrom
ret = sserial_init(&ssmod, board, 0, 1, SSLBP_REMOTE_7I77_ANALOG);
out.analog0 = 1 * 0xFFF / 10;

View file

@ -156,7 +156,7 @@ int main(int argc, char *argv[]) {
board->open(board); // open board for communication
board->print_info(board); // print what card it is
hm2_read_idrom(&(board->llio)); // read hostmot2 idrom
hm2_read_idrom(&(board->llio.hm2)); // read hostmot2 idrom
ret = encoder_init(&enc, board, instance, delay); // init encoder 'instance' module on 'board'
if (ret < 0) {

View file

@ -20,29 +20,29 @@
#include <string.h>
#include "hostmot2.h"
void hm2_read_idrom(llio_t *llio) {
void hm2_read_idrom(hostmot2_t *hm2) {
u32 idrom_addr, cookie;
int i;
llio->read(llio, HM2_COOKIE_REG, &(cookie), sizeof(u32));
hm2->llio->read(hm2->llio, HM2_COOKIE_REG, &(cookie), sizeof(u32));
if (cookie != HM2_COOKIE) {
printf("ERROR: no HOSTMOT2 firmware found. %X\n", cookie);
return;
}
// check if it was already readed
if (strncmp(llio->hm2.config_name, "HOSTMOT2", 8) == 0)
if (strncmp(hm2->config_name, "HOSTMOT2", 8) == 0)
return;
llio->read(llio, HM2_CONFIG_NAME, &(llio->hm2.config_name), HM2_CONFIG_NAME_LEN);
llio->read(llio, HM2_IDROM_ADDR, &(idrom_addr), sizeof(u32));
llio->read(llio, idrom_addr, &(llio->hm2.idrom), sizeof(llio->hm2.idrom));
hm2->llio->read(hm2->llio, HM2_CONFIG_NAME, &(hm2->config_name), HM2_CONFIG_NAME_LEN);
hm2->llio->read(hm2->llio, HM2_IDROM_ADDR, &(idrom_addr), sizeof(u32));
hm2->llio->read(hm2->llio, idrom_addr, &(hm2->idrom), sizeof(hm2->idrom));
for (i = 0; i < HM2_MAX_MODULES; i++) {
llio->read(llio, idrom_addr + llio->hm2.idrom.offset_to_modules + i*sizeof(hm2_module_desc_t),
&(llio->hm2.modules[i]), sizeof(hm2_module_desc_t));
hm2->llio->read(hm2->llio, idrom_addr + hm2->idrom.offset_to_modules + i*sizeof(hm2_module_desc_t),
&(hm2->modules[i]), sizeof(hm2_module_desc_t));
}
for (i = 0; i < HM2_MAX_PINS; i++) {
llio->read(llio, idrom_addr + llio->hm2.idrom.offset_to_pins + i*sizeof(hm2_pin_desc_t),
&(llio->hm2.pins[i]), sizeof(hm2_module_desc_t));
hm2->llio->read(hm2->llio, idrom_addr + hm2->idrom.offset_to_pins + i*sizeof(hm2_pin_desc_t),
&(hm2->pins[i]), sizeof(hm2_module_desc_t));
}
}
@ -263,15 +263,15 @@ hm2_module_desc_t *hm2_find_module(hostmot2_t *hm2, u8 gtag) {
return NULL;
}
void hm2_set_pin_source(llio_t *llio, int pin_number, u8 source) {
void hm2_set_pin_source(hostmot2_t *hm2, int pin_number, u8 source) {
u32 data;
if ((pin_number < 0) || (pin_number >= (llio->hm2.idrom.io_ports*llio->hm2.idrom.io_width))) {
if ((pin_number < 0) || (pin_number >= (hm2->idrom.io_ports*hm2->idrom.io_width))) {
printf("hm2_set_pin_source(): invalid pin number %d\n", pin_number);
return;
}
llio->read(llio, HM2_MODULE_GPIO_ALT_SOURCE + (pin_number / 24)*4, &data, sizeof(data));
hm2->llio->read(hm2->llio, HM2_MODULE_GPIO_ALT_SOURCE + (pin_number / 24)*4, &data, sizeof(data));
if (source == HM2_PIN_SOURCE_IS_PRIMARY) {
data &= ~(1 << (pin_number % 24));
} else if (source == HM2_PIN_SOURCE_IS_SECONDARY) {
@ -280,18 +280,18 @@ void hm2_set_pin_source(llio_t *llio, int pin_number, u8 source) {
printf("hm2_set_pin_source(): invalid pin source 0x%02X\n", source);
return;
}
llio->write(llio, HM2_MODULE_GPIO_ALT_SOURCE + (pin_number / 24)*4, &data, sizeof(data));
hm2->llio->write(hm2->llio, HM2_MODULE_GPIO_ALT_SOURCE + (pin_number / 24)*4, &data, sizeof(data));
}
void hm2_set_pin_direction(llio_t *llio, int pin_number, u8 direction) {
void hm2_set_pin_direction(hostmot2_t *hm2, int pin_number, u8 direction) {
u32 data;
if ((pin_number < 0) || (pin_number >= (llio->hm2.idrom.io_ports*llio->hm2.idrom.io_width))) {
if ((pin_number < 0) || (pin_number >= (hm2->idrom.io_ports*hm2->idrom.io_width))) {
printf("hm2_set_pin_direction(): invalid pin number %d\n", pin_number);
return;
}
llio->read(llio, HM2_MODULE_GPIO_DDR + (pin_number / 24)*4, &data, sizeof(data));
hm2->llio->read(hm2->llio, HM2_MODULE_GPIO_DDR + (pin_number / 24)*4, &data, sizeof(data));
if (direction == HM2_PIN_DIR_IS_INPUT) {
data &= ~(1 << (pin_number % 24));
} else if (direction == HM2_PIN_DIR_IS_OUTPUT) {
@ -300,7 +300,7 @@ void hm2_set_pin_direction(llio_t *llio, int pin_number, u8 direction) {
printf("hm2_set_pin_direction(): invalid pin direction 0x%02X\n", direction);
return;
}
llio->write(llio, HM2_MODULE_GPIO_DDR + (pin_number / 24)*4, &data, sizeof(data));
hm2->llio->write(hm2->llio, HM2_MODULE_GPIO_DDR + (pin_number / 24)*4, &data, sizeof(data));
}
void hm2_print_idrom(hostmot2_t *hm2) {

View file

@ -42,7 +42,7 @@ typedef struct {
typedef struct llio_struct llio_t;
typedef struct {
llio_t *board;
llio_t *llio;
char config_name[8];
hm2_idrom_desc_t idrom;
hm2_module_desc_t modules[HM2_MAX_MODULES];
@ -63,7 +63,7 @@ struct llio_struct {
int num_leds;
const char *fpga_part_number;
char board_name[16];
void *private;
void *board;
hostmot2_t hm2;
sserial_interface_t ss_interface[HM2_SSERIAL_MAX_INTEFACES];
sserial_device_t ss_device[HM2_SSERIAL_MAX_CHANNELS];
@ -81,7 +81,7 @@ typedef struct {
} mod_name_t;
int hm2_check_cookie(llio_t *llio);
void hm2_read_idrom(llio_t *llio);
void hm2_read_idrom(hostmot2_t *hm2);
hm2_module_desc_t *hm2_find_module(hostmot2_t *hm2, u8 gtag);
void hm2_print_idrom(hostmot2_t *hm2);
void hm2_print_modules(hostmot2_t *hm2);

View file

@ -80,7 +80,7 @@ int lbp16_board_reset(llio_t *self) {
}
int lbp16_board_reload(llio_t *self, int fallback_flag) {
board_t *board = self->private;
board_t *board = self->board;
int send;
u32 boot_addr;
u16 fw_ver;

View file

@ -434,7 +434,7 @@ static u16 plx9056_read_eeprom_word(board_t *board, u16 reg) {
}
static int plx9030_program_fpga(llio_t *self, char *bitfile_name) {
board_t *board = self->private;
board_t *board = self->board;
int bindex, bytesread;
u32 status, control;
char part_name[32];
@ -513,7 +513,7 @@ fail:
}
static int plx9030_reset(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
u32 status;
u32 control;
@ -565,7 +565,7 @@ static int plx9030_reset(llio_t *self) {
}
static void plx9030_fixup_LASxBRD_READY(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
int offsets[] = {PLX9030_LAS0BRD_OFFSET, PLX9030_LAS1BRD_OFFSET, PLX9030_LAS2BRD_OFFSET, PLX9030_LAS3BRD_OFFSET};
int i;
@ -583,7 +583,7 @@ static void plx9030_fixup_LASxBRD_READY(llio_t *self) {
}
static int plx905x_program_fpga(llio_t *self, char *bitfile_name) {
board_t *board = self->private;
board_t *board = self->board;
int bindex, bytesread, i;
u32 status;
char part_name[32];
@ -643,7 +643,7 @@ static int plx905x_program_fpga(llio_t *self, char *bitfile_name) {
}
static int plx905x_reset(llio_t *self) {
board_t *board = self->private;
board_t *board = self->board;
int i;
u32 status, control;
@ -678,7 +678,7 @@ static int plx905x_reset(llio_t *self) {
}
static int pci_board_reload(llio_t *self, int fallback_flag) {
board_t *board = self->private;
board_t *board = self->board;
int i;
u32 boot_addr, bar0_reg, cookie;
u16 cmd_reg;
@ -755,7 +755,7 @@ static void pci_fix_bar_lengths(struct pci_dev *dev) {
}
int pci_read(llio_t *self, u32 addr, void *buffer, int size) {
board_t *board = self->private;
board_t *board = self->board;
memcpy(buffer, (board->base + addr), size);
// printf("READ %X, (%X + %X), %d\n", buffer, board->base, addr, size);
@ -763,7 +763,7 @@ int pci_read(llio_t *self, u32 addr, void *buffer, int size) {
}
int pci_write(llio_t *self, u32 addr, void *buffer, int size) {
board_t *board = self->private;
board_t *board = self->board;
memcpy((board->base + addr), buffer, size);
return 0;
@ -851,6 +851,7 @@ void pci_boards_scan(board_access_t *access) {
if (access->recover == 1) {
for (dev = pacc->devices; dev != NULL; dev = dev->next) {
board = &boards[boards_count];
board_init_struct(board);
if ((dev->vendor_id == VENDORID_XIO2001) && (dev->device_id == DEVICEID_XIO2001)) {
board->type = BOARD_PCI;
strncpy(board->llio.board_name, "6I25 (RECOVER)", 14);
@ -862,7 +863,6 @@ void pci_boards_scan(board_access_t *access) {
board->llio.num_leds = 2;
board->llio.write_flash = &local_write_flash;
board->llio.verify_flash = &local_verify_flash;
board->llio.private = board;
board->open = &pci_board_open;
board->close = &pci_board_close;
@ -882,6 +882,7 @@ void pci_boards_scan(board_access_t *access) {
for (dev = pacc->devices; dev != NULL; dev = dev->next) {
board = &boards[boards_count];
board_init_struct(board);
if (dev->vendor_id == VENDORID_MESAPCI) {
if (dev->device_id == DEVICEID_MESA4I74) {
@ -898,7 +899,6 @@ void pci_boards_scan(board_access_t *access) {
board->llio.write = &pci_write;
board->llio.write_flash = &local_write_flash;
board->llio.verify_flash = &local_verify_flash;
board->llio.private = board;
board->open = &pci_board_open;
board->close = &pci_board_close;
@ -927,7 +927,6 @@ void pci_boards_scan(board_access_t *access) {
board->llio.write_flash = &local_write_flash;
board->llio.verify_flash = &local_verify_flash;
board->llio.reload = &pci_board_reload;
board->llio.private = board;
board->open = &pci_board_open;
board->close = &pci_board_close;
@ -955,7 +954,6 @@ void pci_boards_scan(board_access_t *access) {
board->llio.write_flash = &local_write_flash;
board->llio.verify_flash = &local_verify_flash;
board->llio.reload = &pci_board_reload;
board->llio.private = board;
board->open = &pci_board_open;
board->close = &pci_board_close;
@ -984,7 +982,6 @@ void pci_boards_scan(board_access_t *access) {
board->llio.write_flash = &local_write_flash;
board->llio.verify_flash = &local_verify_flash;
board->llio.reload = &pci_board_reload;
board->llio.private = board;
board->open = &pci_board_open;
board->close = &pci_board_close;
@ -1012,7 +1009,6 @@ void pci_boards_scan(board_access_t *access) {
board->llio.write_flash = &local_write_flash;
board->llio.verify_flash = &local_verify_flash;
board->llio.reload = &pci_board_reload;
board->llio.private = board;
board->open = &pci_board_open;
board->close = &pci_board_close;
@ -1044,7 +1040,6 @@ void pci_boards_scan(board_access_t *access) {
board->llio.write = &pci_write;
board->llio.program_fpga = &plx9030_program_fpga;
board->llio.reset = &plx9030_reset;
board->llio.private = board;
board->open = &pci_board_open;
board->close = &pci_board_close;
@ -1075,7 +1070,6 @@ void pci_boards_scan(board_access_t *access) {
board->llio.write = &pci_write;
board->llio.program_fpga = &plx9030_program_fpga;
board->llio.reset = &plx9030_reset;
board->llio.private = board;
board->open = &pci_board_open;
board->close = &pci_board_close;
@ -1109,7 +1103,6 @@ void pci_boards_scan(board_access_t *access) {
board->llio.write = &pci_write;
board->llio.program_fpga = &plx905x_program_fpga;
board->llio.reset = &plx905x_reset;
board->llio.private = board;
board->open = &pci_board_open;
board->close = &pci_board_close;
@ -1137,7 +1130,6 @@ void pci_boards_scan(board_access_t *access) {
board->llio.write = &pci_write;
board->llio.program_fpga = &plx905x_program_fpga;
board->llio.reset = &plx905x_reset;
board->llio.private = board;
board->open = &pci_board_open;
board->close = &pci_board_close;
@ -1171,7 +1163,6 @@ void pci_boards_scan(board_access_t *access) {
board->llio.write = &pci_write;
board->llio.program_fpga = &plx905x_program_fpga;
board->llio.reset = &plx905x_reset;
board->llio.private = board;
board->open = &pci_board_open;
board->close = &pci_board_close;
@ -1200,7 +1191,6 @@ void pci_boards_scan(board_access_t *access) {
board->llio.write = &pci_write;
board->llio.program_fpga = &plx905x_program_fpga;
board->llio.reset = &plx905x_reset;
board->llio.private = board;
board->open = &pci_board_open;
board->close = &pci_board_close;
@ -1233,7 +1223,6 @@ void pci_boards_scan(board_access_t *access) {
board->llio.write = &pci_write;
board->llio.program_fpga = &plx905x_program_fpga;
board->llio.reset = &plx905x_reset;
board->llio.private = board;
board->open = &pci_board_open;
board->close = &pci_board_close;
@ -1276,7 +1265,6 @@ void pci_boards_scan(board_access_t *access) {
board->llio.reset = &plx905x_reset;
board->llio.write_flash = &local_write_flash;
board->llio.verify_flash = &local_verify_flash;
board->llio.private = board;
board->open = &pci_board_open;
board->close = &pci_board_close;
@ -1296,7 +1284,6 @@ void pci_boards_scan(board_access_t *access) {
} else if (dev->device_id == DEVICEID_PLX8112) {
board->type = BOARD_PCI;
strncpy(board->llio.board_name, "5I71", 4);
board->llio.private = board;
board->open = &pci_board_open;
board->close = &pci_board_close;
board->print_info = &pci_print_info;

View file

@ -172,6 +172,8 @@ void serial_boards_scan(board_access_t *access) {
if (strncmp(buff, "7I90HD", 6) == 0) {
board_t *board = &boards[boards_count];
board_init_struct(board);
board->type = BOARD_SER;
strncpy(board->dev_addr, access->dev_addr, 16);
strncpy(board->llio.board_name, buff, 16);
@ -188,7 +190,6 @@ void serial_boards_scan(board_access_t *access) {
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->llio.private = board;
board->open = &serial_board_open;
board->close = &serial_board_close;

View file

@ -139,6 +139,8 @@ void spi_boards_scan(board_access_t *access) {
u32 cookie[] = {0x55aacafe, 0x54534f48, 0x32544f4d};
board_t *board = &boards[boards_count];
board_init_struct(board);
if (spi_read(&(board->llio), HM2_COOKIE_REG, &buf, sizeof(buf)) < 0) {
return;
}
@ -162,7 +164,6 @@ void spi_boards_scan(board_access_t *access) {
board->llio.ioport_connector_name[1] = "P2";
board->llio.ioport_connector_name[2] = "P3";
board->llio.num_leds = 2;
board->llio.private = board;
board->llio.verbose = access->verbose;
board->llio.write = spi_write;
board->llio.read = spi_read;
@ -186,4 +187,3 @@ void spi_boards_scan(board_access_t *access) {
void spi_print_info(board_t *board) {
}

View file

@ -54,7 +54,7 @@ int usb_write(llio_t *self, u32 addr, void *buffer, int size) {
}
static int usb_program_fpga(llio_t *self, char *bitfile_name) {
board_t *board = self->private;
board_t *board = self->board;
int bindex, bytesread;
u32 status, control;
char part_name[32];
@ -126,6 +126,8 @@ void usb_boards_scan(board_access_t *access) {
char dev_name[4];
u32 cookie;
board_init_struct(board);
data = lbp_read_ctrl(LBP_CMD_READ_COOKIE);
if (data == LBP_COOKIE) {
dev_name[0] = lbp_read_ctrl(LBP_CMD_READ_DEV_NAME0);
@ -137,7 +139,6 @@ void usb_boards_scan(board_access_t *access) {
board->type = BOARD_USB;
strcpy(board->dev_addr, access->dev_addr);
strncpy(board->llio.board_name, dev_name, 4);
board->llio.private = board;
board->llio.verbose = access->verbose;
boards_count++;
@ -153,7 +154,6 @@ void usb_boards_scan(board_access_t *access) {
board->llio.num_leds = 8;
board->llio.read = &usb_read;
board->llio.write = &usb_write;
board->llio.private = board;
board->open = &usb_board_open;
board->close = &usb_board_close;
@ -201,7 +201,6 @@ void usb_boards_scan(board_access_t *access) {
board->llio.fpga_part_number = "3s200tq144";
board->llio.num_leds = 8;
board->llio.program_fpga = &usb_program_fpga;
board->llio.private = board;
board->llio.verbose = access->verbose;
board->open = &usb_board_open;
board->close = &usb_board_close;