From patchwork Fri Jun 12 00:04:22 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 28612 Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 94DF1B71B6 for ; Fri, 12 Jun 2009 10:07:47 +1000 (EST) Received: by ozlabs.org (Postfix) id 84C9CDDD1C; Fri, 12 Jun 2009 10:07:47 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (bilbo.ozlabs.org [203.10.76.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "bilbo.ozlabs.org", Issuer "CAcert Class 3 Root" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 8249BDDD1B for ; Fri, 12 Jun 2009 10:07:47 +1000 (EST) Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by bilbo.ozlabs.org (Postfix) with ESMTP id 2D235B7CC1 for ; Fri, 12 Jun 2009 10:05:22 +1000 (EST) Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 0D805B7535 for ; Fri, 12 Jun 2009 10:04:58 +1000 (EST) Received: by ozlabs.org (Postfix) id E94ACDDD1B; Fri, 12 Jun 2009 10:04:57 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [92.198.50.35]) by ozlabs.org (Postfix) with ESMTP id 12E3DDDDD4 for ; Fri, 12 Jun 2009 10:04:57 +1000 (EST) Received: from themisto.ext.pengutronix.de ([92.198.50.58] helo=pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.63) (envelope-from ) id 1MEuGF-00034p-Mm; Fri, 12 Jun 2009 02:04:51 +0200 From: Wolfram Sang To: linux-kernel@vger.kernel.org Date: Fri, 12 Jun 2009 02:04:22 +0200 Message-Id: <1244765062-14144-3-git-send-email-w.sang@pengutronix.de> X-Mailer: git-send-email 1.6.3.1 In-Reply-To: <1244765062-14144-1-git-send-email-w.sang@pengutronix.de> References: <1244765062-14144-1-git-send-email-w.sang@pengutronix.de> X-SA-Exim-Connect-IP: 92.198.50.58 X-SA-Exim-Mail-From: w.sang@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on metis.extern.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.8 required=4.5 tests=AWL,BAYES_00,RCVD_IN_PBL shortcircuit=no autolearn=no version=3.2.4 Subject: [PATCH 2/2] uio: add an of_genirq driver X-SA-Exim-Version: 4.2.1 (built Tue, 09 Jan 2007 17:23:22 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: linuxppc-dev@ozlabs.org Cc: devicetree-discuss@ozlabs.org, "Hans J. Koch" , linuxppc-dev@ozlabs.org, Greg KH X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Picking up the now exported generic probe function from the platform-variant of this driver, this patch adds an of-version. Also add the binding documentation. Signed-off-by: Wolfram Sang Cc: Magnus Damm Cc: Hans J. Koch Cc: Greg KH --- In probe, I put the resources-array on the stack to simplify the code. If this is considered too huge for the stack (140 byte for a 32-bit system at the moment), I can also post a version using kzalloc. Documentation/powerpc/dts-bindings/uio-generic.txt | 16 +++ drivers/uio/Kconfig | 6 + drivers/uio/Makefile | 1 + drivers/uio/uio_of_genirq.c | 98 ++++++++++++++++++++ 4 files changed, 121 insertions(+), 0 deletions(-) create mode 100644 Documentation/powerpc/dts-bindings/uio-generic.txt create mode 100644 drivers/uio/uio_of_genirq.c diff --git a/Documentation/powerpc/dts-bindings/uio-generic.txt b/Documentation/powerpc/dts-bindings/uio-generic.txt new file mode 100644 index 0000000..8ad9861 --- /dev/null +++ b/Documentation/powerpc/dts-bindings/uio-generic.txt @@ -0,0 +1,16 @@ +UIO for custom devices + +A device which will be mapped using the UIO subsystem. + +Properties: + - compatible : should contain the specific model used, followed by + "generic-uio". + - reg : address range(s) of the device (up to MAX_UIO_MAPS) + - interrupts : interrupt of the device + +Example: + c64fpga@0 { + compatible = "ptx,c64fpga001", "generic-uio"; + reg = <0x0 0x10000>; + interrupts = <0 0 3>; + }; diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 7f86534..18efe38 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig @@ -46,6 +46,12 @@ config UIO_PDRV_GENIRQ If you don't know what to do here, say N. +config UIO_OF_GENIRQ + tristate "Userspace I/O OF driver with generic IRQ handling" + depends on UIO_PDRV_GENIRQ && OF + help + OF wrapper for the above platform driver. + config UIO_SMX tristate "SMX cryptengine UIO interface" default n diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile index 5c2586d..089fd56 100644 --- a/drivers/uio/Makefile +++ b/drivers/uio/Makefile @@ -2,6 +2,7 @@ obj-$(CONFIG_UIO) += uio.o obj-$(CONFIG_UIO_CIF) += uio_cif.o obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o +obj-$(CONFIG_UIO_OF_GENIRQ) += uio_of_genirq.o obj-$(CONFIG_UIO_SMX) += uio_smx.o obj-$(CONFIG_UIO_AEC) += uio_aec.o obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o diff --git a/drivers/uio/uio_of_genirq.c b/drivers/uio/uio_of_genirq.c new file mode 100644 index 0000000..254ec5b --- /dev/null +++ b/drivers/uio/uio_of_genirq.c @@ -0,0 +1,98 @@ +/* + * OF wrapper to make use of the uio_pdrv_genirq-driver. + * + * Copyright (C) 2009 Wolfram Sang, Pengutronix + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include + +#define OF_DRIVER_VERSION "1" + +static __devinit int uio_of_genirq_probe(struct of_device *op, + const struct of_device_id *match) +{ + struct uio_info *uioinfo; + struct resource resources[MAX_UIO_MAPS]; + int i, ret; + + uioinfo = kzalloc(sizeof(*uioinfo), GFP_KERNEL); + if (!uioinfo) + return -ENOMEM; + + uioinfo->name = op->node->name; + uioinfo->version = OF_DRIVER_VERSION; + uioinfo->irq = irq_of_parse_and_map(op->node, 0); + if (!uioinfo->irq) + uioinfo->irq = UIO_IRQ_NONE; + + for (i = 0; i < MAX_UIO_MAPS; ++i) + if (of_address_to_resource(op->node, i, &resources[i])) + break; + + ret = __uio_pdrv_genirq_probe(&op->dev, uioinfo, &resources, i); + if (ret) + goto err_cleanup; + + return 0; + +err_cleanup: + if (uioinfo->irq != UIO_IRQ_NONE) + irq_dispose_mapping(uioinfo->irq); + + kfree(uioinfo); + return ret; +} + +static __devexit int uio_of_genirq_remove(struct of_device *op) +{ + struct uio_pdrv_genirq_platdata *priv = dev_get_drvdata(&op->dev); + + uio_unregister_device(priv->uioinfo); + + if (priv->uioinfo->irq != UIO_IRQ_NONE) + irq_dispose_mapping(priv->uioinfo->irq); + + kfree(priv->uioinfo); + kfree(priv); + return 0; +} + +/* Match table for of_platform binding */ +static const struct of_device_id __devinitconst uio_of_genirq_match[] = { + { .compatible = "generic-uio", }, + {}, +}; +MODULE_DEVICE_TABLE(of, uio_of_genirq_match); + +static struct of_platform_driver uio_of_genirq_driver = { + .owner = THIS_MODULE, + .name = "uio-of-genirq", + .match_table = uio_of_genirq_match, + .probe = uio_of_genirq_probe, + .remove = __devexit_p(uio_of_genirq_remove), +}; + +static inline int __init uio_of_genirq_init(void) +{ + return of_register_platform_driver(&uio_of_genirq_driver); +} +module_init(uio_of_genirq_init); + +static inline void __exit uio_of_genirq_exit(void) +{ + of_unregister_platform_driver(&uio_of_genirq_driver); +} +module_exit(uio_of_genirq_exit); + +MODULE_AUTHOR("Wolfram Sang"); +MODULE_DESCRIPTION("Userspace I/O OF driver with generic IRQ handling"); +MODULE_LICENSE("GPL v2");