[PATCH V4] powerpc/MPIC: Add get_version API both for internal and external use

2013-04-07 Thread Jia Hongtao
MPIC version is useful information for both mpic_alloc() and mpic_init().
The patch provide an API to get MPIC version for reusing the code.
Also, some other IP block may need MPIC version for their own use.
The API for external use is also provided.

Signed-off-by: Jia Hongtao 
Signed-off-by: Li Yang 
---
Changes for V4:
* change the name of function from mpic_get_version() to
  fsl_mpic_get_version().

Changes for V3:
* change the name of function from mpic_primary_get_version() to
  fsl_mpic_primary_get_version().
* return 0 if mpic_primary is null.

Changes for V2:
* Using mpic_get_version() to implement mpic_primary_get_version()

 arch/powerpc/include/asm/mpic.h |  3 +++
 arch/powerpc/sysdev/mpic.c  | 29 ++---
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
index c0f9ef9..ea6bf72 100644
--- a/arch/powerpc/include/asm/mpic.h
+++ b/arch/powerpc/include/asm/mpic.h
@@ -393,6 +393,9 @@ struct mpic
 #defineMPIC_REGSET_STANDARDMPIC_REGSET(0)  /* Original 
MPIC */
 #defineMPIC_REGSET_TSI108  MPIC_REGSET(1)  /* Tsi108/109 
PIC */
 
+/* Get the version of primary MPIC */
+extern u32 fsl_mpic_primary_get_version(void);
+
 /* Allocate the controller structure and setup the linux irq descs
  * for the range if interrupts passed in. No HW initialization is
  * actually performed.
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index d30e6a6..48c8fae 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1165,10 +1165,30 @@ static struct irq_domain_ops mpic_host_ops = {
.xlate = mpic_host_xlate,
 };
 
+static u32 fsl_mpic_get_version(struct mpic *mpic)
+{
+   u32 brr1;
+
+   brr1 = _mpic_read(mpic->reg_type, &mpic->thiscpuregs,
+   MPIC_FSL_BRR1);
+
+   return brr1 & MPIC_FSL_BRR1_VER;
+}
+
 /*
  * Exported functions
  */
 
