* [PATCH 2/2] powerpc: create mpc85xx pci err platform device for EDAC
@ 2008-02-11 20:34 Dave Jiang
2008-02-11 21:56 ` Kumar Gala
2008-02-11 23:32 ` Stephen Rothwell
0 siblings, 2 replies; 4+ messages in thread
From: Dave Jiang @ 2008-02-11 20:34 UTC (permalink / raw)
To: galak, linuxppc-dev
Creating a platform device for the PCI error registers in order for the
mpc85xx EDAC driver to pick up proper resources. This is to prevent the
EDAC driver from monopolizing the of_device and thus preventing future PCI
code from using the PCI of_device(s).
Signed-off-by: Dave Jiang <djiang@mvista.com>
---
commit 9436d0792f1352e9a034436c82b2229622fc3364
tree 0beeed478786b16cdb33be41ac803f781b8ea0cc
parent 187841bf9dff25e4ac1a7174daa55bb036c724b1
author Dave Jiang <djiang@blade.(none)> Mon, 11 Feb 2008 12:55:45 -0700
committer Dave Jiang <djiang@blade.(none)> Mon, 11 Feb 2008 12:55:45 -0700
arch/powerpc/sysdev/fsl_pci.c | 52 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index bf13c21..c064c91 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -19,6 +19,8 @@
#include <linux/string.h>
#include <linux/init.h>
#include <linux/bootmem.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
#include <asm/io.h>
#include <asm/prom.h>
@@ -27,6 +29,56 @@
#include <sysdev/fsl_soc.h>
#include <sysdev/fsl_pci.h>
+#ifdef CONFIG_85xx
+/* setting up 85xx PCI error platform device for EDAC consumption */
+static int __init mpc85xx_pcierr_setup(void)
+{
+ struct device_node *np = NULL;
+ struct of_device *of_dev;
+ struct platform_device *pdev;
+ struct resource res[2];
+ int id = 0;
+ int err;
+
+ for_each_compatible_node(np, "pci", "fsl,mpc8540-pci") {
+ memset(res, 0, sizeof(struct resource) * 2);
+ if (of_address_to_resource(np, 0, &res[0])) {
+ printk(KERN_WARNING "Can't get pci register base!\n");
+ continue;
+ }
+
+ /* move start to where the error registers are */
+ res[0].start += 0xe00;
+
+ of_irq_to_resource(np, 0, &res[1]);
+
+ of_dev = of_find_device_by_node(np);
+ if (!of_dev)
+ return -ENODEV;
+
+ pdev = platform_device_alloc("mpc85xx_pci_err", id++);
+ if (!pdev)
+ return -ENOMEM;
+
+ err = platform_device_add_resources(pdev, res, 2);
+ if (err)
+ goto error;
+
+ pdev->dev.parent = &of_dev->dev;
+
+ err = platform_device_add(pdev);
+ if (err)
+ goto error;
+ }
+ return 0;
+
+error:
+ platform_device_put(pdev);
+ return err;
+}
+late_initcall(mpc85xx_pcierr_setup);
+#endif
+
/* atmu setup for fsl pci/pcie controller */
void __init setup_pci_atmu(struct pci_controller *hose, struct resource *rsrc)
{
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] powerpc: create mpc85xx pci err platform device for EDAC
2008-02-11 20:34 [PATCH 2/2] powerpc: create mpc85xx pci err platform device for EDAC Dave Jiang
@ 2008-02-11 21:56 ` Kumar Gala
2008-02-13 21:41 ` Dave Jiang
2008-02-11 23:32 ` Stephen Rothwell
1 sibling, 1 reply; 4+ messages in thread
From: Kumar Gala @ 2008-02-11 21:56 UTC (permalink / raw)
To: Dave Jiang; +Cc: linuxppc-dev
On Feb 11, 2008, at 2:34 PM, Dave Jiang wrote:
> Creating a platform device for the PCI error registers in order for
> the
> mpc85xx EDAC driver to pick up proper resources. This is to prevent
> the
> EDAC driver from monopolizing the of_device and thus preventing
> future PCI
> code from using the PCI of_device(s).
>
> Signed-off-by: Dave Jiang <djiang@mvista.com>
I'd rather we didn't add new platform devices, but do this via
of_platform in the driver itself.
Also, we need to 'rename' the compatible field for some of these
devices.
- k
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] powerpc: create mpc85xx pci err platform device for EDAC
2008-02-11 20:34 [PATCH 2/2] powerpc: create mpc85xx pci err platform device for EDAC Dave Jiang
2008-02-11 21:56 ` Kumar Gala
@ 2008-02-11 23:32 ` Stephen Rothwell
1 sibling, 0 replies; 4+ messages in thread
From: Stephen Rothwell @ 2008-02-11 23:32 UTC (permalink / raw)
To: Dave Jiang; +Cc: linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 868 bytes --]
Hi Dave,
On Mon, 11 Feb 2008 13:34:45 -0700 Dave Jiang <djiang@mvista.com> wrote:
>
> +++ b/arch/powerpc/sysdev/fsl_pci.c
> +static int __init mpc85xx_pcierr_setup(void)
> +{
> + struct device_node *np = NULL;
You don't need to initialiase this as it is first used in
for_each_compatible_node().
> + for_each_compatible_node(np, "pci", "fsl,mpc8540-pci") {
> + of_dev = of_find_device_by_node(np);
> + if (!of_dev)
> + return -ENODEV;
You need an of_node_put(np) before you return.
> + pdev = platform_device_alloc("mpc85xx_pci_err", id++);
> + if (!pdev)
> + return -ENOMEM;
And again.
> + }
> + return 0;
> +
> +error:
> + platform_device_put(pdev);
You need an of_node_put(np) here.
> + return err;
> +}
--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] powerpc: create mpc85xx pci err platform device for EDAC
2008-02-11 21:56 ` Kumar Gala
@ 2008-02-13 21:41 ` Dave Jiang
0 siblings, 0 replies; 4+ messages in thread
From: Dave Jiang @ 2008-02-13 21:41 UTC (permalink / raw)
To: Kumar Gala; +Cc: linuxppc-dev
Kumar Gala wrote:
> On Feb 11, 2008, at 2:34 PM, Dave Jiang wrote:
>
>> Creating a platform device for the PCI error registers in order for
>> the
>> mpc85xx EDAC driver to pick up proper resources. This is to prevent
>> the
>> EDAC driver from monopolizing the of_device and thus preventing
>> future PCI
>> code from using the PCI of_device(s).
>>
>> Signed-off-by: Dave Jiang <djiang@mvista.com>
>
> I'd rather we didn't add new platform devices, but do this via
> of_platform in the driver itself.
Kumar,
Here's the thread of discussion between Arnd Bergmann and I why platform
device is used. The original patch was of_device based....
http://ozlabs.org/pipermail/linuxppc-dev/2007-July/thread.html
Does it still make sense or do I need to go back to of_device?
>
> Also, we need to 'rename' the compatible field for some of these
> devices.
>
> - k
>
--
------------------------------------------------------
Dave Jiang
Software Engineer
MontaVista Software, Inc.
http://www.mvista.com
------------------------------------------------------
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-02-13 21:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-11 20:34 [PATCH 2/2] powerpc: create mpc85xx pci err platform device for EDAC Dave Jiang
2008-02-11 21:56 ` Kumar Gala
2008-02-13 21:41 ` Dave Jiang
2008-02-11 23:32 ` Stephen Rothwell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.