linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Porting MIPS IRQ handler to ARM
@ 2015-09-01 16:14 Mason
  2015-09-01 16:58 ` Florian Fainelli
  2015-09-01 17:07 ` Måns Rullgård
  0 siblings, 2 replies; 15+ messages in thread
From: Mason @ 2015-09-01 16:14 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

I'm trying to port to my ARM platform: IRQ handling code written for MIPS.

https://github.com/mansr/linux-tangox/blob/master/drivers/irqchip/irq-tangox.c

static void tangox_irq_handler(unsigned int irq, struct irq_desc *desc)
{
	struct irq_domain *dom = irq_desc_get_handler_data(desc);
	struct tangox_irq_chip *chip = dom->host_data;
	unsigned int status, status_hi;
	unsigned int sr = 0;

	status = intc_readl(chip, chip->ctl + IRQ_STATUS);
	status_hi = intc_readl(chip, chip->ctl + IRQ_CTL_HI + IRQ_STATUS);

	if (!(status | status_hi)) {
		spurious_interrupt();
		return;
	}

	if (chip->mask)
		sr = clear_c0_status(chip->mask);

	tangox_dispatch_irqs(dom, status, 0);
	tangox_dispatch_irqs(dom, status_hi, 32);

	if (chip->mask)
		write_c0_status(sr);
}

  CC      drivers/irqchip/irq-tangox.o
drivers/irqchip/irq-tangox.c: In function 'tangox_irq_handler':
drivers/irqchip/irq-tangox.c:85:3: error: implicit declaration of function 'spurious_interrupt' [-Werror=implicit-function-declaration]
   spurious_interrupt();
   ^
drivers/irqchip/irq-tangox.c:90:3: error: implicit declaration of function 'clear_c0_status' [-Werror=implicit-function-declaration]
   sr = clear_c0_status(chip->mask);
   ^
drivers/irqchip/irq-tangox.c:96:3: error: implicit declaration of function 'write_c0_status' [-Werror=implicit-function-declaration]
   write_c0_status(sr);
   ^
drivers/irqchip/irq-tangox.c: In function 'tangox_irq_init':
drivers/irqchip/irq-tangox.c:205:41: error: 'STATUSB_IP2' undeclared (first use in this function)
  chip->mask = ((1 << (irq - 2)) - 1) << STATUSB_IP2;
                                         ^
drivers/irqchip/irq-tangox.c:205:41: note: each undeclared identifier is reported only once for each function it appears in


In arch/mips/kernel/irq.c

atomic_t irq_err_count;

int arch_show_interrupts(struct seq_file *p, int prec)
{
	seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
	return 0;
}

asmlinkage void spurious_interrupt(void)
{
	atomic_inc(&irq_err_count);
}


In arch/arm/kernel/irq.c

unsigned long irq_err_count;

int arch_show_interrupts(struct seq_file *p, int prec)
{
#ifdef CONFIG_FIQ
	show_fiq_list(p, prec);
#endif
#ifdef CONFIG_SMP
	show_ipi_list(p, prec);
#endif
	seq_printf(p, "%*s: %10lu\n", prec, "Err", irq_err_count);
	return 0;
}

static inline void ack_bad_irq(int irq)
{
	extern unsigned long irq_err_count;
	irq_err_count++;
	pr_crit("unexpected IRQ trap at vector %02x\n", irq);
}


