Commit a7ab2109 authored by Federico Vaga's avatar Federico Vaga

kernel: replace FMC with PLATFORM

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 58fdabab
[submodule "zio"]
path = zio
url = git://ohwr.org/misc/zio.git
[submodule "fmc-bus"]
path = fmc-bus
url = git://ohwr.org/fmc-projects/fmc-bus.git
[submodule "mamma"]
path = mamma
url = https://github.com/FedericoVaga/mamma.git
......@@ -10,24 +10,21 @@ CONFIG_WR_NIC=n
export CONFIG_WR_NIC
# The user can override, using environment variables, all these three:
FMC_BUS ?= $(shell pwd)/fmc-bus
ZIO ?= $(shell pwd)/zio
# FMC_BUS_ABS and ZIO_ABS has to be absolut path, due to beeing
# ZIO_ABS has to be absolut path, due to beeing
# passed to the Kbuild
FMC_BUS_ABS ?= $(abspath $(FMC_BUS) )
ZIO_ABS ?= $(abspath $(ZIO) )
export FMC_BUS_ABS
export ZIO_ABS
ZIO_VERSION = $(shell cd $(ZIO_ABS); git describe --always --dirty --long --tags)
export ZIO_VERSION
DIRS = $(FMC_BUS_ABS) $(ZIO_ABS) kernel lib tools mamma/lib unittest
DIRS = $(ZIO_ABS) kernel lib tools mamma/lib unittest
kernel: $(FMC_BUS_ABS) $(ZIO_ABS)
kernel: $(ZIO_ABS)
lib: $(ZIO_ABS)
tools: lib
......@@ -48,7 +45,7 @@ $(DIRS):
$(MAKE) -C $@ $(TARGET)
SUBMOD = $(FMC_BUS_ABS) $(ZIO_ABS)
SUBMOD = $(ZIO_ABS)
prereq_install_warn:
@test -f .prereq_installed || \
......@@ -58,13 +55,8 @@ prereq_install:
for d in $(SUBMOD); do $(MAKE) -C $$d modules_install || exit 1; done
touch .prereq_installed
$(FMC_BUS_ABS): fmc-bus-init_repo
$(ZIO_ABS): zio-init_repo
# init submodule if missing
fmc-bus-init_repo:
@test -d $(FMC_BUS_ABS)/doc || ( echo "Checking out submodule $(FMC_BUS_ABS)"; git submodule update --init $(FMC_BUS_ABS) )
# init submodule if missing
zio-init_repo:
@test -d $(ZIO_ABS)/doc || ( echo "Checking out submodule $(ZIO_ABS)" && git submodule update --init $(ZIO_ABS) )
......
fmc-bus @ eb86efcf
Subproject commit eb86efcf4e19a31a25471c4ddf3fd9fef8df02ec
# FMC_BUS, ZIO, comes from the Makefile
# ZIO comes from the Makefile
KBUILD_EXTRA_SYMBOLS := \
$(ZIO_ABS)/Module.symvers \
$(FMC_BUS_ABS)/kernel/Module.symvers
# The library includes <sdb.h>, so point -I directtly there
# include our header before to avoid conflicts with the kernel
LINUXINCLUDE := -I$(FMC_BUS_ABS)/kernel/include -I$(FMC_BUS_ABS)/kernel/include/linux $(LINUXINCLUDE)
ccflags-y = -DGIT_VERSION=\"$(GIT_VERSION)\" \
-I$(src) \
-I$(ZIO_ABS)/include \
-I$(FMC_BUS_ABS)/sdb-lib/
ccflags-$(CONFIG_FMC_TDC_DEBUG) += -DDEBUG
ccflags-$(CONFIG_FMC_TDC_VERBOSE_DEBUG) += -DVERBOSE_DEBUG
......@@ -29,7 +23,6 @@ SUBMODULE_VERSIONS += MODULE_INFO(version_$(CONFIG_SUPER_REPO),\"$(CONFIG_SUPER_
endif
endif
# add versions of used submodules
SUBMODULE_VERSIONS += MODULE_INFO(version_fmc_bus,\"$(FMC_BUS_VERSION)\");
SUBMODULE_VERSIONS += MODULE_INFO(version_zio,\"$(ZIO_VERSION)\");
ccflags-y += -DADDITIONAL_VERSIONS="$(SUBMODULE_VERSIONS)"
......@@ -37,6 +30,10 @@ ccflags-y += -DADDITIONAL_VERSIONS="$(SUBMODULE_VERSIONS)"
subdirs-ccflags-y = $(ccflags-y)
obj-m := fmc-tdc.o
fmc-tdc-objs = acam.o calibration.o fmc-util.o \
ft-core.o ft-time.o ft-zio.o ft-buf.o ft-fifo.o\
fmc-bus-link/sdb-lib/access.o fmc-bus-link/sdb-lib/glue.o
fmc-tdc-objs := acam.o
fmc-tdc-objs += calibration.o
fmc-tdc-objs += ft-buf.o
fmc-tdc-objs += ft-core.o
fmc-tdc-objs += ft-fifo.o
fmc-tdc-objs += ft-time.o
fmc-tdc-objs += ft-zio.o
......@@ -6,21 +6,17 @@ REPO_PARENT ?= $(shell /bin/pwd)/../..
LINUX ?= /lib/modules/$(shell uname -r)/build
FMC_BUS ?= ../fmc-bus
ZIO ?= ../zio
# FMC_BUS_ABS and ZIO_ABS has to be absolut path, due to beeing
# ZIO_ABS has to be absolut path, due to beeing
# passed to the Kbuild
FMC_BUS_ABS ?= $(abspath $(FMC_BUS) )
ZIO_ABS ?= $(abspath $(ZIO) )
GIT_VERSION = $(shell git describe --always --dirty --long --tags)
export GIT_VERSION
FMC_BUS_VERSION ?= $(shell cd $(FMC_BUS_ABS); git describe --always --dirty --long --tags)
ZIO_VERSION ?= $(shell cd $(ZIO_ABS); git describe --always --dirty --long --tags)
export FMC_BUS_VERSION
export ZIO_VERSION
CPPCHECK ?= cppcheck
......@@ -28,10 +24,7 @@ CPPCHECK ?= cppcheck
all: modules
modules_install modules:
rm -f fmc-bus-link
ln -s $(FMC_BUS_ABS) fmc-bus-link
$(MAKE) -C $(LINUX) M=$(shell /bin/pwd) FMC_BUS_ABS=$(FMC_BUS_ABS) ZIO_ABS=$(ZIO_ABS) $@
rm -f fmc-bus-link
$(MAKE) -C $(LINUX) M=$(shell /bin/pwd) ZIO_ABS=$(ZIO_ABS) SPEC_SW_ABS=$(SPEC_SW_ABS) $@
clean:
$(MAKE) -C $(LINUX) M=$(shell /bin/pwd) $@
......
......@@ -62,7 +62,7 @@ int ft_acam_init(struct fmctdc_dev *ft)
int i;
unsigned long tmo;
dev_dbg(&ft->fmc->dev, "%s: initializing ACAM TDC...\n", __func__);
dev_dbg(&ft->pdev->dev, "%s: initializing ACAM TDC...\n", __func__);
ft_writel(ft, TDC_CTRL_RESET_ACAM, TDC_REG_CTRL);
......@@ -85,13 +85,13 @@ int ft_acam_init(struct fmctdc_dev *ft)
tmo = jiffies + 2 * HZ;
while (time_before(jiffies, tmo)) {
if (acam_is_pll_locked(ft)) {
dev_dbg(&ft->fmc->dev, "%s: ACAM initialization OK.\n",
dev_dbg(&ft->pdev->dev, "%s: ACAM initialization OK.\n",
__func__);
return 0;
}
}
dev_err(&ft->fmc->dev, "%s: ACAM PLL doesn't lock\n", __func__);
dev_err(&ft->pdev->dev, "%s: ACAM PLL doesn't lock\n", __func__);
return -EIO;
}
......
......@@ -31,6 +31,12 @@
#define FT_CH_1 1
#define FT_NUM_CHANNELS 5
enum mock_turtle_versions {
TDC_VER_SPEC = 0,
TDC_VER_SVEC,
};
enum ft_zattr_dev_idx {
FT_ATTR_DEV_VERSION = 0,
FT_ATTR_DEV_SECONDS,
......@@ -118,8 +124,26 @@ struct ft_calibration_raw {
#include <linux/dma-mapping.h>
#include <linux/spinlock.h>
#include <linux/timer.h>
#include <linux/fmc.h>
#include <linux/version.h>
#include <linux/platform_device.h>
struct ft_memory_ops {
u32 (*read)(void *addr);
void (*write)(u32 value, void *addr);
};
enum mockturtle_irq_resource {
TDC_IRQ = 0,
};
enum mockturtle_mem_resource {
TDC_MEM_BASE = 0,
TDC_CARR_MEM_BASE,
};
enum mockturtle_bus_resource {
TDC_BUS_FMC_SLOT = 0,
};
#include <linux/zio-dma.h>
#include <linux/zio-trigger.h>
......@@ -212,15 +236,18 @@ struct fmctdc_dev {
/* HW buffer/FIFO access lock */
spinlock_t lock;
/* base addresses, taken from SDB */
int ft_core_base;
int ft_i2c_base;
int ft_owregs_base;
int ft_irq_base;
int ft_fifo_base;
int ft_dma_base;
int ft_dma_eic_base;
void *ft_carrier_base;
void *ft_base;
void *ft_core_base;
void *ft_i2c_base;
void *ft_owregs_base;
void *ft_irq_base;
void *ft_fifo_base;
void *ft_dma_base;
void *ft_dma_eic_base;
struct ft_memory_ops memops;
/* IRQ base index (for SVEC) */
struct fmc_device *fmc;
struct platform_device *pdev;
struct zio_device *zdev, *hwzdev;
/* carrier private data */
void *carrier_data;
......@@ -245,15 +272,15 @@ struct fmctdc_dev {
int dma_chan_mask;
};
static inline u32 ft_ioread(struct fmctdc_dev *ft, unsigned long addr)
static inline u32 ft_ioread(struct fmctdc_dev *ft, void *addr)
{
return fmc_readl(ft->fmc, addr);
return ft->memops.read(addr);
}
static inline void ft_iowrite(struct fmctdc_dev *ft,
u32 value, unsigned long addr)
u32 value, void *addr)
{
fmc_writel(ft->fmc, value, addr);
ft->memops.write(value, addr);
}
static inline uint32_t ft_readl(struct fmctdc_dev *ft, unsigned long reg)
......@@ -269,14 +296,14 @@ static inline void ft_writel(struct fmctdc_dev *ft, uint32_t v,
static inline uint32_t dma_readl(struct fmctdc_dev *ft, uint32_t reg)
{
return ft_ioread(ft, TDC_SPEC_DMA_BASE + reg);
return ft_ioread(ft, ft->ft_carrier_base + TDC_SPEC_DMA_BASE + reg);
}
static inline void dma_writel(struct fmctdc_dev *ft, uint32_t data, uint32_t reg)
{
dev_vdbg(&ft->fmc->dev, "%s %x %x\n",
dev_vdbg(&ft->pdev->dev, "%s %x %x\n",
__func__, data, TDC_SPEC_DMA_BASE + reg);
ft_iowrite(ft, data, TDC_SPEC_DMA_BASE + reg);
ft_iowrite(ft, data, ft->ft_carrier_base + TDC_SPEC_DMA_BASE + reg);
}
......@@ -325,10 +352,6 @@ struct zio_channel;
int ft_enable_termination(struct fmctdc_dev *ft, int channel, int enable);
signed long fmc_sdb_find_nth_device (struct sdb_array *tree, uint64_t vid,
uint32_t did, int *ordinal,
uint32_t *size );
void gn4124_dma_read(struct fmctdc_dev *ft, uint32_t src, void *dst, int len);
int gn4124_dma_sg(struct fmctdc_dev *ft,
uint32_t offset, void *buf, int size,
......@@ -407,13 +430,13 @@ static inline enum gncore_dma_status gn4124_dma_wait_done(struct fmctdc_dev *ft,
tmp = dma_readl(ft, GENNUM_DMA_STA);
switch (tmp & GENUM_DMA_STA_MASK) {
case GENNUM_DMA_STA_ERROR:
dev_err(&ft->fmc->dev, "DMA problem: 0x%x", tmp);
dev_err(&ft->pdev->dev, "DMA problem: 0x%x", tmp);
case GENNUM_DMA_STA_ABORT:
case GENNUM_DMA_STA_DONE:
return tmp;
default:
if (time_after(jiffies, timeout)) {
dev_err(&ft->fmc->dev, "DMA timeout: 0x%x", tmp);
dev_err(&ft->pdev->dev, "DMA timeout: 0x%x", tmp);
gn4124_dma_abort(ft);
}
cpu_relax();
......@@ -440,7 +463,6 @@ static inline void gn4124_dma_config(struct fmctdc_dev *ft,
dma_writel(ft, item->attribute, GENNUM_DMA_ATTR);
}
#endif // __KERNEL__
#endif // __FMC_TDC_H__
/*
* Some utility functions not supported in the current version of fmc-bus.
*
* Copyright (C) 2012-2014 CERN (www.cern.ch)
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* Author: Alessandro Rubini <rubini@gnudd.com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <linux/fmc.h>
#include <linux/fmc-sdb.h>
#include <linux/err.h>
#include <asm/byteorder.h>
#include "fmc-tdc.h"
typedef int (*sdb_traverse_cb) (uint32_t address, uint32_t size, uint64_t vid, uint32_t did, void *data);
static int traverse_sdb_devices(struct sdb_array *tree,
sdb_traverse_cb cb,
void *data)
{
union sdb_record *r;
struct sdb_product *p;
struct sdb_component *c;
int i, n = tree->len, rv;
uint64_t last, first, vid;
uint32_t did, size;
/* FIXME: what if the first interconnect is not at zero? */
for (i = 0; i < n; i++) {
r = &tree->record[i];
c = &r->dev.sdb_component;
p = &c->product;
if (!IS_ERR(tree->subtree[i]))
{
rv = traverse_sdb_devices ( tree->subtree[i], cb, data );
if(rv > 0)
return 1;
}
if (r->empty.record_type != sdb_type_device)
continue;
/* record is a device?*/
last = __be64_to_cpu(c->addr_last);
first = __be64_to_cpu(c->addr_first);
vid = __be64_to_cpu(p->vendor_id);
did = __be32_to_cpu(p->device_id);
size = (uint32_t) (last + 1 - first);
if (cb (first + tree->baseaddr, size, vid, did, data))
return 1;
}
return 0;
}
struct callback_state {
int n;
int *ordinal;
uint32_t current_address;
uint32_t current_size;
uint64_t did;
uint32_t vid;
};
static int callback (uint32_t address, uint32_t size, uint64_t vid_, uint32_t did_, void *data)
{
struct callback_state *st = (struct callback_state *) data;
if(vid_ == st->vid && did_ == st->did)
{
st->n++;
st->current_address = address;
st->current_size = size;
if(!st->ordinal || st->n == *st->ordinal)
{
return 1;
}
}
return 0; /* continue scanning */
}
/* Finds the Nth SDB device that matches (vid/did) pair, where N <= *ordinal.
If N < *ordinal, the value of N is stored at *ordinal.
This magic is used to handle hybrid bistreams (with two or more different
mezzanines). */
signed long fmc_sdb_find_nth_device (struct sdb_array *tree, uint64_t vid, uint32_t did, int *ordinal, uint32_t *size )
{
struct callback_state st;
st.n = -1;
st.ordinal = ordinal;
st.vid = vid;
st.did = did;
traverse_sdb_devices (tree, callback, &st);
if (st.n >= 0)
{
if(size)
*size = st.current_size;
if(ordinal)
*ordinal = st.n;
return st.current_address;
}
return -ENODEV;
}
......@@ -13,6 +13,7 @@
#include <linux/bitops.h>
#include <linux/io.h>
#include <linux/moduleparam.h>
#include <linux/interrupt.h>
#include <linux/zio.h>
#include <linux/zio-trigger.h>
......@@ -40,7 +41,7 @@ static void ft_buffer_burst_size_set(struct fmctdc_dev *ft,
unsigned int chan,
uint32_t size)
{
const uint32_t base = ft->ft_dma_base + (0x40 * chan);
void *base = ft->ft_dma_base + (0x40 * chan);
uint32_t tmp;
tmp = ft_ioread(ft, base + TDC_BUF_REG_CSR);
......@@ -52,7 +53,7 @@ static void ft_buffer_burst_size_set(struct fmctdc_dev *ft,
static void ft_buffer_burst_enable(struct fmctdc_dev *ft,
unsigned int chan)
{
const uint32_t base = ft->ft_dma_base + (0x40 * chan);
void *base = ft->ft_dma_base + (0x40 * chan);
uint32_t tmp;
tmp = ft_ioread(ft, base + TDC_BUF_REG_CSR);
......@@ -64,7 +65,7 @@ static void ft_buffer_burst_enable(struct fmctdc_dev *ft,
static void ft_buffer_burst_disable(struct fmctdc_dev *ft,
unsigned int chan)
{
const uint32_t base = ft->ft_dma_base + (0x40 * chan);
void *base = ft->ft_dma_base + (0x40 * chan);
uint32_t tmp;
tmp = ft_ioread(ft, base + TDC_BUF_REG_CSR);
......@@ -191,7 +192,7 @@ static int gennum_dma_fill(struct zio_dma_sg *zsg)
if (zsg->page_idx == 0)
gn4124_dma_config(ft, item);
dev_dbg(ft->fmc->hwdev, "DMA item %d (block %d)\n"
dev_dbg(&ft->pdev->dev, "DMA item %d (block %d)\n"
" pool 0x%llx\n"
" addr 0x%x\n"
" addr_l 0x%x\n"
......@@ -223,7 +224,7 @@ static int gennum_dma_fill(struct zio_dma_sg *zsg)
static unsigned int ft_buffer_switch(struct fmctdc_dev *ft, int chan)
{
struct ft_channel_state *st = &ft->channels[chan];
uint32_t base = ft->ft_dma_base + chan * 0x40;
void *base = ft->ft_dma_base + chan * 0x40;
uint32_t csr, base_cur;
unsigned int transfer_buffer;
......@@ -275,7 +276,7 @@ static unsigned int ft_buffer_switch(struct fmctdc_dev *ft, int chan)
*/
static unsigned int ft_buffer_count(struct fmctdc_dev *ft, unsigned int chan)
{
uint32_t base = ft->ft_dma_base + chan * 0x40;
void *base = ft->ft_dma_base + chan * 0x40;
return ft_ioread(ft, base + TDC_BUF_REG_CUR_COUNT);
}
......@@ -297,8 +298,7 @@ static void ft_abort_acquisition(struct zio_cset *cset)
static irqreturn_t ft_irq_handler_dma_complete(int irq, void *dev_id)
{
struct fmc_device *fmc = dev_id;
struct fmctdc_dev *ft = fmc->mezzanine_data;
struct fmctdc_dev *ft = dev_id;
uint32_t irq_stat;
unsigned long *loop;
int i;
......@@ -323,7 +323,7 @@ static irqreturn_t ft_irq_handler_dma_complete(int irq, void *dev_id)
zio_cset_busy_clear(&ft->zdev->cset[i], 1);
if (irq_stat & DMA_EIC_EIC_IDR_DMA_ERROR) {
dev_err(ft->fmc->hwdev, "0x%X 0x%X",
dev_err(&ft->pdev->dev, "0x%X 0x%X",
irq_stat, dma_readl(ft, GENNUM_DMA_STA));
for_each_set_bit(i, loop, FT_NUM_CHANNELS)
......@@ -338,7 +338,6 @@ static irqreturn_t ft_irq_handler_dma_complete(int irq, void *dev_id)
}
out:
fmc_irq_ack(fmc);
/* Re-Enable interrupts that were disabled in the IRQ handler */
ft_irq_enable_restore(ft);
......@@ -390,8 +389,7 @@ static inline unsigned int ft_irq_status_is_valid(struct fmctdc_dev *ft,
static irqreturn_t ft_irq_handler_ts_dma(int irq, void *dev_id)
{
struct fmc_device *fmc = dev_id;
struct fmctdc_dev *ft = fmc->mezzanine_data;
struct fmctdc_dev *ft = dev_id;
struct ft_channel_state *st;
struct zio_cset *cset;
struct zio_block *blocks[ft->zdev->n_cset];
......@@ -434,7 +432,7 @@ static irqreturn_t ft_irq_handler_ts_dma(int irq, void *dev_id)
cset = &ft->zdev->cset[0]; /* ZIO is not really using the channel,
and probably it should not */
ft->zdma = zio_dma_alloc_sg(cset->chan, ft->fmc->hwdev,
ft->zdma = zio_dma_alloc_sg(cset->chan, &ft->pdev->dev,
blocks, n_block, GFP_ATOMIC);
if (IS_ERR_OR_NULL(ft->zdma))
goto err_alloc;
......@@ -449,19 +447,17 @@ static irqreturn_t ft_irq_handler_ts_dma(int irq, void *dev_id)
for_each_set_bit(i, loop, ft->zdev->n_cset)
zio_cset_busy_set(&ft->zdev->cset[i], 1);
dma_sync_single_for_device(ft->fmc->hwdev, ft->zdma->dma_page_desc_pool,
dma_sync_single_for_device(&ft->pdev->dev, ft->zdma->dma_page_desc_pool,
sizeof(struct gncore_dma_item) * ft->zdma->sgt.nents,
DMA_TO_DEVICE);
gn4124_dma_start(ft);
fmc_irq_ack(fmc);
return IRQ_HANDLED;
err_map:
zio_dma_free_sg(ft->zdma);
err_alloc:
dev_err(ft->fmc->hwdev, "Cannot execute DMA\n");
dev_err(&ft->pdev->dev, "Cannot execute DMA\n");
ft->zdma = NULL;
for_each_set_bit(i, loop, ft->zdev->n_cset) {
zio_cset_busy_clear(&ft->zdev->cset[i], 1);
......@@ -470,9 +466,6 @@ err_alloc:
ft_irq_enable_restore(ft);
/* Ack the FMC signal, we have finished */
fmc_irq_ack(fmc);
return IRQ_HANDLED;
}
......@@ -483,7 +476,7 @@ err_alloc:
*/
static void ft_buffer_size_set(struct fmctdc_dev *ft, int channel)
{
const uint32_t base = ft->ft_dma_base + (0x40 * channel);
void *base = ft->ft_dma_base + (0x40 * channel);
uint32_t val;
struct ft_channel_state *st;
......@@ -514,11 +507,11 @@ static void ft_buffer_size_set(struct fmctdc_dev *ft, int channel)
ft_buffer_burst_size_set(ft, channel, dma_buf_ddr_burst_size_default);
ft_buffer_burst_enable(ft, channel);
dev_vdbg(&ft->fmc->dev,
"Config channel %d: base = 0x%x buf[0] = 0x%08x, buf[1] = 0x%08x, %d timestamps per buffer\n",
dev_vdbg(&ft->pdev->dev,
"Config channel %d: base = %p buf[0] = 0x%08x, buf[1] = 0x%08x, %d timestamps per buffer\n",
channel, base, st->buf_addr[0], st->buf_addr[1],
st->buf_size);
dev_vdbg(&ft->fmc->dev, "CSR: %08x\n",
dev_vdbg(&ft->pdev->dev, "CSR: %08x\n",
ft_ioread(ft, base + TDC_BUF_REG_CSR));
}
......@@ -529,7 +522,7 @@ static void ft_buffer_size_set(struct fmctdc_dev *ft, int channel)
*/
static void ft_buffer_size_clr(struct fmctdc_dev *ft, int channel)
{
const uint32_t base = ft->ft_dma_base + (0x40 * channel);
void *base = ft->ft_dma_base + (0x40 * channel);
ft_iowrite(ft, 0, base + TDC_BUF_REG_CUR_SIZE);
ft_iowrite(ft, 0, base + TDC_BUF_REG_NEXT_SIZE);
......@@ -539,17 +532,18 @@ static void ft_buffer_size_clr(struct fmctdc_dev *ft, int channel)
int ft_buf_init(struct fmctdc_dev *ft)
{
struct resource *r;
unsigned int i;
int ret;
ft_irq_coalescing_timeout_set(ft, -1, irq_timeout_ms_default);
ft_irq_coalescing_size_set(ft, -1, 40);
ft->fmc->irq = ft->ft_irq_base;
ret = fmc_irq_request(ft->fmc, ft_irq_handler_ts_dma,
"fmc-tdc-dma-start", 0);
r = platform_get_resource(ft->pdev, IORESOURCE_IRQ, 0);
ret = request_any_context_irq(r->start, ft_irq_handler_ts_dma, 0,
r->name, ft);
if (ret < 0) {
dev_err(&ft->fmc->dev,
dev_err(&ft->pdev->dev,
"Request interrupt 'DMA Start' failed: %d\n",
ret);
return ret;
......@@ -558,18 +552,16 @@ int ft_buf_init(struct fmctdc_dev *ft)
* DMA completion interrupt (from the GN4124 core), like in
* the FMCAdc design
*/
ft->fmc->irq = ft->ft_irq_base + 1;
ret = fmc_irq_request(ft->fmc, ft_irq_handler_dma_complete,
"fmc-tdc-dma-over", 0);
r = platform_get_resource(ft->pdev, IORESOURCE_IRQ, 1);
ret = request_any_context_irq(r->start, ft_irq_handler_dma_complete, 0,
r->name, ft);
if (ret < 0) {
dev_err(&ft->fmc->dev,
dev_err(&ft->pdev->dev,
"Request interrupt 'DMA Over' failed: %d\n",
ret);
ft->fmc->irq = ft->ft_irq_base;
fmc_irq_free(ft->fmc);
free_irq(platform_get_irq(ft->pdev, 0), ft);
}
/* kick off the interrupts (fixme: possible issue with the HDL) */
fmc_irq_ack(ft->fmc);
/*
* We enable interrupts on all channel. but if we do not enable
* the channel, we should not receive anything. So, even if
......@@ -600,11 +592,8 @@ void ft_buf_exit(struct fmctdc_dev *ft)
DMA_EIC_EIC_IDR_DMA_DONE | DMA_EIC_EIC_IDR_DMA_ERROR,
ft->ft_dma_eic_base + DMA_EIC_REG_EIC_IER);
ft->fmc->irq = ft->ft_irq_base;
fmc_irq_free(ft->fmc);
ft->fmc->irq = ft->ft_irq_base + 1;
fmc_irq_free(ft->fmc);
free_irq(platform_get_irq(ft->pdev, 0), ft);
free_irq(platform_get_irq(ft->pdev, 1), ft);
for (i = 0; i < FT_NUM_CHANNELS; i++)
ft_buffer_size_clr(ft, i);
......
This diff is collapsed.
......@@ -13,6 +13,7 @@
#include <linux/bitops.h>
#include <linux/io.h>
#include <linux/moduleparam.h>
#include <linux/interrupt.h>
#include <linux/zio.h>
#include <linux/zio-trigger.h>
......@@ -35,7 +36,7 @@
static int ft_timestamp_get(struct zio_cset *cset, struct ft_hw_timestamp *hwts)
{
struct fmctdc_dev *ft = cset->zdev->priv_d;
uint32_t fifo_addr = ft->ft_fifo_base + TDC_FIFO_OFFSET * cset->index;
void *fifo_addr = ft->ft_fifo_base + TDC_FIFO_OFFSET * cset->index;
hwts->seconds = ft_ioread(ft, fifo_addr + TSF_REG_FIFO_R0);
hwts->coarse = ft_ioread(ft, fifo_addr + TSF_REG_FIFO_R1);
......@@ -87,9 +88,9 @@ static inline uint32_t ft_irq_fifo_status(struct fmctdc_dev *ft)
static irqreturn_t ft_irq_handler_ts_fifo(int irq, void *dev_id)
{
struct fmc_device *fmc = dev_id;
struct fmctdc_dev *ft = fmc->mezzanine_data;
uint32_t irq_stat, tmp_irq_stat, fifo_stat, fifo_csr_addr;
struct fmctdc_dev *ft = dev_id;
uint32_t irq_stat, tmp_irq_stat, fifo_stat;
void *fifo_csr_addr;
unsigned long *loop;
struct zio_cset *cset;
int i;
......@@ -131,25 +132,23 @@ irq:
if (irq_stat)
goto irq;
/* Ack the FMC signal, we have finished */
fmc_irq_ack(fmc);
return IRQ_HANDLED;
}
int ft_fifo_init(struct fmctdc_dev *ft)
{
struct resource *r;
int ret;
ft_irq_coalescing_timeout_set(ft, -1, irq_timeout_ms_default);
ft_irq_coalescing_size_set(ft, -1, 40);
ft->fmc->irq = ft->ft_irq_base;
ret = fmc_irq_request(ft->fmc, ft_irq_handler_ts_fifo,
"fmc-tdc-fifo", 0);
r = platform_get_resource(ft->pdev, IORESOURCE_IRQ, 0);
ret = request_any_context_irq(r->start, ft_irq_handler_ts_fifo, 0,
r->name, ft);
if (ret < 0) {
dev_err(&ft->fmc->dev,
dev_err(&ft->pdev->dev,
"Request interrupt 'FIFO' failed: %d\n",
ret);
return ret;
......@@ -166,6 +165,5 @@ void ft_fifo_exit(struct fmctdc_dev *ft)
{
ft_iowrite(ft, ~0, ft->ft_irq_base + TDC_EIC_REG_EIC_IDR);
ft->fmc->irq = ft->ft_irq_base;
fmc_irq_free(ft->fmc);
free_irq(platform_get_irq(ft->pdev, 0), ft);
}
......@@ -88,11 +88,11 @@ void ft_set_tai_time(struct fmctdc_dev *ft, uint64_t seconds, uint32_t coarse)
if (ft->verbose)
dev_info(&ft->fmc->dev, "Setting TAI time to %lld:%d\n",
dev_info(&ft->pdev->dev, "Setting TAI time to %lld:%d\n",
seconds, coarse);
if (coarse != 0)
dev_warn(&ft->fmc->dev,
dev_warn(&ft->pdev->dev,
"Warning: ignoring sub-second part (%d) when setting time.\n",
coarse);
......
......@@ -21,8 +21,6 @@
#include <linux/zio-buffer.h>
#include <linux/zio-trigger.h>
#include <linux/fmc.h>
#include "fmc-tdc.h"
#include "hw/timestamp_fifo_regs.h"
#include "hw/tdc_onewire_regs.h"
......@@ -73,7 +71,7 @@ static void ft_update_offsets(struct fmctdc_dev *ft, int channel)
{
struct ft_channel_state *st = &ft->channels[channel];
struct ft_hw_timestamp hw_offset = {0, 0, 0, 0};
uint32_t fifo_addr;
void *fifo_addr;
fifo_addr = ft->ft_fifo_base + TDC_FIFO_OFFSET * channel;
......@@ -107,7 +105,8 @@ static int ft_delta_reference_set(struct fmctdc_dev *ft,
unsigned int chan,
unsigned int ref)
{
uint32_t fifo_addr, csr;
uint32_t csr;
void *fifo_addr;
if (ref > ft->zdev->n_cset || chan > ft->zdev->n_cset)
return -EINVAL;
......@@ -133,7 +132,8 @@ static int ft_delta_reference_get(struct fmctdc_dev *ft,
unsigned int chan,
int *ref)
{
uint32_t fifo_addr, csr;
uint32_t csr;
void *fifo_addr;
if (chan > ft->zdev->n_cset)
return -EINVAL;
......@@ -151,7 +151,7 @@ static void ft_raw_mode_set(struct fmctdc_dev *ft,
unsigned int chan,
unsigned int raw_enable)
{
uint32_t fifo_addr = ft->ft_fifo_base + TDC_FIFO_OFFSET * chan;
void *fifo_addr = ft->ft_fifo_base + TDC_FIFO_OFFSET * chan;
uint32_t csr = ft_ioread(ft, fifo_addr + TSF_REG_CSR);
if (raw_enable)
......@@ -166,7 +166,7 @@ static void ft_raw_mode_set(struct fmctdc_dev *ft,
static int ft_raw_mode_get(struct fmctdc_dev *ft,
unsigned int chan)
{
uint32_t fifo_addr = ft->ft_fifo_base + TDC_FIFO_OFFSET * chan;
void *fifo_addr = ft->ft_fifo_base + TDC_FIFO_OFFSET * chan;
uint32_t csr = ft_ioread(ft, fifo_addr + TSF_REG_CSR);
return (csr & TSF_CSR_RAW_MODE) ? 1 : 0;
......@@ -457,7 +457,8 @@ static void ft_change_flags(struct zio_obj_head *head, unsigned long mask)
ien = ft_readl(ft, TDC_REG_INPUT_ENABLE);
if (chan->flags & ZIO_STATUS) {
uint32_t csr, fifo_addr;
uint32_t csr;
void *fifo_addr;
/* DISABLED */
ft_disable(ft, chan->cset->index);
......@@ -735,7 +736,7 @@ int ft_zio_init(struct fmctdc_dev *ft)
ft->hwzdev->owner = THIS_MODULE;
ft->hwzdev->priv_d = ft;
dev_id = ft->fmc->device_id;
dev_id = ft->pdev->id;
err = zio_register_device(ft->hwzdev, "tdc-1n5c", dev_id);
if (err)
......
......@@ -116,11 +116,13 @@
/* TDC core submodule offsets (wrs to the TDC control registers block) */
#define TDC_MEZZ_ONEWIRE_OFFSET (-0x1000)
#define TDC_MEZZ_EIC_OFFSET (0x1000)
#define TDC_MEZZ_I2C_OFFSET (0x2000)
#define TDC_MEZZ_MEM_FIFO_OFFSET (0x3000)
#define TDC_MEZZ_MEM_DMA_OFFSET (0x4000)
#define TDC_MEZZ_ONEWIRE_OFFSET 0x1000
#define TDC_MEZZ_CORE_OFFSET 0x2000
#define TDC_MEZZ_EIC_OFFSET 0x3000
#define TDC_MEZZ_I2C_OFFSET 0x4000
#define TDC_MEZZ_MEM_OFFSET 0x5000
#define TDC_MEZZ_MEM_DMA_OFFSET 0x6000
#define TDC_MEZZ_MEM_DMA_EIC_OFFSET 0x7000
#endif /* __TDC_REGISTERS_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