Commit a98296a1 authored by Federico Vaga's avatar Federico Vaga

sw:drv: re-write get/set for bootselect

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 71d631a7
......@@ -127,7 +127,7 @@ int spec_fw_load(struct spec_dev *spec, const char *name)
}
spec_gpio_fpga_select(spec, SPEC_FPGA_SELECT_GN4124);
spec_gpio_fpga_select_set(spec, SPEC_FPGA_SELECT_GN4124_FPGA);
err = compat_spec_fw_load(spec, name);
if (err)
......@@ -138,7 +138,7 @@ int spec_fw_load(struct spec_dev *spec, const char *name)
dev_warn(&spec->dev, "FPGA incorrectly programmed\n");
out:
spec_gpio_fpga_select(spec, SPEC_FPGA_SELECT_FLASH);
spec_gpio_fpga_select_set(spec, SPEC_FPGA_SELECT_FPGA_FLASH);
return err;
}
......
......@@ -8,26 +8,34 @@
#include "spec.h"
#include "spec-compat.h"
void spec_gpio_fpga_select(struct spec_dev *spec, enum spec_fpga_select sel)
void spec_gpio_fpga_select_set(struct spec_dev *spec,
enum spec_fpga_select sel)
{
switch (sel) {
case SPEC_FPGA_SELECT_FLASH:
gpiod_set_value(spec->gpiod[GN4124_GPIO_BOOTSEL0], 1);
gpiod_set_value(spec->gpiod[GN4124_GPIO_BOOTSEL1], 1);
break;
case SPEC_FPGA_SELECT_GN4124:
gpiod_set_value(spec->gpiod[GN4124_GPIO_BOOTSEL0], 1);
gpiod_set_value(spec->gpiod[GN4124_GPIO_BOOTSEL1], 0);
break;
case SPEC_FPGA_SELECT_SPI:
gpiod_set_value(spec->gpiod[GN4124_GPIO_BOOTSEL0], 0);
gpiod_set_value(spec->gpiod[GN4124_GPIO_BOOTSEL1], 0);
case SPEC_FPGA_SELECT_FPGA_FLASH:
case SPEC_FPGA_SELECT_GN4124_FPGA:
case SPEC_FPGA_SELECT_GN4124_FLASH:
gpiod_set_value(spec->gpiod[GN4124_GPIO_BOOTSEL0],
!!(sel & 0x1));
gpiod_set_value(spec->gpiod[GN4124_GPIO_BOOTSEL1],
!!(sel & 0x2));
break;
default:
break;
}
}
enum spec_fpga_select spec_gpio_fpga_select_get(struct spec_dev *spec)
{
enum spec_fpga_select sel = 0;
sel |= !!gpiod_get_value(spec->gpiod[GN4124_GPIO_BOOTSEL1]) << 1;
sel |= !!gpiod_get_value(spec->gpiod[GN4124_GPIO_BOOTSEL0]) << 0;
return sel;
}
static const struct gpiod_lookup_table spec_gpiod_table = {
.table = {
GPIO_LOOKUP_IDX("gn412x-gpio", GN4124_GPIO_BOOTSEL0,
......
......@@ -45,15 +45,17 @@
#define GN4124_GPIO_SDA 4
/**
* @SPEC_FPGA_SELECT_FLASH: (default) the FPGA takes its configuration from
* flash
* @SPEC_FPGA_SELECT_GN4124: the FPGA takes its configuration from GN4124
* @SPEC_FPGA_SELECT_SPI: the SPI flash is accessible from GN4124
* @SPEC_FPGA_SELECT_FPGA_FLASH: (default) the FPGA is an SPI master that can
* access the flash (at boot it takes its
* configuration from flash)
* @SPEC_FPGA_SELECT_GN4124_FPGA: the GN4124 can configure the FPGA
* @SPEC_FPGA_SELECT_GN4124_FLASH: the GN4124 is an SPI master that can access
* the flash
*/
enum spec_fpga_select {
SPEC_FPGA_SELECT_FLASH = 0,
SPEC_FPGA_SELECT_GN4124,
SPEC_FPGA_SELECT_SPI,
SPEC_FPGA_SELECT_FPGA_FLASH = 0x3,
SPEC_FPGA_SELECT_GN4124_FPGA = 0x1,
SPEC_FPGA_SELECT_GN4124_FLASH = 0x0,
};
......@@ -188,8 +190,10 @@ extern void spec_dbg_exit(struct spec_dev *spec);
extern int spec_fmc_init(struct spec_dev *spec);
extern int spec_fmc_exit(struct spec_dev *spec);
extern void spec_gpio_fpga_select(struct spec_dev *spec,
enum spec_fpga_select sel);
extern void spec_gpio_fpga_select_set(struct spec_dev *spec,
enum spec_fpga_select sel);
extern enum spec_fpga_select spec_gpio_fpga_select_get(struct spec_dev *spec);
extern int spec_gpio_init(struct spec_dev *spec);
extern void spec_gpio_exit(struct spec_dev *spec);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment