From patchwork Wed Jun 1 16:37:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 840792 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p51GcsxJ031530 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 1 Jun 2011 16:39:15 GMT Received: from canuck.infradead.org ([134.117.69.58]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QRoR8-00015S-1K; Wed, 01 Jun 2011 16:38:26 +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 1QRoR7-0007Bg-OG; Wed, 01 Jun 2011 16:38:25 +0000 Received: from mail-gy0-f177.google.com ([209.85.160.177]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QRoQp-00077p-7V for linux-arm-kernel@lists.infradead.org; Wed, 01 Jun 2011 16:38:08 +0000 Received: by gyh20 with SMTP id 20so2768395gyh.36 for ; Wed, 01 Jun 2011 09:38:05 -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=WMCntmAduCeXHuO06/uFsiJdt+u+p3jr9aR2MmZLbLM=; b=ARTiwwQ1GpSnSFXMNo2+xHKWsR7p4zQo7HKDKOI38HtpU+QPuUfHs4qRMDkRgVOeQl yCV4MLqIk9+57dMSaZPLWDAmqojtUo0UcwDRAi9apqVmpBnzX+Bx3ZQxLoNgy2NOejp6 rTYtfSmf3rbtIXarEr/Hg3cXElVeLCrbtAjrc= 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=V4U8qYCZrfxAWYff32goINqUycHBSSblvh+/JoYUnQfTxSGLaxBdgieOnN8dUAVPQs BsvNGfWaM0gbtslvTrW3YEAEQcwssvNRsFS6hBhFAjuxOGnwqulidkoVD0HlvT8Gsnt+ iJMWQdnPxcUkuJM9w9nDxgNFJiRYgrBIopsz4= Received: by 10.91.126.14 with SMTP id d14mr6471667agn.58.1306946285044; Wed, 01 Jun 2011 09:38:05 -0700 (PDT) Received: from rob-laptop.i.smooth-stone.com ([173.226.190.126]) by mx.google.com with ESMTPS id t27sm802923anh.1.2011.06.01.09.38.02 (version=SSLv3 cipher=OTHER); Wed, 01 Jun 2011 09:38:03 -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: Wed, 1 Jun 2011 11:37:48 -0500 Message-Id: <1306946270-18379-2-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1306946270-18379-1-git-send-email-robherring2@gmail.com> References: <1306946270-18379-1-git-send-email-robherring2@gmail.com> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110601_123807_427016_41719097 X-CRM114-Status: GOOD ( 14.66 ) 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.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.177 listed in list.dnswl.org] 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.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 (demeter2.kernel.org [140.211.167.43]); Wed, 01 Jun 2011 16:39:15 +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 --- arch/arm/kernel/pmu.c | 23 ++++++++++++++++++----- 1 files changed, 18 insertions(+), 5 deletions(-) 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, };