brintos

brintos / linux-shallow public Read only

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