Patchwork [RFC,PATCHv1,3/5] arm: mach-kirkwood: seperate PCIe window init from other windows

login
register
mail settings
Submitter Thomas Petazzoni
Date March 27, 2013, 6:05 p.m.
Message ID <1364407504-13524-4-git-send-email-thomas.petazzoni@free-electrons.com>
Download mbox | patch
Permalink /patch/231776/
State Not Applicable
Headers show

Comments

Thomas Petazzoni - March 27, 2013, 6:05 p.m.
Since we are going to enable the usage of the mvebu PCIe driver on
Kirkwood, we need a way to disable the static addition of address
decoding windows currently done by the Kirkwood code. In order to do
this, we split the initialization of windows in two functions: one
function for the PCIe windows, and a second function for the other
windows.

Then, we have three cases:

 * non-DT platforms: PCIe windows are always initialized statically,
   by a call to kirkwood_setup_pcie_wins() in
   mach-kirkwood/commonc:kirkwood_init().

 * DT platforms that don't yet use the mvebu PCIe driver (example:
   board-iconnect.c). The kirkwood_setup_pcie_wins() function is
   called from mach-kirkwood/board-dt.c:kirkwood_dt_init(), because
   needs_pcie_wins is true.

 * DT platforms that use the mvebu PCIe driver (none as of this
   patch). They will set needs_pcie_wins to false in
   mach-kirkwood/board-dt.c:kirkwood_dt_init().

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 arch/arm/mach-kirkwood/board-dt.c |    5 +++++
 arch/arm/mach-kirkwood/common.c   |    7 ++++++-
 arch/arm/mach-kirkwood/common.h   |    1 +
 3 files changed, 12 insertions(+), 1 deletion(-)
Jason Gunthorpe - March 27, 2013, 6:35 p.m.
On Wed, Mar 27, 2013 at 07:05:02PM +0100, Thomas Petazzoni wrote:

This all looks really great to me, I hope to try it as well when I get
time. But just one small suggestion:

> diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
> index ea49476..1b4675f 100644
> +++ b/arch/arm/mach-kirkwood/board-dt.c
> @@ -72,6 +72,8 @@ static void __init kirkwood_of_clk_init(void)
>  
>  static void __init kirkwood_dt_init(void)
>  {
> +	int needs_pcie_wins = 1;
> +
>  	pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
>  
>  	/*
> @@ -144,6 +146,9 @@ static void __init kirkwood_dt_init(void)
>  	if (of_machine_is_compatible("usi,topkick"))
>  		usi_topkick_init();
>  
> +	if (needs_pcie_wins)
> +		kirkwood_setup_pcie_wins();
> +
>  	of_platform_populate(NULL, kirkwood_dt_match_table, NULL, NULL);
>  }

Moving the window setup into mach-kirkwood/pcie.c:kirkwood_pcie_init
would avoid this needs_pcie_wins thing since kirkwood_pcie_init will
naturally never be called once the other patches are applied.

Cheers,
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Thomas Petazzoni - March 27, 2013, 8:17 p.m.
Dear Jason Gunthorpe,

On Wed, 27 Mar 2013 12:35:34 -0600, Jason Gunthorpe wrote:
> On Wed, Mar 27, 2013 at 07:05:02PM +0100, Thomas Petazzoni wrote:
> 
> This all looks really great to me, I hope to try it as well when I get
> time. But just one small suggestion:
> 
> > diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
> > index ea49476..1b4675f 100644
> > +++ b/arch/arm/mach-kirkwood/board-dt.c
> > @@ -72,6 +72,8 @@ static void __init kirkwood_of_clk_init(void)
> >  
> >  static void __init kirkwood_dt_init(void)
> >  {
> > +	int needs_pcie_wins = 1;
> > +
> >  	pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
> >  
> >  	/*
> > @@ -144,6 +146,9 @@ static void __init kirkwood_dt_init(void)
> >  	if (of_machine_is_compatible("usi,topkick"))
> >  		usi_topkick_init();
> >  
> > +	if (needs_pcie_wins)
> > +		kirkwood_setup_pcie_wins();
> > +
> >  	of_platform_populate(NULL, kirkwood_dt_match_table, NULL, NULL);
> >  }
> 
> Moving the window setup into mach-kirkwood/pcie.c:kirkwood_pcie_init
> would avoid this needs_pcie_wins thing since kirkwood_pcie_init will
> naturally never be called once the other patches are applied.

Ah, yes, right. I now remember you made this suggestion when reviewing
the mvebu-mbus patch set, and I replied that I would do it when I'll
start working on using the pci-mvebu driver on Kirkwood. It looks like
it's time for me to honor this commitment :-)

Thanks for the feedback,

Thomas

Patch

diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
index ea49476..1b4675f 100644
--- a/arch/arm/mach-kirkwood/board-dt.c
+++ b/arch/arm/mach-kirkwood/board-dt.c
@@ -72,6 +72,8 @@  static void __init kirkwood_of_clk_init(void)
 
 static void __init kirkwood_dt_init(void)
 {
+	int needs_pcie_wins = 1;
+
 	pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
 
 	/*
@@ -144,6 +146,9 @@  static void __init kirkwood_dt_init(void)
 	if (of_machine_is_compatible("usi,topkick"))
 		usi_topkick_init();
 
+	if (needs_pcie_wins)
+		kirkwood_setup_pcie_wins();
+
 	of_platform_populate(NULL, kirkwood_dt_match_table, NULL, NULL);
 }
 
diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
index c2cae69..9a5d65a 100644
--- a/arch/arm/mach-kirkwood/common.c
+++ b/arch/arm/mach-kirkwood/common.c
@@ -652,7 +652,7 @@  char * __init kirkwood_id(void)
 	}
 }
 
-void __init kirkwood_setup_wins(void)
+void __init kirkwood_setup_pcie_wins(void)
 {
 	/*
 	 * The PCIe windows will no longer be statically allocated
@@ -678,6 +678,10 @@  void __init kirkwood_setup_wins(void)
 					  KIRKWOOD_PCIE1_MEM_SIZE,
 					  MVEBU_MBUS_NO_REMAP,
 					  MVEBU_MBUS_PCI_MEM);
+}
+
+void __init kirkwood_setup_wins(void)
+{
 	mvebu_mbus_add_window("nand", KIRKWOOD_NAND_MEM_PHYS_BASE,
 			      KIRKWOOD_NAND_MEM_SIZE);
 	mvebu_mbus_add_window("sram", KIRKWOOD_SRAM_PHYS_BASE,
@@ -710,6 +714,7 @@  void __init kirkwood_init(void)
 	writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
 
 	kirkwood_setup_wins();
+	kirkwood_setup_pcie_wins();
 
 	kirkwood_l2_init();
 
diff --git a/arch/arm/mach-kirkwood/common.h b/arch/arm/mach-kirkwood/common.h
index e24f743..de280f5 100644
--- a/arch/arm/mach-kirkwood/common.h
+++ b/arch/arm/mach-kirkwood/common.h
@@ -31,6 +31,7 @@  void kirkwood_init_early(void);
 void kirkwood_init_irq(void);
 
 void kirkwood_setup_wins(void);
+void kirkwood_setup_pcie_wins(void);
 
 void kirkwood_enable_pcie(void);
 void kirkwood_pcie_id(u32 *dev, u32 *rev);