xillybus_of.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/drivers/misc/xillybus_of.c
  4. *
  5. * Copyright 2011 Xillybus Ltd, http://xillybus.com
  6. *
  7. * Driver for the Xillybus FPGA/host framework using Open Firmware.
  8. */
  9. #include <linux/module.h>
  10. #include <linux/device.h>
  11. #include <linux/slab.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/of.h>
  14. #include <linux/err.h>
  15. #include "xillybus.h"
  16. MODULE_DESCRIPTION("Xillybus driver for Open Firmware");
  17. MODULE_AUTHOR("Eli Billauer, Xillybus Ltd.");
  18. MODULE_ALIAS("xillybus_of");
  19. MODULE_LICENSE("GPL v2");
  20. static const char xillyname[] = "xillybus_of";
  21. /* Match table for of_platform binding */
  22. static const struct of_device_id xillybus_of_match[] = {
  23. { .compatible = "xillybus,xillybus-1.00.a", },
  24. { .compatible = "xlnx,xillybus-1.00.a", }, /* Deprecated */
  25. {}
  26. };
  27. MODULE_DEVICE_TABLE(of, xillybus_of_match);
  28. static int xilly_drv_probe(struct platform_device *op)
  29. {
  30. struct device *dev = &op->dev;
  31. struct xilly_endpoint *endpoint;
  32. int rc;
  33. int irq;
  34. endpoint = xillybus_init_endpoint(dev);
  35. if (!endpoint)
  36. return -ENOMEM;
  37. dev_set_drvdata(dev, endpoint);
  38. endpoint->owner = THIS_MODULE;
  39. endpoint->registers = devm_platform_ioremap_resource(op, 0);
  40. if (IS_ERR(endpoint->registers))
  41. return PTR_ERR(endpoint->registers);
  42. irq = platform_get_irq(op, 0);
  43. rc = devm_request_irq(dev, irq, xillybus_isr, 0, xillyname, endpoint);
  44. if (rc) {
  45. dev_err(endpoint->dev,
  46. "Failed to register IRQ handler. Aborting.\n");
  47. return -ENODEV;
  48. }
  49. return xillybus_endpoint_discovery(endpoint);
  50. }
  51. static int xilly_drv_remove(struct platform_device *op)
  52. {
  53. struct device *dev = &op->dev;
  54. struct xilly_endpoint *endpoint = dev_get_drvdata(dev);
  55. xillybus_endpoint_remove(endpoint);
  56. return 0;
  57. }
  58. static struct platform_driver xillybus_platform_driver = {
  59. .probe = xilly_drv_probe,
  60. .remove = xilly_drv_remove,
  61. .driver = {
  62. .name = xillyname,
  63. .of_match_table = xillybus_of_match,
  64. },
  65. };
  66. module_platform_driver(xillybus_platform_driver);