+u32 fsl_mpic_primary_get_version(void)
+{
+   struct mpic *mpic = mpic_primary;
+
+   if (mpic)
+   return fsl_mpic_get_version(mpic);
+
+   return 0;
+}
+
 struct mpic * __init mpic_alloc(struct device_node *node,
phys_addr_t phys_addr,
unsigned int flags,
@@ -1315,7 +1335,6 @@ struct mpic * __init mpic_alloc(struct device_node *node,
mpic_map(mpic, mpic->paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 
0x1000);
 
if (mpic->flags & MPIC_FSL) {
-   u32 brr1;
int ret;
 
/*
@@ -1326,9 +1345,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
mpic_map(mpic, mpic->paddr, &mpic->thiscpuregs,
 MPIC_CPU_THISBASE, 0x1000);
 
-   brr1 = _mpic_read(mpic->reg_type, &mpic->thiscpuregs,
-   MPIC_FSL_BRR1);
-   fsl_version = brr1 & MPIC_FSL_BRR1_VER;
+   fsl_version = fsl_mpic_get_version(mpic);
 
/* Error interrupt mask register (EIMR) is required for
 * handling individual device error interrupts. EIMR
@@ -1518,9 +1535,7 @@ void __init mpic_init(struct mpic *mpic)
mpic_cpu_write(MPIC_INFO(CPU_CURRENT_TASK_PRI), 0xf);
 
if (mpic->flags & MPIC_FSL) {
-   u32 brr1 = _mpic_read(mpic->reg_type, &mpic->thiscpuregs,
- MPIC_FSL_BRR1);
-   u32 version = brr1 & MPIC_FSL_BRR1_VER;
+   u32 version = fsl_mpic_get_version(mpic);
 
/*
 * Timer group B is present at the latest in MPIC 3.1 (e.g.
-- 
1.8.0


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


RE: [PATCH 1/4][v2] powerpc/fsl-booke: Add initial silicon device tree files for B4860 and B4420

2013-04-07 Thread Leekha Shaveta-B20052


-Original Message-
From: Leekha Shaveta-B20052 
Sent: Friday, April 05, 2013 9:13 PM
To: 'Kumar Gala'
Cc: linuxppc-dev@lists.ozlabs.org list
Subject: RE: [PATCH 1/4][v2] powerpc/fsl-booke: Add initial silicon device tree 
files for B4860 and B4420



-Original Message-
From: Kumar Gala [mailto:ga...@kernel.crashing.org] 
Sent: Friday, April 05, 2013 7:53 PM
To: Leekha Shaveta-B20052
Cc: linuxppc-dev@lists.ozlabs.org list
Subject: Re: [PATCH 1/4][v2] powerpc/fsl-booke: Add initial silicon device tree 
files for B4860 and B4420


On Apr 5, 2013, at 1:33 AM, Shaveta Leekha wrote:

> B4860 and B4420 are similar that share some commonalities
> 
> * common features have been added in b4si-pre.dtsi and b4si-post.dtsi
> * differences are added in respective silicon files of B4860 and B4420
> 
> There are several things missing from the device trees of B4860 and B4420:
> 
> * DPAA related nodes (Qman, Bman, Fman, Rman)
> * DSP related nodes/information
> * serdes, sfp(security fuse processor), thermal, gpio, maple, cpri, 
> quad timers nodes
> 
> Signed-off-by: Shaveta Leekha 
> Signed-off-by: Zhao Chenhui 
> Signed-off-by: Li Yang 
> Signed-off-by: Tang Yuantian 
> Signed-off-by: Varun Sethi 
> Signed-off-by: Minghuan Lian 
> Signed-off-by: Ramneek Mehresh 
> Signed-off-by: Kumar Gala 
> Signed-off-by: Andy Fleming 
> Signed-off-by: Vakul Garg 
> ---
> v2: 
>  - incorporated review comments on commits message
>  - change unit address of cpu nodes to match the reg property
> 
> arch/powerpc/boot/dts/fsl/b4420si-post.dtsi |   94 ++
> arch/powerpc/boot/dts/fsl/b4420si-pre.dtsi  |   49 +
> arch/powerpc/boot/dts/fsl/b4860si-post.dtsi |  138 ++
> arch/powerpc/boot/dts/fsl/b4860si-pre.dtsi  |   59 ++
> arch/powerpc/boot/dts/fsl/b4si-post.dtsi|  262 +++
> arch/powerpc/boot/dts/fsl/b4si-pre.dtsi |   65 +++
> 6 files changed, 667 insertions(+), 0 deletions(-) create mode 100644 
> arch/powerpc/boot/dts/fsl/b4420si-post.dtsi
> create mode 100644 arch/powerpc/boot/dts/fsl/b4420si-pre.dtsi
> create mode 100644 arch/powerpc/boot/dts/fsl/b4860si-post.dtsi
> create mode 100644 arch/powerpc/boot/dts/fsl/b4860si-pre.dtsi
> create mode 100644 arch/powerpc/boot/dts/fsl/b4si-post.dtsi
> create mode 100644 arch/powerpc/boot/dts/fsl/b4si-pre.dtsi

Is there a reason you didn't get rid of b4si-pre.dtsi and just merge it into 
b4860si-pre.dtsi & b4420-pre.dtsi?
[SL] No particular reason. I have just tried to re-factored these files as you 
have suggested. Hence managed the commonalities in B4 files and differences in 
B4860's and B4420's respective files to reduce duplicity.

Regards,
Shaveta 

[SL] Kumar, please suggest. 

Regards,
Shaveta

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 3/3] powerpc: Set default VGA device

2013-04-07 Thread Michael Ellerman
On Fri, Apr 05, 2013 at 02:24:09PM -0600, Bjorn Helgaas wrote:
> On Thu, Apr 4, 2013 at 3:58 PM, Brian King  wrote:
> > @@ -1725,3 +1726,15 @@ static void fixup_hide_host_resource_fsl
> >  }
> >  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MOTOROLA, PCI_ANY_ID, 
> > fixup_hide_host_resource_fsl);
> >  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_FREESCALE, PCI_ANY_ID, 
> > fixup_hide_host_resource_fsl);
> > +
> > +static void fixup_vga(struct pci_dev *pdev)
> > +{
> > +   u16 cmd;
> > +
> > +   pci_read_config_word(pdev, PCI_COMMAND, &cmd);
> > +   if ((cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) || 
> > !vga_default_device())
> > +   vga_set_default_device(pdev);
> > +
> > +}
> > +DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
> > + PCI_CLASS_DISPLAY_VGA, 8, fixup_vga);
> 
> This not really an arch-specific issue, so it's a shame to add another
> arch-specific quirk for it (in addition to the x86 and ia64 ones we
> already have).
> 
> In b5e4efe7e0, Eiichiro Oiwa  tried to
> make this quirk generic, but the implementation was naive and it
> didn't work for sparc64.  There's a good thread about the sparc issue
> at https://lkml.org/lkml/2006/10/19/17
> 
> The outcome was to basically revert back to arch-specific quirks with
> 6b5c76b8e2, but I think the generic version probably could have been
> made to work, possibly with a pcibios hook or something for anything
> that really is arch-dependent, like the shadowed ROM image.
> 
> This particular patch is arch-specific, and I'm not going to try to
> nack it because I'm not the powerpc maintainer, but I will certainly
> try to help you if you want to push on making a generic version.

OK.

Looking at x86, ia64 and ours, there's a fair bit of difference.

x86/ia64 both walk up the parents checking PCI_BRIDGE_CTL_VGA, which
powerpc doesn't (though maybe it should?).

x86/ia64 set IORESOURCE_ROM_SHADOW, which powerpc doesn't.

ia64 doesn't call vga_set_default_device(), x86 and powerpc do.

So we'll merge this and maybe someone can tease out the common bits, but
personally I don't see that there's an obvious chunk of generic logic.

cheers
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 2/3] powerpc: Enable boot_vga sysfs attribute for graphics adapters on Power

2013-04-07 Thread Michael Ellerman
On Fri, Apr 05, 2013 at 02:11:01PM -0600, Bjorn Helgaas wrote:
> On Thu, Apr 4, 2013 at 3:58 PM, Brian King  wrote:
> >
> > Initialize dev->dev.type such that the PCI group attributes for boot_vga
> > and SR-IOV can be displayed if appropriate. This fixes an issue seen on
> > Power preventing X from auto initializing a graphics adapter when using KMS.
> >
> > Signed-off-by: Brian King 
> > ---
> >
> >  arch/powerpc/kernel/pci_of_scan.c |1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff -puN arch/powerpc/kernel/pci_of_scan.c~powerpc_set_pci_dev_type 
> > arch/powerpc/kernel/pci_of_scan.c
> > --- linux/arch/powerpc/kernel/pci_of_scan.c~powerpc_set_pci_dev_type
> > 2013-04-03 09:43:19.0 -0500
> > +++ linux-bjking1/arch/powerpc/kernel/pci_of_scan.c 2013-04-03 
> > 09:43:19.0 -0500
> > @@ -141,6 +141,7 @@ struct pci_dev *of_create_pci_dev(struct
> > dev->dev.of_node = of_node_get(node);
> > dev->dev.parent = bus->bridge;
> > dev->dev.bus = &pci_bus_type;
> > +   dev->dev.type = &pci_dev_type;
> > dev->devfn = devfn;
> > dev->multifunction = 0; /* maybe a lie? */
> > dev->needs_freset = 0;  /* pcie fundamental reset required 
> > */
> 
> I think sparc has the same issue in its own copy of of_create_pci_dev().
> 
> Of course, both of_create_pci_dev() implementations are basically
> copies of the generic pci_setup_device() that most arches use.  That's
> the reason why I wish sparc and powerpc had used config space
> accessors that hid the OF mangling internally so they could use the
> generic pci_setup_device() instead of cloning it.
> 
> Of course, they don't, and that's too much work for fixing this issue,
> but if anybody wanted to work on that, I think it would be an
> interesting project.
> 
> But what if you set dev->dev.type in alloc_pci_dev()?  I think if you
> did that, you wouldn't need to export "pci_dev_type," and  it should
> fix this for both powerpc and sparc.

That sounds good, Brian can you confirm that works and send a new series
using that technique.

cheers
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 3/3] powerpc: Set default VGA device

2013-04-07 Thread Benjamin Herrenschmidt
On Mon, 2013-04-08 at 15:21 +1000, Michael Ellerman wrote:

> Looking at x86, ia64 and ours, there's a fair bit of difference.
> 
> x86/ia64 both walk up the parents checking PCI_BRIDGE_CTL_VGA, which
> powerpc doesn't (though maybe it should?).

Unclear for several reasons.

That bit indicates that the bridge forwards the hard coded legacy VGA IO
ports and memory aperture. These are not necessary to get modern video
cards going. Only if legacy modes are used.

On x86, that tends to be the case (is it always even with EFI
nowadays ?).

On other architectures that is not necessarily the case. The firmware
can (and will) initialize the card using MMIO entirely and even if
possible disabling the legacy stuff, which means that turning those bits
on in the bridge is also unnecessary.

In fact, on such setups, the isn't really a concept of a "primary" video
card to begin with.

On the other hand, that also means that a video card initialized like
that is pretty much out of the grasp of the vga arbiter which has no
effect on it either.

Also be careful that while it may be relevant on x86, the VGA fwd bit is
not on the PCIe root complex on IBM machines.

Finally, P8 has no IO space at all...

> x86/ia64 set IORESOURCE_ROM_SHADOW, which powerpc doesn't.
> 
> ia64 doesn't call vga_set_default_device(), x86 and powerpc do.
> 
> So we'll merge this and maybe someone can tease out the common bits, but
> personally I don't see that there's an obvious chunk of generic logic.

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev