From patchwork Mon Jun 16 11:23:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sricharan R X-Patchwork-Id: 31946 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 996BE20E7A for ; Mon, 16 Jun 2014 11:28:14 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id ij19sf19829008vcb.2 for ; Mon, 16 Jun 2014 04:28:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=M1d460pkreKiWc8X6PBtDmzpVnJ2IqYctNHW8b7s0jg=; b=eAEkNITmqtMs5/P6KNSf3RVytrlZJ+Ml9M6WUfwT7U0mmz7BuKvZLoiKIPwd87sd6l 2oUJ9f4fq3M1dQ+yD/cs/mNR6ib/w6m9xHoikTsEeEujleS/zh4DQU7IkhjpjDw24qSV +09jH7Ahzl1ZVRKFeR8FW0WLIryrn//rwdNmkqCu5YOFfqXoHA2c6vFPnrYNUgzk1pi3 Io3wydAG7GpQon6Vw+Z9RbBPXk7oZIXLZI8EXWGgHyxXoNt1lDR6dciJzGd8D+Bj8eFc oSfn+HJzPgM8l7qCmqB7HX8lz/txeqEyuMbwZlHsJxt+CgLLrNWfPx6pXNKn5FQ4yh/K wQsQ== X-Gm-Message-State: ALoCoQk/gQBzuUfuglbhQ+mslDgCLBwBacxTLRRtOyQhXQ+m15Tq43skHABExjVOamWbB2yeQWmo X-Received: by 10.58.187.44 with SMTP id fp12mr1232063vec.24.1402918094438; Mon, 16 Jun 2014 04:28:14 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.80.81 with SMTP id b75ls4306979qgd.34.gmail; Mon, 16 Jun 2014 04:28:14 -0700 (PDT) X-Received: by 10.58.56.102 with SMTP id z6mr11647542vep.7.1402918094348; Mon, 16 Jun 2014 04:28:14 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id fa1si3990265vcb.39.2014.06.16.04.28.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Jun 2014 04:28:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id id10so4817836vcb.10 for ; Mon, 16 Jun 2014 04:28:14 -0700 (PDT) X-Received: by 10.52.25.130 with SMTP id c2mr4557719vdg.27.1402918094195; Mon, 16 Jun 2014 04:28:14 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp127376vcb; Mon, 16 Jun 2014 04:28:13 -0700 (PDT) X-Received: by 10.69.25.105 with SMTP id ip9mr23554690pbd.145.1402918093265; Mon, 16 Jun 2014 04:28:13 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zi3si13341516pac.179.2014.06.16.04.28.12; Mon, 16 Jun 2014 04:28:12 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755526AbaFPL2J (ORCPT + 9 others); Mon, 16 Jun 2014 07:28:09 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:47848 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755434AbaFPL0p (ORCPT ); Mon, 16 Jun 2014 07:26:45 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s5GBQHUG014627; Mon, 16 Jun 2014 06:26:17 -0500 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5GBQHsO026477; Mon, 16 Jun 2014 06:26:17 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Mon, 16 Jun 2014 06:26:17 -0500 Received: from uda0393807.india.ti.com. (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5GBOx4A008965; Mon, 16 Jun 2014 06:26:13 -0500 From: Sricharan R To: , , , CC: , , , , , , , , Subject: [PATCH V3 13/16] irqchip: crossbar: introduce ti, max-crossbar-sources to identify valid crossbar mapping Date: Mon, 16 Jun 2014 16:53:13 +0530 Message-ID: <1402917796-31574-14-git-send-email-r.sricharan@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1402917796-31574-1-git-send-email-r.sricharan@ti.com> References: <1402917796-31574-1-git-send-email-r.sricharan@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: r.sricharan@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Nishanth Menon Currently we attempt to map any crossbar value to an IRQ, however, this is not correct from hardware perspective. There is a max crossbar event number upto which hardware supports. So describe the same in device tree using 'ti,max-crossbar-sources' property and use it to validate requests. Signed-off-by: Nishanth Menon Signed-off-by: Sricharan R --- .../devicetree/bindings/arm/omap/crossbar.txt | 2 ++ drivers/irqchip/irq-crossbar.c | 21 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/omap/crossbar.txt b/Documentation/devicetree/bindings/arm/omap/crossbar.txt index e54d1fb..41aef44 100644 --- a/Documentation/devicetree/bindings/arm/omap/crossbar.txt +++ b/Documentation/devicetree/bindings/arm/omap/crossbar.txt @@ -10,6 +10,7 @@ Required properties: - compatible : Should be "ti,irq-crossbar" - reg: Base address and the size of the crossbar registers. - ti,max-irqs: Total number of irqs available at the interrupt controller. +- ti,max-crossbar-sources: Maximum number of crossbar sources that can be routed. - ti,reg-size: Size of a individual register in bytes. Every individual register is assumed to be of same size. Valid sizes are 1, 2, 4. - ti,irqs-reserved: List of the reserved irq lines that are not muxed using @@ -29,6 +30,7 @@ Examples: compatible = "ti,irq-crossbar"; reg = <0x4a002a48 0x130>; ti,max-irqs = <160>; + ti,max-crossbar-sources = <400>; ti,reg-size = <2>; ti,irqs-reserved = <0 1 2 3 5 6 131 132 139 140>; }; diff --git a/drivers/irqchip/irq-crossbar.c b/drivers/irqchip/irq-crossbar.c index df16ef8..c46e14b 100644 --- a/drivers/irqchip/irq-crossbar.c +++ b/drivers/irqchip/irq-crossbar.c @@ -26,6 +26,7 @@ * struct crossbar_device - crossbar device description * @int_max: maximum number of supported interrupts * @safe_map: safe default value to initialize the crossbar + * @max_crossbar_sources: Maximum number of crossbar sources * @irq_map: array of interrupts to crossbar number mapping * @crossbar_base: crossbar base address * @register_offsets: offsets for each irq number @@ -34,6 +35,7 @@ struct crossbar_device { uint int_max; uint safe_map; + uint max_crossbar_sources; uint *irq_map; void __iomem *crossbar_base; int *register_offsets; @@ -117,12 +119,19 @@ static int crossbar_domain_xlate(struct irq_domain *d, unsigned int *out_type) { int ret; + int req_num = intspec[1]; - ret = get_prev_map_irq(intspec[1]); + if (req_num >= cb->max_crossbar_sources) { + pr_err("%s: requested crossbar number %d > max %d\n", + __func__, req_num, cb->max_crossbar_sources); + return -EINVAL; + } + + ret = get_prev_map_irq(req_num); if (ret >= 0) goto found; - ret = allocate_free_irq(intspec[1]); + ret = allocate_free_irq(req_num); if (ret < 0) return ret; @@ -153,6 +162,14 @@ static int __init crossbar_of_init(struct device_node *node) if (!cb->crossbar_base) goto err_cb; + of_property_read_u32(node, "ti,max-crossbar-sources", + &cb->max_crossbar_sources); + if (!cb->max_crossbar_sources) { + pr_err("missing 'ti,max-crossbar-sources' property\n"); + ret = -EINVAL; + goto err_base; + } + of_property_read_u32(node, "ti,max-irqs", &max); if (!max) { pr_err("missing 'ti,max-irqs' property\n");