From patchwork Sun Jun 29 16:21:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Heider X-Patchwork-Id: 4444781 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B8F609F32E for ; Sun, 29 Jun 2014 16:26:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED3EF20328 for ; Sun, 29 Jun 2014 16:25:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 18200202F8 for ; Sun, 29 Jun 2014 16:25:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X1HtU-0004Hr-66; Sun, 29 Jun 2014 16:23:56 +0000 Received: from mail-wg0-x22e.google.com ([2a00:1450:400c:c00::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X1Hs1-0003OT-Rz for linux-arm-kernel@lists.infradead.org; Sun, 29 Jun 2014 16:22:26 +0000 Received: by mail-wg0-f46.google.com with SMTP id y10so7185872wgg.29 for ; Sun, 29 Jun 2014 09:22:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tqJjyeNmjVlYzlTCIJqNP2MI6Xtj/c3qtJfljkgyb1Y=; b=V1scRWQJFapwBxUKgogjXKK7y2UOt/PtQvqTt0d0bcig5vSzSdT0CNpx7FHRzAvs9/ iDcIw7K80RNb2R54/5wWMirSSFIBCyQezEKqS2IbLPVe7f3fEKCNjPu432gMhlWZnq2h 8aVFmkA2TDZh+TsOMfIz2x685/bIQoilBLT7s3fjwz1rJjAzpljr1u9bO6X6LZet/now SbTq2G/EOqKxJPMloa1J1Cw/ZDKFFbiR+PMtJ4PrJlRHerMOAjox9of9l2sNM8ufrK+V XrQ+rmX9MjC4iFT3Yj/MzfIU8lZjcSytWEvgFMGF+5s1ONJo+sxgsw3/PnXhClC4hXND ktmw== X-Received: by 10.194.8.102 with SMTP id q6mr38795308wja.74.1404058925876; Sun, 29 Jun 2014 09:22:05 -0700 (PDT) Received: from mamamia.internal (a89-182-10-130.net-htp.de. [89.182.10.130]) by mx.google.com with ESMTPSA id gh16sm21137573wic.3.2014.06.29.09.22.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 29 Jun 2014 09:22:05 -0700 (PDT) From: Andre Heider To: linux-omap@vger.kernel.org Subject: [PATCH 09/13] uio: uio_pruss: add devicetree support Date: Sun, 29 Jun 2014 18:21:43 +0200 Message-Id: <1404058907-21112-10-git-send-email-a.heider@gmail.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1404058907-21112-1-git-send-email-a.heider@gmail.com> References: <1404058907-21112-1-git-send-email-a.heider@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140629_092226_117125_6630776F X-CRM114-Status: GOOD ( 17.64 ) X-Spam-Score: -0.1 (/) Cc: devicetree@vger.kernel.org, Paul Walmsley , Tony Lindgren , Greg Kroah-Hartman , Matt Porter , "Hans J . Koch" , =?UTF-8?q?Beno=C3=AEt=20Cousson?= , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support to probe via devicetree. Signed-off-by: Andre Heider --- drivers/uio/uio_pruss.c | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c index afaf726..2df54ab 100644 --- a/drivers/uio/uio_pruss.c +++ b/drivers/uio/uio_pruss.c @@ -26,6 +26,7 @@ #include #include #include +#include #define DRV_NAME "pruss_uio" #define DRV_VERSION "1.0" @@ -70,6 +71,27 @@ struct uio_pruss_dev { struct gen_pool *sram_pool; }; +#ifdef CONFIG_OF +struct uio_pruss_params { + u32 pintc_offset; +}; + +static const struct uio_pruss_params uio_pruss_v1_params = { + .pintc_offset = 0x4000, +}; + +static const struct uio_pruss_params uio_pruss_v2_params = { + .pintc_offset = 0x20000, +}; + +static const struct of_device_id pruss_of_match_table[] = { + { .compatible = "ti,pruss-v1", .data = &uio_pruss_v1_params, }, + { .compatible = "ti,pruss-v2", .data = &uio_pruss_v2_params, }, + {}, +}; +MODULE_DEVICE_TABLE(of, pruss_of_match_table); +#endif + static irqreturn_t pruss_handler(int irq, struct uio_info *info) { struct uio_pruss_dev *gdev = info->priv; @@ -111,6 +133,8 @@ static int pruss_probe(struct platform_device *pdev) struct uio_pruss_dev *gdev; struct resource *regs_prussio; struct device *dev = &pdev->dev; + const struct of_device_id *match; + const struct uio_pruss_params *params; int ret = -ENODEV, cnt = 0, i; struct uio_pruss_pdata *pdata = dev_get_platdata(dev); dma_addr_t ddr_paddr; @@ -123,13 +147,21 @@ static int pruss_probe(struct platform_device *pdev) if (!gdev->info) return -ENOMEM; - /* Power on PRU in case its not done as part of boot-loader */ - gdev->pruss_clk = clk_get(dev, "pruss"); - if (IS_ERR(gdev->pruss_clk)) { - dev_err(dev, "Failed to get clock\n"); - return PTR_ERR(gdev->pruss_clk); + if (dev->of_node) { + match = of_match_device(pruss_of_match_table, dev); + params = match->data; + gdev->pintc_base = params->pintc_offset; } else { + /* Power on PRU in case its not done as part of boot-loader */ + gdev->pruss_clk = clk_get(dev, "pruss"); + if (IS_ERR(gdev->pruss_clk)) { + dev_err(dev, "Failed to get clock\n"); + return PTR_ERR(gdev->pruss_clk); + } + clk_enable(gdev->pruss_clk); + + gdev->pintc_base = pdata->pintc_base; } regs_prussio = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -139,7 +171,7 @@ static int pruss_probe(struct platform_device *pdev) goto out_free; } - if (pdata->sram_pool) { + if (pdata && pdata->sram_pool) { gdev->sram_pool = pdata->sram_pool; gdev->sram_vaddr = (unsigned long)gen_pool_dma_alloc(gdev->sram_pool, @@ -156,7 +188,6 @@ static int pruss_probe(struct platform_device *pdev) goto out_free; } - gdev->pintc_base = pdata->pintc_base; gdev->hostirq_start = platform_get_irq(pdev, 0); for (cnt = 0, p = gdev->info; cnt < MAX_PRUSS_EVT; cnt++, p++) { @@ -214,6 +245,7 @@ static struct platform_driver pruss_driver = { .driver = { .name = DRV_NAME, .owner = THIS_MODULE, + .of_match_table = of_match_ptr(pruss_of_match_table), }, };