From: "Lorenzo Pieralisi" <Lorenzo.Pieralisi-5wv7dgnIgG8@public.gmane.org>
To: 'Grant Likely' <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Cc: linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org,
nico-vtqb6HGKxmzR7s880joybQ@public.gmane.org,
Catalin Marinas <Catalin.Marinas-5wv7dgnIgG8@public.gmane.org>,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
Philippe Robin <Philippe.Robin-5wv7dgnIgG8@public.gmane.org>,
jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org
Subject: RE: [RFC PATCH 11/14] ARM: PMU: add device tree probing
Date: Fri, 20 Aug 2010 11:56:32 +0100 [thread overview]
Message-ID: <7735.97662705487$1282301819@news.gmane.org> (raw)
In-Reply-To: <AANLkTinz2CWrzPk3BtM6tWxu1udeAS1LFzjACB9spq-y-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
> -----Original Message-----
> From: glikely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org [mailto:glikely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org] On Behalf Of Grant
> Likely
> Sent: 18 August 2010 22:37
> To: Lorenzo Pieralisi
> Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org; Philippe Robin; nico-vtqb6HGKxmzR7s880joybQ@public.gmane.org;
> linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org; Catalin Marinas; jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org
> Subject: Re: [RFC PATCH 11/14] ARM: PMU: add device tree probing
>
> On Wed, Aug 18, 2010 at 12:59 PM, Lorenzo Pieralisi
> <lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org> wrote:
> > When OF is enabled, platform drivers are required to define a
> > match table in order to allow the kernel to find drivers suitable
> > for a given device. The device tree allows to retrieve resources
> > from device tree nodes dynamically.
> >
> > This patch adds device tree support to the ARM PMU driver. This
> > includes a match table and code to initialize the driver id from
> > the respective device tree node compatible property.
> >
> > Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
> > ---
> > arch/arm/include/asm/pmu.h | 6 ++++++
> > arch/arm/kernel/Makefile | 3 ++-
> > arch/arm/kernel/pmu-of.c | 30 ++++++++++++++++++++++++++++++
> > arch/arm/kernel/pmu.c | 18 ++++++++++++------
> > 4 files changed, 50 insertions(+), 7 deletions(-)
> > create mode 100644 arch/arm/kernel/pmu-of.c
> >
> > diff --git a/arch/arm/include/asm/pmu.h b/arch/arm/include/asm/pmu.h
> > index 8ccea01..d317b64 100644
> > --- a/arch/arm/include/asm/pmu.h
> > +++ b/arch/arm/include/asm/pmu.h
> > @@ -17,6 +17,12 @@ enum arm_pmu_type {
> > ARM_NUM_PMU_DEVICES,
> > };
> >
> > +#ifndef CONFIG_OF
> > +static inline int pmu_probe_dt(struct platform_device *pdev) { return -
> ENODEV; }
> > +#else
> > +extern int __devinit pmu_probe_dt(struct platform_device *pdev);
> > +#endif
> > +
> > #ifdef CONFIG_CPU_HAS_PMU
> >
> > /**
> > diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
> > index 0ace897..b7d846f 100644
> > --- a/arch/arm/kernel/Makefile
> > +++ b/arch/arm/kernel/Makefile
> > @@ -48,7 +48,8 @@ obj-$(CONFIG_CPU_XSCALE) += xscale-cp0.o
> > obj-$(CONFIG_CPU_XSC3) += xscale-cp0.o
> > obj-$(CONFIG_CPU_MOHAWK) += xscale-cp0.o
> > obj-$(CONFIG_IWMMXT) += iwmmxt.o
> > -obj-$(CONFIG_CPU_HAS_PMU) += pmu.o
> > +pmu_of-$(CONFIG_OF) := pmu-of.o
> > +obj-$(CONFIG_CPU_HAS_PMU) += pmu.o $(pmu_of-y)
> > obj-$(CONFIG_HW_PERF_EVENTS) += perf_event.o
> > AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxt
> >
> > diff --git a/arch/arm/kernel/pmu-of.c b/arch/arm/kernel/pmu-of.c
> > new file mode 100644
> > index 0000000..5c5ee94
> > --- /dev/null
> > +++ b/arch/arm/kernel/pmu-of.c
> > @@ -0,0 +1,30 @@
> > +/*
> > + * linux/arch/arm/kernel/pmu-of.c -- PMU DT probe function
> > + *
> > + * 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 <linux/kernel.h>
> > +#include <linux/of.h>
> > +#include <linux/platform_device.h>
> > +
> > +#include <asm/pmu.h>
> > +
> > +int __devinit pmu_probe_dt(struct platform_device *pdev)
> > +{
> > + int ret = -ENODEV;
> > + struct device_node *node = pdev->dev.of_node;
> > +
> > + if (of_device_is_compatible(node, "arm,arm-pmu")) {
> > + pdev->id = ARM_PMU_DEVICE_CPU;
> > + ret = 0;
> > + } else {
> > + pr_warning("Probing device not recognized "
> > + "device %s\n", node->full_name);
>
> Do you really want the warning on an OF-enabled kernel when booting on
> an non-OF board?
>
Good point. I would answer no. Valid in other contexts as well.
I will take that into account.
> > + }
> > +
> > + return ret;
> > +}
>
> How about:
> {
> if (!of_match_node(arm_pmu_matches, node))
> return -ENODEV;
>
> pdev->id = ARM_PMU_DEVICE_CPU;
> return 0;
> }
>
> Clearer and more concise, no?
>
Definitely.
> Also, (as you've brought up before) the pdev->id issue needs to be
> solved. I don't believe it is allowed to change the id field after
> the platform_device is registered. I'd rather see the id dynamically
> assigned, which generally works in the OF use-case because
> interconnections between devices are described in the tree and
> specific ids aren't really needed. However, it could be that the best
> thing to do is retrieve the system-wide unique id from the aliases
> node.
>
> ... and ditto on my comment that this will be simpler if it lives
> directly in pmu.c. :-)
When you say "retrieve the system-wide id from the aliases node" you mean
at platform_device register time in the OF layer (ie of_device_register),
right ?
>
> > diff --git a/arch/arm/kernel/pmu.c b/arch/arm/kernel/pmu.c
> > index b8af96e..f070b3d 100644
> > --- a/arch/arm/kernel/pmu.c
> > +++ b/arch/arm/kernel/pmu.c
> > @@ -27,12 +27,12 @@ static struct platform_device
> *pmu_devices[ARM_NUM_PMU_DEVICES];
> >
> > static int __devinit pmu_device_probe(struct platform_device *pdev)
> > {
> > -
> > - if (pdev->id < 0 || pdev->id >= ARM_NUM_PMU_DEVICES) {
> > - pr_warning("received registration request for unknown "
> > - "device %d\n", pdev->id);
> > - return -EINVAL;
> > - }
> > + if (pmu_probe_dt(pdev) == -ENODEV)
> > + if (pdev->id < 0 || pdev->id >= ARM_NUM_PMU_DEVICES) {
> > + pr_warning("received registration request for
> unknown "
> > + "device %d\n", pdev->id);
> > + return -EINVAL;
> > + }
> >
> > if (pmu_devices[pdev->id])
> > pr_warning("registering new PMU device type %d overwrites
> "
> > @@ -45,6 +45,11 @@ static int __devinit pmu_device_probe(struct
> platform_device *pdev)
> > return 0;
> > }
> >
> > +static struct of_device_id arm_pmu_matches[] = {
> > + { .compatible = "arm,arm-pmu"},
> > + {},
> > +};
> > +
> > static struct platform_driver pmu_driver = {
> > .driver = {
> > .name = "arm-pmu",
> > @@ -54,6 +59,7 @@ static struct platform_driver pmu_driver = {
> >
> > static int __init register_pmu_driver(void)
> > {
> > + platform_init_match(&pmu_driver, arm_pmu_matches);
> > return platform_driver_register(&pmu_driver);
> > }
> > device_initcall(register_pmu_driver);
> > --
> > 1.6.3.3
> >
> >
>
>
>
> --
> Grant Likely, B.Sc., P.Eng.
> Secret Lab Technologies Ltd.
next prev parent reply other threads:[~2010-08-20 10:56 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-18 18:59 [RFC PATCH 00/14] Versatile Express device tree port Lorenzo Pieralisi
[not found] ` <1282158000-23081-1-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2010-08-18 18:59 ` [RFC PATCH 01/14] ARM: amba device memory allocation fix Lorenzo Pieralisi
[not found] ` <1282158000-23081-2-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2010-08-18 18:59 ` [RFC PATCH 02/14] ARM: vexpress: fix clocks definition to comply with new framework Lorenzo Pieralisi
[not found] ` <1282158000-23081-3-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2010-08-18 18:59 ` [RFC PATCH 03/14] ARM: fix add instruction to set the flags Lorenzo Pieralisi
[not found] ` <1282158000-23081-4-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2010-08-18 18:59 ` [RFC PATCH 04/14] ARM: r1 DT mach id init Lorenzo Pieralisi
[not found] ` <1282158000-23081-5-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2010-08-18 18:59 ` [RFC PATCH 05/14] ARM: vexpress: fix typo in addruart Lorenzo Pieralisi
[not found] ` <1282158000-23081-6-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2010-08-18 18:59 ` [RFC PATCH 06/14] platform: add function to initialize OF match table Lorenzo Pieralisi
[not found] ` <1282158000-23081-7-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2010-08-18 18:59 ` [RFC PATCH 07/14] drivers/smsc911x: add DT support Lorenzo Pieralisi
[not found] ` <1282158000-23081-8-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2010-08-18 18:59 ` [RFC PATCH 08/14] ARM: versatile-i2c driver DT port Lorenzo Pieralisi
[not found] ` <1282158000-23081-9-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2010-08-18 18:59 ` [RFC PATCH 09/14] ARM: ARM flash " Lorenzo Pieralisi
[not found] ` <1282158000-23081-10-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2010-08-18 18:59 ` [RFC PATCH 10/14] drivers/USB: isp1760 DT platform parsing and binding Lorenzo Pieralisi
[not found] ` <1282158000-23081-11-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2010-08-18 18:59 ` [RFC PATCH 11/14] ARM: PMU: add device tree probing Lorenzo Pieralisi
[not found] ` <1282158000-23081-12-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2010-08-18 18:59 ` [RFC PATCH 12/14] ARM: vexpress: add board support for DT probing Lorenzo Pieralisi
[not found] ` <1282158000-23081-13-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2010-08-18 18:59 ` [RFC PATCH 13/14] ARM: vexpress: Definition of vexpress dts specification Lorenzo Pieralisi
[not found] ` <1282158000-23081-14-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2010-08-18 19:00 ` [RFC PATCH 14/14] ARM: vexpress: add device tree build system and dtbuImage Lorenzo Pieralisi
[not found] ` <1282158000-23081-15-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2010-08-18 22:03 ` Grant Likely
2010-08-18 21:55 ` [RFC PATCH 13/14] ARM: vexpress: Definition of vexpress dts specification Grant Likely
[not found] ` <AANLkTimb1vgf1v3TQKsBFBPGrxr9iPpKY3Z6fzfAEPgZ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-08-20 17:51 ` Lorenzo Pieralisi
[not found] ` <977313260285850582@unknownmsgid>
2010-08-20 20:32 ` Grant Likely
[not found] ` <AANLkTi=WiHd06=e4d_WdCe+HMfFhj-Q=xRS_4f-TzGUs-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-08-20 21:03 ` M. Warner Losh
[not found] ` <20100820.150336.619446192412742106.imp-uzTCJ5RojNnQT0dZR+AlfA@public.gmane.org>
2010-08-20 21:37 ` Grant Likely
2010-08-23 15:47 ` Lorenzo Pieralisi
[not found] ` <1086814508538526416@unknownmsgid>
2010-08-25 8:24 ` Grant Likely
2010-08-18 22:30 ` [RFC PATCH 12/14] ARM: vexpress: add board support for DT probing Grant Likely
2010-08-18 23:56 ` Mitch Bradley
[not found] ` <4C6C7310.1070103-D5eQfiDGL7eakBO8gow8eQ@public.gmane.org>
2010-08-19 0:03 ` Grant Likely
2010-08-18 21:36 ` [RFC PATCH 11/14] ARM: PMU: add device tree probing Grant Likely
[not found] ` <AANLkTinz2CWrzPk3BtM6tWxu1udeAS1LFzjACB9spq-y-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-08-20 10:56 ` Lorenzo Pieralisi [this message]
[not found] ` <-4778531030339335058@unknownmsgid>
2010-08-25 7:39 ` Grant Likely
2010-08-18 21:27 ` [RFC PATCH 10/14] drivers/USB: isp1760 DT platform parsing and binding Grant Likely
2010-08-18 21:22 ` [RFC PATCH 09/14] ARM: ARM flash driver DT port Grant Likely
[not found] ` <AANLkTik2gPYrP+xh-jhFLWjVbr8dwCuCMnVXXvYP56e4-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-08-20 10:29 ` Catalin Marinas
[not found] ` <1282300189.3888.4.camel-uqmqopRKlSLZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2010-08-25 7:40 ` Grant Likely
2010-08-18 21:17 ` [RFC PATCH 08/14] ARM: versatile-i2c " Grant Likely
2010-08-18 21:17 ` [RFC PATCH 07/14] drivers/smsc911x: add DT support Grant Likely
2010-08-19 0:30 ` Grant Likely
2010-08-20 10:24 ` Lorenzo Pieralisi
[not found] ` <-4137939526196482437@unknownmsgid>
2010-08-20 21:14 ` Grant Likely
2010-08-18 20:58 ` [RFC PATCH 05/14] ARM: vexpress: fix typo in addruart Grant Likely
2010-08-18 20:56 ` [RFC PATCH 04/14] ARM: r1 DT mach id init Grant Likely
2010-08-18 19:26 ` [RFC PATCH 03/14] ARM: fix add instruction to set the flags Grant Likely
2010-08-18 19:25 ` [RFC PATCH 02/14] ARM: vexpress: fix clocks definition to comply with new framework Grant Likely
2010-08-18 19:24 ` [RFC PATCH 01/14] ARM: amba device memory allocation fix Grant Likely
2010-08-18 19:14 ` [RFC PATCH 00/14] Versatile Express device tree port Grant Likely
2010-08-19 2:45 ` Jeremy Kerr
2010-08-23 8:49 ` Jeremy Kerr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='7735.97662705487$1282301819@news.gmane.org' \
--to=lorenzo.pieralisi-5wv7dgnigg8@public.gmane.org \
--cc=Catalin.Marinas-5wv7dgnIgG8@public.gmane.org \
--cc=Philippe.Robin-5wv7dgnIgG8@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
--cc=jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org \
--cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
--cc=nico-vtqb6HGKxmzR7s880joybQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox