diff mbox

[2/3] ARM: Orion: Bind the orion bridge interrupt controller through DT

Message ID 1355188683-18208-2-git-send-email-jgunthorpe@obsidianresearch.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jason Gunthorpe Dec. 11, 2012, 1:18 a.m. UTC
This adds the common DT code and board support for kirkwood and dove

- Add the marvell,orion-bridge-intc DT node to the DTSI file
- Make the call to orion_bridge_irq_init happen only in the non-DT
  case

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
---
 .../devicetree/bindings/arm/mrvl/intc.txt          |   21 ++++++++++++++++++++
 arch/arm/boot/dts/dove.dtsi                        |   10 +++++++++
 arch/arm/boot/dts/kirkwood.dtsi                    |   12 +++++++++++
 arch/arm/mach-dove/common.c                        |    4 ---
 arch/arm/mach-dove/irq.c                           |    5 ++++
 arch/arm/mach-kirkwood/common.c                    |    4 ---
 arch/arm/mach-kirkwood/irq.c                       |    5 ++++
 arch/arm/plat-orion/irq.c                          |   20 +++++++++++++++++++
 8 files changed, 73 insertions(+), 8 deletions(-)

Comments

Andrew Lunn Dec. 11, 2012, 6:24 a.m. UTC | #1
On Mon, Dec 10, 2012 at 06:18:02PM -0700, Jason Gunthorpe wrote:
> This adds the common DT code and board support for kirkwood and dove
> 
> - Add the marvell,orion-bridge-intc DT node to the DTSI file
> - Make the call to orion_bridge_irq_init happen only in the non-DT
>   case
> 
> Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> ---
>  .../devicetree/bindings/arm/mrvl/intc.txt          |   21 ++++++++++++++++++++
>  arch/arm/boot/dts/dove.dtsi                        |   10 +++++++++
>  arch/arm/boot/dts/kirkwood.dtsi                    |   12 +++++++++++
>  arch/arm/mach-dove/common.c                        |    4 ---
>  arch/arm/mach-dove/irq.c                           |    5 ++++
>  arch/arm/mach-kirkwood/common.c                    |    4 ---
>  arch/arm/mach-kirkwood/irq.c                       |    5 ++++
>  arch/arm/plat-orion/irq.c                          |   20 +++++++++++++++++++
>  8 files changed, 73 insertions(+), 8 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/arm/mrvl/intc.txt b/Documentation/devicetree/bindings/arm/mrvl/intc.txt
> index 8b53273..cf633f1 100644
> --- a/Documentation/devicetree/bindings/arm/mrvl/intc.txt
> +++ b/Documentation/devicetree/bindings/arm/mrvl/intc.txt
> @@ -58,3 +58,24 @@ Example:
>                  reg = <0xfed20204 0x04>,
>  		      <0xfed20214 0x04>;
>          };
> +
> +* Marvell Orion Bridge Interrupt controller
> +
> +Required properties
> +- compatible :  Should be "marvell,orion-bridge-intc".
> +- #interrupt-cells: Specifies the number of cells needed to encode an
> +  interrupt source. Supported value is <1>.
> +- interrupt-controller : Declare this node to be an interrupt controller.
> +- interrupts: The interrupt number the bridge is attached to on the main
> +              controller.
> +- reg : Interrupt cause address.
> +
> +Example:
> +
> +	bridge_intc: bridge_intc@20110 {
> +		compatible = "marvell,orion-bridge-intc";
> +		interrupt-controller;
> +		#interrupt-cells = <1>;
> +		interrupts = <1>;
> +		reg = <0x20110 0x08>;
> +        };
> diff --git a/arch/arm/boot/dts/dove.dtsi b/arch/arm/boot/dts/dove.dtsi
> index 5a00022..b726ba8 100644
> --- a/arch/arm/boot/dts/dove.dtsi
> +++ b/arch/arm/boot/dts/dove.dtsi
> @@ -67,6 +67,8 @@
>  			status = "disabled";
>  		};
>  
> +		/* The interrupt controller stanzas are in an
> +		 * order that matches irqs.h */
>  		gpio0: gpio@d0400 {
>  			compatible = "marvell,orion-gpio";
>  			#gpio-cells = <2>;
> @@ -93,6 +95,14 @@
>  			ngpio = <8>;
>  		};
>  
> +		bridge_intc: bridge_intc@20110 {
> +			compatible = "marvell,orion-bridge-intc";
> +			interrupt-controller;
> +			#interrupt-cells = <1>;
> +			interrupts = <0>;
> +			reg = <0x20110 0x08>;
> +		};
> +
>  		spi0: spi@10600 {
>  			compatible = "marvell,orion-spi";
>  			#address-cells = <1>;
> diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
> index 4e5b815..854e532 100644
> --- a/arch/arm/boot/dts/kirkwood.dtsi
> +++ b/arch/arm/boot/dts/kirkwood.dtsi
> @@ -19,6 +19,8 @@
>  		#address-cells = <1>;
>  		#size-cells = <1>;
>  
> +		/* The interrupt controller stanzas are in an
> +		 * order that matches irqs.h */
>  		gpio0: gpio@10100 {
>  			compatible = "marvell,orion-gpio";
>  			#gpio-cells = <2>;
> @@ -37,6 +39,14 @@
>  			interrupts = <39>, <40>, <41>;
>  		};
>  
> +		bridge_intc: bridge_intc@20110 {
> +			compatible = "marvell,orion-bridge-intc";
> +			interrupt-controller;
> +			#interrupt-cells = <1>;
> +			interrupts = <1>;
> +			reg = <0x20110 0x08>;
> +		};
> +
>  		serial@12000 {
>  			compatible = "ns16550a";
>  			reg = <0x12000 0x100>;
> @@ -73,6 +83,8 @@
>  
>  		wdt@20300 {
>  			compatible = "marvell,orion-wdt";
> +			interrupt-parent = <&bridge_intc>;
> +			interrupts = <3>;
>  			reg = <0x20300 0x28>;
>  			status = "okay";
>  		};
> diff --git a/arch/arm/mach-dove/common.c b/arch/arm/mach-dove/common.c
> index 6bad21b..b570211 100644
> --- a/arch/arm/mach-dove/common.c
> +++ b/arch/arm/mach-dove/common.c
> @@ -243,10 +243,6 @@ static int __init dove_find_tclk(void)
>  static void __init dove_timer_init(void)
>  {
>  	dove_tclk = dove_find_tclk();
> -	if (orion_bridge_irq_init(IRQ_DOVE_BRIDGE,
> -				  IRQ_DOVE_BRIDGE_START,
> -				  BRIDGE_CAUSE, NULL))
> -		panic("Unable to setup bridge irqs");
>  	orion_time_init(IRQ_DOVE_BRIDGE_TIMER1, dove_tclk);
>  }
>  
> diff --git a/arch/arm/mach-dove/irq.c b/arch/arm/mach-dove/irq.c
> index bc4344a..bcb193f 100644
> --- a/arch/arm/mach-dove/irq.c
> +++ b/arch/arm/mach-dove/irq.c
> @@ -139,4 +139,9 @@ void __init dove_init_irq(void)
>  		set_irq_flags(i, IRQF_VALID);
>  	}
>  	irq_set_chained_handler(IRQ_DOVE_PMU, pmu_irq_handler);
> +
> +	if (orion_bridge_irq_init(IRQ_DOVE_BRIDGE,
> +				  IRQ_DOVE_BRIDGE_START,
> +				  BRIDGE_CAUSE, NULL))
> +		panic("Unable to setup bridge irqs");
>  }
> diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
> index ccd3ed5..7398f8b 100644
> --- a/arch/arm/mach-kirkwood/common.c
> +++ b/arch/arm/mach-kirkwood/common.c
> @@ -535,10 +535,6 @@ static void __init kirkwood_timer_init(void)
>  {
>  	kirkwood_tclk = kirkwood_find_tclk();
>  
> -	if (orion_bridge_irq_init(IRQ_KIRKWOOD_BRIDGE,
> -				  IRQ_KIRKWOOD_BRIDGE_START,
> -				  BRIDGE_CAUSE, NULL))
> -		panic("Unable to setup bridge irqs");
>  	orion_time_init(IRQ_KIRKWOOD_BRIDGE_TIMER1, kirkwood_tclk);
>  }
>  
> diff --git a/arch/arm/mach-kirkwood/irq.c b/arch/arm/mach-kirkwood/irq.c
> index 8847035..a1388ef 100644
> --- a/arch/arm/mach-kirkwood/irq.c
> +++ b/arch/arm/mach-kirkwood/irq.c
> @@ -41,4 +41,9 @@ void __init kirkwood_init_irq(void)
>  			IRQ_KIRKWOOD_GPIO_START, gpio0_irqs);
>  	orion_gpio_init(NULL, 32, 18, GPIO_HIGH_VIRT_BASE, 0,
>  			IRQ_KIRKWOOD_GPIO_START + 32, gpio1_irqs);
> +
> +	if (orion_bridge_irq_init(IRQ_KIRKWOOD_BRIDGE,
> +				  IRQ_KIRKWOOD_BRIDGE_START,
> +				  BRIDGE_CAUSE, NULL))
> +		panic("Unable to setup bridge irqs");
>  }
> diff --git a/arch/arm/plat-orion/irq.c b/arch/arm/plat-orion/irq.c
> index a903012..2dcccda 100644
> --- a/arch/arm/plat-orion/irq.c
> +++ b/arch/arm/plat-orion/irq.c
> @@ -131,9 +131,29 @@ static int __init orion_add_irq_domain(struct device_node *np,
>  	return 0;
>  }
>  
> +static int __init orion_add_bridge_irq_domain(
> +	struct device_node *np, struct device_node *interrupt_parent)
> +{
> +	void __iomem *base;
> +	int bridge_irq;
> +
> +	base = of_iomap(np, 0);
> +	if (!base)
> +		return -ENODEV;
> +	bridge_irq = irq_of_parse_and_map(np, 0);
> +	/* FIXME: irq_of_parse_and_map returns 0 on error, but on Dove the
> +	 * bridge IRQ is 0.
> +	if (!bridge_irq)
> +		return -ENODEV;*/
> +
> +	return orion_bridge_irq_init(bridge_irq, -1, base, np);

Hi Jason

So does this mean for Dove it will currently always fail?

   Thanks
	Andrew
Jason Gunthorpe Dec. 11, 2012, 6:58 a.m. UTC | #2
> > +	bridge_irq = irq_of_parse_and_map(np, 0);
> > +	/* FIXME: irq_of_parse_and_map returns 0 on error, but on Dove the
> > +	 * bridge IRQ is 0.
> > +	if (!bridge_irq)
> > +		return -ENODEV;*/
> > +
> > +	return orion_bridge_irq_init(bridge_irq, -1, base, np);
> 
> So does this mean for Dove it will currently always fail?

I guess that is hard to read without syntax hi-lighting, the 'if' is
also commented out.

I was hopefull it would work as is, but looking deeper at
irq_of_parse_and_map and its call tree makes me doubtfull now..

Fixing irq_of_parse_and_map is way to big a job for me :(

What to do from here? Add a dummy 0 interrupt to dove? Take dove out
of this patch series?

Jason
Andrew Lunn Dec. 11, 2012, 7:13 a.m. UTC | #3
On Mon, Dec 10, 2012 at 11:58:13PM -0700, Jason Gunthorpe wrote:
> > > +	bridge_irq = irq_of_parse_and_map(np, 0);
> > > +	/* FIXME: irq_of_parse_and_map returns 0 on error, but on Dove the
> > > +	 * bridge IRQ is 0.
> > > +	if (!bridge_irq)
> > > +		return -ENODEV;*/
> > > +
> > > +	return orion_bridge_irq_init(bridge_irq, -1, base, np);
> > 
> > So does this mean for Dove it will currently always fail?
> 
> I guess that is hard to read without syntax hi-lighting, the 'if' is
> also commented out.
> 
> I was hopefull it would work as is, but looking deeper at
> irq_of_parse_and_map and its call tree makes me doubtfull now..
> 
> Fixing irq_of_parse_and_map is way to big a job for me :(

Hi Jason

https://lwn.net/Articles/470820/

I don't think its fixable. 

> What to do from here? Add a dummy 0 interrupt to dove? Take dove out
> of this patch series?

We need to see how other machine remap 0 to some other value and
implement that for Dove.

	  Andrew
Jason Gunthorpe Dec. 11, 2012, 6:55 p.m. UTC | #4
On Tue, Dec 11, 2012 at 08:13:33AM +0100, Andrew Lunn wrote:
> On Mon, Dec 10, 2012 at 11:58:13PM -0700, Jason Gunthorpe wrote:
> > > > +	bridge_irq = irq_of_parse_and_map(np, 0);
> > > > +	/* FIXME: irq_of_parse_and_map returns 0 on error, but on Dove the
> > > > +	 * bridge IRQ is 0.
> > > > +	if (!bridge_irq)
> > > > +		return -ENODEV;*/
> > > > +
> > > > +	return orion_bridge_irq_init(bridge_irq, -1, base, np);
> > > 
> > > So does this mean for Dove it will currently always fail?
> > 
> > I guess that is hard to read without syntax hi-lighting, the 'if' is
> > also commented out.
> > 
> > I was hopefull it would work as is, but looking deeper at
> > irq_of_parse_and_map and its call tree makes me doubtfull now..
> > 
> > Fixing irq_of_parse_and_map is way to big a job for me :(
> 
> Hi Jason
> 
> https://lwn.net/Articles/470820/
> 
> I don't think its fixable. 

Oh right. That.

Looking at this some more, I think it should work, but not for very
good reasons.. irq_of_parse_and_map will return 0 on dove. It returns
0 because it is going through its error paths because it saw a 0 deep
inside, but it still returns 0.

orion_bridge_irq_init will work with 0 as a bridge_irq, we know this
because the timer code was using those code paths for a long time

> We need to see how other machine remap 0 to some other value and
> implement that for Dove.

It looks like it is straightforward to adjust Dove's
get_irqnr_and_base to add 1 to all the interrupt numbers, adjust
irqs.h to add 1, and adjust the irq setup. There would be no
performance penalty to doing this, but testing would be need to be
sure 100% of changes were made. If the above works it would be better
to do that sort of change after, or maybe after the non-DT code is
purged...

Kirkwood is already OK WRT the 0 IRQ, it is handled internally to
get_irqnr_and_base.

So, I will suggest to please test on dove as-is...

Did the other patches look OK?

I threw together an interrupt panic patch for the wdt, and that works
OK as well, so the kirkwood configuration is tested with this
series.

116:    4995890  orion_bridge  orion_tick
117:          0  orion_bridge  orion_wdt

Thanks,
Jason
Jason Cooper Jan. 10, 2013, 1:47 a.m. UTC | #5
Sebastian,

On Tue, Dec 11, 2012 at 11:55:35AM -0700, Jason Gunthorpe wrote:
> On Tue, Dec 11, 2012 at 08:13:33AM +0100, Andrew Lunn wrote:
> > On Mon, Dec 10, 2012 at 11:58:13PM -0700, Jason Gunthorpe wrote:
> > > > > +	bridge_irq = irq_of_parse_and_map(np, 0);
> > > > > +	/* FIXME: irq_of_parse_and_map returns 0 on error, but on Dove the
> > > > > +	 * bridge IRQ is 0.
> > > > > +	if (!bridge_irq)
> > > > > +		return -ENODEV;*/
> > > > > +
> > > > > +	return orion_bridge_irq_init(bridge_irq, -1, base, np);
> > > > 
> > > > So does this mean for Dove it will currently always fail?
> > > 
> > > I guess that is hard to read without syntax hi-lighting, the 'if' is
> > > also commented out.
> > > 
> > > I was hopefull it would work as is, but looking deeper at
> > > irq_of_parse_and_map and its call tree makes me doubtfull now..
> > > 
> > > Fixing irq_of_parse_and_map is way to big a job for me :(
> > 
> > Hi Jason
> > 
> > https://lwn.net/Articles/470820/
> > 
> > I don't think its fixable. 
> 
> Oh right. That.
> 
> Looking at this some more, I think it should work, but not for very
> good reasons.. irq_of_parse_and_map will return 0 on dove. It returns
> 0 because it is going through its error paths because it saw a 0 deep
> inside, but it still returns 0.
> 
> orion_bridge_irq_init will work with 0 as a bridge_irq, we know this
> because the timer code was using those code paths for a long time
> 
> > We need to see how other machine remap 0 to some other value and
> > implement that for Dove.
> 
> It looks like it is straightforward to adjust Dove's
> get_irqnr_and_base to add 1 to all the interrupt numbers, adjust
> irqs.h to add 1, and adjust the irq setup. There would be no
> performance penalty to doing this, but testing would be need to be
> sure 100% of changes were made. If the above works it would be better
> to do that sort of change after, or maybe after the non-DT code is
> purged...
> 
> Kirkwood is already OK WRT the 0 IRQ, it is handled internally to
> get_irqnr_and_base.
> 
> So, I will suggest to please test on dove as-is...

Did you have a chance to test this on dove?

thx,

Jason.
Andrew Lunn Jan. 10, 2013, 6:07 a.m. UTC | #6
On Wed, Jan 09, 2013 at 08:47:34PM -0500, Jason Cooper wrote:
> Sebastian,
> 
> On Tue, Dec 11, 2012 at 11:55:35AM -0700, Jason Gunthorpe wrote:
> > On Tue, Dec 11, 2012 at 08:13:33AM +0100, Andrew Lunn wrote:
> > > On Mon, Dec 10, 2012 at 11:58:13PM -0700, Jason Gunthorpe wrote:
> > > > > > +	bridge_irq = irq_of_parse_and_map(np, 0);
> > > > > > +	/* FIXME: irq_of_parse_and_map returns 0 on error, but on Dove the
> > > > > > +	 * bridge IRQ is 0.
> > > > > > +	if (!bridge_irq)
> > > > > > +		return -ENODEV;*/
> > > > > > +
> > > > > > +	return orion_bridge_irq_init(bridge_irq, -1, base, np);
> > > > > 
> > > > > So does this mean for Dove it will currently always fail?
> > > > 
> > > > I guess that is hard to read without syntax hi-lighting, the 'if' is
> > > > also commented out.
> > > > 
> > > > I was hopefull it would work as is, but looking deeper at
> > > > irq_of_parse_and_map and its call tree makes me doubtfull now..
> > > > 
> > > > Fixing irq_of_parse_and_map is way to big a job for me :(
> > > 
> > > Hi Jason
> > > 
> > > https://lwn.net/Articles/470820/
> > > 
> > > I don't think its fixable. 
> > 
> > Oh right. That.
> > 
> > Looking at this some more, I think it should work, but not for very
> > good reasons.. irq_of_parse_and_map will return 0 on dove. It returns
> > 0 because it is going through its error paths because it saw a 0 deep
> > inside, but it still returns 0.
> > 
> > orion_bridge_irq_init will work with 0 as a bridge_irq, we know this
> > because the timer code was using those code paths for a long time
> > 
> > > We need to see how other machine remap 0 to some other value and
> > > implement that for Dove.
> > 
> > It looks like it is straightforward to adjust Dove's
> > get_irqnr_and_base to add 1 to all the interrupt numbers, adjust
> > irqs.h to add 1, and adjust the irq setup. There would be no
> > performance penalty to doing this, but testing would be need to be
> > sure 100% of changes were made. If the above works it would be better
> > to do that sort of change after, or maybe after the non-DT code is
> > purged...
> > 
> > Kirkwood is already OK WRT the 0 IRQ, it is handled internally to
> > get_irqnr_and_base.
> > 
> > So, I will suggest to please test on dove as-is...
> 
> Did you have a chance to test this on dove?

Hi Jason

We discussed this a little and I prefer Sebastians implementation.

Sebastian, do you have time to work on your code and get it ready?

Thanks
	Andrew
Sebastian Hesselbarth Jan. 10, 2013, 9:54 a.m. UTC | #7
On 01/10/2013 07:07 AM, Andrew Lunn wrote:
> On Wed, Jan 09, 2013 at 08:47:34PM -0500, Jason Cooper wrote:
>> Sebastian,
>>
>> On Tue, Dec 11, 2012 at 11:55:35AM -0700, Jason Gunthorpe wrote:
>>> On Tue, Dec 11, 2012 at 08:13:33AM +0100, Andrew Lunn wrote:
>>>> On Mon, Dec 10, 2012 at 11:58:13PM -0700, Jason Gunthorpe wrote:
>>>>>>> +	bridge_irq = irq_of_parse_and_map(np, 0);
>>>>>>> +	/* FIXME: irq_of_parse_and_map returns 0 on error, but on Dove the
>>>>>>> +	 * bridge IRQ is 0.
>>>>>>> +	if (!bridge_irq)
>>>>>>> +		return -ENODEV;*/
>>>>>>> +
>>>>>>> +	return orion_bridge_irq_init(bridge_irq, -1, base, np);
>>>>>>
>>>>>> So does this mean for Dove it will currently always fail?
>>>>>
>>>>> I guess that is hard to read without syntax hi-lighting, the 'if' is
>>>>> also commented out.
>>>>>
>>>>> I was hopefull it would work as is, but looking deeper at
>>>>> irq_of_parse_and_map and its call tree makes me doubtfull now..
>>>>>
>>>>> Fixing irq_of_parse_and_map is way to big a job for me :(
>>>>
>>>> Hi Jason
>>>>
>>>> https://lwn.net/Articles/470820/
>>>>
>>>> I don't think its fixable.
>>>
>>> Oh right. That.
>>>
>>> Looking at this some more, I think it should work, but not for very
>>> good reasons.. irq_of_parse_and_map will return 0 on dove. It returns
>>> 0 because it is going through its error paths because it saw a 0 deep
>>> inside, but it still returns 0.
>>>
>>> orion_bridge_irq_init will work with 0 as a bridge_irq, we know this
>>> because the timer code was using those code paths for a long time
>>>
>>>> We need to see how other machine remap 0 to some other value and
>>>> implement that for Dove.
>>>
>>> It looks like it is straightforward to adjust Dove's
>>> get_irqnr_and_base to add 1 to all the interrupt numbers, adjust
>>> irqs.h to add 1, and adjust the irq setup. There would be no
>>> performance penalty to doing this, but testing would be need to be
>>> sure 100% of changes were made. If the above works it would be better
>>> to do that sort of change after, or maybe after the non-DT code is
>>> purged...
>>>
>>> Kirkwood is already OK WRT the 0 IRQ, it is handled internally to
>>> get_irqnr_and_base.
>>>
>>> So, I will suggest to please test on dove as-is...
>>
>> Did you have a chance to test this on dove?
>
> Hi Jason
>
> We discussed this a little and I prefer Sebastians implementation.
>
> Sebastian, do you have time to work on your code and get it ready?

Jason, Andrew,

we chose to jump to irqchip instead of fixing old code. I thought
Jason Gunthorpe volunteered to get it ready? Moving to irqchip also
requires clksrc-orion or reimplementing orion into clksrc-mvebu.

I can do it but it depends on when it should be ready?

Sebastian
Jason Gunthorpe Jan. 10, 2013, 6:48 p.m. UTC | #8
On Thu, Jan 10, 2013 at 10:54:13AM +0100, Sebastian Hesselbarth wrote:

> >>>Kirkwood is already OK WRT the 0 IRQ, it is handled internally to
> >>>get_irqnr_and_base.
> >>>
> >>>So, I will suggest to please test on dove as-is...
> >>
> >>Did you have a chance to test this on dove?
> >
> >Hi Jason
> >
> >We discussed this a little and I prefer Sebastians implementation.
> >
> >Sebastian, do you have time to work on your code and get it ready?
> 
> Jason, Andrew,
> 
> we chose to jump to irqchip instead of fixing old code. I thought
> Jason Gunthorpe volunteered to get it ready? Moving to irqchip also
> requires clksrc-orion or reimplementing orion into clksrc-mvebu.

I looked into it, but at the time there was so much churn going into
the merge window that it was too much to tackle, then there was/is
holidays for me :) Feburary would probably be the soonest I could
actually get my systems running the latest kernels and do any work on
this subject.

The drivers Sebastian posted looked close to what I posted, a few
things like edge interrupts should be copied over from my patches
though..

The irqchip can be done prior to the timer, if the bridge cause
decoding is left disabled in the DT then the existing timer should
still work..

There is a bunch of prep stuff that may still be pending:
 - Fixup remaining drivers (usb? ethernet?) to have DT bindings and
   get the IRQ number through DT
 - Fixup the GPIO driver to dynamically allocate IRQs rather than
   having a hardwired start (did the pinctl change fix this?)
 - Separate the non-DT and DT IRQ related stuff, the IRQ numbering
   changes with the irqchip driver's dynamic allocation. This solves
   the 0 IRQ problem..
 - Remove non-DT code? Andrew was talking about this..

Jason
Jason Cooper Jan. 10, 2013, 6:57 p.m. UTC | #9
Jason,

On Thu, Jan 10, 2013 at 11:48:32AM -0700, Jason Gunthorpe wrote:
> There is a bunch of prep stuff that may still be pending:
>  - Fixup remaining drivers (usb? ethernet?) to have DT bindings and
>    get the IRQ number through DT

any chance I could get you post your changes to the ethernet driver (DT
bindings)?  iirc, you said you had based them off of Ian Molton's work.
Even if you posted them RFC, it'd be a good place to start from,
reignite conversation and so forth.

thx,

Jason.
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/arm/mrvl/intc.txt b/Documentation/devicetree/bindings/arm/mrvl/intc.txt
index 8b53273..cf633f1 100644
--- a/Documentation/devicetree/bindings/arm/mrvl/intc.txt
+++ b/Documentation/devicetree/bindings/arm/mrvl/intc.txt
@@ -58,3 +58,24 @@  Example:
                 reg = <0xfed20204 0x04>,
 		      <0xfed20214 0x04>;
         };
+
+* Marvell Orion Bridge Interrupt controller
+
+Required properties
+- compatible :  Should be "marvell,orion-bridge-intc".
+- #interrupt-cells: Specifies the number of cells needed to encode an
+  interrupt source. Supported value is <1>.
+- interrupt-controller : Declare this node to be an interrupt controller.
+- interrupts: The interrupt number the bridge is attached to on the main
+              controller.
+- reg : Interrupt cause address.
+
+Example:
+
+	bridge_intc: bridge_intc@20110 {
+		compatible = "marvell,orion-bridge-intc";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		interrupts = <1>;
+		reg = <0x20110 0x08>;
+        };
diff --git a/arch/arm/boot/dts/dove.dtsi b/arch/arm/boot/dts/dove.dtsi
index 5a00022..b726ba8 100644
--- a/arch/arm/boot/dts/dove.dtsi
+++ b/arch/arm/boot/dts/dove.dtsi
@@ -67,6 +67,8 @@ 
 			status = "disabled";
 		};
 
+		/* The interrupt controller stanzas are in an
+		 * order that matches irqs.h */
 		gpio0: gpio@d0400 {
 			compatible = "marvell,orion-gpio";
 			#gpio-cells = <2>;
@@ -93,6 +95,14 @@ 
 			ngpio = <8>;
 		};
 
+		bridge_intc: bridge_intc@20110 {
+			compatible = "marvell,orion-bridge-intc";
+			interrupt-controller;
+			#interrupt-cells = <1>;
+			interrupts = <0>;
+			reg = <0x20110 0x08>;
+		};
+
 		spi0: spi@10600 {
 			compatible = "marvell,orion-spi";
 			#address-cells = <1>;
diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
index 4e5b815..854e532 100644
--- a/arch/arm/boot/dts/kirkwood.dtsi
+++ b/arch/arm/boot/dts/kirkwood.dtsi
@@ -19,6 +19,8 @@ 
 		#address-cells = <1>;
 		#size-cells = <1>;
 
+		/* The interrupt controller stanzas are in an
+		 * order that matches irqs.h */
 		gpio0: gpio@10100 {
 			compatible = "marvell,orion-gpio";
 			#gpio-cells = <2>;
@@ -37,6 +39,14 @@ 
 			interrupts = <39>, <40>, <41>;
 		};
 
+		bridge_intc: bridge_intc@20110 {
+			compatible = "marvell,orion-bridge-intc";
+			interrupt-controller;
+			#interrupt-cells = <1>;
+			interrupts = <1>;
+			reg = <0x20110 0x08>;
+		};
+
 		serial@12000 {
 			compatible = "ns16550a";
 			reg = <0x12000 0x100>;
@@ -73,6 +83,8 @@ 
 
 		wdt@20300 {
 			compatible = "marvell,orion-wdt";
+			interrupt-parent = <&bridge_intc>;
+			interrupts = <3>;
 			reg = <0x20300 0x28>;
 			status = "okay";
 		};
diff --git a/arch/arm/mach-dove/common.c b/arch/arm/mach-dove/common.c
index 6bad21b..b570211 100644
--- a/arch/arm/mach-dove/common.c
+++ b/arch/arm/mach-dove/common.c
@@ -243,10 +243,6 @@  static int __init dove_find_tclk(void)
 static void __init dove_timer_init(void)
 {
 	dove_tclk = dove_find_tclk();
-	if (orion_bridge_irq_init(IRQ_DOVE_BRIDGE,
-				  IRQ_DOVE_BRIDGE_START,
-				  BRIDGE_CAUSE, NULL))
-		panic("Unable to setup bridge irqs");
 	orion_time_init(IRQ_DOVE_BRIDGE_TIMER1, dove_tclk);
 }
 
diff --git a/arch/arm/mach-dove/irq.c b/arch/arm/mach-dove/irq.c
index bc4344a..bcb193f 100644
--- a/arch/arm/mach-dove/irq.c
+++ b/arch/arm/mach-dove/irq.c
@@ -139,4 +139,9 @@  void __init dove_init_irq(void)
 		set_irq_flags(i, IRQF_VALID);
 	}
 	irq_set_chained_handler(IRQ_DOVE_PMU, pmu_irq_handler);
+
+	if (orion_bridge_irq_init(IRQ_DOVE_BRIDGE,
+				  IRQ_DOVE_BRIDGE_START,
+				  BRIDGE_CAUSE, NULL))
+		panic("Unable to setup bridge irqs");
 }
diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
index ccd3ed5..7398f8b 100644
--- a/arch/arm/mach-kirkwood/common.c
+++ b/arch/arm/mach-kirkwood/common.c
@@ -535,10 +535,6 @@  static void __init kirkwood_timer_init(void)
 {
 	kirkwood_tclk = kirkwood_find_tclk();
 
-	if (orion_bridge_irq_init(IRQ_KIRKWOOD_BRIDGE,
-				  IRQ_KIRKWOOD_BRIDGE_START,
-				  BRIDGE_CAUSE, NULL))
-		panic("Unable to setup bridge irqs");
 	orion_time_init(IRQ_KIRKWOOD_BRIDGE_TIMER1, kirkwood_tclk);
 }
 
diff --git a/arch/arm/mach-kirkwood/irq.c b/arch/arm/mach-kirkwood/irq.c
index 8847035..a1388ef 100644
--- a/arch/arm/mach-kirkwood/irq.c
+++ b/arch/arm/mach-kirkwood/irq.c
@@ -41,4 +41,9 @@  void __init kirkwood_init_irq(void)
 			IRQ_KIRKWOOD_GPIO_START, gpio0_irqs);
 	orion_gpio_init(NULL, 32, 18, GPIO_HIGH_VIRT_BASE, 0,
 			IRQ_KIRKWOOD_GPIO_START + 32, gpio1_irqs);
+
+	if (orion_bridge_irq_init(IRQ_KIRKWOOD_BRIDGE,
+				  IRQ_KIRKWOOD_BRIDGE_START,
+				  BRIDGE_CAUSE, NULL))
+		panic("Unable to setup bridge irqs");
 }
diff --git a/arch/arm/plat-orion/irq.c b/arch/arm/plat-orion/irq.c
index a903012..2dcccda 100644
--- a/arch/arm/plat-orion/irq.c
+++ b/arch/arm/plat-orion/irq.c
@@ -131,9 +131,29 @@  static int __init orion_add_irq_domain(struct device_node *np,
 	return 0;
 }
 
+static int __init orion_add_bridge_irq_domain(
+	struct device_node *np, struct device_node *interrupt_parent)
+{
+	void __iomem *base;
+	int bridge_irq;
+
+	base = of_iomap(np, 0);
+	if (!base)
+		return -ENODEV;
+	bridge_irq = irq_of_parse_and_map(np, 0);
+	/* FIXME: irq_of_parse_and_map returns 0 on error, but on Dove the
+	 * bridge IRQ is 0.
+	if (!bridge_irq)
+		return -ENODEV;*/
+
+	return orion_bridge_irq_init(bridge_irq, -1, base, np);
+}
+
 static const struct of_device_id orion_irq_match[] = {
 	{ .compatible = "marvell,orion-intc",
 	  .data = orion_add_irq_domain, },
+	{ .compatible = "marvell,orion-bridge-intc",
+	  .data = orion_add_bridge_irq_domain, },
 	{},
 };