Commit 0c081bed authored by Federico Vaga's avatar Federico Vaga

sw:drv: add possibility to not load FD/TDC

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 105b23b6
...@@ -5,9 +5,15 @@ ...@@ -5,9 +5,15 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include<linux/moduleparam.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mfd/core.h> #include <linux/mfd/core.h>
static char *drivers = "";
module_param(drivers, charp, 0444);
MODULE_PARM_DESC(drivers,
"Extra drivers to load: fd (fmc-fine-delay), tdc (fmc-tdc), fdtdc (fmc-fine-delay and fmc-tdc)\n");
enum wrtd_stf_dev_offsets { enum wrtd_stf_dev_offsets {
WRTD_STF_FDT_MEM_START = 0x00006000, WRTD_STF_FDT_MEM_START = 0x00006000,
WRTD_STF_FDT_MEM_END = 0x000061FF, WRTD_STF_FDT_MEM_END = 0x000061FF,
...@@ -18,11 +24,6 @@ enum wrtd_stf_dev_offsets { ...@@ -18,11 +24,6 @@ enum wrtd_stf_dev_offsets {
}; };
/* MFD devices */ /* MFD devices */
enum spec_fpga_mfd_devs_enum {
WRTD_STF_MFD_TRTL = 0,
WRTD_STF_MFD_FDT,
WRTD_STF_MFD_TDC,
};
static struct resource wrtd_stf_fdt_res[] = { static struct resource wrtd_stf_fdt_res[] = {
{ {
...@@ -77,30 +78,67 @@ static struct resource wrtd_stf_trtl_res[] = { ...@@ -77,30 +78,67 @@ static struct resource wrtd_stf_trtl_res[] = {
}, },
}; };
static const struct mfd_cell wrtd_stf_mfd_devs[] = { #define MFD_CELL_TRTL { \
[WRTD_STF_MFD_TRTL] = { .name = "mock-turtle", \
.name = "mock-turtle", .platform_data = NULL, \
.platform_data = NULL, .pdata_size = 0, \
.pdata_size = 0, .num_resources = ARRAY_SIZE(wrtd_stf_trtl_res), \
.num_resources = ARRAY_SIZE(wrtd_stf_trtl_res), .resources = wrtd_stf_trtl_res, \
.resources = wrtd_stf_trtl_res, }
}, #define MFD_CELL_FDT { \
[WRTD_STF_MFD_FDT] = { .name = "fmc-fdelay-tdc", \
.name = "fmc-fdelay-tdc", .platform_data = NULL, \
.platform_data = NULL, .pdata_size = 0, \
.pdata_size = 0, .num_resources = ARRAY_SIZE(wrtd_stf_fdt_res), \
.num_resources = ARRAY_SIZE(wrtd_stf_fdt_res), .resources = wrtd_stf_fdt_res, \
.resources = wrtd_stf_fdt_res, }
}, #define MFD_CELL_TDC { \
[WRTD_STF_MFD_TDC] = { .name = "fmc-tdc", \
.name = "fmc-tdc", .platform_data = NULL, \
.platform_data = NULL, .pdata_size = 0, \
.pdata_size = 0, .num_resources = ARRAY_SIZE(wrtd_stf_tdc_res), \
.num_resources = ARRAY_SIZE(wrtd_stf_tdc_res), .resources = wrtd_stf_tdc_res, \
.resources = wrtd_stf_tdc_res, }
},
static const struct mfd_cell __wrtd_stf_mfd_devs_base[] = {
MFD_CELL_TRTL,
};
static const struct mfd_cell __wrtd_stf_mfd_devs_fdt[] = {
MFD_CELL_TRTL,
MFD_CELL_FDT,
};
static const struct mfd_cell __wrtd_stf_mfd_devs_tdc[] = {
MFD_CELL_TRTL,
MFD_CELL_TDC,
};
static const struct mfd_cell __wrtd_stf_mfd_devs_fdtdc[] = {
MFD_CELL_TRTL,
MFD_CELL_FDT,
MFD_CELL_TDC,
}; };
static const struct mfd_cell *wrtd_stf_mfd_cells(const char *extra)
{
if (strncmp("fdtdc", extra, 5) == 0)
return __wrtd_stf_mfd_devs_fdtdc;
else if (strncmp("tdc", extra, 3) == 0)
return __wrtd_stf_mfd_devs_tdc;
else if (strncmp("fd", extra, 2) == 0)
return __wrtd_stf_mfd_devs_fdt;
else
return __wrtd_stf_mfd_devs_base;
}
static unsigned int wrtd_stf_mfd_count(const char *extra)
{
int count = 1;
if (strncmp("fd", extra, 2) == 0)
count++;
if (strncmp("tdc", extra, 3) == 0 ||
strncmp("fdtdc", extra, 5) == 0)
count++;
return count;
}
static int wrtd_stf_probe(struct platform_device *pdev) static int wrtd_stf_probe(struct platform_device *pdev)
{ {
...@@ -126,8 +164,8 @@ static int wrtd_stf_probe(struct platform_device *pdev) ...@@ -126,8 +164,8 @@ static int wrtd_stf_probe(struct platform_device *pdev)
*/ */
return mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO, return mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO,
wrtd_stf_mfd_devs, wrtd_stf_mfd_cells(drivers),
ARRAY_SIZE(wrtd_stf_mfd_devs), wrtd_stf_mfd_count(drivers),
rmem, irq, NULL); rmem, irq, NULL);
} }
...@@ -176,4 +214,4 @@ MODULE_VERSION(DRV_VERSION); ...@@ -176,4 +214,4 @@ MODULE_VERSION(DRV_VERSION);
MODULE_DESCRIPTION("Driver for the WRTD SVEC TDC Fine-Delay"); MODULE_DESCRIPTION("Driver for the WRTD SVEC TDC Fine-Delay");
MODULE_DEVICE_TABLE(platform, wrtd_stf_id_table); MODULE_DEVICE_TABLE(platform, wrtd_stf_id_table);
MODULE_SOFTDEP("pre: svec_fmc_carrier mockturtle fmc-fine-delay fmc-tdc"); MODULE_SOFTDEP("pre: svec_fmc_carrier mockturtle");
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