Skip to content
Snippets Groups Projects
Commit b1c0717c authored by Manohar Vanga's avatar Manohar Vanga
Browse files

Merge branch 'rubi-111106' of ohwr.org:hdl-core-lib/fpga-config-space

parents ec69965d c94ebcb4
Branches
Tags
No related merge requests found
*.aux
*.dvi
*.lof
*.log
*.lot
*.pdf
*.toc
......@@ -4,8 +4,7 @@
LINUX ?= $(HOME)/linux-for-wbonesim
# temporarily, use local <linux/wishbone.h>
export WISHBONE_DIR ?= $(shell /bin/pwd)
EXTRA_CFLAGS := -I$(WISHBONE_DIR)/include
EXTRA_CFLAGS := -I$(obj)/include
obj-m = wishbone.o fakedac.o fakeadc.o fake_wb_bus.o
......
......@@ -56,7 +56,7 @@ in the simulation/fw/ directory.
To generate a firmware file (the wishbone memory space):
$ ./wb_addrgen wbone.def firmware.bin
$ ./wb_addrgen wbone.list firmware.bin
The wbone.def file specifies the devices that should be attached
to the Wishbone bus. The format for specifying devices can be seen
......
......@@ -8,7 +8,7 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
......@@ -63,20 +63,20 @@ static int fake_wbbus_probe(struct device *dev)
*/
sprintf(fwname, "fakespec-%08x-%04x", spec_vendor, spec_device);
if (request_firmware(&wb_fw, fwname, dev)) {
printk(KERN_ERR KBUILD_MODNAME ": failed to load "
pr_err(KBUILD_MODNAME ": failed to load "
"firmware \"%s\"\n", fwname);
return -1;
}
header = (struct sdwb_head *)&wb_fw->data[header_addr];
if (header->magic != SDWB_HEAD_MAGIC) {
printk(KERN_ERR KBUILD_MODNAME ": invalid sdwb header at %p "
pr_err(KBUILD_MODNAME ": invalid sdwb header at %p "
"(magic %llx)\n", header, header->magic);
goto head_fail;
}
id = (struct sdwb_wbid *)&wb_fw->data[header->wbid_address];
printk(KERN_INFO KBUILD_MODNAME ": found sdwb bistream: 0x%llx\n",
pr_info(KBUILD_MODNAME ": found sdwb bistream: 0x%llx\n",
id->bstream_type);
wbd = (struct sdwb_wbd *)&wb_fw->data[header->wbd_address];
......@@ -93,7 +93,7 @@ static int fake_wbbus_probe(struct device *dev)
mutex_unlock(&list_lock);
wbd++;
}
printk(KERN_INFO KBUILD_MODNAME ": found %d wishbone devices\n", ndev);
pr_info(KBUILD_MODNAME ": found %d wishbone devices\n", ndev);
return 0;
register_fail:
......@@ -133,10 +133,13 @@ static struct device fake_wbbus_device = {
static int __init fake_wb_bus_init(void)
{
if (device_register(&fake_wbbus_device) < 0) {
printk(KERN_ERR KBUILD_MODNAME "failed to register fake"
int ret;
ret = device_register(&fake_wbbus_device);
if (ret) {
pr_err(KBUILD_MODNAME "failed to register fake"
"Wishbone bus\n");
return -1;
return ret;
}
fake_wbbus_probe(&fake_wbbus_device);
return 0;
......
......@@ -8,7 +8,7 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
......@@ -22,7 +22,7 @@
#include <linux/wishbone.h>
#define WB_ADC_VENDOR 0x0
#define WB_ADC_VENDOR 0x0
#define WB_ADC_DEVICE 0x1
static struct wb_device_id fakeadc_ids[] = {
......@@ -32,13 +32,13 @@ static struct wb_device_id fakeadc_ids[] = {
static int fakeadc_probe(struct wb_device *dev)
{
printk(KERN_INFO KBUILD_MODNAME ": %s\n", __func__);
pr_info(KBUILD_MODNAME ": %s\n", __func__);
return 0;
}
static int fakeadc_remove(struct wb_device *dev)
{
printk(KERN_INFO KBUILD_MODNAME ": %s\n", __func__);
pr_info(KBUILD_MODNAME ": %s\n", __func__);
return 0;
}
......
......@@ -22,7 +22,7 @@
#include <linux/wishbone.h>
#define WB_DAC_VENDOR 0x0
#define WB_DAC_VENDOR 0x0
#define WB_DAC_DEVICE 0x2
static struct wb_device_id fakedac_ids[] = {
......@@ -32,13 +32,13 @@ static struct wb_device_id fakedac_ids[] = {
static int fakedac_probe(struct wb_device *dev)
{
printk(KERN_INFO KBUILD_MODNAME ": %s\n", __func__);
pr_info(KBUILD_MODNAME ": %s\n", __func__);
return 0;
}
static int fakedac_remove(struct wb_device *dev)
{
printk(KERN_INFO KBUILD_MODNAME ": %s\n", __func__);
pr_info(KBUILD_MODNAME ": %s\n", __func__);
return 0;
}
......
......@@ -8,7 +8,7 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
......@@ -24,12 +24,13 @@
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <linux/sdwb.h>
#define PRIORITY(flag) ((flag >> 28) & 0xf)
#define PRIORITY(flag) ((flag >> 28) & 0xf)
#define CLASS(flag) ((flag >> 16) & 0xfff)
#define VERSION(flag) (flag & 0xffff)
#define VERSION(flag) (flag & 0xffff)
void print_wbd(uint8_t major, uint8_t minor,
uint64_t vendor, uint32_t device,
......@@ -54,7 +55,7 @@ struct sdwb_head *sdwb_create_header(uint64_t wbid_addr, uint64_t wbd_addr)
head = malloc(sizeof(struct sdwb_head));
if (!head)
return NULL;
head->magic = SDWB_HEAD_MAGIC;
head->wbid_address = wbid_addr;
head->wbd_address = wbd_addr;
......@@ -69,18 +70,18 @@ struct sdwb_wbid *sdwb_create_id()
id = malloc(sizeof(struct sdwb_wbid));
if (!id)
return NULL;
id->bstream_type = rand();
return id;
}
struct sdwb_wbd *sdwb_create_device(uint8_t major, uint8_t minor,
uint64_t vendor, uint32_t device,
uint64_t base, uint64_t size,
uint32_t flags, uint32_t class,
uint32_t version, uint32_t date,
char *vname, char *dname)
uint64_t vendor, uint32_t device,
uint64_t base, uint64_t size,
uint32_t flags, uint32_t class,
uint32_t version, uint32_t date,
char *vname, char *dname)
{
struct sdwb_wbd *dev;
......@@ -112,35 +113,39 @@ int main(int argc, char *argv[])
char c;
struct sdwb_head *header;
struct sdwb_wbid *id;
FILE *fin, *fout;
char buf[128];
int size = 0;
int num = 0;
if (argc != 3) {
printf("usage: %s <device-list-file> <fw-file>\n", argv[0]);
fprintf(stderr, "Usage: %s <device-list-file> <fw-file>\n",
argv[0]);
return 1;
}
FILE *fin, *fout;
char buf[128];
/* Header placed at address 0 and ID immediately after it. followed by devices */
header = sdwb_create_header(sizeof(struct sdwb_head), sizeof(struct sdwb_head) + sizeof(struct sdwb_wbid));
/* Header at address 0 and ID immediately after it. Then, devices */
header = sdwb_create_header(sizeof(struct sdwb_head),
sizeof(struct sdwb_head)
+ sizeof(struct sdwb_wbid));
id = sdwb_create_id();
fin = fopen(argv[1], "r");
if (!fin) {
printf("Unable to open wishbone device specification file: %s\n", argv[1]);
fprintf(stderr, "%s: %s: %s\n", argv[0], argv[1],
strerror(errno));
return 1;
}
fout = fopen(argv[2], "w");
if (!fout) {
printf("Unable to open output firmware file for writing: %s\b", argv[2]);
fclose(fin);
fprintf(stderr, "%s: %s: %s\n", argv[0], argv[2],
strerror(errno));
return 1;
}
int size = 0;
fwrite(header, sizeof(struct sdwb_head), 1, fout);
size += sizeof(struct sdwb_head);
fwrite(id, sizeof(struct sdwb_wbid), 1, fout);
size += sizeof(struct sdwb_wbid);
int num = 0;
while (fgets(buf, 128, fin) != NULL) {
if (strlen(buf) == 0)
continue;
......@@ -149,16 +154,20 @@ int main(int argc, char *argv[])
uint32_t major, minor, vendor, base, sz;
uint32_t device, flags, class, version, date;
char vname[16], dname[16];
sscanf(buf, "%d %d %x %d %x %x %x %x %d %x\n", &major, &minor, &vendor, &device,
&base, &sz, &flags, &class, &version, &date);
sscanf(buf, "%d %d %x %d %x %x %x %x %d %x\n",
&major, &minor, &vendor, &device,
&base, &sz, &flags, &class, &version, &date);
fgets(buf, 128, fin);
sscanf(buf, "%s\n", vname);
fgets(buf, 128, fin);
sscanf(buf, "%s\n", dname);
print_wbd(major, minor, vendor, device, base, sz, flags, class, version, date, vname, dname);
print_wbd(major, minor, vendor, device, base, sz,
flags, class, version, date, vname, dname);
struct sdwb_wbd *dev;
dev = sdwb_create_device(major, minor, vendor, device, base, sz, flags, class, version, date, vname, dname);
dev = sdwb_create_device(major, minor, vendor, device,
base, sz, flags, class, version,
date, vname, dname);
fwrite(dev, sizeof(struct sdwb_wbd), 1, fout);
size += sizeof(struct sdwb_wbd);
num++;
......
......@@ -8,7 +8,7 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
......
......@@ -8,7 +8,7 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
......
......@@ -8,7 +8,7 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
......@@ -25,11 +25,12 @@
#include <linux/init.h>
#include <linux/device.h>
#include <linux/list.h>
#include <linux/atomic.h>
#include <linux/slab.h>
#include <linux/wishbone.h>
#include <asm/atomic.h> /* before 2.6.37 no <linux/atomic.h> */
static struct device wb_dev;
static struct bus_type wb_bus_type;
......@@ -103,7 +104,7 @@ int memcpy_from_wb(struct wb_bus *bus, uint64_t addr, size_t len,
}
return -EIO;
}
int memcpy_to_wb(struct wb_bus *bus, uint64_t addr, size_t len,
const uint8_t *buf)
{
......@@ -125,7 +126,7 @@ static void wb_dev_release(struct device *dev)
wb_dev = to_wb_device(dev);
printk(KERN_DEBUG KBUILD_MODNAME ": release %016llx:%08lx\n",
pr_info(KBUILD_MODNAME ": release %016llx:%08lx\n",
wb_dev->wbd.vendor, (unsigned long)wb_dev->wbd.device);
}
......@@ -138,7 +139,7 @@ int wb_register_device(struct wb_device *wbdev)
int devno;
if (!wbdev || !wbdev->bus) {
printk(KERN_ERR KBUILD_MODNAME ": bus not set\n");
pr_err(KBUILD_MODNAME ": bus not set\n");
return -EFAULT;
}
......@@ -206,7 +207,7 @@ int wb_register_bus(struct wb_bus *bus)
return -ENODEV;
if (!bus->ops) {
printk(KERN_ERR KBUILD_MODNAME ": no wb_ops specified\n");
pr_err(KBUILD_MODNAME ": no wb_ops specified\n");
return -EFAULT;
}
......@@ -214,7 +215,7 @@ int wb_register_bus(struct wb_bus *bus)
!bus->ops->read64 || !bus->ops->write8 || !bus->ops->write16 ||
!bus->ops->write32 || !bus->ops->write64 ||
!bus->ops->memcpy_from_wb || !bus->ops->memcpy_to_wb) {
printk(KERN_ERR KBUILD_MODNAME ": all ops are required\n");
pr_err(KBUILD_MODNAME ": all ops are required\n");
return -EFAULT;
}
......@@ -228,13 +229,13 @@ int wb_register_bus(struct wb_bus *bus)
ret = memcpy_from_wb(bus, bus->sdwb_header_base,
sizeof(struct sdwb_head), (uint8_t *)&head);
if (ret < 0) {
printk(KERN_ERR KBUILD_MODNAME ": SDWB header read failed\n");
pr_err(KBUILD_MODNAME ": SDWB header read failed\n");
return ret;
}
/* verify our header using the magic field */
if (head.magic != SDWB_HEAD_MAGIC) {
printk(KERN_ERR KBUILD_MODNAME ": invalid sdwb header at %llx "
pr_err(KBUILD_MODNAME ": invalid sdwb header at %llx "
"(magic %llx)\n", bus->sdwb_header_base, head.magic);
return -EFAULT;
}
......@@ -242,22 +243,22 @@ int wb_register_bus(struct wb_bus *bus)
ret = memcpy_from_wb(bus, head.wbid_address, sizeof(struct sdwb_wbid),
(uint8_t *)&wbid);
if (ret < 0) {
printk(KERN_ERR KBUILD_MODNAME ": SDWB ID read failed\n");
pr_err(KBUILD_MODNAME ": SDWB ID read failed\n");
return ret;
}
printk(KERN_INFO KBUILD_MODNAME ": found sdwb bistream: 0x%llx\n",
pr_info(KBUILD_MODNAME ": found sdwb bistream: 0x%llx\n",
wbid.bstream_type);
ret = memcpy_from_wb(bus, head.wbd_address, sizeof(struct sdwb_wbd),
(uint8_t *)&wbd);
if (ret < 0) {
printk(KERN_ERR KBUILD_MODNAME ": SDWB dev read failed\n");
pr_err(KBUILD_MODNAME ": SDWB dev read failed\n");
return ret;
}
while (wbd.wbd_magic == SDWB_WBD_MAGIC) {
wbdev = (struct wb_device *)kzalloc(sizeof(struct wb_device),
wbdev = kzalloc(sizeof(struct wb_device),
GFP_KERNEL);
if (!wbdev) {
ret = -ENOMEM;
......@@ -281,7 +282,7 @@ int wb_register_bus(struct wb_bus *bus)
goto err_wbdev_read;
}
printk(KERN_INFO KBUILD_MODNAME
pr_info(KBUILD_MODNAME
": found %d wishbone devices on wishbone bus %s\n",
bus->ndev, bus->name);
......
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