From patchwork Tue Jun 7 14:22:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 856972 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p57ENVMj021330 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 7 Jun 2011 14:23:52 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QTxBW-000677-VQ; Tue, 07 Jun 2011 14:23:11 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QTxBW-0004Fz-Cl; Tue, 07 Jun 2011 14:23:10 +0000 Received: from mail-iw0-f177.google.com ([209.85.214.177]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QTxAw-00049J-P8 for linux-arm-kernel@lists.infradead.org; Tue, 07 Jun 2011 14:22:36 +0000 Received: by iwn36 with SMTP id 36so5597012iwn.36 for ; Tue, 07 Jun 2011 07:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:subject:date:message-id:x-mailer :in-reply-to:references; bh=DZ3FQUKnG+ndBPf3JN565xg5AytwOieSs+W6ITaz06g=; b=f5yvD0pyBa2v145ByKI1SgHbiuu2iVtVNKG6Fl7cBpNsgZWpe8uWGbx4RD/BatWJ5a lXjO53iqnFMFBb4ZIuq9q+MDBsgDeRRdHpOFWJqb3zHZN3VAyBw/cOrz8R/lgiQRC9T7 asqKyCHcb9JsPkkFhW8RRENd3eXC+u3ykeleY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; b=AWHPbA18OvR1fLRnQn52yGLKzuve7dNE6UNeVRWFss02a+y1GlB1dau+MOx+vH3rAB dHv6kd+DNVXrc0Shzc23SqHNgYEeLnBEjpvCgTzfas1Dn3uUhVhEDkearj3BwCAd5scn kjQHzagl/461n/Tp2xgzyUAH5EaBXSkICYSrg= Received: by 10.231.123.141 with SMTP id p13mr10386532ibr.29.1307456551959; Tue, 07 Jun 2011 07:22:31 -0700 (PDT) Received: from rob-laptop.i.smooth-stone.com ([173.226.190.126]) by mx.google.com with ESMTPS id s9sm2172964ibe.10.2011.06.07.07.22.30 (version=SSLv3 cipher=OTHER); Tue, 07 Jun 2011 07:22:30 -0700 (PDT) From: Rob Herring To: devicetree-discuss@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] ARM: pmu: add OF probing support Date: Tue, 7 Jun 2011 09:22:19 -0500 Message-Id: <1307456541-11026-2-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1307456541-11026-1-git-send-email-robherring2@gmail.com> References: <1307456541-11026-1-git-send-email-robherring2@gmail.com> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110607_102235_113020_8E38A501 X-CRM114-Status: GOOD ( 17.09 ) X-Spam-Score: 1.4 (+) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (1.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is freemail (robherring2[at]gmail.com) 2.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (robherring2[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.177 listed in list.dnswl.org] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain 0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 07 Jun 2011 14:23:52 +0000 (UTC) From: Rob Herring Add OF match table to enable OF style driver binding. The dts entry is like this: pmu { compatible = "arm,cortex-a9-pmu"; interrupts = <100 101>; }; The use of pdev->id as an index breaks with OF device binding, so set the type based on the OF compatible string. Signed-off-by: Rob Herring --- Documentation/devicetree/bindings/arm/pmu.txt | 22 ++++++++++++++++++++++ arch/arm/kernel/pmu.c | 23 ++++++++++++++++++----- 2 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/pmu.txt diff --git a/Documentation/devicetree/bindings/arm/pmu.txt b/Documentation/devicetree/bindings/arm/pmu.txt new file mode 100644 index 0000000..739d00c --- /dev/null +++ b/Documentation/devicetree/bindings/arm/pmu.txt @@ -0,0 +1,22 @@ +* ARM Performance Monitor Units + +ARM cores often have a PMU for counting cpu and cache events like cache misses +and hits. The interface to the PMU is part of the ARM ARM. The ARM PMU +representation in the device tree should be done as under:- + +Required properties: + +- compatible : should be one of + "arm,cortex-a9-pmu" + "arm,cortex-a8-pmu" + "arm,arm1176-pmu" + "arm,arm1136-pmu" +- interrupts : 1 combined interrupt or 1 per core. + +Example: + +pmu { + compatible = "arm,cortex-a9-pmu"; + interrupts = <100 101>; +}; + diff --git a/arch/arm/kernel/pmu.c b/arch/arm/kernel/pmu.c index 2c79eec..41bc972 100644 --- a/arch/arm/kernel/pmu.c +++ b/arch/arm/kernel/pmu.c @@ -27,27 +27,40 @@ static struct platform_device *pmu_devices[ARM_NUM_PMU_DEVICES]; static int __devinit pmu_device_probe(struct platform_device *pdev) { + enum arm_pmu_type type = pdev->id; - if (pdev->id < 0 || pdev->id >= ARM_NUM_PMU_DEVICES) { + if (pdev->dev.of_node) + type = ARM_PMU_DEVICE_CPU; + + if (type < 0 || type >= ARM_NUM_PMU_DEVICES) { pr_warning("received registration request for unknown " "device %d\n", pdev->id); return -EINVAL; } - if (pmu_devices[pdev->id]) + if (pmu_devices[type]) pr_warning("registering new PMU device type %d overwrites " - "previous registration!\n", pdev->id); + "previous registration!\n", type); else pr_info("registered new PMU device of type %d\n", - pdev->id); + type); - pmu_devices[pdev->id] = pdev; + pmu_devices[type] = pdev; return 0; } +static struct of_device_id pmu_device_ids[] = { + { .compatible = "arm,cortex-a9-pmu" }, + { .compatible = "arm,cortex-a8-pmu" }, + { .compatible = "arm,arm1136-pmu" }, + { .compatible = "arm,arm1176-pmu" }, + {}, +}; + static struct platform_driver pmu_driver = { .driver = { .name = "arm-pmu", + .of_match_table = pmu_device_ids, }, .probe = pmu_device_probe, };