Commit 9f1965ab authored by Wesley W. Terpstra's avatar Wesley W. Terpstra

Merge branch 'vme-wb-130904'

Added Cesar's driver for VME.
parents 9f313e9b 6c4712b7
# This is useful if cross-compiling. Taken from kernel Makefile (CC changed)
#AS =$(CROSS_COMPILE)as
#LD =$(CROSS_COMPILE)ld
#CC =$(CROSS_COMPILE)gcc
#CPP =$(CC) -E
#AR =$(CROSS_COMPILE)ar
#NM =$(CROSS_COMPILE)nm
#STRIP =$(CROSS_COMPILE)strip
#OBJCOPY =$(CROSS_COMPILE)objcopy
#OBJDUMP =$(CROSS_COMPILE)objdump
KERNELVER ?= `uname -r`
KERNELDIR ?= /lib/modules/$(KERNELVER)/build
REPO_VME = git://ohwr.org/hdl-core-lib/vme64x-core/legacy-vme64x-core.git
DRV_DIR = $(shell pwd)/../../legacy-vme64x-core
ifneq ($(KERNELRELEASE),)
obj-m := vme_wb.o
ccflags-y := -I$(M)/../../legacy-vme64x-core/drv/driver
ccflags-y += -I$(M)/../pcie-wb
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
#KBUILD_EXTMOD := $(PWD)/../pcie-wb/Module.symvers
#KBUILD_EXTRA_SYMBOLS += $(M)/Module.symvers.vme
all: gitmodules wishbone modules
gitmodules:
@test -d $(DRV_DIR) && \
echo "Driver source code found" || \
git clone $(REPO_VME) $(DRV_DIR)
wishbone:
$(MAKE) -C ../pcie-wb
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD)
install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
endif
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
0xd5d87388 vme_bus_error_check ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0xfdd837c3 vme_create_window ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0x404e46ad vme_release_mapping ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0x8c7c5159 wishbone_slave_ready ../pcie-wb/wishbone EXPORT_SYMBOL
0x3cc3d254 vme_unregister_driver ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0x27d77c1f vme_do_dma_kernel ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0xd1694422 find_controller ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0x97a23c39 vme_register_berr_handler ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0x38a64230 wishbone_register ../pcie-wb/wishbone EXPORT_SYMBOL
0xd72f079c vme_request_irq ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0xa63fcdf2 wishbone_unregister ../pcie-wb/wishbone EXPORT_SYMBOL
0x8ecccb22 vme_free_irq ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0x17f13619 find_vme_mapping_from_addr ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0xae07c6e9 vme_find_mapping ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0x74ee0fbc vme_bus_error_check_clear ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0x3a330d53 vme_register_driver ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0x7832e4d0 vme_generate_interrupt ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0x2fe70581 vme_destroy_window ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0xbea0c878 vme_do_dma ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0xbccb7cc9 return_controller ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0x0106863e vme_unregister_berr_handler ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0x824cc545 vme_intclr ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0xe35baa39 vme_intset ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
0x20314cbf vme_get_window_attr ../../vetar_drv/vmebridge/driver/vmebus EXPORT_SYMBOL_GPL
* Author: Cesar Prados <c.prados@gsi.de>
*
* Released according to the GNU GPL, version 2 or any later version
*
* VME-WB bridge for VME
This kernle module provides methods for using Etherbone over VME. It depens on
the wishbone and vmebridge modules. The first steers the Ethernet communication and
the later provides the needed methods for managing the vme bus (open, create
windows, destroy windows, write and read) wraping up the Ethernet protocol in
VME transactions.
The module create 3 VME windows:
1) CS/CSR[AM=VME_CR_CSR, DW=VME_D32, size=0x80000, base=0x80000 * Slot]
This window exposes the configuration area of the Legacy vme64x-core:
[WB Base Addres]
[WB Ctrl Base Addres]
[IRQ Leve and Vector]
[WB bus 32 o 64 bits]
[Enable/Disable the WB Bus]
2) WB Bus[AM=VME_A32_USER_MBLT, DW=VME_D32, size=0x1000000, base=0x1000000 * Slot]
This widows exposes the internal WB bus in the device that the VME bus in connected to.
3) WB Ctrl[AM=VME_A24_USER_MBLT, DW=VME_D32, size=0xA0, base=0x400 * Slot]
This windows exposes a sort of registers that contain Etherbone config parameters, control the WB bus,
and the MSI WB bus
This kernel module handles MSI interrupts using Etherbone interfaces.
For loading the module:
#insmod vme_wb.ko slot= vmebase= vector= lun=
<slot> this parameter means in a vme64, the position of the card in the rack, and in legacy
vme, the position of the base address switch.
<vmebase> set the vmebase for the CS/CSR
<vector> of the IRQ
<lun> index value for VME card
#!/bin/bash
insmod vme_wb.ko slot=1 vmebase=0x0 vector=1 lun=1
#!/bin/bash
rmmod vme_wb.ko
This diff is collapsed.
/*
* Copyright (C) 2012-2013 GSI (www.gsi.de)
* Author: Cesar Prados <c.prados@gsi.de>
*
* Released according to the GNU GPL, version 2 or any later version
*
* Driver for VME VME board.
*/
#ifndef __VME_H__
#define __VME_H__
#include <linux/firmware.h>
#include <vmebus.h>
#include <wishbone.h>
#define VME_WB "vme_wb"
#define VME_MAX_DEVICES 32
#define VME_DEFAULT_IDX { [0 ... (VME_MAX_DEVICES-1)] = -1 }
/* VME CSR offsets */
#define FUN0ADER 0x7FF63
#define FUN1ADER 0x7FF73
#define WB_32_64 0x7ff33
#define BIT_SET_REG 0x7FFFB
#define BIT_CLR_REG 0x7FFF7
#define IRQ_VECTOR 0x7FF5F
#define IRQ_LEVEL 0x7FF5B
#define VME_VENDOR_ID_OFFSET 0x24
/* VME CSR VALUES */
#define WB32 1
#define WB64 0
#define RESET_CORE 0x80
#define ENABLE_CORE 0x10
#define VME_IRQ_LEVEL 0x6
#define VME_VENDOR_ID 0x80031
/* VME WB Interdace*/
#define ERROR_FLAG 0
#define SDWB_ADDRESS 8
#define CTRL 16
#define MASTER_CTRL 24
#define MASTER_ADD 32
#define MASTER_DATA 40
enum vme_map_win {
MAP_CR_CSR = 0, /* CR/CSR */
MAP_REG, /* A32 wb space */
MAP_CTRL /* A24 wb ctrl space */
};
/* Our device structure */
struct vme_dev {
int lun;
int slot;
uint32_t vmebase;
int vector;
int level;
char driver[16];
char description[80];
struct vme_mapping *map[3];
/* struct work_struct work; */
unsigned long irq;
};
struct vme_wb_dev {
struct device *vme_dev;
struct wishbone wb;
struct vme_dev vme_res;
struct mutex mutex;
unsigned int window_offset;
unsigned int low_addr, width, shift;
};
/* Functions and data in vme_wb.c */
extern void vme_setup_csr_fa0(void *base, u32 vme, unsigned vector,
unsigned level);
extern int vme_unmap_window(struct vme_wb_dev *vetar,
enum vme_map_win map_type);
extern int vme_map_window(struct vme_wb_dev *vetar, enum vme_map_win map_type);
#endif /* __VME_H__ */
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