Commit ea0634d1 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana Committed by Alessandro Rubini

loader-ll now releases Gennum GPIO lines for BOOTSEL

This is needed so the gennum core (as opposed to the gennum chip)
can access the SPI flash from the newly-programmed fpga image.
With this gpio setting, both the lm32 from inside the fpga
and the host computer can read and write the flash device.
Signed-off-by: Theodor-Adrian Stana's avatarTheodor Stana <t.stana@cern.ch>
Acked-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent a8d2f0ed
......@@ -146,3 +146,18 @@ int loader_low_level(int fd, void __iomem *bar4, const void *data, int size8)
/* Checking for the "interrupt" condition is left to the caller */
return wrote;
}
void waitdone_low_level(int fd, void __iomem *bar4)
{
while ( (lll_read(fd, bar4, FCL_IRQ) & 0x8) == 0 )
;
}
/* After programming, we fix gpio lines so pci can access the flash */
void gpiofix_low_level(int fd, void __iomem *bar4)
{
gpio_out(fd, bar4, GNGPIO_OUTPUT_VALUE, GPIO_BOOTSEL0, 0);
gpio_out(fd, bar4, GNGPIO_OUTPUT_VALUE, GPIO_BOOTSEL1, 0);
gpio_out(fd, bar4, GNGPIO_OUTPUT_ENABLE, GPIO_BOOTSEL0, 0);
gpio_out(fd, bar4, GNGPIO_OUTPUT_ENABLE, GPIO_BOOTSEL1, 0);
}
......@@ -7,11 +7,10 @@
#define __iomem /* nothing, for user space */
#endif
extern int loader_low_level(
int fd, /* This is ignored in kernel space */
void __iomem *bar4, /* This is ignored in user space */
const void *data,
int size8);
/* "fd" was relevant in user space, but now it is ignored */
extern int loader_low_level(int fd, void __iomem *bar4, const void *, int);
extern void waitdone_low_level(int fd, void __iomem *bar4);
extern void gpiofix_low_level(int fd, void __iomem *bar4);
/* The following part implements a different access rule for user and kernel */
......
......@@ -47,7 +47,7 @@ int spec_load_fpga(struct spec_dev *spec, const void *data, int size)
i = readl(spec->remap[2] + FCL_IRQ);
if (i & 0x8) {
dev_info(dev, "FPGA programming successful\n");
return 0;
break;
}
if(i & 0x4) {
......@@ -61,6 +61,8 @@ int spec_load_fpga(struct spec_dev *spec, const void *data, int size)
return -ETIMEDOUT;
}
}
gpiofix_low_level(0 /* unused fd */, spec->remap[2]);
return 0;
}
int spec_load_fpga_file(struct spec_dev *spec, char *name)
......
......@@ -218,12 +218,15 @@ int spec_load_bitstream(void *card, const char *filename)
struct spec_private *p = (struct spec_private *) card;
char *buf;
size_t size;
int rv;
buf = load_binary_file(filename, &size);
if(!buf)
return -1;
int rv = loader_low_level(0, p->bar4, buf, size);
rv = loader_low_level(0, p->bar4, buf, size);
waitdone_low_level(0, p->bar4);
gpiofix_low_level(0, p->bar4);
free(buf);
return rv;
......
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