0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/module.h>
0011 #include <linux/device.h>
0012 #include <linux/slab.h>
0013 #include <linux/platform_device.h>
0014 #include <linux/of.h>
0015 #include <linux/err.h>
0016 #include "xillybus.h"
0017
0018 MODULE_DESCRIPTION("Xillybus driver for Open Firmware");
0019 MODULE_AUTHOR("Eli Billauer, Xillybus Ltd.");
0020 MODULE_ALIAS("xillybus_of");
0021 MODULE_LICENSE("GPL v2");
0022
0023 static const char xillyname[] = "xillybus_of";
0024
0025
0026 static const struct of_device_id xillybus_of_match[] = {
0027 { .compatible = "xillybus,xillybus-1.00.a", },
0028 { .compatible = "xlnx,xillybus-1.00.a", },
0029 {}
0030 };
0031
0032 MODULE_DEVICE_TABLE(of, xillybus_of_match);
0033
0034 static int xilly_drv_probe(struct platform_device *op)
0035 {
0036 struct device *dev = &op->dev;
0037 struct xilly_endpoint *endpoint;
0038 int rc;
0039 int irq;
0040
0041 endpoint = xillybus_init_endpoint(dev);
0042
0043 if (!endpoint)
0044 return -ENOMEM;
0045
0046 dev_set_drvdata(dev, endpoint);
0047
0048 endpoint->owner = THIS_MODULE;
0049
0050 endpoint->registers = devm_platform_ioremap_resource(op, 0);
0051 if (IS_ERR(endpoint->registers))
0052 return PTR_ERR(endpoint->registers);
0053
0054 irq = platform_get_irq(op, 0);
0055
0056 rc = devm_request_irq(dev, irq, xillybus_isr, 0, xillyname, endpoint);
0057
0058 if (rc) {
0059 dev_err(endpoint->dev,
0060 "Failed to register IRQ handler. Aborting.\n");
0061 return -ENODEV;
0062 }
0063
0064 return xillybus_endpoint_discovery(endpoint);
0065 }
0066
0067 static int xilly_drv_remove(struct platform_device *op)
0068 {
0069 struct device *dev = &op->dev;
0070 struct xilly_endpoint *endpoint = dev_get_drvdata(dev);
0071
0072 xillybus_endpoint_remove(endpoint);
0073
0074 return 0;
0075 }
0076
0077 static struct platform_driver xillybus_platform_driver = {
0078 .probe = xilly_drv_probe,
0079 .remove = xilly_drv_remove,
0080 .driver = {
0081 .name = xillyname,
0082 .of_match_table = xillybus_of_match,
0083 },
0084 };
0085
0086 module_platform_driver(xillybus_platform_driver);