fdelay_bus.c 2.12 KB
Newer Older
1 2 3 4 5 6 7
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <getopt.h>

#include "fdelay_lib.h"

8 9 10
#include "sveclib/sveclib.h"
#include "speclib/speclib.h"

11 12 13 14
#include "fdelay_lib.h"

void printk() {};

15 16 17 18 19 20 21 22 23 24
static void fd_svec_writel(void *priv, uint32_t data, uint32_t addr)
{
	svec_writel(priv, data, addr);
}

static uint32_t fd_svec_readl(void *priv, uint32_t addr)
{
	return svec_readl(priv, addr);
}

25 26 27 28 29 30 31 32 33 34 35
static void fd_spec_writel(void *priv, uint32_t data, uint32_t addr)
{
	spec_writel(priv, data, addr);
}

static uint32_t fd_spec_readl(void *priv, uint32_t addr)
{
	return spec_readl(priv, addr);
}

#if 0
36
#endif
37 38


39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

#define VENDOR_CERN 0xce42
#define DEVICE_FD_CORE 0xf19ede1a
#define DEVICE_VUART 0xe2d13d04

static int probe_svec(fdelay_device_t *dev, const char *location)
{
	uint32_t map_base;
	int slot;
	void *card; 
	uint32_t core_base;

	if (!strncmp(location, "svec:"), 5) {
	    sscanf(location+5, "%d,%x,%x", &slot, &map_base, &core_base);
	} else 
	    return -1;

	card = svec_open(slot);
	svec_set_map_base(card, map_base);
    	if(!card)
59
	{
60 61
		fprintf(stderr,"SVEC probe failed.\n");
		return -1;
62 63
	}

64 65 66 67
	dev->priv_io = card;
	dev->writel = fd_svec_writel;
	dev->readl = fd_svec_readl;
	dev->base_addr = core_base;
68

69 70
	dbg("svec: using slot %d, A32/D32 base: 0x%x, core base 0x%x\n", slot, map_base, core_base);
	return 0;
71 72 73
}


74
void loader_low_level() {};
75

76
static int probe_spec(fdelay_device_t *dev, const char *location)
77
{
78 79
	uint32_t core_base;
	int slot;
80

81 82 83 84
	if (!strncmp(location, "spec:"), 5) {
	    sscanf(location+5, "%d,%x", &slot, &core_base);
	} else 
	    return -1;
85

86
	dev->priv_io = spec_open(slot, -1);
87

88 89 90 91 92 93 94 95 96 97 98
	if(!dev->priv_io)
	{
	 	fprintf(stderr,"Can't map the SPEC @ slot %d\n", slot);
	 	return -1;
	}

	dev->writel = fd_spec_writel;
	dev->readl = fd_spec_readl;
	dev->base_addr = core_base;

	dbg("spec: using slot %d, core base 0x%x\n", slot, core_base);
99

100 101
        return 0;
}
102 103 104

int fdelay_probe(fdelay_device_t *dev, const char *location)
{
105 106 107 108
    if(!probe_svec(dev, location))
    	return 0;
    if(!probe_spec(dev, location))
    	return 0;
109 110 111 112 113 114
}

fdelay_device_t *fdelay_create()
{
	return (fdelay_device_t *) malloc(sizeof(fdelay_device_t));
}