Commit 66939603 authored by Miguel Jimenez Lopez's avatar Miguel Jimenez Lopez

kernel: Make changes for the WR node configuration.

Currently, only SPEC board is supported.
parent 8549bcd1
......@@ -30,7 +30,11 @@
* a module parameter or somehow configurable. For the time being we keep
* it hard-coded here.
*/
#if WR_IS_SWITCH
static const char *irqdomain_name = "htvic-wr-swi.0";
#else
static const char *irqdomain_name = "htvic-spec.0";
#endif
static inline struct wrn_dev *wrn_from_pdev(struct platform_device *pdev)
{
......@@ -117,17 +121,53 @@ static int __wrn_map_resources(struct platform_device *pdev)
return 0;
}
static int wrn_probe(struct platform_device *pdev)
/* This helper is used by probe below */
static int __wrn_map_irq(struct platform_device *pdev, struct irq_domain *irqdomain)
{
struct net_device *netdev;
struct wrn_ep *ep;
int i;
struct resource *res;
struct wrn_dev *wrn = wrn_from_pdev(pdev);
int i, err = 0, irq;
int err = 0, irq;
/* Lazily: irqs are not in the resource list */
static int irqs[] = WRN_IRQ_NUMBERS;
static char *irq_names[] = WRN_IRQ_NAMES;
static irq_handler_t irq_handlers[] = WRN_IRQ_HANDLERS;
if (WR_IS_SWITCH) {
/* Register the interrupt handlers (not shared) */
for (i = 0; i < ARRAY_SIZE(irq_names); i++) {
irq = irq_find_mapping(irqdomain, irqs[i]);
err = request_irq(irq, irq_handlers[i],
IRQF_TRIGGER_LOW, irq_names[i], wrn);
if (err)
break;
wrn->irq_registered |= 1 << i;
}
} else {
/* Register the interrupt handlers (not shared) */
for (i = 0; i < pdev->num_resources; i++) {
res = platform_get_resource(pdev, IORESOURCE_IRQ, i);
if (!res)
continue;
irq = irq_find_mapping(irqdomain, res->start);
err = request_irq(irq, irq_handlers[i],
IRQF_TRIGGER_LOW, res->name, wrn);
if (err)
break;
wrn->irq_registered |= 1 << i;
}
}
return err;
}
static int wrn_probe(struct platform_device *pdev)
{
struct net_device *netdev;
struct wrn_ep *ep;
struct wrn_dev *wrn = wrn_from_pdev(pdev);
int i, err = 0;
struct irq_domain *irqdomain;
irqdomain = irq_find_host((struct device_node *)irqdomain_name);
......@@ -162,17 +202,9 @@ static int wrn_probe(struct platform_device *pdev)
printk("regs %p, txd %p, rxd %p, buffer %p\n",
wrn->regs, wrn->txd, wrn->rxd, wrn->databuf);
if (WR_IS_SWITCH) {
/* Register the interrupt handlers (not shared) */
for (i = 0; i < ARRAY_SIZE(irq_names); i++) {
irq = irq_find_mapping(irqdomain, irqs[i]);
err = request_irq(irq, irq_handlers[i],
IRQF_TRIGGER_LOW, irq_names[i], wrn);
if (err)
/* Map our interrupts */
if( (err = __wrn_map_irq(pdev,irqdomain)) )
goto out;
wrn->irq_registered |= 1 << i;
}
}
/* Finally, register one interface per endpoint */
memset(wrn->dev, 0, sizeof(wrn->dev));
......@@ -254,7 +286,11 @@ struct platform_driver wrn_driver = {
.remove = wrn_remove, /* not __exit_p as probe calls it */
/* No suspend or resume by now */
.driver = {
#if WR_IS_SWITCH
.name = KBUILD_MODNAME,
#else
.name = "spec-nic",
#endif
.owner = THIS_MODULE,
},
};
......@@ -19,9 +19,11 @@
#include "wr-nic.h"
/* Our platform data is actually the device itself, and we have 1 only */
static struct wrn_dev wrn_dev;
#if WR_IS_SWITCH
/* The WRN_RES_ names are defined in the header file. Each block 64kB */
#define __RES(name_) { \
.start = FPGA_BASE_ ## name_, \
......@@ -55,6 +57,7 @@ static struct platform_device wrn_device = {
/* dma_mask not used, as we make no DMA */
},
};
#endif
/*
* Module init and exit stuff. Here we register the platform data
......@@ -68,7 +71,9 @@ int __init wrn_init(void)
/* A few fields must be initialized at run time */
spin_lock_init(&wrn_dev.lock);
#if WR_IS_SWITCH
platform_device_register(&wrn_device);
#endif
platform_driver_register(&wrn_driver);
return 0;
}
......@@ -76,7 +81,9 @@ int __init wrn_init(void)
void __exit wrn_exit(void)
{
platform_driver_unregister(&wrn_driver);
#if WR_IS_SWITCH
platform_device_unregister(&wrn_device);
#endif
return;
}
......
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