Commit f6c3b2b0 authored by Federico Vaga's avatar Federico Vaga

drv: remove FMC bus: not used yet

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent f22736d6
......@@ -10,19 +10,15 @@ endif
ccflags-y += -DADDITIONAL_VERSIONS="$(SUBMODULE_VERSIONS)"
ccflags-y += -DGIT_VERSION=\"$(GIT_VERSION)\"
ccflags-y += -I$(FPGA_MGR_ABS)/include
ccflags-y += -I$(FMC_ABS)/include
ccflags-y += -I$(I2C_ABS)/include
ccflags-y += -Wall -Werror
# priority to I2C headers from our sources
LINUXINCLUDE := -I$(FMC_MGR_ABS)/include -I$(FMC_MGR_ABS)/include/linux -I$(FMC_ABS)/include -I$(FMC_ABS)/include/linux -I$(I2C_ABS)/include -I$(I2C_ABS)/include/linux $(LINUXINCLUDE)
LINUXINCLUDE := -I$(FMC_MGR_ABS)/include -I$(FMC_MGR_ABS)/include/linux $(LINUXINCLUDE)
KBUILD_EXTRA_SYMBOLS += $(FPGA_MGR_ABS)/drivers/fpga/Module.symvers
KBUILD_EXTRA_SYMBOLS += $(FMC_ABS)/drivers/fmc/Module.symvers
obj-m := spec.o
spec-objs := spec-core.o
spec-objs += spec-fpga.o
spec-objs += spec-fmc.o
spec-objs += spec-irq.o
......@@ -19,7 +19,7 @@ all: modules
.PHONY: all modules clean help install modules_install
modules help install modules_install:
$(MAKE) -C $(LINUX) M=$(shell pwd) GIT_VERSION=$(GIT_VERSION) FPGA_MGR_ABS=$(FPGA_MGR_ABS) FMC_ABS=$(FMC_ABS) I2C_ABS=$(I2C_ABS) $@
$(MAKE) -C $(LINUX) M=$(shell pwd) GIT_VERSION=$(GIT_VERSION) FPGA_MGR_ABS=$(FPGA_MGR_ABS) $@
# be able to run the "clean" rule even if $(LINUX) is not valid
clean:
......
......@@ -65,10 +65,6 @@ static int spec_probe(struct pci_dev *pdev,
if (err)
goto err_fpga;
err = spec_fmc_init(spec);
if (err)
goto err_fmc;
err = spec_irq_init(spec);
if (err)
goto err_irq;
......@@ -78,8 +74,6 @@ static int spec_probe(struct pci_dev *pdev,
return 0;
err_irq:
spec_fmc_exit(spec);
err_fmc:
spec_fpga_exit(spec);
err_fpga:
device_unregister(&spec->dev);
......@@ -104,7 +98,6 @@ static void spec_remove(struct pci_dev *pdev)
spec_irq_exit(spec);
spec_fmc_exit(spec);
spec_fpga_exit(spec);
for (i = 0; i < 3; i++)
......
/*
* Copyright (C) 2017 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <linux/kernel.h>
#include <linux/platform_data/i2c-ocores.h>
#include "spec.h"
static int spec_fmc_is_present(struct fmc_carrier *carrier,
struct fmc_slot *slot)
{
/* TODO implement me */
return 0;
}
static const struct fmc_carrier_operations spec_fmc_ops = {
.is_present = spec_fmc_is_present,
};
static const struct ocores_i2c_platform_data pdata = {
.reg_shift = 0,
.reg_io_width = 4,
.clock_khz = 62500,
.big_endian = 0,
.num_devices = 0,
.devices = NULL,
};
static int spec_i2c_find_adapter(struct device *dev, void *data)
{
struct spec_dev *spec = data;
struct i2c_adapter *adap, *adap_parent;
if (dev->type != &i2c_adapter_type)
return 0;
adap = to_i2c_adapter(dev);
adap_parent = i2c_parent_is_i2c_adapter(adap);
if (!adap_parent)
return 0;
if (&spec->i2c_pdev->dev != adap_parent->dev.parent)
return 0;
/* Found! */
return i2c_adapter_id(adap);
}
/**
* Get the I2C adapter associated with an FMC slot
* @spec: SPEC instance
*
* Return: the I2C bus to be used
*/
static int spec_i2c_get_bus(struct spec_dev *spec)
{
return i2c_for_each_dev(spec, spec_i2c_find_adapter);
}
static int id;
/**
* It builds the platform_device_info necessary to register the
* I2C master device.
* @spec the SPEC instance
*
* Return: an array of I2C master devices
*/
static int spec_i2c_add(struct spec_dev *spec)
{
struct resource res = {
.name = "i2c-ocores-mem",
.flags = IORESOURCE_MEM,
};
int err;
/* VME function 1 */
res.start = pci_resource_start(to_pci_dev(spec->dev.parent), 0);
res.start += SPEC_I2C_MASTER_ADDR;
res.end = res.start + SPEC_I2C_MASTER_SIZE;
/* FIXME find better ID */
spec->i2c_pdev = platform_device_register_resndata(&spec->dev,
"ocores-i2c", id++,
&res, 1,
&pdata,
sizeof(pdata));
if (!spec->i2c_pdev)
return -ENODEV;
err = i2c_for_each_dev(spec, spec_i2c_find_adapter);
if (err <= 0)
goto err;
return 0;
err:
platform_device_unregister(spec->i2c_pdev);
return -ENODEV;
}
static void spec_i2c_del(struct spec_dev *spec)
{
platform_device_unregister(spec->i2c_pdev);
if (spec->i2c_adapter)
i2c_put_adapter(spec->i2c_adapter);
}
int spec_fmc_init(struct spec_dev *spec)
{
int err;
return 0; /* UNTIL WE TEST IT */
if (!spec)
return -EINVAL;
err = spec_i2c_add(spec);
if (err)
goto err_i2c;
spec->slot_info.i2c_bus_nr = spec_i2c_get_bus(spec);
if (spec->slot_info.i2c_bus_nr <= 0)
goto err_i2c_bus;
spec->slot_info.ga = 0;
spec->slot_info.lun = 0;
err = fmc_carrier_register(&spec->dev, &spec_fmc_ops,
SPEC_FMC_SLOTS, &spec->slot_info, spec);
if (err)
goto err_fmc;
return 0;
err_fmc:
err_i2c_bus:
spec_i2c_del(spec);
err_i2c:
return err;
}
void spec_fmc_exit(struct spec_dev *spec)
{
return; /* UNTIL WE TEST IT */
if (!spec)
return;
fmc_carrier_unregister(&spec->dev);
spec_i2c_del(spec);
}
......@@ -10,7 +10,6 @@
#include <linux/completion.h>
#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/fmc.h>
#include <linux/fpga/fpga-mgr.h>
#include <linux/i2c.h>
#include <linux/irqdomain.h>
......@@ -128,10 +127,6 @@ struct spec_dev {
DECLARE_BITMAP(flags, SPEC_FLAG_BITS);
void __iomem *remap[3]; /* ioremap of bar 0, 2, 4 */
struct fmc_slot_info slot_info;
struct platform_device *i2c_pdev;
struct i2c_adapter *i2c_adapter;
struct dentry *dbg_dir;
#define SPEC_DBG_INFO_NAME "info"
struct dentry *dbg_info;
......@@ -189,9 +184,6 @@ static inline void gennum_mask_val(struct spec_dev *spec,
extern int spec_fpga_init(struct spec_dev *spec);
extern void spec_fpga_exit(struct spec_dev *spec);
extern int spec_fmc_init(struct spec_dev *spec);
extern void spec_fmc_exit(struct spec_dev *spec);
extern int spec_irq_init(struct spec_dev *spec);
extern void spec_irq_exit(struct spec_dev *spec);
......
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