devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
	Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org>
Cc: andrew-g2DYL2Zd6BY@public.gmane.org,
	Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>,
	michael-QKn5cuLxLXY@public.gmane.org,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Subject: Re: kirkwood devicetree respin
Date: Fri, 06 Apr 2012 16:20:12 -0700	[thread overview]
Message-ID: <20120406232012.544173E111F@localhost> (raw)
In-Reply-To: <201203131557.49488.arnd-r2nGTMty4D4@public.gmane.org>

On Tue, 13 Mar 2012 15:57:49 +0000, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote:
> On Monday 12 March 2012, Jason Cooper wrote:
> > I haven't had a chance to push this series to the ml yet (maybe
> > tonight), but I wanted to give Jamie something better to go off of.
> > 
> > Only issue I have (I think unrelated) is that orion-ehci isn't coming
> > up.  But these patches don't touch that, so I think it might be my
> > config again.  Although it doesn't look like it...
> 
> I looked at your patches but also couldn't find anything that hints
> at why ehci would break.
> 
> > Also, serial comes up, works without earlyprintk, but says irq = 0.
> > Could be due to the way I setup serial in dtsi/dts.
> 
> Well, in this series you don't have any interrupt-controller node
> in the device tree, so the interrupt number lookup fails for
> any irq you put into the device tree.
> 
> I wanted to understand how this works for myself, so I've tried
> implementing it in the patch below. This probably doesn't work
> right away, but it should give you an idea of what needs to
> be done.
> 
> It is based on the latest irqdomain series from
> git://git.secretlab.ca/git/linux-2.6.git irqdomain/next
> together with your own patches.
> 
> Grant, can you have a look at this? I'm trying to help out
> multiple people right now who are converting a number of platforms
> to devicetree. It would be good to know if I'm giving the right
> recommendations.
> 
> Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
> 
> diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
> index 3474ef8..762f8e2 100644
> --- a/arch/arm/boot/dts/kirkwood.dtsi
> +++ b/arch/arm/boot/dts/kirkwood.dtsi
> @@ -2,6 +2,7 @@
>  
>  / {
>  	compatible = "mrvl,kirkwood";
> +	interrupt-parent = <&irq>;
>  
>  	ocp@f1000000 {
>  		compatible = "simple-bus";
> @@ -9,6 +10,22 @@
>  		#address-cells = <1>;
>  		#size-cells = <1>;
>  
> +		irq: irq@f1020204 {
> +			compatible = "mrvl,kirkwood-irq", "mrvl,orion-irq";
> +			interrupt-controller;
> +			#interrupt-cells = <1>;
> +			reg = <0x20204 0x4 0x14>;
> +		};
> +
> +		gpio: gpio@f1010100 {
> +			compatible = "mrvl,kirkwood-gpio", "mrvl,orion-gpio";
> +			gpio-controller;
> +			interrupt-controller;
> +			#interrupt-cells = <1>;
> +			#gpio-cells = <1>;
> +			reg = <0x10100 0x40 0x10140 0x40>;
> +		};
> +
>  		serial@12000 {
>  			compatible = "ns16550a";
>  			reg = <0x12000 0x100>;
> diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
> index 0819240..67a356c 100644
> --- a/arch/arm/mach-kirkwood/board-dt.c
> +++ b/arch/arm/mach-kirkwood/board-dt.c
> @@ -16,6 +16,7 @@
>  #include <linux/of_platform.h>
>  #include <asm/mach/arch.h>
>  #include <asm/mach/map.h>
> +#include <plat/irq.h>
>  #include <mach/bridge-regs.h>
>  #include "common.h"
>  
> @@ -67,7 +68,7 @@ DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
>  	/* Maintainer: Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org> */
>  	.map_io		= kirkwood_map_io,
>  	.init_early	= kirkwood_init_early,
> -	.init_irq	= kirkwood_init_irq,
> +	.init_irq	= orion_dt_init_irq,
>  	.timer		= &kirkwood_timer,
>  	.init_machine	= kirkwood_dt_init,
>  	.restart	= kirkwood_restart,
> diff --git a/arch/arm/mach-kirkwood/irq.c b/arch/arm/mach-kirkwood/irq.c
> index c4c68e5..a0e13d2 100644
> --- a/arch/arm/mach-kirkwood/irq.c
> +++ b/arch/arm/mach-kirkwood/irq.c
> @@ -46,3 +46,4 @@ void __init kirkwood_init_irq(void)
>  	irq_set_chained_handler(IRQ_KIRKWOOD_GPIO_HIGH_16_23,
>  				gpio_irq_handler);
>  }
> +
> diff --git a/arch/arm/plat-orion/include/plat/irq.h b/arch/arm/plat-orion/include/plat/irq.h
> index f05eeab..dc83270 100644
> --- a/arch/arm/plat-orion/include/plat/irq.h
> +++ b/arch/arm/plat-orion/include/plat/irq.h
> @@ -13,5 +13,6 @@
>  
>  void orion_irq_init(unsigned int irq_start, void __iomem *maskaddr);
>  
> +void orion_dt_init_irq(void);
>  
>  #endif
> diff --git a/arch/arm/plat-orion/irq.c b/arch/arm/plat-orion/irq.c
> index 2d5b9c1..2e8e5db 100644
> --- a/arch/arm/plat-orion/irq.c
> +++ b/arch/arm/plat-orion/irq.c
> @@ -12,7 +12,12 @@
>  #include <linux/init.h>
>  #include <linux/irq.h>
>  #include <linux/io.h>
> +#include <linux/irqdomain.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>
> +
>  #include <plat/irq.h>
> +#include <plat/gpio.h>
>  
>  void __init orion_irq_init(unsigned int irq_start, void __iomem *maskaddr)
>  {
> @@ -32,3 +37,67 @@ void __init orion_irq_init(unsigned int irq_start, void __iomem *maskaddr)
>  	irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_MASK_CACHE,
>  			       IRQ_NOREQUEST, IRQ_LEVEL | IRQ_NOPROBE);
>  }
> +
> +#ifdef CONFIG_OF
> +static int __init orion_dt_irq_setup(struct device_node *node, struct device_node *parent)
> +{
> +	int i;
> +	void __iomem *reg;
> +
> +	for (i = 0; (reg = of_iomap(node, i)) != NULL; i++) {
> +		orion_irq_init(i * 32, reg);
> +		irq_domain_add_legacy(node, 32, i * 32, 0,
> +					&irq_domain_simple_ops, NULL);

I'm rather late to this dicussion, and it appears that things have
progressed since you posted this initial patch, but I wanted to
comment on this.

I really don't want the irq_domain registration code separated from
the irq_driver itself.  That was done for some of the early DT irq
support code, but that was very much a temporary measure until the
support logic is in place.

What should be done instead is the irq controller driver should be
converted to always use an irq_domain (DT and non-DT).

> +	}
> +
> +	return 0;
> +}
> +
> +static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
> +{
> +	orion_gpio_irq_handler((long)irq_data_get_irq_handler_data(&desc->irq_data));
> +}
> +
> +unsigned int irq_orion_gpio_start = 64; /* can be overridden from platform */
> +static int __init orion_dt_gpio_irq_setup(struct device_node *node, struct device_node *parent)
> +{
> +	int i;
> +	void __iomem *reg;
> +	for (i = 0; (reg = of_iomap(node, i)) != NULL; i++) {
> +		int nr_irqs;
> +
> +		for (nr_irqs = 0; nr_irqs < 4; nr_irqs++) {
> +			int parent_irq;
> +			parent_irq = irq_of_parse_and_map(node, i * 4 + nr_irqs);
> +			if (!parent_irq)
> +				break;
> +
> +			irq_domain_add_legacy(node, 8,
> +					irq_orion_gpio_start + nr_irqs * 8,
> +					i * 32 + nr_irqs * 8,
> +					&irq_domain_simple_ops,
> +					(void *)parent_irq);

It has already been pointed out that irq_domain_add_*() can only be
called once for a give *device_node.  However, it is fine and
supported to have a single node cover all of the banks of a gpio
controller.

> +			irq_set_chained_handler(parent_irq, gpio_irq_handler);
> +			irq_set_handler_data(parent_irq,
> +					(void *)(i * 32 + nr_irqs * 8));
> +		}
> +
> +		orion_gpio_init(i * 32, nr_irqs, (u32)reg, 0,
> +				irq_orion_gpio_start);
> +		irq_orion_gpio_start += nr_irqs;
> +	}
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id orion_dt_irq_match[] __initconst = {
> +	{ .compatible = "mrvl,orion-irq", .data = &orion_dt_irq_setup },
> +	{ .compatible = "mrvl,orion-gpio", .data = &orion_dt_gpio_irq_setup },
> +	{ }
> +};
> +
> +void __init orion_dt_init_irq(void)
> +{
> +	of_irq_init(orion_dt_irq_match);
> +}
> +#endif

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies,Ltd.

      parent reply	other threads:[~2012-04-06 23:20 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20120312214325.GD5050@titan.lakedaemon.net>
     [not found] ` <20120312214325.GD5050-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
2012-03-13 15:57   ` kirkwood devicetree respin Arnd Bergmann
     [not found]     ` <201203131557.49488.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-13 16:00       ` Arnd Bergmann
2012-03-13 16:44       ` Jason Cooper
2012-03-15  2:22       ` Jason Cooper
2012-03-20 17:22       ` Jason Cooper
     [not found]         ` <20120320172238.GC2484-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
2012-03-20 18:03           ` Nicolas Pitre
     [not found]             ` <alpine.LFD.2.02.1203201401410.24151-QuJgVwGFrdf/9pzu0YdTqQ@public.gmane.org>
2012-03-20 18:24               ` Jason Cooper
     [not found]                 ` <20120320182459.GD2484-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
2012-03-20 19:03                   ` Nicolas Pitre
     [not found]                     ` <alpine.LFD.2.02.1203201454540.24151-QuJgVwGFrdf/9pzu0YdTqQ@public.gmane.org>
2012-03-20 19:16                       ` Jason Cooper
2012-03-20 19:15           ` Arnd Bergmann
     [not found]             ` <201203201915.08317.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-20 19:32               ` Andrew Lunn
     [not found]                 ` <20120320193222.GD8315-g2DYL2Zd6BY@public.gmane.org>
2012-03-20 19:44                   ` Jason Cooper
     [not found]                     ` <20120320194449.GH2484-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
2012-03-20 20:45                       ` Andrew Lunn
     [not found]                         ` <20120320204504.GE8315-g2DYL2Zd6BY@public.gmane.org>
2012-03-20 20:57                           ` Arnd Bergmann
     [not found]                             ` <201203202057.38365.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-20 22:01                               ` Jason Cooper
     [not found]                                 ` <20120320220156.GI2484-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
2012-03-20 22:15                                   ` Arnd Bergmann
     [not found]                                     ` <201203202215.09227.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-20 23:06                                       ` Jason Cooper
2012-03-21  3:54                                       ` Nicolas Pitre
     [not found]                                         ` <alpine.LFD.2.02.1203202348150.24151-QuJgVwGFrdf/9pzu0YdTqQ@public.gmane.org>
2012-03-21  8:21                                           ` Haojian Zhuang
     [not found]                                             ` <CAN1soZymEsMiivL_76o_g+-P1HhLx72Z2vbV3HBDs0x+oeWn+w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-21  8:34                                               ` Andrew Lunn
     [not found]                                                 ` <20120321083428.GA25111-g2DYL2Zd6BY@public.gmane.org>
2012-03-21  8:42                                                   ` Haojian Zhuang
     [not found]                                                     ` <CAN1soZyObqAPq=fhn8eB1z0aYqTs87oNBsF_AXbo6kq9fpvhMA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-21 10:09                                                       ` Arnd Bergmann
     [not found]                                                         ` <201203211009.40934.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-21 11:45                                                           ` Felipe Balbi
     [not found]                                                             ` <20120321114546.GC3092-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-03-21 13:17                                                               ` Arnd Bergmann
     [not found]                                                                 ` <201203211317.38339.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-21 13:22                                                                   ` Felipe Balbi
     [not found]                                                                     ` <20120321132230.GL3092-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-03-21 20:06                                                                       ` Paul Zimmerman
     [not found]                                                                         ` <A2CA0424C0A6F04399FB9E1CD98E0304090B77CA-Yu2iAY70zvrYN67daEjeMPufCSb+aD3WLzEdoUbNIic@public.gmane.org>
2012-03-22  8:13                                                                           ` Felipe Balbi
     [not found]                                                                             ` <20120322081315.GG31160-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-03-22 18:28                                                                               ` Paul Zimmerman
     [not found]                                                                                 ` <A2CA0424C0A6F04399FB9E1CD98E0304090B7F02-Yu2iAY70zvrYN67daEjeMPufCSb+aD3WLzEdoUbNIic@public.gmane.org>
2012-03-27  9:05                                                                                   ` Felipe Balbi
     [not found]                                                                                     ` <20120327090518.GL7379-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-03-27 17:40                                                                                       ` Paul Zimmerman
2012-03-21 13:36                                           ` EHCI_MV confusion was: " Jason Cooper
     [not found]                                             ` <20120321133609.GK2484-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
2012-03-21 13:56                                               ` Alan Stern
     [not found]                                                 ` <Pine.LNX.4.44L0.1203210955140.1369-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2012-03-21 15:12                                                   ` Jason Cooper
2012-03-21 16:18                                                   ` Nicolas Pitre
     [not found]                                                     ` <alpine.LFD.2.02.1203211216010.24151-QuJgVwGFrdf/9pzu0YdTqQ@public.gmane.org>
2012-03-21 16:27                                                       ` Alan Stern
     [not found]                                                         ` <Pine.LNX.4.44L0.1203211226310.1369-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2012-03-22  1:39                                                           ` Neil Zhang
2012-03-20 19:33               ` Jason Cooper
2012-04-06 23:20       ` Grant Likely [this message]

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=20120406232012.544173E111F@localhost \
    --to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
    --cc=andrew-g2DYL2Zd6BY@public.gmane.org \
    --cc=arnd-r2nGTMty4D4@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org \
    --cc=jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org \
    --cc=michael-QKn5cuLxLXY@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;
as well as URLs for NNTP newsgroup(s).