Commit f4cc44a0 authored by Federico Vaga's avatar Federico Vaga

TEMP wrnc hack - wait for SDB bus for a real solution

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 36f70fe4
......@@ -22,6 +22,8 @@ module_param_named(test_irq, spec_test_irq, int, 0444);
static int spec_show_sdb;
module_param_named(show_sdb, spec_show_sdb, int, 0444);
static int spec_create_wrnc(struct spec_dev *spec);
/* The main role of this file is offering the fmc_operations for the spec */
static int spec_validate(struct fmc_device *fmc, struct fmc_driver *drv)
......@@ -581,6 +583,8 @@ int spec_fmc_create(struct spec_dev *spec, struct fmc_gateware *gw)
spec_gpio_init(fmc); /* May fail, we don't care */
spec->flags |= SPEC_FLAG_FMC_REGISTERED;
spec_create_wrnc(spec);
return ret;
out_irq:
......@@ -593,6 +597,10 @@ out_free:
void spec_fmc_destroy(struct spec_dev *spec)
{
if (spec->fmc_wrnc) {
fmc_device_unregister(spec->fmc_wrnc);
spec->fmc_wrnc = NULL;
}
if (!(spec->flags & SPEC_FLAG_FMC_REGISTERED))
return;
/* undo the things in the reverse order, but pin the device first */
......@@ -609,3 +617,91 @@ void spec_fmc_destroy(struct spec_dev *spec)
spec->fmc = NULL;
spec->flags &= ~SPEC_FLAG_FMC_REGISTERED;
}
#define WRNC_EEPROM_SIZE 8192 /* The standard eeprom size */
static const char wrnc_eeimg[WRNC_EEPROM_SIZE] = {
0x01, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x00, 0xf4, 0x01, 0x09, 0x00, 0xd9,
0x99, 0x97, 0xc4, 0x63, 0x65, 0x72, 0x6e, 0xcc, 0x77, 0x72, 0x2d, 0x6e,
0x6f, 0x64, 0x65, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0xc4, 0x30, 0x30, 0x30,
0x31, 0xcb, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2d, 0x70, 0x61, 0x72,
0x74, 0xda, 0x32, 0x30, 0x31, 0x34, 0x2d, 0x31, 0x31, 0x2d, 0x32, 0x31,
0x20, 0x31, 0x32, 0x3a, 0x34, 0x31, 0x3a, 0x33, 0x37, 0x2e, 0x37, 0x31,
0x31, 0x39, 0x31, 0x31, 0xc1, 0x00, 0x00, 0xc4, 0x02, 0x02, 0x0d, 0xf7,
0xf8, 0x02, 0xb0, 0x04, 0x74, 0x04, 0xec, 0x04, 0x00, 0x00, 0x00, 0x00,
0xe8, 0x03, 0x02, 0x02, 0x0d, 0x5c, 0x93, 0x01, 0x4a, 0x01, 0x39, 0x01,
0x5a, 0x01, 0x00, 0x00, 0x00, 0x00, 0xb8, 0x0b, 0x02, 0x02, 0x0d, 0x63,
0x8c, 0x00, 0xfa, 0x00, 0xed, 0x00, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00,
0xa0, 0x0f, 0x01, 0x02, 0x0d, 0xfb, 0xf5, 0x05, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x0d, 0xfc,
0xf4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x02, 0x0d, 0xfd, 0xf3, 0x03, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x82, 0x0b, 0xea,
0x8f, 0xa2, 0x12, 0x00, 0x00, 0x1e, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
static int spec_create_wrnc(struct spec_dev *spec)
{
struct fmc_device *fmc;
int ret, err;
if (spec->fmc_wrnc) {
dev_err(&spec->pdev->dev, "WhiteRebbit NodeCore aldready exists\n");
return -EBUSY;
}
ret = fmc_scan_sdb_tree(spec->fmc, 0x0);
if (ret < 0 && ret != -EBUSY)
return ret; /* wrnc is not there */
/* Look for the WhiteRabbit NodeCore component and create a device
based of FMC device on virtual slot 1 */
ret = fmc_find_sdb_device(spec->fmc->sdb, 0xCE42, 0x90DE, NULL);
if (ret < 0)
return ret;
fmc = kzalloc(sizeof(*fmc), GFP_KERNEL);
if (!fmc) {
dev_err(&spec->pdev->dev,
"cannot allocate fmc slot for White-Rabbit Node-Core\n");
return -ENOMEM;
}
fmc->version = FMC_VERSION;
fmc->carrier_name = "SPEC";
fmc->carrier_data = spec;
fmc->owner = THIS_MODULE;
fmc->fpga_base = spec->remap[0];
fmc->irq = 0; /*TO-DO */
fmc->op = &spec_fmc_operations;
fmc->hwdev = &spec->pdev->dev; /* for messages */
fmc->slot_id = 1; /* Yes, is a virtual FMC slot, so
outside SPEC slot enumeration */
fmc->device_id = ((spec->pdev->bus->number << 8) | spec->pdev->devfn) + 1;
/* Overwrite with the white rabbit fake eeprom */
fmc->eeprom_len = WRNC_EEPROM_SIZE;
fmc->eeprom = wrnc_eeimg;
fmc->eeprom_addr = SPEC_I2C_EEPROM_ADDR;
fmc->memlen = 1 << 20;
fmc->flags &= ~FMC_DEVICE_HAS_GOLDEN;
fmc->flags |= FMC_DEVICE_HAS_CUSTOM;
err = fmc_device_register(fmc);
if (err){
dev_err(&spec->pdev->dev,
"Cannot register White-Rabbit Node-Core\n");
return err;
}
spec->fmc_wrnc = fmc;
return 0;
}
......@@ -35,6 +35,7 @@ struct spec_dev {
unsigned long flags; /* see below */
struct list_head list;
struct fmc_device *fmc;
struct fmc_device *fmc_wrnc; /* HACK: REMOVE ME when we move to SDB-bus */
int irq_count; /* for mezzanine use too */
struct completion compl;
struct gpio_chip *gpio;
......
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