Replacing spurious_interrupt() with ack_bad_irq() doesn't feel correct.
(Writing to the console from an IRQ handler can't be good?)

It's the same interrupt controller hardware on the MIPS and ARM platforms.
Are there platform-agnostic / generic alternatives?


In arch/mips/include/asm/mipsregs.h

/*
 * Manipulate bits in a c0 register.
 */
#define __BUILD_SET_C0(name)
set_c0_##name
clear_c0_##name
change_c0_##name
__BUILD_SET_C0(status)

#define read_c0_status()	__read_32bit_c0_register($12, 0)
#define write_c0_status(val)	__write_32bit_c0_register($12, 0, val)

Obviously very platform-specific...
Guess I'll have to take a look@the MIPS programmer's guide.

Regards.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Porting MIPS IRQ handler to ARM
  2015-09-01 16:14 Porting MIPS IRQ handler to ARM Mason
@ 2015-09-01 16:58 ` Florian Fainelli
  2015-09-02 16:25   ` Mason
  2015-09-01 17:07 ` Måns Rullgård
  1 sibling, 1 reply; 15+ messages in thread
From: Florian Fainelli @ 2015-09-01 16:58 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/09/15 09:14, Mason wrote:
> Hello,
> 
> I'm trying to port to my ARM platform: IRQ handling code written for MIPS.
> 
> https://github.com/mansr/linux-tangox/blob/master/drivers/irqchip/irq-tangox.c

On MIPS, you usually have a built-in interrupt controller in the CPU off
which you can have as many interrupt controllers which are SoC-specific.
This means that you typically register a cascading handler for one of
the MIPS HW interrupts (typically 2 and 3).

Calling clear_c0_status() and write_c0_status() in tangox_irq_handler()
sounds like a layering violation here, this should be taken care of by
the interrupt code once proper parenting between the MIPS IRQ controller
and your tangox controller is established.

You could take a look at drivers/irqchip/irq-bcm7038-l1.c and
arch/mips/bmips/irq.c for an example of an interrupt controller that
works on both ARM and MIPS.

> 
> static void tangox_irq_handler(unsigned int irq, struct irq_desc *desc)
> {
> 	struct irq_domain *dom = irq_desc_get_handler_data(desc);
> 	struct tangox_irq_chip *chip = dom->host_data;
> 	unsigned int status, status_hi;
> 	unsigned int sr = 0;
> 
> 	status = intc_readl(chip, chip->ctl + IRQ_STATUS);
> 	status_hi = intc_readl(chip, chip->ctl + IRQ_CTL_HI + IRQ_STATUS);
> 
> 	if (!(status | status_hi)) {
> 		spurious_interrupt();
> 		return;
> 	}
> 
> 	if (chip->mask)
> 		sr = clear_c0_status(chip->mask);
> 
> 	tangox_dispatch_irqs(dom, status, 0);
> 	tangox_dispatch_irqs(dom, status_hi, 32);
> 
> 	if (chip->mask)
> 		write_c0_status(sr);
> }
> 
>   CC      drivers/irqchip/irq-tangox.o
> drivers/irqchip/irq-tangox.c: In function 'tangox_irq_handler':
> drivers/irqchip/irq-tangox.c:85:3: error: implicit declaration of function 'spurious_interrupt' [-Werror=implicit-function-declaration]
>    spurious_interrupt();
>    ^
> drivers/irqchip/irq-tangox.c:90:3: error: implicit declaration of function 'clear_c0_status' [-Werror=implicit-function-declaration]
>    sr = clear_c0_status(chip->mask);
>    ^
> drivers/irqchip/irq-tangox.c:96:3: error: implicit declaration of function 'write_c0_status' [-Werror=implicit-function-declaration]
>    write_c0_status(sr);
>    ^
> drivers/irqchip/irq-tangox.c: In function 'tangox_irq_init':
> drivers/irqchip/irq-tangox.c:205:41: error: 'STATUSB_IP2' undeclared (first use in this function)
>   chip->mask = ((1 << (irq - 2)) - 1) << STATUSB_IP2;
>                                          ^
> drivers/irqchip/irq-tangox.c:205:41: note: each undeclared identifier is reported only once for each function it appears in
> 
> 
> In arch/mips/kernel/irq.c
> 
> atomic_t irq_err_count;
> 
> int arch_show_interrupts(struct seq_file *p, int prec)
> {
> 	seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
> 	return 0;
> }
> 
> asmlinkage void spurious_interrupt(void)
> {
> 	atomic_inc(&irq_err_count);
> }
> 
> 
> In arch/arm/kernel/irq.c
> 
> unsigned long irq_err_count;
> 
> int arch_show_interrupts(struct seq_file *p, int prec)
> {
> #ifdef CONFIG_FIQ
> 	show_fiq_list(p, prec);
> #endif
> #ifdef CONFIG_SMP
> 	show_ipi_list(p, prec);
> #endif
> 	seq_printf(p, "%*s: %10lu\n", prec, "Err", irq_err_count);
> 	return 0;
> }
> 
> static inline void ack_bad_irq(int irq)
> {
> 	extern unsigned long irq_err_count;
> 	irq_err_count++;
> 	pr_crit("unexpected IRQ trap at vector %02x\n", irq);
> }
> 
> 
> Replacing spurious_interrupt() with ack_bad_irq() doesn't feel correct.
> (Writing to the console from an IRQ handler can't be good?)
> 
> It's the same interrupt controller hardware on the MIPS and ARM platforms.
> Are there platform-agnostic / generic alternatives?
> 
> 
> In arch/mips/include/asm/mipsregs.h
> 
> /*
>  * Manipulate bits in a c0 register.
>  */
> #define __BUILD_SET_C0(name)
> set_c0_##name
> clear_c0_##name
> change_c0_##name
> __BUILD_SET_C0(status)
> 
> #define read_c0_status()	__read_32bit_c0_register($12, 0)
> #define write_c0_status(val)	__write_32bit_c0_register($12, 0, val)
> 
> Obviously very platform-specific...
> Guess I'll have to take a look at the MIPS programmer's guide.
> 
> Regards.
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 


-- 
Florian

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Porting MIPS IRQ handler to ARM
  2015-09-01 16:14 Porting MIPS IRQ handler to ARM Mason
  2015-09-01 16:58 ` Florian Fainelli
@ 2015-09-01 17:07 ` Måns Rullgård
  2015-09-01 17:57   ` Mason
  1 sibling, 1 reply; 15+ messages in thread
From: Måns Rullgård @ 2015-09-01 17:07 UTC (permalink / raw)
  To: linux-arm-kernel

Mason <slash.tmp@free.fr> writes:

> Hello,
>
> I'm trying to port to my ARM platform: IRQ handling code written for MIPS.
>
> https://github.com/mansr/linux-tangox/blob/master/drivers/irqchip/irq-tangox.c

Go get the latest version of that file.  It should work on ARM now.

-- 
M?ns Rullg?rd
mans at mansr.com

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Porting MIPS IRQ handler to ARM
  2015-09-01 17:07 ` Måns Rullgård
@ 2015-09-01 17:57   ` Mason
  2015-09-01 18:07     ` Florian Fainelli
  0 siblings, 1 reply; 15+ messages in thread
From: Mason @ 2015-09-01 17:57 UTC (permalink / raw)
  To: linux-arm-kernel

M?ns Rullg?rd wrote:

> Mason wrote:
> 
>> I'm trying to port to my ARM platform: IRQ handling code written for MIPS.
>> https://github.com/mansr/linux-tangox/blob/master/drivers/irqchip/irq-tangox.c
> 
> Go get the latest version of that file.  It should work on ARM now.

It would probably have taken me days to figure out I could just delete
the arch-dependent code. Linux internals are so hard to grok... <sigh>

Would you like me to ask if they can send you a dev board? :-)

By the way, it seems the generic UART driver does not use interrupts,
which would explain why the console works despite my busted device tree.
Does that mean that the driver polls? (I'll take a closer look tomorrow.)

Is it not worth it to use interrupts for slow devices?

Regards.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Porting MIPS IRQ handler to ARM
  2015-09-01 17:57   ` Mason
@ 2015-09-01 18:07     ` Florian Fainelli
  2015-09-01 19:01       ` Mason
  0 siblings, 1 reply; 15+ messages in thread
From: Florian Fainelli @ 2015-09-01 18:07 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/09/15 10:57, Mason wrote:
> M?ns Rullg?rd wrote:
> 
>> Mason wrote:
>>
>>> I'm trying to port to my ARM platform: IRQ handling code written for MIPS.
>>> https://github.com/mansr/linux-tangox/blob/master/drivers/irqchip/irq-tangox.c
>>
>> Go get the latest version of that file.  It should work on ARM now.
> 
> It would probably have taken me days to figure out I could just delete
> the arch-dependent code. Linux internals are so hard to grok... <sigh>
> 
> Would you like me to ask if they can send you a dev board? :-)
> 
> By the way, it seems the generic UART driver does not use interrupts,
> which would explain why the console works despite my busted device tree.
> Does that mean that the driver polls? (I'll take a closer look tomorrow.)

Kernel console is buffer and polled, user-space (tty) console uses
interrupts.
-- 
Florian

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Porting MIPS IRQ handler to ARM
  2015-09-01 18:07     ` Florian Fainelli
@ 2015-09-01 19:01       ` Mason
  0 siblings, 0 replies; 15+ messages in thread
From: Mason @ 2015-09-01 19:01 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/09/2015 20:07, Florian Fainelli wrote:

> On 01/09/15 10:57, Mason wrote:
> 
>> By the way, it seems the generic UART driver does not use interrupts,
>> which would explain why the console works despite my busted device tree.
>> Does that mean that the driver polls? (I'll take a closer look tomorrow.)
> 
> Kernel console is buffer and polled, user-space (tty) console uses
> interrupts.

Thanks for clearing that up.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Porting MIPS IRQ handler to ARM
  2015-09-01 16:58 ` Florian Fainelli
@ 2015-09-02 16:25   ` Mason
  2015-09-02 17:17     ` Måns Rullgård
  0 siblings, 1 reply; 15+ messages in thread
From: Mason @ 2015-09-02 16:25 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/09/2015 18:58, Florian Fainelli wrote:

> On 01/09/15 09:14, Mason wrote:
>
>> I'm trying to port to my ARM platform: IRQ handling code written for MIPS.
>> https://github.com/mansr/linux-tangox/blob/master/drivers/irqchip/irq-tangox.c
> 
> Calling clear_c0_status() and write_c0_status() in tangox_irq_handler()
> sounds like a layering violation here, this should be taken care of by
> the interrupt code once proper parenting between the MIPS IRQ controller
> and your tangox controller is established.

Following Mans' suggestion, I deleted the arch-specific code, and
the driver now compiles and links.

Unfortunately, I still can't get it to work, and I've been banging
my head against the wall over this device tree monstrosity.

tangox_irq_init() fails in irq_of_parse_and_map()

I see that
irqchip_init is called
gic_of_init is called
but of_irq_parse_one(dev, index, &oirq) fails... :-(

Also, it makes no sense to me that an "interrupt-parent" specifies
"downstream" controllers. Parent relationship usually moves closer
to the "source" (like clk IIRC).

I've attached my (lame) attempt at a device tree.

If anyone can help me, I'd be eternally grateful. It doesn't help
that device tree syntax looks like Klingon to me. My eyes have been
glazing over [1] for days, but nothing is sinking in, and I find
myself unscientifically hacking random bits with 0 success.

[1] Documentation/devicetree/bindings/interrupt-controller/interrupts.txt

Regards.

-------------- next part --------------
/dts-v1/;

/ {
	compatible = "sigma,tango4-soc";

	#address-cells = <1>;
	#size-cells = <1>;

	gic: interrupt-controller at 20001000 {
		compatible = "arm,cortex-a9-gic";
		interrupt-controller;
		#interrupt-cells = <3>;
		reg = <0x20001000 0x1000>,
		      <0x20000100 0x0100>;
	};

	soc {
		compatible = "simple-bus";
		interrupt-parent = <&irqintc>;
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		uart0: serial at 10700 {
			compatible = "ns16550a";
			reg = <0x10700 0x100>;
			clock-frequency = <7372800>;
			reg-shift = <2>;
			no-loopback-test;
		};

/*		eth0: emac at 26000 {
			compatible = "sigma,smp8640-emac";
			reg = <0x26000 0x800>;
			interrupts = <38>;
			clocks = <396000000>;
		}; */
	};

	cpublock: cpublock {
		compatible = "simple-bus";
		reg = <0x60000 0x10000>;
		ranges = <0x0 0x60000 0x10000>;
		interrupt-parent = <&irqintc>;
		#address-cells = <1>;
		#size-cells = <1>;

		intc: intc at e000 {
			compatible = "sigma,tango-intc";
			reg = <0xe000 0x1000>;
			ranges = <0x0 0xe000 0x1000>;
			interrupt-parent = <&gic>;
			interrupt-controller;
			#address-cells = <1>;
			#size-cells = <1>;

			irqintc: irq at 000 {
				reg = <0x000 0x100>;
				#interrupt-cells = <2>;
				interrupts = <2>;
				label = "IRQ";
			};

			fiqintc: fiq at 100 {
				reg = <0x100 0x100>;
				#interrupt-cells = <2>;
				interrupts = <3>;
				label = "FIQ";
			};

			iiqintc: iiq at 300 {
				reg = <0x300 0x100>;
				#interrupt-cells = <2>;
				interrupts = <4>;
				label = "IIQ";
			};
		};
	};

};

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Porting MIPS IRQ handler to ARM
  2015-09-02 16:25   ` Mason
@ 2015-09-02 17:17     ` Måns Rullgård
  2015-09-02 18:01       ` Mason
  0 siblings, 1 reply; 15+ messages in thread
From: Måns Rullgård @ 2015-09-02 17:17 UTC (permalink / raw)
  To: linux-arm-kernel

Mason <slash.tmp@free.fr> writes:

> On 01/09/2015 18:58, Florian Fainelli wrote:
>
>> On 01/09/15 09:14, Mason wrote:
>>
>>> I'm trying to port to my ARM platform: IRQ handling code written for MIPS.
>>> https://github.com/mansr/linux-tangox/blob/master/drivers/irqchip/irq-tangox.c
>> 
>> Calling clear_c0_status() and write_c0_status() in tangox_irq_handler()
>> sounds like a layering violation here, this should be taken care of by
>> the interrupt code once proper parenting between the MIPS IRQ controller
>> and your tangox controller is established.
>
> Following Mans' suggestion, I deleted the arch-specific code, and
> the driver now compiles and links.
>
> Unfortunately, I still can't get it to work, and I've been banging
> my head against the wall over this device tree monstrosity.
>
> tangox_irq_init() fails in irq_of_parse_and_map()
>
> I see that
> irqchip_init is called
> gic_of_init is called
> but of_irq_parse_one(dev, index, &oirq) fails... :-(

Use the latest DT from my tree.  It looks like you're missing some
changes.

-- 
M?ns Rullg?rd
mans at mansr.com

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Porting MIPS IRQ handler to ARM
  2015-09-02 17:17     ` Måns Rullgård
@ 2015-09-02 18:01       ` Mason
  2015-09-04 16:13         ` Mason
  0 siblings, 1 reply; 15+ messages in thread
From: Mason @ 2015-09-02 18:01 UTC (permalink / raw)
  To: linux-arm-kernel

On 02/09/2015 19:17, M?ns Rullg?rd wrote:

> Use the latest DT from my tree.  It looks like you're missing some
> changes.

Indeed, my repo is not up-to-date. (I was vaguely worried that you'd
have made further changes that I'd have to revert when back-porting
to 3.14)

I'll try upgrading and report back.

By the way, did you write the DT from scratch?

Are there people walking this earth that can write device tree like C?

Regards.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Porting MIPS IRQ handler to ARM
  2015-09-02 18:01       ` Mason
@ 2015-09-04 16:13         ` Mason
  2015-09-04 16:36           ` Måns Rullgård
  2015-09-04 16:37           ` Måns Rullgård
  0 siblings, 2 replies; 15+ messages in thread
From: Mason @ 2015-09-04 16:13 UTC (permalink / raw)
  To: linux-arm-kernel

On 02/09/2015 20:01, Mason wrote:

> On 02/09/2015 19:17, M?ns Rullg?rd wrote:
> 
>> Use the latest DT from my tree.  It looks like you're missing some
>> changes.
> 
> Indeed, my repo is not up-to-date. (I was vaguely worried that you'd
> have made further changes that I'd have to revert when back-porting
> to 3.14)
> 
> I'll try upgrading and report back.
> 
> By the way, did you write the DT from scratch?
> 
> Are there people walking this earth that can write device tree like C?

No cigar :-(

There's just too much DT syntax that flies light-years over my head.
#address-cells, #size-cells, #interrupt-cells, ranges, aliases, etc.
Basically, all I understand is /dts-v1/;
(Anyone have links to good tutorials?)

I've attached the current version I'm playing with (I tried to make it
as small as possible). If some charitable soul spots an obvious problem...
(Commented blocks have been tested uncommented, of course.)

Regards

-------------- next part --------------
/dts-v1/;

/ {
	compatible = "sigma,tango4-soc";

	#address-cells = <1>;
	#size-cells = <1>;

	gic: interrupt-controller at 20001000 {
		compatible = "arm,cortex-a9-gic";
		interrupt-controller;
		#interrupt-cells = <3>;
		reg = <0x20001000 0x1000>,
		      <0x20000100 0x0100>;
	};

	soc {
		compatible = "simple-bus";
/*		interrupt-parent = <&irqintc>;	*/
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		uart0: uart at 10700 {
			compatible = "ns16550a";
			reg = <0x10700 0x100>;
			clock-frequency = <7372800>;
			reg-shift = <2>;
			no-loopback-test;
		};
	};

	cpublock: cpublock {
		compatible = "simple-bus";
		reg = <0x60000 0x10000>;
		ranges = <0x0 0x60000 0x10000>;
/*		interrupt-parent = <&irqintc>;	*/
		#address-cells = <1>;
		#size-cells = <1>;

		intc: intc at e000 {
			compatible = "sigma,tango-intc";
			reg = <0xe000 0x1000>;
			ranges = <0x0 0xe000 0x1000>;
			interrupt-parent = <&gic>;
			interrupt-controller;
			#address-cells = <1>;
			#size-cells = <1>;

			irqintc: irq at 000 {
				reg = <0x000 0x100>;
				interrupt-controller;
				#interrupt-cells = <2>;
				interrupts = <2>;
				label = "IRQ";
			};

/*
			fiqintc: fiq at 100 {
				reg = <0x100 0x100>;
				interrupt-controller;
				#interrupt-cells = <2>;
				interrupts = <3>;
				label = "FIQ";
			};

			iiqintc: iiq at 300 {
				reg = <0x300 0x100>;
				interrupt-controller;
				#interrupt-cells = <2>;
				interrupts = <4>;
				label = "IIQ";
			};
*/
		};
	};

};

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Porting MIPS IRQ handler to ARM
  2015-09-04 16:13         ` Mason
@ 2015-09-04 16:36           ` Måns Rullgård
  2015-09-04 17:46             ` Mason
  2015-09-04 16:37           ` Måns Rullgård
  1 sibling, 1 reply; 15+ messages in thread
From: Måns Rullgård @ 2015-09-04 16:36 UTC (permalink / raw)
  To: linux-arm-kernel

Mason <slash.tmp@free.fr> writes:

> On 02/09/2015 20:01, Mason wrote:
>
>> On 02/09/2015 19:17, M?ns Rullg?rd wrote:
>> 
>>> Use the latest DT from my tree.  It looks like you're missing some
>>> changes.
>> 
>> Indeed, my repo is not up-to-date. (I was vaguely worried that you'd
>> have made further changes that I'd have to revert when back-porting
>> to 3.14)
>> 
>> I'll try upgrading and report back.
>> 
>> By the way, did you write the DT from scratch?
>> 
>> Are there people walking this earth that can write device tree like C?
>
> No cigar :-(
>
> There's just too much DT syntax that flies light-years over my head.
> #address-cells, #size-cells, #interrupt-cells, ranges, aliases, etc.
> Basically, all I understand is /dts-v1/;
> (Anyone have links to good tutorials?)
>
> I've attached the current version I'm playing with (I tried to make it
> as small as possible). If some charitable soul spots an obvious problem...
> (Commented blocks have been tested uncommented, of course.)

What happens when you try to boot with this device tree?

> /dts-v1/;
>
> / {
> 	compatible = "sigma,tango4-soc";
>
> 	#address-cells = <1>;
> 	#size-cells = <1>;
>
> 	gic: interrupt-controller at 20001000 {
> 		compatible = "arm,cortex-a9-gic";
> 		interrupt-controller;
> 		#interrupt-cells = <3>;
> 		reg = <0x20001000 0x1000>,
> 		      <0x20000100 0x0100>;
> 	};
>
> 	soc {
> 		compatible = "simple-bus";
> /*		interrupt-parent = <&irqintc>;	*/
> 		#address-cells = <1>;
> 		#size-cells = <1>;
> 		ranges;
>
> 		uart0: uart at 10700 {
> 			compatible = "ns16550a";
> 			reg = <0x10700 0x100>;
> 			clock-frequency = <7372800>;
> 			reg-shift = <2>;
> 			no-loopback-test;
> 		};
> 	};
>
> 	cpublock: cpublock {
> 		compatible = "simple-bus";
> 		reg = <0x60000 0x10000>;
> 		ranges = <0x0 0x60000 0x10000>;
> /*		interrupt-parent = <&irqintc>;	*/
> 		#address-cells = <1>;
> 		#size-cells = <1>;
>
> 		intc: intc at e000 {
> 			compatible = "sigma,tango-intc";
> 			reg = <0xe000 0x1000>;
> 			ranges = <0x0 0xe000 0x1000>;

Are you sure these addresses are correct?  Those are the values from
tango3.

> 			interrupt-parent = <&gic>;
> 			interrupt-controller;
> 			#address-cells = <1>;
> 			#size-cells = <1>;
>
> 			irqintc: irq at 000 {
> 				reg = <0x000 0x100>;
> 				interrupt-controller;
> 				#interrupt-cells = <2>;
> 				interrupts = <2>;

This "interrupts" specification is wrong for a source wired into the
GIC.  For the correct format, see the binding spec in
Documentation/devicetree/bindings/arm/gic.txt:

  The 1st cell is the interrupt type; 0 for SPI interrupts, 1 for PPI
  interrupts.

  The 2nd cell contains the interrupt number for the interrupt type.
  SPI interrupts are in the range [0-987].  PPI interrupts are in the
  range [0-15].

  The 3rd cell is the flags, encoded as follows:
	bits[3:0] trigger type and level flags.
		1 = low-to-high edge triggered
		2 = high-to-low edge triggered (invalid for SPIs)
		4 = active high level-sensitive
		8 = active low level-sensitive (invalid for SPIs).
	bits[15:8] PPI interrupt cpu mask.  Each bit corresponds to each of
	the 8 possible cpus attached to the GIC.  A bit set to '1' indicated
	the interrupt is wired to that CPU.  Only valid for PPI interrupts.
	Also note that the configurability of PPI interrupts is IMPLEMENTATION
	DEFINED and as such not guaranteed to be present (most SoC available
	in 2014 seem to ignore the setting of this flag and use the hardware
	default value).

The correct values for these three fields should be available in your
datasheet.

> 				label = "IRQ";
> 			};
>
> /*
> 			fiqintc: fiq at 100 {
> 				reg = <0x100 0x100>;
> 				interrupt-controller;
> 				#interrupt-cells = <2>;
> 				interrupts = <3>;
> 				label = "FIQ";
> 			};
>
> 			iiqintc: iiq at 300 {
> 				reg = <0x300 0x100>;
> 				interrupt-controller;
> 				#interrupt-cells = <2>;
> 				interrupts = <4>;
> 				label = "IIQ";
> 			};
> */
> 		};
> 	};
>
> };

-- 
M?ns Rullg?rd
mans at mansr.com

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Porting MIPS IRQ handler to ARM
  2015-09-04 16:13         ` Mason
  2015-09-04 16:36           ` Måns Rullgård
@ 2015-09-04 16:37           ` Måns Rullgård
  2015-09-04 21:20             ` Matthias Brugger
  1 sibling, 1 reply; 15+ messages in thread
From: Måns Rullgård @ 2015-09-04 16:37 UTC (permalink / raw)
  To: linux-arm-kernel

Mason <slash.tmp@free.fr> writes:

> On 02/09/2015 20:01, Mason wrote:
>
>> On 02/09/2015 19:17, M?ns Rullg?rd wrote:
>> 
>>> Use the latest DT from my tree.  It looks like you're missing some
>>> changes.
>> 
>> Indeed, my repo is not up-to-date. (I was vaguely worried that you'd
>> have made further changes that I'd have to revert when back-porting
>> to 3.14)
>> 
>> I'll try upgrading and report back.
>> 
>> By the way, did you write the DT from scratch?
>> 
>> Are there people walking this earth that can write device tree like C?
>
> No cigar :-(
>
> There's just too much DT syntax that flies light-years over my head.
> #address-cells, #size-cells, #interrupt-cells, ranges, aliases, etc.
> Basically, all I understand is /dts-v1/;
> (Anyone have links to good tutorials?)

Here's something: http://devicetree.org/Device_Tree_Usage

-- 
M?ns Rullg?rd
mans at mansr.com

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Porting MIPS IRQ handler to ARM
  2015-09-04 16:36           ` Måns Rullgård
@ 2015-09-04 17:46             ` Mason
  2015-09-04 21:49               ` Måns Rullgård
  0 siblings, 1 reply; 15+ messages in thread
From: Mason @ 2015-09-04 17:46 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/09/2015 18:36, M?ns Rullg?rd wrote:

> Mason wrote:
> 
>> There's just too much DT syntax that flies light-years over my head.
>> #address-cells, #size-cells, #interrupt-cells, ranges, aliases, etc.
>> Basically, all I understand is /dts-v1/;
>> (Anyone have links to good tutorials?)
>>
>> I've attached the current version I'm playing with (I tried to make it
>> as small as possible). If some charitable soul spots an obvious problem...
>> (Commented blocks have been tested uncommented, of course.)
> 
> What happens when you try to boot with this device tree?

It panics in tangox_irq_init IIRC.

> Are you sure these addresses are correct?  Those are the values from
> tango3.

AFAIU, that HW block hasn't changed in a long time, but I'll
double-check to be sure.

>> 			interrupt-parent = <&gic>;
>> 			interrupt-controller;
>> 			#address-cells = <1>;
>> 			#size-cells = <1>;
>>
>> 			irqintc: irq at 000 {
>> 				reg = <0x000 0x100>;
>> 				interrupt-controller;
>> 				#interrupt-cells = <2>;
>> 				interrupts = <2>;
> 
> This "interrupts" specification is wrong for a source wired into the
> GIC.  For the correct format, see the binding spec in
> Documentation/devicetree/bindings/arm/gic.txt:

Doooh! I'd read that document (about 12 times) but for some
reason, it never occurred to me that I had to follow the
syntax for the intc (although that seems obvious now that
you mention it).

I suspect you've nailed my problem. Wish I could test right
away, but it'll have to wait after the weekend.

Thanks (again).

Regards.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Porting MIPS IRQ handler to ARM
  2015-09-04 16:37           ` Måns Rullgård
@ 2015-09-04 21:20             ` Matthias Brugger
  0 siblings, 0 replies; 15+ messages in thread
From: Matthias Brugger @ 2015-09-04 21:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Friday, September 04, 2015 05:37:57 PM M?ns Rullg?rd wrote:
> Mason <slash.tmp@free.fr> writes:
> > On 02/09/2015 20:01, Mason wrote:
> >> On 02/09/2015 19:17, M?ns Rullg?rd wrote:
> >>> Use the latest DT from my tree.  It looks like you're missing some
> >>> changes.
> >> 
> >> Indeed, my repo is not up-to-date. (I was vaguely worried that you'd
> >> have made further changes that I'd have to revert when back-porting
> >> to 3.14)
> >> 
> >> I'll try upgrading and report back.
> >> 
> >> By the way, did you write the DT from scratch?
> >> 
> >> Are there people walking this earth that can write device tree like C?
> > 
> > No cigar :-(
> > 
> > There's just too much DT syntax that flies light-years over my head.
> > #address-cells, #size-cells, #interrupt-cells, ranges, aliases, etc.
> > Basically, all I understand is /dts-v1/;
> > (Anyone have links to good tutorials?)
> 
> Here's something: http://devicetree.org/Device_Tree_Usage

And here:
http://events.linuxfoundation.org/sites/events/files/slides/petazzoni-device-tree-dummies.pdf

Video to the slides:
https://www.youtube.com/watch?v=m_NyYEBxfn8

Have fun ;)

Matthias

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Porting MIPS IRQ handler to ARM
  2015-09-04 17:46             ` Mason
@ 2015-09-04 21:49               ` Måns Rullgård
  0 siblings, 0 replies; 15+ messages in thread
From: Måns Rullgård @ 2015-09-04 21:49 UTC (permalink / raw)
  To: linux-arm-kernel

Mason <slash.tmp@free.fr> writes:

> On 04/09/2015 18:36, M?ns Rullg?rd wrote:
>
>> Mason wrote:
>> 
>>> There's just too much DT syntax that flies light-years over my head.
>>> #address-cells, #size-cells, #interrupt-cells, ranges, aliases, etc.
>>> Basically, all I understand is /dts-v1/;
>>> (Anyone have links to good tutorials?)
>>>
>>> I've attached the current version I'm playing with (I tried to make it
>>> as small as possible). If some charitable soul spots an obvious problem...
>>> (Commented blocks have been tested uncommented, of course.)
>> 
>> What happens when you try to boot with this device tree?
>
> It panics in tangox_irq_init IIRC.
>
>> Are you sure these addresses are correct?  Those are the values from
>> tango3.
>
> AFAIU, that HW block hasn't changed in a long time, but I'll
> double-check to be sure.

Even if the HW block itself is unchanged, it may be mapped at a
different address.  ARM and MIPS systems generally have quite
different-looking memory maps, so I'd actually be surprised if hasn't
been moved.

-- 
M?ns Rullg?rd
mans at mansr.com

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-09-04 21:49 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-01 16:14 Porting MIPS IRQ handler to ARM Mason
2015-09-01 16:58 ` Florian Fainelli
2015-09-02 16:25   ` Mason
2015-09-02 17:17     ` Måns Rullgård
2015-09-02 18:01       ` Mason
2015-09-04 16:13         ` Mason
2015-09-04 16:36           ` Måns Rullgård
2015-09-04 17:46             ` Mason
2015-09-04 21:49               ` Måns Rullgård
2015-09-04 16:37           ` Måns Rullgård
2015-09-04 21:20             ` Matthias Brugger
2015-09-01 17:07 ` Måns Rullgård
2015-09-01 17:57   ` Mason
2015-09-01 18:07     ` Florian Fainelli
2015-09-01 19:01       ` Mason

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).