Commit d122ba4a authored by Wesley W. Terpstra's avatar Wesley W. Terpstra

vme-wb: use external driver as a submodule

Trying to manage an external repository that was optionally built
or not depending on the kernel version was a nightmare.

Including it lets us use a single Makefile that does the right thing.
parent d2cd2363
[submodule "legacy-vme64x-core"]
path = legacy-vme64x-core
url = git://ohwr.org/hdl-core-lib/vme64x-core/legacy-vme64x-core.git
legacy-vme64x-core @ 01c38151
Subproject commit 01c381514ac22ced03d6eef75641f0519c994a1b
/*
* 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 <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
#define EMUL_DAT_WD 48
#define WINDOW_OFFSET_LOW 56
#define WINDOW_OFFSET_HIGH 64
#define WBM_ADD_MASK 0xFFFFFFFC
#define WINDOW_HIGH 0xFFFF0000UL
#define WINDOW_LOW 0x0000FFFCUL
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__ */
KERNEL_LIMIT := 3.10.0
TEMP := $(shell /bin/echo "$(KERNELVERSION)'\'n$(KERNEL_LIMIT)")
KERNEL := $(shell /bin/echo -e $(TEMP) | sed '/^$$/d' | sort -t. -k1,1nr -k2,2nr | head -1)
# If the user did not specify otherwise, use the in-kernel VME driver iff it was enabled
ifeq ($(VME_SOURCE),)
VME_SOURCE=external
ifeq ($(CONFIG_VME_BUS),y)
VME_SOURCE=inkernel
endif
ifeq ($(CONFIG_VME_BUS),m)
VME_SOURCE=inkernel
endif
endif
ifneq ($(VME_SOURCE),external)
ifneq ($(VME_SOURCE),inkernel)
$(error VME_SOURCE must be inkernel or external)
endif
endif
ifeq ($(VME_SOURCE),external)
ifneq ($(KERNEL),$(KERNEL_LIMIT))
$(error Cannot build external VME driver with 3.10 - enable in-tree VME $(KERNEL) $(KERNEL_LIMIT))
endif
endif
ifeq ($(VME_SOURCE),internal)
ifneq ($(CONFIG_VME_BUS),y)
ifneq ($(CONFIG_VME_BUS),m)
$(warn Kernel must have in-tree VME feature enabled)
endif
endif
endif
KBUILD_EXTRA_SYMBOLS += $(M)/../pcie-wb/Module.symvers
ccflags-y += -I$(M)/../pcie-wb
obj-m += vme_wb.o
ifeq ($(VME_SOURCE),external)
ccflags-y += -I$(M)/../legacy-vme64x-core/drv/driver
obj-m += ../legacy-vme64x-core/drv/driver/
vme_wb-objs := vme_wb_external.o
else
vme_wb-objs := vme_wb_inkernel.o
endif
REPO_VME = git://ohwr.org/hdl-core-lib/vme64x-core/legacy-vme64x-core.git
DRV_DIR = $(shell pwd)/../../legacy-vme64x-core
SRC_NEWK := 3.10
ifneq ($(KERNELRELEASE),)
KERNEL_LIMIT := 3.10.0
TEMP := $(shell /bin/echo "$(KERNELVERSION)'\'n$(KERNEL_LIMIT)")
KERNEL := $(shell /bin/echo -e $(TEMP) | sed '/^$$/d' | sort -t. -k1,1nr -k2,2nr | head -1)
# If the user did not specify otherwise, use the in-kernel VME driver iff it was enabled
ifeq ($(VME_SOURCE),)
VME_SOURCE=external
ifeq ($(CONFIG_VME_BUS),y)
VME_SOURCE=inkernel
endif
ifeq ($(CONFIG_VME_BUS),m)
VME_SOURCE=inkernel
endif
endif
ifneq ($(VME_SOURCE),inkernel) # external
ifneq ($(KERNEL),$(KERNEL_LIMIT))
$(error Cannot build external VME driver with 3.10 - enable in-tree VME $(KERNEL) $(KERNEL_LIMIT))
endif
endif
ifneq ($(VME_SOURCE),external) # internal
ifneq ($(CONFIG_VME_BUS),y)
ifneq ($(CONFIG_VME_BUS),m)
$(warn Kernel must have in-tree VME feature enabled)
endif
endif
endif
KBUILD_EXTRA_SYMBOLS += $(M)/../pcie-wb/Module.symvers
ifeq ($(VME_SOURCE),external)
KBUILD_EXTRA_SYMBOLS += $(M)/../../legacy-vme64x-core/drv/driver/Module.symvers
obj-m += vme_wb.o
$(obj)/vme_wb.c::
$(MAKE) -C $(obj)/../../legacy-vme64x-core/drv/driver KERNELDIR="$(CURDIR)"
else
obj-m += $(SRC_NEWK)/vme_wb.o
endif
ccflags-y += -I$(M)/../../legacy-vme64x-core/drv/driver
ccflags-y += -I$(M)/../pcie-wb
else
KERNELVER ?= $(shell /bin/uname -r)
KERNELDIR ?= /lib/modules/$(KERNELVER)/build
PWD := $(shell pwd)
all: gitmodules wishbone modules
gitmodules:
@test -d $(DRV_DIR) && \
echo "Driver source code found" || \
git clone $(REPO_VME) $(DRV_DIR)
all: wishbone modules
wishbone:
$(MAKE) -C ../pcie-wb KERNELDIR="$(KERNELDIR)"
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD)
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
install:
test ! -f ../../legacy-vme64x-core/drv/driver/vmebus.ko || \
$(MAKE) -C ../../legacy-vme64x-core/drv/driver install
$(MAKE) -C $(KERNELDIR) M=$(PWD) INSTALL_MOD_PATH=$(STAGING) modules_install
clean:
$(MAKE) -C $(KERNELDIR) M=$(PWD) clean
$(MAKE) -C ../../legacy-vme64x-core/drv/driver clean
endif
$(MAKE) -C ../legacy-vme64x-core/drv/driver clean
......@@ -10,7 +10,6 @@
#define __VME_H__
#include <linux/firmware.h>
#include <vmebus.h>
#include <wishbone.h>
#define VME_WB "vme_wb"
......
......@@ -15,6 +15,7 @@
#include <linux/firmware.h>
#include <linux/delay.h>
#include <linux/io.h>
#include <vmebus.h>
#include "vme_wb.h"
#include "wishbone.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