Commit 182e30e7 authored by Federico Vaga's avatar Federico Vaga

Add support for SPEC 100T version

parents 0598de40 83d3fa57
...@@ -27,12 +27,30 @@ ...@@ -27,12 +27,30 @@
#include "spec.h" #include "spec.h"
#include "loader-ll.h" #include "loader-ll.h"
char *spec_fw_name = "fmc/spec-init.bin"; static char *spec_fw_name_45t = "fmc/spec-init.bin";
static char *spec_fw_name_100t = "fmc/spec-init-100T.bin";
char *spec_fw_name = "";
module_param_named(fw_name, spec_fw_name, charp, 0444); module_param_named(fw_name, spec_fw_name, charp, 0444);
int spec_use_msi = 0; int spec_use_msi = 0;
module_param_named(use_msi, spec_use_msi, int, 0444); module_param_named(use_msi, spec_use_msi, int, 0444);
/**
* According to the PCI device ID, load different golden
*/
static char *spec_golden_name_get(unsigned int device_id)
{
if (strlen(spec_fw_name) > 0)
return spec_fw_name;
switch (device_id) {
case PCI_DEVICE_ID_SPEC_45T:
return spec_fw_name_45t;
case PCI_DEVICE_ID_SPEC_100T:
return spec_fw_name_100t;
}
return NULL;
}
/* Load the FPGA. This bases on loader-ll.c, a kernel/user space thing */ /* Load the FPGA. This bases on loader-ll.c, a kernel/user space thing */
int spec_load_fpga(struct spec_dev *spec, const void *data, int size) int spec_load_fpga(struct spec_dev *spec, const void *data, int size)
{ {
...@@ -76,6 +94,11 @@ int spec_load_fpga_file(struct spec_dev *spec, char *name) ...@@ -76,6 +94,11 @@ int spec_load_fpga_file(struct spec_dev *spec, char *name)
const struct firmware *fw; const struct firmware *fw;
int err = 0; int err = 0;
if (!name) {
dev_err(dev, "You must provide a golden binary\n");
return -EINVAL;
}
err = request_firmware(&fw, name, dev); err = request_firmware(&fw, name, dev);
if (err < 0) { if (err < 0) {
dev_err(dev, "request firmware \"%s\": error %i\n", name, err); dev_err(dev, "request firmware \"%s\": error %i\n", name, err);
...@@ -97,7 +120,8 @@ static int spec_reconfigure(struct spec_dev *spec, struct fmc_gateware *gw) ...@@ -97,7 +120,8 @@ static int spec_reconfigure(struct spec_dev *spec, struct fmc_gateware *gw)
spec_fmc_destroy(spec); spec_fmc_destroy(spec);
/* Load the golden FPGA binary to read the eeprom */ /* Load the golden FPGA binary to read the eeprom */
ret = spec_load_fpga_file(spec, spec_fw_name); ret = spec_load_fpga_file(spec,
spec_golden_name_get(spec->pdev->device));
if (ret) if (ret)
return ret; return ret;
...@@ -171,7 +195,7 @@ static void spec_destroy_misc_device(struct spec_dev *spec) ...@@ -171,7 +195,7 @@ static void spec_destroy_misc_device(struct spec_dev *spec)
/* * * * * * END MISC DEVICE * * * * */ /* * * * * * END MISC DEVICE * * * * */
static int spec_probe(struct pci_dev *pdev, static int spec_probe(struct pci_dev *pdev,
const struct pci_device_id *id) const struct pci_device_id *id)
{ {
struct spec_dev *spec; struct spec_dev *spec;
int i, ret; int i, ret;
...@@ -284,7 +308,8 @@ static void spec_remove(struct pci_dev *pdev) ...@@ -284,7 +308,8 @@ static void spec_remove(struct pci_dev *pdev)
DEFINE_PCI_DEVICE_TABLE(spec_idtable) = { DEFINE_PCI_DEVICE_TABLE(spec_idtable) = {
{ PCI_DEVICE(PCI_VENDOR_ID_CERN, PCI_DEVICE_ID_SPEC) }, { PCI_DEVICE(PCI_VENDOR_ID_CERN, PCI_DEVICE_ID_SPEC_45T) },
{ PCI_DEVICE(PCI_VENDOR_ID_CERN, PCI_DEVICE_ID_SPEC_100T) },
{ PCI_DEVICE(PCI_VENDOR_ID_GENNUM, PCI_DEVICE_ID_GN4124) }, { PCI_DEVICE(PCI_VENDOR_ID_GENNUM, PCI_DEVICE_ID_GN4124) },
{ 0,}, { 0,},
}; };
......
...@@ -17,9 +17,10 @@ ...@@ -17,9 +17,10 @@
#include <linux/gpio.h> #include <linux/gpio.h>
#define PCI_VENDOR_ID_CERN 0x10dc #define PCI_VENDOR_ID_CERN 0x10dc
#define PCI_DEVICE_ID_SPEC 0x018d #define PCI_DEVICE_ID_SPEC_45T 0x018d
#define PCI_DEVICE_ID_SPEC_100T 0x01a2
#define PCI_VENDOR_ID_GENNUM 0x1a39 #define PCI_VENDOR_ID_GENNUM 0x1a39
#define PCI_DEVICE_ID_GN4124 0x0004 #define PCI_DEVICE_ID_GN4124 0x0004
#define SPEC_DEFAULT_LM32_ADDR 0x80000 /* used if "1" is passed */ #define SPEC_DEFAULT_LM32_ADDR 0x80000 /* used if "1" is passed */
......
...@@ -67,9 +67,10 @@ static int spec_check_id(int bus, int dev) ...@@ -67,9 +67,10 @@ static int spec_check_id(int bus, int dev)
fscanf(f, "%x", &vendor); fscanf(f, "%x", &vendor);
fclose(f); fclose(f);
if (device== PCI_DEVICE_ID_SPEC && vendor== PCI_VENDOR_ID_CERN) if (vendor== PCI_VENDOR_ID_CERN && device== PCI_DEVICE_ID_SPEC_45T)
return 1;
if (vendor== PCI_VENDOR_ID_CERN && device== PCI_DEVICE_ID_SPEC_100T)
return 1; return 1;
if (device== PCI_DEVICE_ID_GN4124 && vendor== PCI_VENDOR_ID_GENNUM) if (device== PCI_DEVICE_ID_GN4124 && vendor== PCI_VENDOR_ID_GENNUM)
return 1; return 1;
......
...@@ -5,10 +5,14 @@ ...@@ -5,10 +5,14 @@
/* Vendor/Device ID to identify the SPEC */ /* Vendor/Device ID to identify the SPEC */
#define PCI_VENDOR_ID_CERN 0x10dc #define PCI_VENDOR_ID_CERN 0x10dc
#define PCI_DEVICE_ID_SPEC 0x018d #define PCI_DEVICE_ID_SPEC_45T 0x018d
#define PCI_DEVICE_ID_SPEC_100T 0x01a2
#define PCI_VENDOR_ID_GENNUM 0x1a39 #define PCI_VENDOR_ID_GENNUM 0x1a39
#define PCI_DEVICE_ID_GN4124 0x0004 #define PCI_DEVICE_ID_GN4124 0x0004
/* For compatibility */
#define PCI_DEVICE_ID_SPEC PCI_DEVICE_ID_SPEC_45T
/* 'Opens' the SPEC card at PCI bus [bus], device/function [dev]. /* 'Opens' the SPEC card at PCI bus [bus], device/function [dev].
Returns a handle to the card or NULL in case of failure. */ Returns a handle to the card or NULL in case of failure. */
void *spec_open(int bus, int dev); void *spec_open(int bus, int dev);
......
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