* [PATCH 03/11] x86/dtb: Add a device tree for CE4100
[not found] ` <1290706801-7323-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
@ 2010-11-25 17:39 ` Sebastian Andrzej Siewior
[not found] ` <1290706801-7323-4-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
0 siblings, 1 reply; 36+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-25 17:39 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ, Sebastian Andrzej Siewior,
x86-DgEjT+Ai2ygdnm+yROfE0A,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
CC: x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
arch/x86/platform/ce4100/ce4100.dts | 210 +++++++++++++++++++++++++++++++++++
1 files changed, 210 insertions(+), 0 deletions(-)
create mode 100644 arch/x86/platform/ce4100/ce4100.dts
diff --git a/arch/x86/platform/ce4100/ce4100.dts b/arch/x86/platform/ce4100/ce4100.dts
new file mode 100644
index 0000000..2901882
--- /dev/null
+++ b/arch/x86/platform/ce4100/ce4100.dts
@@ -0,0 +1,210 @@
+/*
+ * CE4100 on Falcon Falls
+ *
+ * (c) Copyright 2010 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+/dts-v1/;
+/ {
+ model = "x86,CE4100";
+ compatible = "x86,CE4100";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ cpus {
+ x86,Atom@0 {
+ device_type = "cpu";
+ };
+ };
+
+ atom@0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ device_type = "soc";
+ compatible = "simple-bus";
+ ranges;
+
+ /* Local APIC */
+ lapic@fee00000 {
+ compatible = "intel,lapic";
+ reg = <0xfee00000 0x1000>;
+ phys_reg = <0xfee00000>;
+ };
+ /* Primary IO-APIC */
+ ioapic1: pic@fec00000 {
+ #interrupt-cells = <2>;
+ compatible = "intel,ioapic";
+ interrupt-controller;
+ device_type = "interrupt-controller";
+ id = <1>;
+ reg = <0xfec00000 0x1000>;
+ phys_reg = <0xfec00000>;
+ };
+
+ hpet@fed00000 {
+ compatible = "intel,hpet";
+ reg = <0xfed00000 0x200>;
+ phys_reg = <0xfed00000>;
+ };
+ };
+
+ isa@legacy {
+ device_type = "isa";
+ compatible = "simple-bus";
+ #address-cells = <2>;
+ #size-cells = <1>;
+ ranges = <0 0 0 0x400>;
+
+ rtc@legacy {
+ compatible = "motorola,mc146818";
+ interrupts = <8 3>;
+ interrupt-parent = <&ioapic1>;
+ ctrl_reg = <2>;
+ freq_reg = <0x26>;
+ reg = <1 0x70 2>;
+ };
+
+ pci@3fc {
+ #address-cells = <3>;
+ #interrupt-cells = <1>;
+ #size-cells = <1>;
+ compatible = "intel,ce4100-pci";
+ device_type = "pci";
+ bus-range = <0 0>;
+
+ /* Secondary IO-APIC */
+ ioapic2: pic@bffff000 {
+ #interrupt-cells = <2>;
+ compatible = "intel,ioapic";
+ interrupt-controller;
+ device_type = "interrupt-controller";
+ id = <2>;
+ reg = <0x100 0x0 0x0 0x0>;
+ phys_reg = <0xbffff000>;
+ };
+
+ pci@av {
+ #address-cells = <3>;
+ #interrupt-cells = <1>;
+ #size-cells = <1>;
+ compatible = "intel,ce4100-pci";
+ device_type = "pci";
+ bus-range = <1 1>;
+ interrupt-map-mask = <0xffffff 0x0 0x0 0x0>;
+ interrupt-map = <
+ /* GFX: 0x2E5B */
+ 0x11000 0x0 0x0 0x0 &ioapic2 0 0x1
+ /* ***** FIXME ****** Compositing Engine: 0x2E72 */
+ /* 0x11100 0x0 0x0 0x1 &ioapic2 0 0x1 */
+ /* MFD: 0x2E5C */
+ 0x11800 0x0 0x0 0x0 &ioapic2 2 0x1
+ /* TS Prefilter: 0x2E5D */
+ 0x12000 0x0 0x0 0x0 &ioapic2 4 0x1
+ /* TS Demux: 0x2E5E */
+ 0x12100 0x0 0x0 0x0 &ioapic2 5 0x1
+ /* ***** FIXME ***** Audio DSP: 0x2E5F */
+ /* 0x13000 0x0 0x0 0x1 &ioapic2 0 0x1 */
+ /* Audio Interfaces: 0x2E60 */
+ 0x13200 0x0 0x0 0x0 &ioapic2 8 0x1
+ /* VDC: 0x2E61 */
+ 0x14000 0x0 0x0 0x0 &ioapic2 9 0x1
+ /* DPE: 0x2E62 */
+ 0x14100 0x0 0x0 0x0 &ioapic2 10 0x1
+ /* HDMI Tx: 0x2E63 */
+ 0x14200 0x0 0x0 0x0 &ioapic2 11 0x1
+ /* SEC: 0x2E64 */
+ 0x14800 0x0 0x0 0x0 &ioapic2 12 0x1
+ /* EXP: 0x2E65 */
+ 0x15000 0x0 0x0 0x0 &ioapic2 13 0x1
+ /* UART0/1: 0x2E66 */
+ 0x15800 0x0 0x0 0x0 &ioapic2 14 0x1
+ /* GPIO: 0x2E67 */
+ 0x15900 0x0 0x0 0x0 &ioapic2 15 0x1
+ /* I2C0/1/2: 0x2E68 */
+ 0x15a00 0x0 0x0 0x0 &ioapic2 16 0x1
+ /* Smart Card 0/1: 0x2E69 */
+ 0x15b00 0x0 0x0 0x0 &ioapic2 15 0x1
+ /* SPI: 0x2E6A */
+ 0x15c00 0x0 0x0 0x0 &ioapic2 15 0x1
+ /* MSPOD: 0x2E6B */
+ 0x15d00 0x0 0x0 0x0 &ioapic2 19 0x1
+ /* IR: 0x2E6C */
+ 0x15e00 0x0 0x0 0x0 &ioapic2 16 0x1
+ /* **** FIXME ***** DFX: 0x2E6D */
+ /* 0x15f00 0x0 0x0 0x1 &ioapic2 0x0 0x1 */
+ /* Gig Ethernet: 0x2E6E */
+ 0x16000 0x0 0x0 0x0 &ioapic2 21 0x1
+ /* IEEE1588 and Clock Recovery Unit: 0x2E6F */
+ 0x16100 0x0 0x0 0x0 &ioapic2 3 0x1
+ /* USB0: 0x2E70 */
+ 0x16800 0x0 0x0 0x0 &ioapic2 22 0x3
+ /* USB1: 0x2E70 */
+ 0x16900 0x0 0x0 0x0 &ioapic2 22 0x3
+ /* SATA: 0x2E71 */
+ 0x17000 0x0 0x0 0x0 &ioapic2 23 0x3
+ >;
+
+ i2c@15a00 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x15a00 0x0 0x0 0x0>;
+
+
+ i2c@0 {
+ reg = <0>;
+ };
+
+ i2c@1 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <1>;
+
+ pcf8575@26 {
+ compatible = "ti,pcf8575";
+ reg = <0x26>;
+ };
+ };
+
+ i2c@2 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <2>;
+
+ pcf8575@26 {
+ compatible = "ti,pcf8575";
+ reg = <0x26>;
+ };
+ };
+ };
+
+ spi@15c00 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x15c00 0x0 0x0 0x0>;
+
+ pcm1755@0 {
+ compatible = "ti,pcm1755";
+ reg = <0>;
+ spi-max-frequency = <115200>;
+ };
+
+ pcm1609a@1 {
+ compatible = "ti,pcm1609a";
+ reg = <1>;
+ spi-max-frequency = <115200>;
+ };
+
+ at93c46@2 {
+ compatible = "atmel,at93c46";
+ reg = <2>;
+ spi-max-frequency = <115200>;
+ };
+ };
+ };
+ };
+ };
+};
--
1.7.3.2
^ permalink raw reply related [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
[not found] ` <1290706801-7323-4-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
@ 2010-11-26 21:57 ` Benjamin Herrenschmidt
2010-11-28 16:04 ` Sebastian Andrzej Siewior
2010-11-29 2:22 ` David Gibson
0 siblings, 2 replies; 36+ messages in thread
From: Benjamin Herrenschmidt @ 2010-11-26 21:57 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A, linux-kernel-u79uwXL29TY76Z2rM5mHXA
> + */
> +/dts-v1/;
> +/ {
> + model = "x86,CE4100";
> + compatible = "x86,CE4100";
Use a vendor name rather than "x86" here.
> + #address-cells = <1>;
> + #size-cells = <1>;
> +
> + cpus {
> + x86,Atom@0 {
"Atom" would benefit from being more precise, like adding the model
number. Also you want some properties there defining maybe the mask, the
cache characteristics, etc... There's an exising OFW binding for x86, I
suppose you could follow it. A "reg" property at least is mandatory
here.
Also how do you plan to expose threading capability ?
You probably also want some linkage from the processor to the local APIC
no ?
> + device_type = "cpu";
> + };
> + };
> +
> + atom@0 {
> + #address-cells = <1>;
> + #size-cells = <1>;
> + device_type = "soc";
> + compatible = "simple-bus";
> + ranges;
> +
> + /* Local APIC */
> + lapic@fee00000 {
> + compatible = "intel,lapic";
> + reg = <0xfee00000 0x1000>;
> + phys_reg = <0xfee00000>;
> + };
> + /* Primary IO-APIC */
> + ioapic1: pic@fec00000 {
> + #interrupt-cells = <2>;
> + compatible = "intel,ioapic";
> + interrupt-controller;
> + device_type = "interrupt-controller";
> + id = <1>;
> + reg = <0xfec00000 0x1000>;
> + phys_reg = <0xfec00000>;
> + };
> +
What are those phys-reg properties ? Also APICs have some kind od
versionning, they aren't all identical, so your compatible property
needs to be more precise at least.
> + hpet@fed00000 {
> + compatible = "intel,hpet";
> + reg = <0xfed00000 0x200>;
> + phys_reg = <0xfed00000>;
> + };
> + };
All HPETs are identical ? If not, make your compatible property more
precise or if they are generally compatible from a programmer
perspective, use two entries from more generic to more specific, for
example:
compatible = "intel,hpet","intel,hpet-atom-XXYY"
(or make up a numbering/naming scheme that makes sense for Intel gear)
> + isa@legacy {
So ISA isn't a child of "atom"... that makes "atom" a bit strange as a
node, tho not a big deal per se. I suppose it represent the on-die
peripherals but then you need at least some linkage between that and
the /cpus nodes.
> + device_type = "isa";
> + compatible = "simple-bus";
What does "simple-bus" means ? ISA has a well defined binding, you
should follow it.
> + #address-cells = <2>;
> + #size-cells = <1>;
> + ranges = <0 0 0 0x400>;
> +
> + rtc@legacy {
> + compatible = "motorola,mc146818";
> + interrupts = <8 3>;
> + interrupt-parent = <&ioapic1>;
> + ctrl_reg = <2>;
> + freq_reg = <0x26>;
> + reg = <1 0x70 2>;
> + };
I think the ISA binding mandate the use of the PNP codes in the
compatible properties, doesn't it ? At least that's the common usage
pattern I've seen so far on powerpc.
Also, "ctrl_reg" and "freq_reg" follow an existing binding ? If not,
then I'd suggest you use "-" instead of "_" which is more common in OFW
land and use more descriptive names since "reg" has a meaning of its own
and the above is a bit confusing.
> + pci@3fc {
> + #address-cells = <3>;
> + #interrupt-cells = <1>;
> + #size-cells = <1>;
> + compatible = "intel,ce4100-pci";
> + device_type = "pci";
> + bus-range = <0 0>;
> +
> + /* Secondary IO-APIC */
> + ioapic2: pic@bffff000 {
> + #interrupt-cells = <2>;
> + compatible = "intel,ioapic";
> + interrupt-controller;
> + device_type = "interrupt-controller";
> + id = <2>;
> + reg = <0x100 0x0 0x0 0x0>;
> + phys_reg = <0xbffff000>;
> + };
Here you define a PCI bus with a child device that isn't PCI from what I
can tell, tho the "reg" property content is confusing, and then there's
a unit address that doesn't match "reg" and a "phys_reg" (what the heck
is that ?) that matches the unit-address. Care to explain a bit
more ? :-) I suspect that isn't the right way to represent the secondary
APIC
Also same comments about the compatible property.
> + pci@av {
> + #address-cells = <3>;
> + #interrupt-cells = <1>;
> + #size-cells = <1>;
> + compatible = "intel,ce4100-pci";
> + device_type = "pci";
> + bus-range = <1 1>;
> + interrupt-map-mask = <0xffffff 0x0 0x0 0x0>;
I notice that the interrupt number isn't part of your mask, is that
expected ? If you decide to make it so, remember that INT_A is 1 not 0
iirc (dbl check maybe ? I think that's how it is :-)
> + interrupt-map = <
> + /* GFX: 0x2E5B */
> + 0x11000 0x0 0x0 0x0 &ioapic2 0 0x1
> + /* ***** FIXME ****** Compositing Engine: 0x2E72 */
> + /* 0x11100 0x0 0x0 0x1 &ioapic2 0 0x1 */
> + /* MFD: 0x2E5C */
> + 0x11800 0x0 0x0 0x0 &ioapic2 2 0x1
> + /* TS Prefilter: 0x2E5D */
> + 0x12000 0x0 0x0 0x0 &ioapic2 4 0x1
> + /* TS Demux: 0x2E5E */
> + 0x12100 0x0 0x0 0x0 &ioapic2 5 0x1
> + /* ***** FIXME ***** Audio DSP: 0x2E5F */
> + /* 0x13000 0x0 0x0 0x1 &ioapic2 0 0x1 */
> + /* Audio Interfaces: 0x2E60 */
> + 0x13200 0x0 0x0 0x0 &ioapic2 8 0x1
> + /* VDC: 0x2E61 */
> + 0x14000 0x0 0x0 0x0 &ioapic2 9 0x1
> + /* DPE: 0x2E62 */
> + 0x14100 0x0 0x0 0x0 &ioapic2 10 0x1
> + /* HDMI Tx: 0x2E63 */
> + 0x14200 0x0 0x0 0x0 &ioapic2 11 0x1
> + /* SEC: 0x2E64 */
> + 0x14800 0x0 0x0 0x0 &ioapic2 12 0x1
> + /* EXP: 0x2E65 */
> + 0x15000 0x0 0x0 0x0 &ioapic2 13 0x1
> + /* UART0/1: 0x2E66 */
> + 0x15800 0x0 0x0 0x0 &ioapic2 14 0x1
> + /* GPIO: 0x2E67 */
> + 0x15900 0x0 0x0 0x0 &ioapic2 15 0x1
> + /* I2C0/1/2: 0x2E68 */
> + 0x15a00 0x0 0x0 0x0 &ioapic2 16 0x1
> + /* Smart Card 0/1: 0x2E69 */
> + 0x15b00 0x0 0x0 0x0 &ioapic2 15 0x1
> + /* SPI: 0x2E6A */
> + 0x15c00 0x0 0x0 0x0 &ioapic2 15 0x1
> + /* MSPOD: 0x2E6B */
> + 0x15d00 0x0 0x0 0x0 &ioapic2 19 0x1
> + /* IR: 0x2E6C */
> + 0x15e00 0x0 0x0 0x0 &ioapic2 16 0x1
> + /* **** FIXME ***** DFX: 0x2E6D */
> + /* 0x15f00 0x0 0x0 0x1 &ioapic2 0x0 0x1 */
> + /* Gig Ethernet: 0x2E6E */
> + 0x16000 0x0 0x0 0x0 &ioapic2 21 0x1
> + /* IEEE1588 and Clock Recovery Unit: 0x2E6F */
> + 0x16100 0x0 0x0 0x0 &ioapic2 3 0x1
> + /* USB0: 0x2E70 */
> + 0x16800 0x0 0x0 0x0 &ioapic2 22 0x3
> + /* USB1: 0x2E70 */
> + 0x16900 0x0 0x0 0x0 &ioapic2 22 0x3
> + /* SATA: 0x2E71 */
> + 0x17000 0x0 0x0 0x0 &ioapic2 23 0x3
> + >;
> +
> + i2c@15a00 {
> + #address-cells = <1>;
> + #size-cells = <0>;
> + reg = <0x15a00 0x0 0x0 0x0>;
OFW PCI binding, which we follow, mandates an "assigned-addresses"
property, tho I suppose that if you haven't assigned anything yet (and
will let Linux do so) the above is kosher. Your "reg" is a bit odd but I
don't have time to dbl check vs. the binding right now.
> + i2c@0 {
> + reg = <0>;
> + };
> +
> + i2c@1 {
> + #address-cells = <1>;
> + #size-cells = <0>;
> + reg = <1>;
> +
> + pcf8575@26 {
> + compatible = "ti,pcf8575";
> + reg = <0x26>;
> + };
> + };
> +
> + i2c@2 {
> + #address-cells = <1>;
> + #size-cells = <0>;
> + reg = <2>;
> +
> + pcf8575@26 {
> + compatible = "ti,pcf8575";
> + reg = <0x26>;
> + };
> + };
> + };
> +
> + spi@15c00 {
> + #address-cells = <1>;
> + #size-cells = <0>;
> + reg = <0x15c00 0x0 0x0 0x0>;
> +
> + pcm1755@0 {
> + compatible = "ti,pcm1755";
> + reg = <0>;
> + spi-max-frequency = <115200>;
> + };
> +
> + pcm1609a@1 {
> + compatible = "ti,pcm1609a";
> + reg = <1>;
> + spi-max-frequency = <115200>;
> + };
> +
> + at93c46@2 {
> + compatible = "atmel,at93c46";
> + reg = <2>;
> + spi-max-frequency = <115200>;
> + };
> + };
> + };
> + };
> + };
> +};
Cheers,
Ben.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
2010-11-26 21:57 ` Benjamin Herrenschmidt
@ 2010-11-28 16:04 ` Sebastian Andrzej Siewior
[not found] ` <20101128160449.GC30784-Hfxr4Dq0UpYb1SvskN2V4Q@public.gmane.org>
2010-11-29 2:22 ` David Gibson
1 sibling, 1 reply; 36+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-28 16:04 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
sodaville-hfZtesqFncYOwBW4kG4KsQ, Sebastian Andrzej Siewior,
x86-DgEjT+Ai2ygdnm+yROfE0A, linux-kernel-u79uwXL29TY76Z2rM5mHXA
* Benjamin Herrenschmidt | 2010-11-27 08:57:25 [+1100]:
>> + */
>> +/dts-v1/;
>> +/ {
>> + model = "x86,CE4100";
>> + compatible = "x86,CE4100";
>
>Use a vendor name rather than "x86" here.
Okay.
>> + #address-cells = <1>;
>> + #size-cells = <1>;
>> +
>> + cpus {
>> + x86,Atom@0 {
>
>"Atom" would benefit from being more precise, like adding the model
>number. Also you want some properties there defining maybe the mask, the
>cache characteristics, etc... There's an exising OFW binding for x86, I
>suppose you could follow it. A "reg" property at least is mandatory
>here.
I wasn't aware of the OFW binding for X86. I will follow it once I find
it.
>Also how do you plan to expose threading capability ?
I haven't plan because this CPU has to threading capability. If there
is, I would follow the powerpc way (unless it is allready documented how
to do so on x86).
>You probably also want some linkage from the processor to the local APIC
>no ?
Like now I walk through the device tree and look for one but that sounds
like a good idea.
>> + device_type = "cpu";
>> + };
>> + };
>> +
>> + atom@0 {
>> + #address-cells = <1>;
>> + #size-cells = <1>;
>> + device_type = "soc";
>> + compatible = "simple-bus";
>> + ranges;
>> +
>> + /* Local APIC */
>> + lapic@fee00000 {
>> + compatible = "intel,lapic";
>> + reg = <0xfee00000 0x1000>;
>> + phys_reg = <0xfee00000>;
>> + };
>> + /* Primary IO-APIC */
>> + ioapic1: pic@fec00000 {
>> + #interrupt-cells = <2>;
>> + compatible = "intel,ioapic";
>> + interrupt-controller;
>> + device_type = "interrupt-controller";
>> + id = <1>;
>> + reg = <0xfec00000 0x1000>;
>> + phys_reg = <0xfec00000>;
>> + };
>> +
>
>What are those phys-reg properties ?
The second ioapic behind the PCI bus which uses the reg property for the
devfn number so I can't use it for the chip address. I can't query the
PCI information because the PCI bus is not up yet.
The phys_reg property contains the physical address of the chip. The
boot uart code in powerpc's tree has a virtual-reg property. So I though
that this would be nice to keep things simple.
>Also APICs have some kind od
>versionning, they aren't all identical, so your compatible property
>needs to be more precise at least.
The APIC has a register where you can read the version of the chip, yes.
You want me to add this version into the compatible field?
>> + hpet@fed00000 {
>> + compatible = "intel,hpet";
>> + reg = <0xfed00000 0x200>;
>> + phys_reg = <0xfed00000>;
>> + };
>> + };
>
>All HPETs are identical ? If not, make your compatible property more
>precise or if they are generally compatible from a programmer
>perspective, use two entries from more generic to more specific, for
>example:
>
> compatible = "intel,hpet","intel,hpet-atom-XXYY"
>
>(or make up a numbering/naming scheme that makes sense for Intel gear)
All hpets should be equal AFAIK. Some behave different but this was not
intendend in the first place. This information is not even included in
the ACPI tables.
>> + isa@legacy {
>
>So ISA isn't a child of "atom"... that makes "atom" a bit strange as a
>node, tho not a big deal per se. I suppose it represent the on-die
>peripherals but then you need at least some linkage between that and
>the /cpus nodes.
Yes, it should represent the on-die peripherals. How should that look
like? The bus the same level as the cpu node and link from the cpu to
the isa bus?
>> + device_type = "isa";
>> + compatible = "simple-bus";
>
>What does "simple-bus" means ?
I added simple bus in order to get probed. But I now I rember that this
is also supported per device_type. I get rid of it.
>ISA has a well defined binding, you
>should follow it.
I do. The reg property the rtc starts with "1" where 1 means it is an
ioport and not ioremap()able adderess.
>> + #address-cells = <2>;
>> + #size-cells = <1>;
>> + ranges = <0 0 0 0x400>;
>> +
>> + rtc@legacy {
>> + compatible = "motorola,mc146818";
>> + interrupts = <8 3>;
>> + interrupt-parent = <&ioapic1>;
>> + ctrl_reg = <2>;
>> + freq_reg = <0x26>;
>> + reg = <1 0x70 2>;
>> + };
>
>I think the ISA binding mandate the use of the PNP codes in the
>compatible properties, doesn't it ?
I'm not aware of it.
> At least that's the common usage
>pattern I've seen so far on powerpc.
That is true.
>
>Also, "ctrl_reg" and "freq_reg" follow an existing binding ? If not,
>then I'd suggest you use "-" instead of "_" which is more common in OFW
>land and use more descriptive names since "reg" has a meaning of its own
>and the above is a bit confusing.
I posted a patch for this at [0]. Powerpc uses the the pnpPNP,b00 node
for the rtc. This node is handled explictly by chrp and maple. Those two
don't use the generic driver but their own.
The remaining (mpc8572, p2020) handle this via add_rtc() in
arch/powerpc/sysdev/rtc_cmos_setup.c. What they do is, they create a
platform device for the OF node. What is missing is the initialization
of the ctrl_reg register and the frequency. This is performed in a PCI
quirk in quirk_final_uli1575() which is only performed on a few powerpc
machines (is is_quirk_valid() has a list).
This looks like dirty hack to me. I need to add every machine to it
rather then a simple entry into the device tree. If you replace the uli
with something else, you need another setup of this kind for the rtc.
>> + pci@3fc {
>> + #address-cells = <3>;
>> + #interrupt-cells = <1>;
>> + #size-cells = <1>;
>> + compatible = "intel,ce4100-pci";
>> + device_type = "pci";
>> + bus-range = <0 0>;
>> +
>> + /* Secondary IO-APIC */
>> + ioapic2: pic@bffff000 {
>> + #interrupt-cells = <2>;
>> + compatible = "intel,ioapic";
>> + interrupt-controller;
>> + device_type = "interrupt-controller";
>> + id = <2>;
>> + reg = <0x100 0x0 0x0 0x0>;
>> + phys_reg = <0xbffff000>;
>> + };
>
>Here you define a PCI bus with a child device that isn't PCI from what I
>can tell, tho the "reg" property content is confusing, and then there's
>a unit address that doesn't match "reg" and a "phys_reg" (what the heck
>is that ?) that matches the unit-address. Care to explain a bit
>more ? :-)
The reg property contains the devfn number, interrupt mask, pin number.
That is what I've been seeing in PCI nodes. phys_reg is the physical
address of the chip since reg is allready taken and PCI is not yet up
(as I allready explained).
>I suspect that isn't the right way to represent the secondary
>APIC
Well the secondary APIC shows up on this PCI bus. It has devfn, vendor
and device id and config space. Where should I put it if not here?
>Also same comments about the compatible property.
>
>> + pci@av {
>> + #address-cells = <3>;
>> + #interrupt-cells = <1>;
>> + #size-cells = <1>;
>> + compatible = "intel,ce4100-pci";
>> + device_type = "pci";
>> + bus-range = <1 1>;
>> + interrupt-map-mask = <0xffffff 0x0 0x0 0x0>;
>
>I notice that the interrupt number isn't part of your mask, is that
>expected ? If you decide to make it so, remember that INT_A is 1 not 0
>iirc (dbl check maybe ? I think that's how it is :-)
Yes INT_A is 1 :) 0 means no interrupt available. I'm not using the
interrupt pin here and therefore it is not in the mask.
The ref manual contains a static mapping for every device so the
interrupt pin has no meaning. Well this not enirely true: by default the
pic is in legacy mode and all devices are on INT A. You can change this
into a different mode where INT A - D are used. For this to happen you
need to fiddle in some SoC specific registers. If you choose not to
bother with it and use the ioapic instead then the interrupt pin remains
unused. And we don't have real PCI bus where you can plug devices so it
would matter.
>> + i2c@15a00 {
>> + #address-cells = <1>;
>> + #size-cells = <0>;
>> + reg = <0x15a00 0x0 0x0 0x0>;
>
>OFW PCI binding, which we follow, mandates an "assigned-addresses"
>property, tho I suppose that if you haven't assigned anything yet (and
>will let Linux do so) the above is kosher. Your "reg" is a bit odd but I
>don't have time to dbl check vs. the binding right now.
reg is devfn. I just looked up "assigned-addresses" in the PCI BUS Spec
and it looks like what I could use instead of phys-reg property. So if
this is the case then I need to to distinguish between the first on
secondary ioapic and go either for the reg property or
assigned-addresses.
[0]
http://groups.google.com/group/rtc-linux/browse_thread/thread/cd70c4d4865e2b30
>Cheers,
>Ben.
Sebastian
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
[not found] ` <20101128160449.GC30784-Hfxr4Dq0UpYb1SvskN2V4Q@public.gmane.org>
@ 2010-11-28 22:53 ` Benjamin Herrenschmidt
2010-11-29 1:34 ` Mitch Bradley
2010-11-29 19:07 ` Scott Wood
0 siblings, 2 replies; 36+ messages in thread
From: Benjamin Herrenschmidt @ 2010-11-28 22:53 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A, linux-kernel-u79uwXL29TY76Z2rM5mHXA
On Sun, 2010-11-28 at 17:04 +0100, Sebastian Andrzej Siewior wrote:
> * Benjamin Herrenschmidt | 2010-11-27 08:57:25 [+1100]:
>
> >> + */
> >> +/dts-v1/;
> >> +/ {
> >> + model = "x86,CE4100";
> >> + compatible = "x86,CE4100";
> >
> >Use a vendor name rather than "x86" here.
> Okay.
>
> >> + #address-cells = <1>;
> >> + #size-cells = <1>;
> >> +
> >> + cpus {
> >> + x86,Atom@0 {
> >
> >"Atom" would benefit from being more precise, like adding the model
> >number. Also you want some properties there defining maybe the mask, the
> >cache characteristics, etc... There's an exising OFW binding for x86, I
> >suppose you could follow it. A "reg" property at least is mandatory
> >here.
> I wasn't aware of the OFW binding for X86. I will follow it once I find
> it.
Interesting, I though I would find it on
http://www.openfirmware.info/Bindings but it's not there...
CC'ing Mitch who might know where to find that.
> >Also how do you plan to expose threading capability ?
> I haven't plan because this CPU has to threading capability. If there
> is, I would follow the powerpc way (unless it is allready documented how
> to do so on x86).
Atoms have SMT don't they ?
The powerpc way somewhat sucks since it uses a property named
"ibm,interrupt-server#" :-) We might want to define something more
generic here but the base idea is sane.
IE. There is a node per core. Each "thread" is identified by a unique
number we call the "interrupt server number". The "reg" property of a
core node is the isn of the first thread on that core. etc..
> >You probably also want some linkage from the processor to the local APIC
> >no ?
> Like now I walk through the device tree and look for one but that sounds
> like a good idea.
The day you have multiple Atom's on a board the "looking for one" won't
work well :-) Better have explicit references whenever you can for that
type of linkage.
> >> + device_type = "cpu";
> >> + };
> >> + };
> >> +
> >> + atom@0 {
> >> + #address-cells = <1>;
> >> + #size-cells = <1>;
> >> + device_type = "soc";
> >> + compatible = "simple-bus";
> >> + ranges;
> >> +
> >> + /* Local APIC */
> >> + lapic@fee00000 {
> >> + compatible = "intel,lapic";
> >> + reg = <0xfee00000 0x1000>;
> >> + phys_reg = <0xfee00000>;
> >> + };
> >> + /* Primary IO-APIC */
> >> + ioapic1: pic@fec00000 {
> >> + #interrupt-cells = <2>;
> >> + compatible = "intel,ioapic";
> >> + interrupt-controller;
> >> + device_type = "interrupt-controller";
> >> + id = <1>;
> >> + reg = <0xfec00000 0x1000>;
> >> + phys_reg = <0xfec00000>;
> >> + };
> >> +
> >
> >What are those phys-reg properties ?
> The second ioapic behind the PCI bus which uses the reg property for the
> devfn number so I can't use it for the chip address. I can't query the
> PCI information because the PCI bus is not up yet.
For the second ioapic, see below. This one isn't on PCI and should just
have "reg".
> The phys_reg property contains the physical address of the chip. The
> boot uart code in powerpc's tree has a virtual-reg property. So I though
> that this would be nice to keep things simple.
No, virtual-reg is a "hack" which contains a virtual address mapped by
the bootloader in the MMU for use by early boot code before takeover of
the MMU. It's not a physical address.
The physical addresses shall be expressed in the device-tree using the
normal mechanisms so that all the existing code to decode them "just
works".
> >Also APICs have some kind od
> >versionning, they aren't all identical, so your compatible property
> >needs to be more precise at least.
> The APIC has a register where you can read the version of the chip, yes.
> You want me to add this version into the compatible field?
Ideally, you should add something like
intel,ioapic-atomXXX intel-ioapic-vYY intel-ioapic
IE. From the most specific to the most generic. That way if a "quirk" is
ever needed due to an errata specific to that chip model that isn't
directly covered by the "version", you get to use that too (unless that
version register also contains things like mask number etc... in which
case it's probably enough).
> >> + hpet@fed00000 {
> >> + compatible = "intel,hpet";
> >> + reg = <0xfed00000 0x200>;
> >> + phys_reg = <0xfed00000>;
> >> + };
> >> + };
> >
> >All HPETs are identical ? If not, make your compatible property more
> >precise or if they are generally compatible from a programmer
> >perspective, use two entries from more generic to more specific, for
> >example:
> >
> > compatible = "intel,hpet","intel,hpet-atom-XXYY"
And of course I'm full of caca above, it shall be from the ost specific
to the most generic, so the other way around:
compatible = "intel,hpet-atom-XXYY","intel,hpet"
>
> >(or make up a numbering/naming scheme that makes sense for Intel gear)
> All hpets should be equal AFAIK. Some behave different but this was not
> intendend in the first place. This information is not even included in
> the ACPI tables.
Well, you should probably still at least provide the "specific" part in
compatible so that difference can be quirked easily (though of course
Linux probably won't care initially).
> >> + isa@legacy {
> >
> >So ISA isn't a child of "atom"... that makes "atom" a bit strange as a
> >node, tho not a big deal per se. I suppose it represent the on-die
> >peripherals but then you need at least some linkage between that and
> >the /cpus nodes.
>
> Yes, it should represent the on-die peripherals. How should that look
> like? The bus the same level as the cpu node and link from the cpu to
> the isa bus?
I would make isa a child of atom
> >> + device_type = "isa";
> >> + compatible = "simple-bus";
> >
> >What does "simple-bus" means ?
> I added simple bus in order to get probed. But I now I rember that this
> is also supported per device_type. I get rid of it.
device_type is a nasty bugger, we are trying to get rid of Linux
reliance on it.
Things like "simple-bus" don't rock my boat either, it's adding to the
device-tree "informations" that are specific to the way Linux will
interpret it, which is not how it should be.
In this case I would have said something like "atom,isa-bridge" but
heh...
> >ISA has a well defined binding, you
> >should follow it.
> I do. The reg property the rtc starts with "1" where 1 means it is an
> ioport and not ioremap()able adderess.
Ok.
> >> + #address-cells = <2>;
> >> + #size-cells = <1>;
> >> + ranges = <0 0 0 0x400>;
> >> +
> >> + rtc@legacy {
> >> + compatible = "motorola,mc146818";
> >> + interrupts = <8 3>;
> >> + interrupt-parent = <&ioapic1>;
> >> + ctrl_reg = <2>;
> >> + freq_reg = <0x26>;
> >> + reg = <1 0x70 2>;
> >> + };
> >
> >I think the ISA binding mandate the use of the PNP codes in the
> >compatible properties, doesn't it ?
> I'm not aware of it.
>
> > At least that's the common usage
> >pattern I've seen so far on powerpc.
> That is true.
>
> >
> >Also, "ctrl_reg" and "freq_reg" follow an existing binding ? If not,
> >then I'd suggest you use "-" instead of "_" which is more common in OFW
> >land and use more descriptive names since "reg" has a meaning of its own
> >and the above is a bit confusing.
> I posted a patch for this at [0]. Powerpc uses the the pnpPNP,b00 node
> for the rtc. This node is handled explictly by chrp and maple. Those two
> don't use the generic driver but their own.
>
> The remaining (mpc8572, p2020) handle this via add_rtc() in
> arch/powerpc/sysdev/rtc_cmos_setup.c. What they do is, they create a
> platform device for the OF node. What is missing is the initialization
> of the ctrl_reg register and the frequency. This is performed in a PCI
> quirk in quirk_final_uli1575() which is only performed on a few powerpc
> machines (is is_quirk_valid() has a list).
> This looks like dirty hack to me. I need to add every machine to it
> rather then a simple entry into the device tree. If you replace the uli
> with something else, you need another setup of this kind for the rtc.
I definitely agree that it's much better to use a property in the
device-tree and I'n not arguing against it :-) I was merely asking
whether that property name was already defined somewhere and if not,
suggesting a different naming (using dashes rather than underscores)
which is more consistent with traditional usage :-)
(Oh and maybe publish a binding wherever Grant puts these nowadays while
at it so we can all do the same thing from now on)
> >> + pci@3fc {
> >> + #address-cells = <3>;
> >> + #interrupt-cells = <1>;
> >> + #size-cells = <1>;
> >> + compatible = "intel,ce4100-pci";
> >> + device_type = "pci";
> >> + bus-range = <0 0>;
> >> +
> >> + /* Secondary IO-APIC */
> >> + ioapic2: pic@bffff000 {
> >> + #interrupt-cells = <2>;
> >> + compatible = "intel,ioapic";
> >> + interrupt-controller;
> >> + device_type = "interrupt-controller";
> >> + id = <2>;
> >> + reg = <0x100 0x0 0x0 0x0>;
> >> + phys_reg = <0xbffff000>;
> >> + };
> >
> >Here you define a PCI bus with a child device that isn't PCI from what I
> >can tell, tho the "reg" property content is confusing, and then there's
> >a unit address that doesn't match "reg" and a "phys_reg" (what the heck
> >is that ?) that matches the unit-address. Care to explain a bit
> >more ? :-)
> The reg property contains the devfn number, interrupt mask, pin number.
No. The "reg" property contains among other things the devfn, but
certainly not the interrupt mask and pin number. I recommend you look at
the PCI binding for OF, it's actually not very complicated :-)
The "reg" basically contains an entry for the "config space" of the
device which basically represents the devfn only, and an entry for each
BAR which contains the size and various attributes (not the assigned
address tho, this goes into a separate assigned-addresses property).
> That is what I've been seeing in PCI nodes. phys_reg is the physical
> address of the chip since reg is allready taken and PCI is not yet up
> (as I allready explained).
Right but with the appropriate assigned-addresses property, you can
represent that using standard properties (and use existing address
resolution helpers from drivers/of) without inventing a new "phys_reg"
which btw has issues too ("reg" traditionally is a tupple addr/size,
also where is the number of cells used in phys_reg defined ?).
> >I suspect that isn't the right way to represent the secondary
> >APIC
> Well the secondary APIC shows up on this PCI bus. It has devfn, vendor
> and device id and config space. Where should I put it if not here?
Ok, I didn't know that, so if it's a PCI device, do as I wrote above,
give it the proper set of PCI properties :-)
> >Also same comments about the compatible property.
> >
> >> + pci@av {
> >> + #address-cells = <3>;
> >> + #interrupt-cells = <1>;
> >> + #size-cells = <1>;
> >> + compatible = "intel,ce4100-pci";
> >> + device_type = "pci";
> >> + bus-range = <1 1>;
> >> + interrupt-map-mask = <0xffffff 0x0 0x0 0x0>;
> >
> >I notice that the interrupt number isn't part of your mask, is that
> >expected ? If you decide to make it so, remember that INT_A is 1 not 0
> >iirc (dbl check maybe ? I think that's how it is :-)
> Yes INT_A is 1 :) 0 means no interrupt available. I'm not using the
> interrupt pin here and therefore it is not in the mask.
> The ref manual contains a static mapping for every device so the
> interrupt pin has no meaning.
Ok, fair enough.
> Well this not enirely true: by default the
> pic is in legacy mode and all devices are on INT A. You can change this
> into a different mode where INT A - D are used. For this to happen you
> need to fiddle in some SoC specific registers. If you choose not to
> bother with it and use the ioapic instead then the interrupt pin remains
> unused. And we don't have real PCI bus where you can plug devices so it
> would matter.
That's ok, the DT should represent the way the SoC was configured, I
don't think it's worth bothering trying to cover all possible SoC
configurations and pin mux in one tree :-)
>
> >> + i2c@15a00 {
> >> + #address-cells = <1>;
> >> + #size-cells = <0>;
> >> + reg = <0x15a00 0x0 0x0 0x0>;
> >
> >OFW PCI binding, which we follow, mandates an "assigned-addresses"
> >property, tho I suppose that if you haven't assigned anything yet (and
> >will let Linux do so) the above is kosher. Your "reg" is a bit odd but I
> >don't have time to dbl check vs. the binding right now.
> reg is devfn. I just looked up "assigned-addresses" in the PCI BUS Spec
> and it looks like what I could use instead of phys-reg property. So if
> this is the case then I need to to distinguish between the first on
> secondary ioapic and go either for the reg property or
> assigned-addresses.
You don't really need to. There's code that will do that for you :-)
Stuff in drivers/of/address.c shall be able to parse the addresses by
index (tho I suppose you might still want to do a special case for PCI
since the natural way to get to a PCI based address is via a BAR number
while other stuff just takes an address index).
You shouldn't ever have to look directly at "reg" or
"assigned-addresses" yourself.
Cheers,
Ben.
> [0]
> http://groups.google.com/group/rtc-linux/browse_thread/thread/cd70c4d4865e2b30
>
> >Cheers,
> >Ben.
>
> Sebastian
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
2010-11-28 22:53 ` Benjamin Herrenschmidt
@ 2010-11-29 1:34 ` Mitch Bradley
2010-11-29 19:07 ` Scott Wood
1 sibling, 0 replies; 36+ messages in thread
From: Mitch Bradley @ 2010-11-29 1:34 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Sebastian Andrzej Siewior, linux-kernel, sodaville, x86,
devicetree-discuss
On 11/28/2010 12:53 PM, Benjamin Herrenschmidt wrote:
>> I wasn't aware of the OFW binding for X86. I will follow it once I find
>> it.
>
> Interesting, I though I would find it on
> http://www.openfirmware.info/Bindings but it's not there...
>
> CC'ing Mitch who might know where to find that.
I can't find the x86 binding either, which is a little bit embarrassing
since I wrote it, albeit about 15 years ago...
If my memory is correct, it is not particularly useful now. It
primarily dealt with the ABI for transferring control to the OS and for
calling back into the OFW client interface. The only company that used
it was Network Appliance, back when they were building their own x86
motherboards (because most off-the-shelf mobo's of that era did not meet
their stability requirements).
There has been a fair amount of churn since then, in relevant areas like
x86 privileged architecture, compiler versions and code generation
policies, popular bootloaders, OSs, and Linux early startup code. The
net result is that the ABI that the old binding specified probably isn't
right for today.
I'd be happy to work with people to develop a new x86 binding.
The OLPC interface might be of some use as a starting point, but would
need some work. It is currently in use on AMD Geode, Via C7, and Intel
Atom based systems, but, among other issues, it conflicts with the
Physical Address Extension feature.
Mitch
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
2010-11-26 21:57 ` Benjamin Herrenschmidt
2010-11-28 16:04 ` Sebastian Andrzej Siewior
@ 2010-11-29 2:22 ` David Gibson
1 sibling, 0 replies; 36+ messages in thread
From: David Gibson @ 2010-11-29 2:22 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ, Sebastian Andrzej Siewior,
x86-DgEjT+Ai2ygdnm+yROfE0A,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
On Sat, Nov 27, 2010 at 08:57:25AM +1100, Benjamin Herrenschmidt wrote:
>
> > + */
> > +/dts-v1/;
> > +/ {
> > + model = "x86,CE4100";
> > + compatible = "x86,CE4100";
>
> Use a vendor name rather than "x86" here.
>
> > + #address-cells = <1>;
> > + #size-cells = <1>;
> > +
> > + cpus {
> > + x86,Atom@0 {
>
> "Atom" would benefit from being more precise, like adding the model
> number. Also you want some properties there defining maybe the mask, the
> cache characteristics, etc... There's an exising OFW binding for x86, I
> suppose you could follow it. A "reg" property at least is mandatory
> here.
In the PowerPC flat-tree world, the newly established convention is to
extend the generic names convention to cpu nodes, so we name the nodes
just "cpu@0" etc. and move the more specific cpu type ("PowerPC,970FX"
/ "x86,Atom" / whatever) to the compatible property. I'd recommend
this convention to you, even though it's a bit of a break from earlier
standard practice, it makes device tree manipulations by bootloaders
and other intermediate things a bit easier.
> Also how do you plan to expose threading capability ?
Unless the existing x86 bindings specify something different, I'd
suggest the method we're planning to put into ePAPR 1.1 for PowerPC
chips. That is, threads sharing an MMU go in the same cpu node, with
the individual thread numbers given as multiple entries in the "reg"
property.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
2010-11-28 22:53 ` Benjamin Herrenschmidt
2010-11-29 1:34 ` Mitch Bradley
@ 2010-11-29 19:07 ` Scott Wood
2010-11-29 20:05 ` Benjamin Herrenschmidt
[not found] ` <20101129130720.7d060e1c-N/eSCTBpGwP7j4BuCOFQISmX4OfbXNuMKnGXBo5VDl8@public.gmane.org>
1 sibling, 2 replies; 36+ messages in thread
From: Scott Wood @ 2010-11-29 19:07 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Sebastian Andrzej Siewior, sodaville, devicetree-discuss, x86,
linux-kernel
On Mon, 29 Nov 2010 09:53:29 +1100
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> On Sun, 2010-11-28 at 17:04 +0100, Sebastian Andrzej Siewior wrote:
> > >> + isa@legacy {
What is "@legacy"? I don't think I've seen that in a unit address
before, googling only turns up this device tree, and a quick grep
through the ISA and base OF specs turns up nothing.
> > >> + device_type = "isa";
> > >> + compatible = "simple-bus";
> > >
> > >What does "simple-bus" means ?
> > I added simple bus in order to get probed. But I now I rember that this
> > is also supported per device_type. I get rid of it.
>
> device_type is a nasty bugger, we are trying to get rid of Linux
> reliance on it.
>
> Things like "simple-bus" don't rock my boat either, it's adding to the
> device-tree "informations" that are specific to the way Linux will
> interpret it, which is not how it should be.
The motivation for simple-bus comes from Linux, but its definition is
OS-neutral. It indicates that no special bus knowledge is required to
access the devices under it.
I don't think it applies to ISA, though -- I/O space is special bus
knowledge, and the "ranges" looks weird for memory-space as well.
If we're going to get rid of device_type here, it would be nice to have
some other way to indicate that this node follows the ISA binding,
without having to recognize an implementation-specific compatible.
-Scott
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
2010-11-29 19:07 ` Scott Wood
@ 2010-11-29 20:05 ` Benjamin Herrenschmidt
2010-11-29 20:32 ` Mitch Bradley
[not found] ` <20101129130720.7d060e1c-N/eSCTBpGwP7j4BuCOFQISmX4OfbXNuMKnGXBo5VDl8@public.gmane.org>
1 sibling, 1 reply; 36+ messages in thread
From: Benjamin Herrenschmidt @ 2010-11-29 20:05 UTC (permalink / raw)
To: Scott Wood
Cc: Sebastian Andrzej Siewior, sodaville, devicetree-discuss, x86,
linux-kernel
On Mon, 2010-11-29 at 13:07 -0600, Scott Wood wrote:
>
> The motivation for simple-bus comes from Linux, but its definition is
> OS-neutral. It indicates that no special bus knowledge is required to
> access the devices under it.
That's never 100% true. In the case of ISA it's even less true due to
the difference between IO and Memory space.
> I don't think it applies to ISA, though -- I/O space is special bus
> knowledge, and the "ranges" looks weird for memory-space as well.
Right.
> If we're going to get rid of device_type here, it would be nice to
> have some other way to indicate that this node follows the ISA
> binding, without having to recognize an implementation-specific
> compatible.
The code in drivers/of/address.c uses the name property to match isa
busses.
Cheers,
Ben.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
2010-11-29 20:05 ` Benjamin Herrenschmidt
@ 2010-11-29 20:32 ` Mitch Bradley
2010-11-29 23:42 ` Alan Cox
[not found] ` <4CF40DF4.9060204-D5eQfiDGL7eakBO8gow8eQ@public.gmane.org>
0 siblings, 2 replies; 36+ messages in thread
From: Mitch Bradley @ 2010-11-29 20:32 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Scott Wood, sodaville, Sebastian Andrzej Siewior, x86,
devicetree-discuss, linux-kernel
The usual layout is that the PCI bus is a direct child of
the root node, and the ISA bus is a child of the PCI bus.
That reflects the "Northbridge + Southbridge" wiring that
was common at the time that PCI was first introduced.
It's usually the case that faster and wider buses are closer
to the root, with speed and address width decreasing as you
go away from the root.
The fact that PCI configuration accesses are done via I/O
port 0x3fc doesn't make it a child of the ISA bus, because
I/O space is inherent in the x86 CPU architecture and thus
can be considered to be part of the root address space.
In the systems that I have worked with, the ISA bridge is a
first-class PCI device with a PCI config header, so it fits
naturally underneath the PCI bus.
Here are the properties for PCI and ISA on the OLPC XO-1.5
platform (Via C7 x86 CPU with Via VX855 IO chip):
ok dev /pci
ok .properties
interrupt-map 00000800 00000000 00000000 00000001 ff86bf34 0000000a 00000000
00006000 00000000 00000000 00000001 ff86bf34 0000000a 00000000
00008000 00000000 00000000 00000001 ff86bf34 0000000a 00000000
00008100 00000000 00000000 00000002 ff86bf34 00000009 00000000
00008200 00000000 00000000 00000003 ff86bf34 0000000b 00000000
00008400 00000000 00000000 00000004 ff86bf34 0000000a 00000000
0000a000 00000000 00000000 00000001 ff86bf34 00000009 00000000
interrupt-map-mask 0000ff00 00000000 00000000 00000007
#interrupt-cells 00000001
slot-names 00000000
slave-only 00000000
clock-frequency 01fca055
bus-range 00000000 00000000
#size-cells 00000002
#address-cells 00000003
device_type pci
name pci
ok dev /pci/isa
ok .properties
devsel-speed 00000001
class-code 00060100
subsystem-vendor-id 0000152d
subsystem-id 00000833
max-latency 00000000
min-grant 00000000
revision-id 00000000
device-id 00008409
vendor-id 00001106
interrupt-parent ff86bf34
#interrupt-cells 00000002
ranges 00000000 00000000 02000000 00000000 00000000 01000000
00000001 00000000 01000000 00000000 00000000 00010000
clock-frequency 007ea5e0
reg 00008800 00000000 00000000 00000000 00000000
#size-cells 00000001
#address-cells 00000002
device_type isa
name isa
Note that the PCI node has no reg property. On a system with multiple independent PCI buses at the top level, it would be necessary to distinguish them with reg properties reflecting their different addresses in the root address space. PC-style architectures typically (always?) have a single top-level PCI domain, so I've never never needed to do that in x86 land. It used to be pretty common on PPC "big iron".
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
[not found] ` <4CF40DF4.9060204-D5eQfiDGL7eakBO8gow8eQ@public.gmane.org>
@ 2010-11-29 20:44 ` Benjamin Herrenschmidt
2010-11-29 21:32 ` Mitch Bradley
2010-11-29 23:47 ` Alan Cox
2010-11-30 11:51 ` Sebastian Andrzej Siewior
1 sibling, 2 replies; 36+ messages in thread
From: Benjamin Herrenschmidt @ 2010-11-29 20:44 UTC (permalink / raw)
To: Mitch Bradley
Cc: Sebastian Andrzej Siewior, x86-DgEjT+Ai2ygdnm+yROfE0A,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
sodaville-hfZtesqFncYOwBW4kG4KsQ, Scott Wood,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
On Mon, 2010-11-29 at 10:32 -1000, Mitch Bradley wrote:
> The usual layout is that the PCI bus is a direct child of
> the root node, and the ISA bus is a child of the PCI bus.
Right, tho we have been relaxing that on SoC for some time now, at least
on powerpc, since the PCI bus itself tend to hang off one of the SoC
internal busses (as a sibling of other busses) and that those tend to be
represented in the tree, so we make PCI be a child of that SoC bus.
This is also useful in the case where you have multiple SoCs (some are
capable of SMP interconnects) in which case you really have multiple
separate PCI busses and it's clearer to have each of them be the child
of its own SoC node.
> That reflects the "Northbridge + Southbridge" wiring that
> was common at the time that PCI was first introduced.
> It's usually the case that faster and wider buses are closer
> to the root, with speed and address width decreasing as you
> go away from the root.
>
> The fact that PCI configuration accesses are done via I/O
> port 0x3fc doesn't make it a child of the ISA bus, because
> I/O space is inherent in the x86 CPU architecture and thus
> can be considered to be part of the root address space.
>
> In the systems that I have worked with, the ISA bridge is a
> first-class PCI device with a PCI config header, so it fits
> naturally underneath the PCI bus.
This is actually the case of most systems, tho those Atoms SoC are a bit
weird as, afaik, they don't really have PCI... they just simulate some
kind of PCI config space for on-chip devices ,at least that's my
understanding.
Sebastian, do you have a block diagram of the SoC ? Following the actual
bus hierarchy of the chip might be the best approach.
Cheers,
Ben.
> Here are the properties for PCI and ISA on the OLPC XO-1.5
> platform (Via C7 x86 CPU with Via VX855 IO chip):
>
>
> ok dev /pci
> ok .properties
> interrupt-map 00000800 00000000 00000000 00000001 ff86bf34 0000000a 00000000
> 00006000 00000000 00000000 00000001 ff86bf34 0000000a 00000000
> 00008000 00000000 00000000 00000001 ff86bf34 0000000a 00000000
> 00008100 00000000 00000000 00000002 ff86bf34 00000009 00000000
> 00008200 00000000 00000000 00000003 ff86bf34 0000000b 00000000
> 00008400 00000000 00000000 00000004 ff86bf34 0000000a 00000000
> 0000a000 00000000 00000000 00000001 ff86bf34 00000009 00000000
> interrupt-map-mask 0000ff00 00000000 00000000 00000007
> #interrupt-cells 00000001
> slot-names 00000000
> slave-only 00000000
> clock-frequency 01fca055
> bus-range 00000000 00000000
> #size-cells 00000002
> #address-cells 00000003
> device_type pci
> name pci
>
> ok dev /pci/isa
> ok .properties
> devsel-speed 00000001
> class-code 00060100
> subsystem-vendor-id 0000152d
> subsystem-id 00000833
> max-latency 00000000
> min-grant 00000000
> revision-id 00000000
> device-id 00008409
> vendor-id 00001106
> interrupt-parent ff86bf34
> #interrupt-cells 00000002
> ranges 00000000 00000000 02000000 00000000 00000000 01000000
> 00000001 00000000 01000000 00000000 00000000 00010000
> clock-frequency 007ea5e0
> reg 00008800 00000000 00000000 00000000 00000000
> #size-cells 00000001
> #address-cells 00000002
> device_type isa
> name isa
>
> Note that the PCI node has no reg property. On a system with multiple independent PCI buses at the top level, it would be necessary to distinguish them with reg properties reflecting their different addresses in the root address space. PC-style architectures typically (always?) have a single top-level PCI domain, so I've never never needed to do that in x86 land. It used to be pretty common on PPC "big iron".
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
2010-11-29 20:44 ` Benjamin Herrenschmidt
@ 2010-11-29 21:32 ` Mitch Bradley
2010-11-29 23:47 ` Alan Cox
1 sibling, 0 replies; 36+ messages in thread
From: Mitch Bradley @ 2010-11-29 21:32 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Sebastian Andrzej Siewior, x86-DgEjT+Ai2ygdnm+yROfE0A,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
sodaville-hfZtesqFncYOwBW4kG4KsQ, Scott Wood,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
On 11/29/2010 10:44 AM, Benjamin Herrenschmidt wrote:
> On Mon, 2010-11-29 at 10:32 -1000, Mitch Bradley wrote:
>> The usual layout is that the PCI bus is a direct child of
>> the root node, and the ISA bus is a child of the PCI bus.
>
> Right, tho we have been relaxing that on SoC for some time now, at least
> on powerpc, since the PCI bus itself tend to hang off one of the SoC
> internal busses (as a sibling of other busses) and that those tend to be
> represented in the tree, so we make PCI be a child of that SoC bus.
That seems fine to me. It's not important that PCI be directly attached
to the root bus. I was mostly concerned about the relative positions of
ISA and PCI.
>
> This is also useful in the case where you have multiple SoCs (some are
> capable of SMP interconnects) in which case you really have multiple
> separate PCI busses and it's clearer to have each of them be the child
> of its own SoC node.
>
>> That reflects the "Northbridge + Southbridge" wiring that
>> was common at the time that PCI was first introduced.
>> It's usually the case that faster and wider buses are closer
>> to the root, with speed and address width decreasing as you
>> go away from the root.
>>
>> The fact that PCI configuration accesses are done via I/O
>> port 0x3fc doesn't make it a child of the ISA bus, because
>> I/O space is inherent in the x86 CPU architecture and thus
>> can be considered to be part of the root address space.
>>
>> In the systems that I have worked with, the ISA bridge is a
>> first-class PCI device with a PCI config header, so it fits
>> naturally underneath the PCI bus.
>
> This is actually the case of most systems, tho those Atoms SoC are a bit
> weird as, afaik, they don't really have PCI... they just simulate some
> kind of PCI config space for on-chip devices ,at least that's my
> understanding.
>
> Sebastian, do you have a block diagram of the SoC ? Following the actual
> bus hierarchy of the chip might be the best approach.
>
> Cheers,
> Ben.
>
>> Here are the properties for PCI and ISA on the OLPC XO-1.5
>> platform (Via C7 x86 CPU with Via VX855 IO chip):
>>
>>
>> ok dev /pci
>> ok .properties
>> interrupt-map 00000800 00000000 00000000 00000001 ff86bf34 0000000a 00000000
>> 00006000 00000000 00000000 00000001 ff86bf34 0000000a 00000000
>> 00008000 00000000 00000000 00000001 ff86bf34 0000000a 00000000
>> 00008100 00000000 00000000 00000002 ff86bf34 00000009 00000000
>> 00008200 00000000 00000000 00000003 ff86bf34 0000000b 00000000
>> 00008400 00000000 00000000 00000004 ff86bf34 0000000a 00000000
>> 0000a000 00000000 00000000 00000001 ff86bf34 00000009 00000000
>> interrupt-map-mask 0000ff00 00000000 00000000 00000007
>> #interrupt-cells 00000001
>> slot-names 00000000
>> slave-only 00000000
>> clock-frequency 01fca055
>> bus-range 00000000 00000000
>> #size-cells 00000002
>> #address-cells 00000003
>> device_type pci
>> name pci
>>
>> ok dev /pci/isa
>> ok .properties
>> devsel-speed 00000001
>> class-code 00060100
>> subsystem-vendor-id 0000152d
>> subsystem-id 00000833
>> max-latency 00000000
>> min-grant 00000000
>> revision-id 00000000
>> device-id 00008409
>> vendor-id 00001106
>> interrupt-parent ff86bf34
>> #interrupt-cells 00000002
>> ranges 00000000 00000000 02000000 00000000 00000000 01000000
>> 00000001 00000000 01000000 00000000 00000000 00010000
>> clock-frequency 007ea5e0
>> reg 00008800 00000000 00000000 00000000 00000000
>> #size-cells 00000001
>> #address-cells 00000002
>> device_type isa
>> name isa
>>
>> Note that the PCI node has no reg property. On a system with multiple independent PCI buses at the top level, it would be necessary to distinguish them with reg properties reflecting their different addresses in the root address space. PC-style architectures typically (always?) have a single top-level PCI domain, so I've never never needed to do that in x86 land. It used to be pretty common on PPC "big iron".
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at http://www.tux.org/lkml/
>
>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
2010-11-29 20:32 ` Mitch Bradley
@ 2010-11-29 23:42 ` Alan Cox
[not found] ` <4CF40DF4.9060204-D5eQfiDGL7eakBO8gow8eQ@public.gmane.org>
1 sibling, 0 replies; 36+ messages in thread
From: Alan Cox @ 2010-11-29 23:42 UTC (permalink / raw)
To: Mitch Bradley
Cc: Benjamin Herrenschmidt, Scott Wood, sodaville,
Sebastian Andrzej Siewior, x86, devicetree-discuss, linux-kernel
> The usual layout is that the PCI bus is a direct child of
> the root node, and the ISA bus is a child of the PCI bus.
> That reflects the "Northbridge + Southbridge" wiring that
That isn't strictly true either. On many PC devices the ISA bus (or LPC
bus nowdays) has no heirarchy as such because ISA cycles get issued if
the PCI cycles don't generate a response. In addition some cycles go to
both busses on some chipsets and there are various bits of magic so the
I/O spaces and particularly the memory spaces are intertwined.
So it's not a subordinate bus really, its a bit weirder. PCMCIA is
probably a sub-bus when you've got a PCI/PCMCIA adapter but ISA in
general is a bit fuzzy.
And then there are systems like PA-RISC where there are multiple entire
PCI/ISA busses hung off the primary bus which is neither 8)
There are also various bits of "architectural" space which are on the
motherboard (traditionally 0x00-0xFF) but some of which are on the CPU in
some cases (Cyrix was 0x21/22 if I remember), and there are other
architectural spaces like the ELCR which are "magic".
The PC is alas to computer architecture what perl is to programming
languages.
Alan
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
2010-11-29 20:44 ` Benjamin Herrenschmidt
2010-11-29 21:32 ` Mitch Bradley
@ 2010-11-29 23:47 ` Alan Cox
[not found] ` <20101129234735.4ce3a933-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
1 sibling, 1 reply; 36+ messages in thread
From: Alan Cox @ 2010-11-29 23:47 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Mitch Bradley, Scott Wood, sodaville, Sebastian Andrzej Siewior,
x86, devicetree-discuss, linux-kernel
> This is actually the case of most systems, tho those Atoms SoC are a bit
> weird as, afaik, they don't really have PCI... they just simulate some
> kind of PCI config space for on-chip devices ,at least that's my
> understanding.
This is true of a lot of devices on most "PCI" chipsets today. Even back
to things like the VIA K6 era chipsets with the V-Bus, or the
MediaGX/Geode where some of PCI space is a hallucination brought on by
SMM traps and BIOS upgrades have been known to add devices to the bus
which are not even neatly on their own sub-tree of any kind. Indeed some
PCI devices may be half PCI half magic.
> Sebastian, do you have a block diagram of the SoC ? Following the actual
> bus hierarchy of the chip might be the best approach.
That may not be wise. Your real bus heirarchy may not be architecturally
defined on some systems so you can't incorporate it into code, nor is it
necessarily a heirarchy - eg some of the Geodes.
Alan
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
[not found] ` <20101129130720.7d060e1c-N/eSCTBpGwP7j4BuCOFQISmX4OfbXNuMKnGXBo5VDl8@public.gmane.org>
@ 2010-11-29 23:58 ` David Gibson
0 siblings, 0 replies; 36+ messages in thread
From: David Gibson @ 2010-11-29 23:58 UTC (permalink / raw)
To: Scott Wood
Cc: Sebastian Andrzej Siewior, x86-DgEjT+Ai2ygdnm+yROfE0A,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
sodaville-hfZtesqFncYOwBW4kG4KsQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
On Mon, Nov 29, 2010 at 01:07:20PM -0600, Scott Wood wrote:
> On Mon, 29 Nov 2010 09:53:29 +1100
> Benjamin Herrenschmidt <benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org> wrote:
> > On Sun, 2010-11-28 at 17:04 +0100, Sebastian Andrzej Siewior wrote:
> > > >> + isa@legacy {
>
> What is "@legacy"? I don't think I've seen that in a unit address
> before, googling only turns up this device tree, and a quick grep
> through the ISA and base OF specs turns up nothing.
>
> > > >> + device_type = "isa";
> > > >> + compatible = "simple-bus";
> > > >
> > > >What does "simple-bus" means ?
> > > I added simple bus in order to get probed. But I now I rember that this
> > > is also supported per device_type. I get rid of it.
> >
> > device_type is a nasty bugger, we are trying to get rid of Linux
> > reliance on it.
> >
> > Things like "simple-bus" don't rock my boat either, it's adding to the
> > device-tree "informations" that are specific to the way Linux will
> > interpret it, which is not how it should be.
>
> The motivation for simple-bus comes from Linux, but its definition is
> OS-neutral. It indicates that no special bus knowledge is required to
> access the devices under it.
Well, sort of. More specifically, that plus it indicates that the bus
does not support any method of dynamic probing, so the device tree is
the *only* way to figure out what's on it.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
[not found] ` <20101129234735.4ce3a933-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
@ 2010-11-30 2:50 ` Benjamin Herrenschmidt
2010-11-30 11:20 ` Sebastian Andrzej Siewior
0 siblings, 1 reply; 36+ messages in thread
From: Benjamin Herrenschmidt @ 2010-11-30 2:50 UTC (permalink / raw)
To: Alan Cox
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ, Sebastian Andrzej Siewior,
x86-DgEjT+Ai2ygdnm+yROfE0A, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
Scott Wood, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
On Mon, 2010-11-29 at 23:47 +0000, Alan Cox wrote:
>
> That may not be wise. Your real bus heirarchy may not be architecturally
> defined on some systems so you can't incorporate it into code, nor is it
> necessarily a heirarchy - eg some of the Geodes.
Ok, so I'd suggest doing something like:
- pci is below the corresponding atom node
- isa is a child of pci
The later is a useful representation even if it doesn't correspond to
reality. From an address representation perspective, ISA can be
considered somewhat as a substractive decoding child of PCI (again even
if that's not 100% true), which simplifies the representation in the
device-tree a bit, and allows to still have things like VGA devices on
the PCI segment that decode IO ports in the ISA range.
Cheers,
Ben.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
2010-11-30 2:50 ` Benjamin Herrenschmidt
@ 2010-11-30 11:20 ` Sebastian Andrzej Siewior
0 siblings, 0 replies; 36+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-30 11:20 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
Scott Wood, Alan Cox
Benjamin Herrenschmidt wrote:
> On Mon, 2010-11-29 at 23:47 +0000, Alan Cox wrote:
>> That may not be wise. Your real bus heirarchy may not be architecturally
>> defined on some systems so you can't incorporate it into code, nor is it
>> necessarily a heirarchy - eg some of the Geodes.
>
> Ok, so I'd suggest doing something like:
>
> - pci is below the corresponding atom node
> - isa is a child of pci
>
> The later is a useful representation even if it doesn't correspond to
> reality. From an address representation perspective, ISA can be
> considered somewhat as a substractive decoding child of PCI (again even
> if that's not 100% true), which simplifies the representation in the
> device-tree a bit, and allows to still have things like VGA devices on
> the PCI segment that decode IO ports in the ISA range.
okay.
> Cheers,
> Ben.
Sebastian
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
[not found] ` <4CF40DF4.9060204-D5eQfiDGL7eakBO8gow8eQ@public.gmane.org>
2010-11-29 20:44 ` Benjamin Herrenschmidt
@ 2010-11-30 11:51 ` Sebastian Andrzej Siewior
[not found] ` <4CF4E54D.5040403-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
1 sibling, 1 reply; 36+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-30 11:51 UTC (permalink / raw)
To: Mitch Bradley
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
sodaville-hfZtesqFncYOwBW4kG4KsQ, Scott Wood
Mitch Bradley wrote:
> Here are the properties for PCI and ISA on the OLPC XO-1.5
> platform (Via C7 x86 CPU with Via VX855 IO chip):
>
> ok dev /pci/isa
> ok .properties
> reg 00008800 00000000 00000000 00000000 00000000
> Note that the PCI node has no reg property. On a system with multiple independent PCI buses at the top level, it would be necessary to distinguish them with reg properties reflecting their different addresses in the root address space. PC-style architectures typically (always?) have a single top-level PCI domain, so I've never never needed to do that in x86 land. It used to be pretty common on PPC "big iron".
My PCI node does not have a reg property but its child nodes.
In x86_of_pci_init() [0] I walk through the PCI child nodes, read the reg
property of each node which gives me the devfn of the device. I pass this
pci_get_slot() and get the pci_dev struct where I attach the of_node. So
it can by used by the pci driver.
How do I create the PCI device <-> OF node mapping with this? I think your
isa node has this as well. 00008800 is the devfn and I simply forgot the
four blocks of zeros.
[0] http://lkml.org/lkml/2010/11/25/294
Sebastian
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
[not found] ` <4CF4E54D.5040403-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
@ 2010-11-30 20:31 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 36+ messages in thread
From: Benjamin Herrenschmidt @ 2010-11-30 20:31 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
Scott Wood
On Tue, 2010-11-30 at 12:51 +0100, Sebastian Andrzej Siewior wrote:
> My PCI node does not have a reg property but its child nodes.
> In x86_of_pci_init() [0] I walk through the PCI child nodes, read the reg
> property of each node which gives me the devfn of the device. I pass this
> pci_get_slot() and get the pci_dev struct where I attach the of_node. So
> it can by used by the pci driver.
>
> How do I create the PCI device <-> OF node mapping with this? I think your
> isa node has this as well. 00008800 is the devfn and I simply forgot the
> four blocks of zeros.
I think Mitch meant the PCI host bridge usually has a reg property in
the address space of the parent, used to identify the bridge uniquely if
you have multiple of them.
Cheers,
Ben.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Device tree on x86, part v4
@ 2011-02-22 20:07 Sebastian Andrzej Siewior
2011-02-22 20:07 ` [PATCH 01/11] x86/e820: remove conditional early mapping in parse_e820_ext Sebastian Andrzej Siewior
` (2 more replies)
0 siblings, 3 replies; 36+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-02-22 20:07 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A
This patchset introduces device tree support on x86. The device tree is
passed by the bootloader via setup_data. It is used as an additional
source of information and does not replace the "traditional" x86 boot
page.
Right now we get the the following information from it:
- hpet location
- apic & ioapic location
- ioapic's interrupt routing
- legacy devices which are not initialized by bios
- devices which are behind a bus which does not support enumeration like
i2c
History:
- v1 initial post
- v2: Benh took my device tree apart so once this got fixed I refactor a
lot of code. Here are the changes:
- device tree is unflattenend before kmalloc() is working,
alloc_bootmem() is used for that.
- irq_host got renamed to irq_domain. This custom implementation
will leave once the powerpc implementation is in generic shape
- of_irq_map_pci() is moved from ppc & microblaze into drivers/of
and used also by x86 instead of a tiny subset of it. Bridges are
not handled at all on x86 (I don't have any so for so I worry
later)
- the device tree is relocated from its initial location. That
means that the boot loader does not need to know anything about
kernel's memory layout.
- v3: - rebase on top of current tip. The OLPC merged some OF defines
which are mostly nops so I replaced them with the code I have.
irq_create_of_mapping() requires now an irq chip to work. Those
things are moved into prom.c which is enabled by CONFIG_X86_OF.
This probably breaks OLPC but I don't know what they need in the
end.
- Fixed up Grant's review comments. The most noticeable is the i2c
controller node which has now three child nodes, representing the
three controllers indentified by the bar number. Each pci bar
matches via address translation the correct device tree node.
- v4: - rebased on top of tip's x86/platform branch.
- added some documentation about the new compatible properties.
- merged the two rtc commits.
- renamed prom.c to devicetree.c
- renamed CONFIG_X86_OF to CONFIG_USE_OF
- intel,ce4100-immr become intel,ce4100-cp
- "standard" hardware like hpet has "ce4100" in its property. If
further HW is compatible with it, can reuse the property string.
- converted interrupt map to device nodes with an interrupt property.
The series is based on the tip tree and is also available at
git://git.linutronix.de/users/bigeasy/soda.git ce_of_v4
Sebastian Andrzej Siewior (11):
x86/e820: remove conditional early mapping in parse_e820_ext
x86: Add device tree support
x86/dtb: Add a device tree for CE4100
x86/dtb: add irq domain abstraction
x86/dtb: add early parsing of IO APIC
x86/dtb: add support hpet
x86/dtb: add support for PCI devices backed by dtb nodes
x86/dtb: Add generic bus probe
x86/ioapic: Add OF bindings for IO-APIC
x86/ce4100: use OF for ioapic
rtc/cmos: add OF bindings
.../devicetree/bindings/i2c/ce4100-i2c.txt | 93 +++++
Documentation/devicetree/bindings/rtc/rtc-cmos.txt | 28 ++
Documentation/devicetree/bindings/x86/ce4100.txt | 38 ++
.../devicetree/bindings/x86/interrupt.txt | 29 ++
Documentation/devicetree/bindings/x86/timer.txt | 6 +
Documentation/devicetree/booting-without-of.txt | 20 +
arch/x86/Kconfig | 7 +
arch/x86/include/asm/bootparam.h | 1 +
arch/x86/include/asm/e820.h | 2 +-
arch/x86/include/asm/io_apic.h | 7 +
arch/x86/include/asm/irq.h | 3 -
arch/x86/include/asm/irq_controller.h | 12 +
arch/x86/include/asm/prom.h | 72 ++++-
arch/x86/kernel/Makefile | 1 +
arch/x86/kernel/apic/io_apic.c | 99 +++++
arch/x86/kernel/devicetree.c | 337 +++++++++++++++
arch/x86/kernel/e820.c | 8 +-
arch/x86/kernel/irq.c | 9 -
arch/x86/kernel/irqinit.c | 9 +-
arch/x86/kernel/rtc.c | 3 +
arch/x86/kernel/setup.c | 22 +-
arch/x86/platform/ce4100/ce4100.c | 24 +-
arch/x86/platform/ce4100/falconfalls.dts | 430 ++++++++++++++++++++
drivers/of/Kconfig | 2 +-
drivers/of/of_pci.c | 1 +
drivers/rtc/rtc-cmos.c | 45 ++
include/linux/of.h | 12 +
27 files changed, 1287 insertions(+), 33 deletions(-)
create mode 100644 Documentation/devicetree/bindings/i2c/ce4100-i2c.txt
create mode 100644 Documentation/devicetree/bindings/rtc/rtc-cmos.txt
create mode 100644 Documentation/devicetree/bindings/x86/ce4100.txt
create mode 100644 Documentation/devicetree/bindings/x86/interrupt.txt
create mode 100644 Documentation/devicetree/bindings/x86/timer.txt
create mode 100644 arch/x86/include/asm/irq_controller.h
create mode 100644 arch/x86/kernel/devicetree.c
create mode 100644 arch/x86/platform/ce4100/falconfalls.dts
Sebastian
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH 01/11] x86/e820: remove conditional early mapping in parse_e820_ext
2011-02-22 20:07 Device tree on x86, part v4 Sebastian Andrzej Siewior
@ 2011-02-22 20:07 ` Sebastian Andrzej Siewior
[not found] ` <1298405266-1624-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2011-02-22 21:16 ` Device tree on x86, part v4 Grant Likely
2 siblings, 0 replies; 36+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-02-22 20:07 UTC (permalink / raw)
To: linux-kernel
Cc: sodaville, devicetree-discuss, x86, Sebastian Andrzej Siewior,
Dirk Brandewie
This patch ensures that the memory passed from parse_setup_data() is
large enough to cover the complete data structure. That means that the
conditional mapping in parse_e820_ext() can go.
While here, I also attempt not to map two pages if the address is not
aligned to a page boundary.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
---
arch/x86/include/asm/e820.h | 2 +-
arch/x86/kernel/e820.c | 8 +-------
arch/x86/kernel/setup.c | 18 +++++++++++++++---
3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h
index e99d55d..908b969 100644
--- a/arch/x86/include/asm/e820.h
+++ b/arch/x86/include/asm/e820.h
@@ -96,7 +96,7 @@ extern void e820_setup_gap(void);
extern int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize,
unsigned long start_addr, unsigned long long end_addr);
struct setup_data;
-extern void parse_e820_ext(struct setup_data *data, unsigned long pa_data);
+extern void parse_e820_ext(struct setup_data *data);
#if defined(CONFIG_X86_64) || \
(defined(CONFIG_X86_32) && defined(CONFIG_HIBERNATION))
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 294f26d..5fad626 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -667,21 +667,15 @@ __init void e820_setup_gap(void)
* boot_params.e820_map, others are passed via SETUP_E820_EXT node of
* linked list of struct setup_data, which is parsed here.
*/
-void __init parse_e820_ext(struct setup_data *sdata, unsigned long pa_data)
+void __init parse_e820_ext(struct setup_data *sdata)
{
- u32 map_len;
int entries;
struct e820entry *extmap;
entries = sdata->len / sizeof(struct e820entry);
- map_len = sdata->len + sizeof(struct setup_data);
- if (map_len > PAGE_SIZE)
- sdata = early_ioremap(pa_data, map_len);
extmap = (struct e820entry *)(sdata->data);
__append_e820_map(extmap, entries);
sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
- if (map_len > PAGE_SIZE)
- early_iounmap(sdata, map_len);
printk(KERN_INFO "extended physical RAM map:\n");
e820_print_map("extended");
}
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index ca2f106..96cdb9c 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -429,16 +429,28 @@ static void __init parse_setup_data(void)
return;
pa_data = boot_params.hdr.setup_data;
while (pa_data) {
- data = early_memremap(pa_data, PAGE_SIZE);
+ u32 data_len;
+ u32 map_len;
+
+ map_len = max(PAGE_SIZE - (pa_data & ~PAGE_MASK),
+ (u64)sizeof(struct setup_data));
+ data = early_memremap(pa_data, map_len);
+ data_len = data->len + sizeof(struct setup_data);
+ if (data_len > map_len) {
+ early_iounmap(data, map_len);
+ data = early_memremap(pa_data, data_len);
+ map_len = data_len;
+ }
+
switch (data->type) {
case SETUP_E820_EXT:
- parse_e820_ext(data, pa_data);
+ parse_e820_ext(data);
break;
default:
break;
}
pa_data = data->next;
- early_iounmap(data, PAGE_SIZE);
+ early_iounmap(data, map_len);
}
}
--
1.7.4
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 02/11] x86: Add device tree support
[not found] ` <1298405266-1624-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
@ 2011-02-22 20:07 ` Sebastian Andrzej Siewior
2011-02-22 20:07 ` [PATCH 03/11] x86/dtb: Add a device tree for CE4100 Sebastian Andrzej Siewior
` (8 subsequent siblings)
9 siblings, 0 replies; 36+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-02-22 20:07 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A, Sebastian Andrzej Siewior
This patch adds minimal support for device tree support on x86. It will
be passed to the kernel via setup_data which requires atleast boot
protocol 2.09.
Memory size, restricted memory regions, boot arguments are gathered the
traditional way so things like cmd_line are just here to let the code
compile.
The current plan is use the device tree as an extension and to gather
informations from it which can not be enumerated and have to be
hardcoded otherwise. This includes things like
- which devices are on this I2C/ SPI bus?
- how are the interrupts wired to IO APIC?
- where could my hpet be?
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Acked-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
Documentation/devicetree/booting-without-of.txt | 20 +++++++++
arch/x86/Kconfig | 7 +++
arch/x86/include/asm/bootparam.h | 1 +
arch/x86/include/asm/irq.h | 3 -
arch/x86/include/asm/prom.h | 47 ++++++++++++++++++++-
arch/x86/kernel/Makefile | 1 +
arch/x86/kernel/devicetree.c | 51 +++++++++++++++++++++++
arch/x86/kernel/irq.c | 9 ----
arch/x86/kernel/setup.c | 4 ++
9 files changed, 130 insertions(+), 13 deletions(-)
create mode 100644 arch/x86/kernel/devicetree.c
diff --git a/Documentation/devicetree/booting-without-of.txt b/Documentation/devicetree/booting-without-of.txt
index 28b1c9d..55fd262 100644
--- a/Documentation/devicetree/booting-without-of.txt
+++ b/Documentation/devicetree/booting-without-of.txt
@@ -13,6 +13,7 @@ Table of Contents
I - Introduction
1) Entry point for arch/powerpc
+ 2) Entry point for arch/x86
II - The DT block format
1) Header
@@ -225,6 +226,25 @@ it with special cases.
cannot support both configurations with Book E and configurations
with classic Powerpc architectures.
+2) Entry point for arch/x86
+-------------------------------
+
+ There is one single 32bit entry point to the kernel at code32_start,
+ the decompressor (the real mode entry point goes to the same 32bit
+ entry point once it switched into protected mode). That entry point
+ supports one calling convention which is documented in
+ Documentation/x86/boot.txt
+ The physical pointer to the device-tree block (defined in chapter II)
+ is passed via setup_data which requires at least boot protocol 2.09.
+ The type filed is defined as
+
+ #define SETUP_DTB 2
+
+ This device-tree is used as an extension to the "boot page". As such it
+ does not parse / consider data which is already covered by the boot
+ page. This includes memory size, reserved ranges, command line arguments
+ or initrd address. It simply holds information which can not be retrieved
+ otherwise like interrupt routing or a list of devices behind an I2C bus.
II - The DT block format
========================
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index d5ed94d..ce7c7b9 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -297,6 +297,13 @@ config X86_BIGSMP
---help---
This option is needed for the systems that have more than 8 CPUs
+config USE_OF
+ bool "Support for device tree"
+ select OF
+ select OF_EARLY_FLATTREE
+ ---help---
+ Device tree support on X86.
+
if X86_32
config X86_EXTENDED_PLATFORM
bool "Support for extended (non-PC) x86 platforms"
diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h
index c8bfe63..e020d88 100644
--- a/arch/x86/include/asm/bootparam.h
+++ b/arch/x86/include/asm/bootparam.h
@@ -12,6 +12,7 @@
/* setup data types */
#define SETUP_NONE 0
#define SETUP_E820_EXT 1
+#define SETUP_DTB 2
/* extensible setup data list node */
struct setup_data {
diff --git a/arch/x86/include/asm/irq.h b/arch/x86/include/asm/irq.h
index c704b38..ba870bb 100644
--- a/arch/x86/include/asm/irq.h
+++ b/arch/x86/include/asm/irq.h
@@ -10,9 +10,6 @@
#include <asm/apicdef.h>
#include <asm/irq_vectors.h>
-/* Even though we don't support this, supply it to appease OF */
-static inline void irq_dispose_mapping(unsigned int virq) { }
-
static inline int irq_canonicalize(int irq)
{
return ((irq == 2) ? 9 : irq);
diff --git a/arch/x86/include/asm/prom.h b/arch/x86/include/asm/prom.h
index b4ec95f..841697d 100644
--- a/arch/x86/include/asm/prom.h
+++ b/arch/x86/include/asm/prom.h
@@ -1 +1,46 @@
-/* dummy prom.h; here to make linux/of.h's #includes happy */
+/*
+ * Definitions for Device tree / OpenFirmware handling on X86
+ *
+ * based on arch/powerpc/include/asm/prom.h which is
+ * Copyright (C) 1996-2005 Paul Mackerras.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#ifndef _ASM_X86_PROM_H
+#define _ASM_X86_PROM_H
+#ifndef __ASSEMBLY__
+
+#include <linux/of.h>
+#include <linux/types.h>
+#include <asm/irq.h>
+#include <asm/atomic.h>
+#include <asm/setup.h>
+
+#ifdef CONFIG_OF
+extern void add_dtb(u64 data);
+#else
+static inline void add_dtb(u64 data) { }
+#endif
+
+extern char cmd_line[COMMAND_LINE_SIZE];
+
+#define pci_address_to_pio pci_address_to_pio
+unsigned long pci_address_to_pio(phys_addr_t addr);
+
+/**
+ * irq_dispose_mapping - Unmap an interrupt
+ * @virq: linux virq number of the interrupt to unmap
+ *
+ * FIXME: We really should implement proper virq handling like power,
+ * but that's going to be major surgery.
+ */
+static inline void irq_dispose_mapping(unsigned int virq) { }
+
+#define HAVE_ARCH_DEVTREE_FIXUPS
+
+#endif /* __ASSEMBLY__ */
+#endif
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 34244b2..6ac5036 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -109,6 +109,7 @@ obj-$(CONFIG_MICROCODE) += microcode.o
obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o
+obj-$(CONFIG_OF) += devicetree.o
###
# 64 bit specific files
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
new file mode 100644
index 0000000..b86c65e
--- /dev/null
+++ b/arch/x86/kernel/devicetree.c
@@ -0,0 +1,51 @@
+/*
+ * Architecture specific OF callbacks.
+ */
+#include <linux/bootmem.h>
+#include <linux/io.h>
+#include <linux/list.h>
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+#include <linux/of_platform.h>
+#include <linux/slab.h>
+
+char __initdata cmd_line[COMMAND_LINE_SIZE];
+
+unsigned int irq_create_of_mapping(struct device_node *controller,
+ const u32 *intspec, unsigned int intsize)
+{
+ return intspec[0];
+
+}
+EXPORT_SYMBOL_GPL(irq_create_of_mapping);
+
+unsigned long pci_address_to_pio(phys_addr_t address)
+{
+ /*
+ * The ioport address can be directly used by inX / outX
+ */
+ BUG_ON(address >= (1 << 16));
+ return (unsigned long)address;
+}
+EXPORT_SYMBOL_GPL(pci_address_to_pio);
+
+void __init early_init_dt_scan_chosen_arch(unsigned long node)
+{
+ BUG();
+}
+
+void __init early_init_dt_add_memory_arch(u64 base, u64 size)
+{
+ BUG();
+}
+
+void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
+{
+ return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS));
+}
+
+void __init add_dtb(u64 data)
+{
+ initial_boot_params = phys_to_virt((u64) (u32) data +
+ offsetof(struct setup_data, data));
+}
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index 387b6a0..7531360 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -276,15 +276,6 @@ void smp_x86_platform_ipi(struct pt_regs *regs)
EXPORT_SYMBOL_GPL(vector_used_by_percpu_irq);
-#ifdef CONFIG_OF
-unsigned int irq_create_of_mapping(struct device_node *controller,
- const u32 *intspec, unsigned int intsize)
-{
- return intspec[0];
-}
-EXPORT_SYMBOL_GPL(irq_create_of_mapping);
-#endif
-
#ifdef CONFIG_HOTPLUG_CPU
/* A cpu has been removed from cpu_online_mask. Reset irq affinities. */
void fixup_irqs(void)
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 96cdb9c..046bcbc 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -113,6 +113,7 @@
#endif
#include <asm/mce.h>
#include <asm/alternative.h>
+#include <asm/prom.h>
/*
* end_pfn only includes RAM, while max_pfn_mapped includes all e820 entries.
@@ -446,6 +447,9 @@ static void __init parse_setup_data(void)
case SETUP_E820_EXT:
parse_e820_ext(data);
break;
+ case SETUP_DTB:
+ add_dtb(pa_data);
+ break;
default:
break;
}
--
1.7.4
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 03/11] x86/dtb: Add a device tree for CE4100
[not found] ` <1298405266-1624-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2011-02-22 20:07 ` [PATCH 02/11] x86: Add device tree support Sebastian Andrzej Siewior
@ 2011-02-22 20:07 ` Sebastian Andrzej Siewior
2011-02-22 20:59 ` Grant Likely
2011-02-22 20:07 ` [PATCH 04/11] x86/dtb: add irq domain abstraction Sebastian Andrzej Siewior
` (7 subsequent siblings)
9 siblings, 1 reply; 36+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-02-22 20:07 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A, Sebastian Andrzej Siewior
History:
v1..v2:
- dropped device_type except for cpu & pci. I have the compatible string
for pci so I can drop the device_type once it is possible
- I lowercased all compatible types. I will need to resend some patches
which have upper case intel
- The cpu had the same compatible string as the soc node. So I added to
the soc node -immr for internel memory mapped registers.
- I added generic names for all parts.
- I reworked the i2c bars matching the way you suggested. I added a
compatible node for the PCI device which only the PCI ids in its
compatible string. The bars (each represents a complete i2c
controller) have a "intel,ce4100-i2c-controller" compatible node. It
is not used by the driver.
The driver is probed via PCI ids (by the pci subsystem not OF) and
matches the bar address against the ressource in the child node. Once
there is a hit the node is attached.
- The SPI driver is also probed via pci. However I also attached a
compatible property based on PCI ids
v2..v3:
- intel,ce4100-immr become intel,ce4100-cp. cp stands for core
peripherals. The Atom data sheet talks here about ACPI devices. Since
we don't have ACPI this does not apply here.
- The interrupt map is gone. There are now plenty of device nodes.
- The "unit address string" got fixed, it uses not DD,V format.
v3..v4:
- added descriptions for compatible nodes introduced here:
- intel,ce4100-ioapic
- intel,ce4100-lapic
- intel,ce4100-hpet
- intel,ce4100
- intel,ce4100-cp
- intel,ce4100-pci
- added a description about I2C controller magic.
- Added gpio-controller and gpio-cells property to gpio devices. Those
properties are not (yet) used.
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
.../devicetree/bindings/i2c/ce4100-i2c.txt | 93 +++++
Documentation/devicetree/bindings/x86/ce4100.txt | 38 ++
.../devicetree/bindings/x86/interrupt.txt | 29 ++
Documentation/devicetree/bindings/x86/timer.txt | 6 +
arch/x86/platform/ce4100/falconfalls.dts | 430 ++++++++++++++++++++
5 files changed, 596 insertions(+), 0 deletions(-)
create mode 100644 Documentation/devicetree/bindings/i2c/ce4100-i2c.txt
create mode 100644 Documentation/devicetree/bindings/x86/ce4100.txt
create mode 100644 Documentation/devicetree/bindings/x86/interrupt.txt
create mode 100644 Documentation/devicetree/bindings/x86/timer.txt
create mode 100644 arch/x86/platform/ce4100/falconfalls.dts
diff --git a/Documentation/devicetree/bindings/i2c/ce4100-i2c.txt b/Documentation/devicetree/bindings/i2c/ce4100-i2c.txt
new file mode 100644
index 0000000..569b162
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/ce4100-i2c.txt
@@ -0,0 +1,93 @@
+CE4100 I2C
+----------
+
+CE4100 has one PCI device which is described as the I2C-Controller. This
+PCI device has three PCI-bars, each bar contains a complete I2C
+controller. So we have a total of three independent I2C-Controllers
+which share only an interrupt line.
+The driver is probed via the PCI-ID and is gathering the information of
+attached devices from the devices tree.
+Grant Likely recommended to use the ranges property to map the PCI-Bar
+number to its physical address and to use this to find the child nodes
+of the specific I2C controller. This were his exact words:
+
+ Here's where the magic happens. Each entry in
+ ranges describes how the parent pci address space
+ (middle group of 3) is translated to the local
+ address space (first group of 2) and the size of
+ each range (last cell). In this particular case,
+ the first cell of the local address is chosen to be
+ 1:1 mapped to the BARs, and the second is the
+ offset from be base of the BAR (which would be
+ non-zero if you had 2 or more devices mapped off
+ the same BAR)
+
+ ranges allows the address mapping to be described
+ in a way that the OS can interpret without
+ requiring custom device driver code.
+
+This is an example which is used on FalconFalls:
+------------------------------------------------
+ i2c-controller@b,2 {
+ #address-cells = <2>;
+ #size-cells = <1>;
+ compatible = "pci8086,2e68.2",
+ "pci8086,2e68",
+ "pciclass,ff0000",
+ "pciclass,ff00";
+
+ reg = <0x15a00 0x0 0x0 0x0 0x0>;
+ interrupts = <16 1>;
+
+ /* as described by Grant, the first number in the group of
+ * three is the bar number followed by the 64bit bar address
+ * followed by size of the mapping. The bar address
+ * requires also a valid translation in parents ranges
+ * property.
+ */
+ ranges = <0 0 0x02000000 0 0xdffe0500 0x100
+ 1 0 0x02000000 0 0xdffe0600 0x100
+ 2 0 0x02000000 0 0xdffe0700 0x100>;
+
+ i2c@0 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "intel,ce4100-i2c-controller";
+
+ /* The first number in the reg property is the
+ * number of the bar
+ */
+ reg = <0 0 0x100>;
+
+ /* This I2C controller has no devices */
+ };
+
+ i2c@1 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "intel,ce4100-i2c-controller";
+ reg = <1 0 0x100>;
+
+ /* This I2C controller has one gpio controller */
+ gpio@26 {
+ #gpio-cells = <2>;
+ compatible = "ti,pcf8575";
+ reg = <0x26>;
+ gpio-controller;
+ };
+ };
+
+ i2c@2 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "intel,ce4100-i2c-controller";
+ reg = <2 0 0x100>;
+
+ gpio@26 {
+ #gpio-cells = <2>;
+ compatible = "ti,pcf8575";
+ reg = <0x26>;
+ gpio-controller;
+ };
+ };
+ };
diff --git a/Documentation/devicetree/bindings/x86/ce4100.txt b/Documentation/devicetree/bindings/x86/ce4100.txt
new file mode 100644
index 0000000..b49ae59
--- /dev/null
+++ b/Documentation/devicetree/bindings/x86/ce4100.txt
@@ -0,0 +1,38 @@
+CE4100 Device Tree Bindings
+---------------------------
+
+The CE4100 SoC uses for in core peripherals the following compatible
+format: <vendor>,<chip>-<device>.
+Many of the "generic" devices like HPET or IO APIC have the ce4100
+name in their compatible property because they first appeared in this
+SoC.
+
+The CPU node
+------------
+ cpu@0 {
+ device_type = "cpu";
+ compatible = "intel,ce4100";
+ reg = <0>;
+ lapic = <&lapic0>;
+ };
+
+The reg property describes the CPU number. The lapic property points to
+the local APIC timer.
+
+The SoC node
+------------
+
+This node describes the in-core peripherals. Required property:
+ compatible = "intel,ce4100-cp";
+
+The PCI node
+------------
+This node describes the PCI bus on the SoC. Its property should be
+ compatible = "intel,ce4100-pci", "pci";
+
+If the OS is using the IO-APIC for interrupt routing then the reported
+interrupt numbers for devices is no longer true. In order to obtain the
+correct interrupt number, the child node which represents the device has
+to contain the interrupt property. Besides the interrupt property it has
+to contain at least the reg property containing the PCI bus address and
+compatible property according to "PCI Bus Binding Revision 2.1".
diff --git a/Documentation/devicetree/bindings/x86/interrupt.txt b/Documentation/devicetree/bindings/x86/interrupt.txt
new file mode 100644
index 0000000..8b0efb0
--- /dev/null
+++ b/Documentation/devicetree/bindings/x86/interrupt.txt
@@ -0,0 +1,29 @@
+Interrupt chips
+---------------
+
+* Intel I/O Advanced Programmable Interrupt Controller (IO APIC)
+
+ Required properties:
+ --------------------
+ compatible = "intel,ce4100-ioapic";
+ #interrupt-cells = <2>;
+
+ Device's interrupt property:
+
+ interrupts = <P S>;
+
+ The first number (P) represents the interrupt pin which is wired to the
+ IO APIC. The second number (S) represents the sense of interrupt which
+ should be configured and can be one of:
+ 0 - Edge Rising
+ 1 - Level Low
+ 2 - Level High
+ 3 - Edge Falling
+
+* Local APIC
+ Required property:
+
+ compatible = "intel,ce4100-lapic";
+
+ This node is currently unused by Linux as the address of the local APIC
+ read from a MSR.
diff --git a/Documentation/devicetree/bindings/x86/timer.txt b/Documentation/devicetree/bindings/x86/timer.txt
new file mode 100644
index 0000000..c688af5
--- /dev/null
+++ b/Documentation/devicetree/bindings/x86/timer.txt
@@ -0,0 +1,6 @@
+Timers
+------
+
+* High Precision Event Timer (HPET)
+ Required property:
+ compatible = "intel,ce4100-hpet";
diff --git a/arch/x86/platform/ce4100/falconfalls.dts b/arch/x86/platform/ce4100/falconfalls.dts
new file mode 100644
index 0000000..e28de4c
--- /dev/null
+++ b/arch/x86/platform/ce4100/falconfalls.dts
@@ -0,0 +1,430 @@
+/*
+ * CE4100 on Falcon Falls
+ *
+ * (c) Copyright 2010 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ */
+/dts-v1/;
+/ {
+ model = "intel,falconfalls";
+ compatible = "intel,falconfalls";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ cpus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ cpu@0 {
+ device_type = "cpu";
+ compatible = "intel,ce4100";
+ reg = <0>;
+ lapic = <&lapic0>;
+ };
+ };
+
+ soc@0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "intel,ce4100-cp";
+ ranges;
+
+ ioapic1: interrupt-controller@fec00000 {
+ #interrupt-cells = <2>;
+ compatible = "intel,ce4100-ioapic";
+ interrupt-controller;
+ reg = <0xfec00000 0x1000>;
+ };
+
+ timer@fed00000 {
+ compatible = "intel,ce4100-hpet";
+ reg = <0xfed00000 0x200>;
+ };
+
+ lapic0: interrupt-controller@fee00000 {
+ compatible = "intel,ce4100-lapic";
+ reg = <0xfee00000 0x1000>;
+ };
+
+ pci@3fc {
+ #address-cells = <3>;
+ #interrupt-cells = <1>;
+ #size-cells = <2>;
+ compatible = "intel,ce4100-pci", "pci";
+ device_type = "pci";
+ bus-range = <0 0>;
+ ranges = <0x2000000 0 0xbffff000 0xbffff000 0 0x1000
+ 0x2000000 0 0xdffe0000 0xdffe0000 0 0x1000
+ 0x0000000 0 0x0 0x0 0 0x100>;
+
+ /* Secondary IO-APIC */
+ ioapic2: interrupt-controller@0,1 {
+ #interrupt-cells = <2>;
+ compatible = "intel,ce4100-ioapic";
+ interrupt-controller;
+ reg = <0x100 0x0 0x0 0x0 0x0>;
+ assigned-addresses = <0x02000000 0x0 0xbffff000 0x0 0x1000>;
+ };
+
+ pci@1,0 {
+ #address-cells = <3>;
+ #interrupt-cells = <1>;
+ #size-cells = <2>;
+ compatible = "intel,ce4100-pci", "pci";
+ device_type = "pci";
+ bus-range = <1 1>;
+ ranges = <0x2000000 0 0xdffe0000 0x2000000 0 0xdffe0000 0 0x1000>;
+
+ interrupt-parent = <&ioapic2>;
+
+ display@2,0 {
+ compatible = "pci8086,2e5b.2",
+ "pci8086,2e5b",
+ "pciclass038000",
+ "pciclass0380";
+
+ reg = <0x11000 0x0 0x0 0x0 0x0>;
+ interrupts = <0 1>;
+ };
+
+ multimedia@3,0 {
+ compatible = "pci8086,2e5c.2",
+ "pci8086,2e5c",
+ "pciclass048000",
+ "pciclass0480";
+
+ reg = <0x11800 0x0 0x0 0x0 0x0>;
+ interrupts = <2 1>;
+ };
+
+ multimedia@4,0 {
+ compatible = "pci8086,2e5d.2",
+ "pci8086,2e5d",
+ "pciclass048000",
+ "pciclass0480";
+
+ reg = <0x12000 0x0 0x0 0x0 0x0>;
+ interrupts = <4 1>;
+ };
+
+ multimedia@4,1 {
+ compatible = "pci8086,2e5e.2",
+ "pci8086,2e5e",
+ "pciclass048000",
+ "pciclass0480";
+
+ reg = <0x12100 0x0 0x0 0x0 0x0>;
+ interrupts = <5 1>;
+ };
+
+ sound@6,0 {
+ compatible = "pci8086,2e5f.2",
+ "pci8086,2e5f",
+ "pciclass040100",
+ "pciclass0401";
+
+ reg = <0x13000 0x0 0x0 0x0 0x0>;
+ interrupts = <6 1>;
+ };
+
+ sound@6,1 {
+ compatible = "pci8086,2e5f.2",
+ "pci8086,2e5f",
+ "pciclass040100",
+ "pciclass0401";
+
+ reg = <0x13100 0x0 0x0 0x0 0x0>;
+ interrupts = <7 1>;
+ };
+
+ sound@6,2 {
+ compatible = "pci8086,2e60.2",
+ "pci8086,2e60",
+ "pciclass040100",
+ "pciclass0401";
+
+ reg = <0x13200 0x0 0x0 0x0 0x0>;
+ interrupts = <8 1>;
+ };
+
+ display@8,0 {
+ compatible = "pci8086,2e61.2",
+ "pci8086,2e61",
+ "pciclass038000",
+ "pciclass0380";
+
+ reg = <0x14000 0x0 0x0 0x0 0x0>;
+ interrupts = <9 1>;
+ };
+
+ display@8,1 {
+ compatible = "pci8086,2e62.2",
+ "pci8086,2e62",
+ "pciclass038000",
+ "pciclass0380";
+
+ reg = <0x14100 0x0 0x0 0x0 0x0>;
+ interrupts = <10 1>;
+ };
+
+ multimedia@8,2 {
+ compatible = "pci8086,2e63.2",
+ "pci8086,2e63",
+ "pciclass048000",
+ "pciclass0480";
+
+ reg = <0x14200 0x0 0x0 0x0 0x0>;
+ interrupts = <11 1>;
+ };
+
+ entertainment-encryption@9,0 {
+ compatible = "pci8086,2e64.2",
+ "pci8086,2e64",
+ "pciclass101000",
+ "pciclass1010";
+
+ reg = <0x14800 0x0 0x0 0x0 0x0>;
+ interrupts = <12 1>;
+ };
+
+ localbus@a,0 {
+ compatible = "pci8086,2e65.2",
+ "pci8086,2e65",
+ "pciclassff0000",
+ "pciclassff00";
+
+ reg = <0x15000 0x0 0x0 0x0 0x0>;
+ };
+
+ serial@b,0 {
+ compatible = "pci8086,2e66.2",
+ "pci8086,2e66",
+ "pciclass070003",
+ "pciclass0700";
+
+ reg = <0x15800 0x0 0x0 0x0 0x0>;
+ interrupts = <14 1>;
+ };
+
+ gpio@b,1 {
+ compatible = "pci8086,2e67.2",
+ "pci8086,2e67",
+ "pciclassff0000",
+ "pciclassff00";
+
+ #gpio-cells = <2>;
+ reg = <0x15900 0x0 0x0 0x0 0x0>;
+ interrupts = <15 1>;
+ gpio-controller;
+ };
+
+ i2c-controller@b,2 {
+ #address-cells = <2>;
+ #size-cells = <1>;
+ compatible = "pci8086,2e68.2",
+ "pci8086,2e68",
+ "pciclass,ff0000",
+ "pciclass,ff00";
+
+ reg = <0x15a00 0x0 0x0 0x0 0x0>;
+ interrupts = <16 1>;
+ ranges = <0 0 0x02000000 0 0xdffe0500 0x100
+ 1 0 0x02000000 0 0xdffe0600 0x100
+ 2 0 0x02000000 0 0xdffe0700 0x100>;
+
+ i2c@0 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "intel,ce4100-i2c-controller";
+ reg = <0 0 0x100>;
+ };
+
+ i2c@1 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "intel,ce4100-i2c-controller";
+ reg = <1 0 0x100>;
+
+ gpio@26 {
+ #gpio-cells = <2>;
+ compatible = "ti,pcf8575";
+ reg = <0x26>;
+ gpio-controller;
+ };
+ };
+
+ i2c@2 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "intel,ce4100-i2c-controller";
+ reg = <2 0 0x100>;
+
+ gpio@26 {
+ #gpio-cells = <2>;
+ compatible = "ti,pcf8575";
+ reg = <0x26>;
+ gpio-controller;
+ };
+ };
+ };
+
+ smard-card@b,3 {
+ compatible = "pci8086,2e69.2",
+ "pci8086,2e69",
+ "pciclass070500",
+ "pciclass0705";
+
+ reg = <0x15b00 0x0 0x0 0x0 0x0>;
+ interrupts = <15 1>;
+ };
+
+ spi-controller@b,4 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible =
+ "pci8086,2e6a.2",
+ "pci8086,2e6a",
+ "pciclass,ff0000",
+ "pciclass,ff00";
+
+ reg = <0x15c00 0x0 0x0 0x0 0x0>;
+ interrupts = <15 1>;
+
+ dac@0 {
+ compatible = "ti,pcm1755";
+ reg = <0>;
+ spi-max-frequency = <115200>;
+ };
+
+ dac@1 {
+ compatible = "ti,pcm1609a";
+ reg = <1>;
+ spi-max-frequency = <115200>;
+ };
+
+ eeprom@2 {
+ compatible = "atmel,at93c46";
+ reg = <2>;
+ spi-max-frequency = <115200>;
+ };
+ };
+
+ multimedia@b,7 {
+ compatible = "pci8086,2e6d.2",
+ "pci8086,2e6d",
+ "pciclassff0000",
+ "pciclassff00";
+
+ reg = <0x15f00 0x0 0x0 0x0 0x0>;
+ };
+
+ ethernet@c,0 {
+ compatible = "pci8086,2e6e.2",
+ "pci8086,2e6e",
+ "pciclass020000",
+ "pciclass0200";
+
+ reg = <0x16000 0x0 0x0 0x0 0x0>;
+ interrupts = <21 1>;
+ };
+
+ clock@c,1 {
+ compatible = "pci8086,2e6f.2",
+ "pci8086,2e6f",
+ "pciclassff0000",
+ "pciclassff00";
+
+ reg = <0x16100 0x0 0x0 0x0 0x0>;
+ interrupts = <3 1>;
+ };
+
+ usb@d,0 {
+ compatible = "pci8086,2e70.2",
+ "pci8086,2e70",
+ "pciclass0c0320",
+ "pciclass0c03";
+
+ reg = <0x16800 0x0 0x0 0x0 0x0>;
+ interrupts = <22 3>;
+ };
+
+ usb@d,1 {
+ compatible = "pci8086,2e70.2",
+ "pci8086,2e70",
+ "pciclass0c0320",
+ "pciclass0c03";
+
+ reg = <0x16900 0x0 0x0 0x0 0x0>;
+ interrupts = <22 3>;
+ };
+
+ sata@e,0 {
+ compatible = "pci8086,2e71.0",
+ "pci8086,2e71",
+ "pciclass010601",
+ "pciclass0106";
+
+ reg = <0x17000 0x0 0x0 0x0 0x0>;
+ interrupts = <23 3>;
+ };
+
+ flash@f,0 {
+ compatible = "pci8086,701.1",
+ "pci8086,701",
+ "pciclass050100",
+ "pciclass0501";
+
+ reg = <0x17800 0x0 0x0 0x0 0x0>;
+ interrupts = <13 1>;
+ };
+
+ entertainment-encryption@10,0 {
+ compatible = "pci8086,702.1",
+ "pci8086,702",
+ "pciclass101000",
+ "pciclass1010";
+
+ reg = <0x18000 0x0 0x0 0x0 0x0>;
+ };
+
+ co-processor@11,0 {
+ compatible = "pci8086,703.1",
+ "pci8086,703",
+ "pciclass0b4000",
+ "pciclass0b40";
+
+ reg = <0x18800 0x0 0x0 0x0 0x0>;
+ interrupts = <1 1>;
+ };
+
+ multimedia@12,0 {
+ compatible = "pci8086,704.0",
+ "pci8086,704",
+ "pciclass048000",
+ "pciclass0480";
+
+ reg = <0x19000 0x0 0x0 0x0 0x0>;
+ };
+ };
+
+ isa@1f,0 {
+ #address-cells = <2>;
+ #size-cells = <1>;
+ compatible = "isa";
+ ranges = <1 0 0 0 0 0x100>;
+
+ rtc@70 {
+ compatible = "intel,ce4100-rtc", "motorola,mc146818";
+ interrupts = <8 3>;
+ interrupt-parent = <&ioapic1>;
+ ctrl-reg = <2>;
+ freq-reg = <0x26>;
+ reg = <1 0x70 2>;
+ };
+ };
+ };
+ };
+};
--
1.7.4
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 04/11] x86/dtb: add irq domain abstraction
[not found] ` <1298405266-1624-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2011-02-22 20:07 ` [PATCH 02/11] x86: Add device tree support Sebastian Andrzej Siewior
2011-02-22 20:07 ` [PATCH 03/11] x86/dtb: Add a device tree for CE4100 Sebastian Andrzej Siewior
@ 2011-02-22 20:07 ` Sebastian Andrzej Siewior
2011-02-22 21:06 ` Grant Likely
2011-02-22 20:07 ` [PATCH 05/11] x86/dtb: add early parsing of IO APIC Sebastian Andrzej Siewior
` (6 subsequent siblings)
9 siblings, 1 reply; 36+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-02-22 20:07 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A, Sebastian Andrzej Siewior
The here introduced irq_domain abstraction represents a generic irq
controller. It is a subset of powerpc's irq_host which is going to be
renamed to irq_domain and then become generic. This implementation will
be removed once it is generic.
The xlate callback is resposible to parse irq informations like irq type
and number and returns the hardware irq number which is reported by the
hardware as active.
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Tested-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
arch/x86/include/asm/irq_controller.h | 12 ++++++++
arch/x86/include/asm/prom.h | 2 +
arch/x86/kernel/devicetree.c | 47 ++++++++++++++++++++++++++++++++-
3 files changed, 60 insertions(+), 1 deletions(-)
create mode 100644 arch/x86/include/asm/irq_controller.h
diff --git a/arch/x86/include/asm/irq_controller.h b/arch/x86/include/asm/irq_controller.h
new file mode 100644
index 0000000..423bbbd
--- /dev/null
+++ b/arch/x86/include/asm/irq_controller.h
@@ -0,0 +1,12 @@
+#ifndef __IRQ_CONTROLLER__
+#define __IRQ_CONTROLLER__
+
+struct irq_domain {
+ int (*xlate)(struct irq_domain *h, const u32 *intspec, u32 intsize,
+ u32 *out_hwirq, u32 *out_type);
+ void *priv;
+ struct device_node *controller;
+ struct list_head l;
+};
+
+#endif
diff --git a/arch/x86/include/asm/prom.h b/arch/x86/include/asm/prom.h
index 841697d..70467d1 100644
--- a/arch/x86/include/asm/prom.h
+++ b/arch/x86/include/asm/prom.h
@@ -19,9 +19,11 @@
#include <asm/irq.h>
#include <asm/atomic.h>
#include <asm/setup.h>
+#include <asm/irq_controller.h>
#ifdef CONFIG_OF
extern void add_dtb(u64 data);
+void add_interrupt_host(struct irq_domain *ih);
#else
static inline void add_dtb(u64 data) { }
#endif
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
index b86c65e..f2f159c 100644
--- a/arch/x86/kernel/devicetree.c
+++ b/arch/x86/kernel/devicetree.c
@@ -3,19 +3,64 @@
*/
#include <linux/bootmem.h>
#include <linux/io.h>
+#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/of.h>
#include <linux/of_fdt.h>
#include <linux/of_platform.h>
#include <linux/slab.h>
+#include <asm/irq_controller.h>
+
char __initdata cmd_line[COMMAND_LINE_SIZE];
+static LIST_HEAD(irq_domains);
+static DEFINE_RAW_SPINLOCK(big_irq_lock);
+
+void add_interrupt_host(struct irq_domain *ih)
+{
+ unsigned long flags;
+
+ raw_spin_lock_irqsave(&big_irq_lock, flags);
+ list_add(&ih->l, &irq_domains);
+ raw_spin_unlock_irqrestore(&big_irq_lock, flags);
+}
+
+static struct irq_domain *get_ih_from_node(struct device_node *controller)
+{
+ struct irq_domain *ih, *found = NULL;
+ unsigned long flags;
+
+ raw_spin_lock_irqsave(&big_irq_lock, flags);
+ list_for_each_entry(ih, &irq_domains, l) {
+ if (ih->controller == controller) {
+ found = ih;
+ break;
+ }
+ }
+ raw_spin_unlock_irqrestore(&big_irq_lock, flags);
+ return found;
+}
unsigned int irq_create_of_mapping(struct device_node *controller,
const u32 *intspec, unsigned int intsize)
{
- return intspec[0];
+ struct irq_domain *ih;
+ u32 virq;
+ u32 type;
+ int ret;
+ ih = get_ih_from_node(controller);
+ if (!ih)
+ return 0;
+ ret = ih->xlate(ih, intspec, intsize, &virq, &type);
+ if (ret)
+ return ret;
+ if (type == IRQ_TYPE_NONE)
+ return virq;
+ /* set the mask if it is different from current */
+ if (type == (irq_to_desc(virq)->status & IRQF_TRIGGER_MASK))
+ set_irq_type(virq, type);
+ return virq;
}
EXPORT_SYMBOL_GPL(irq_create_of_mapping);
--
1.7.4
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 05/11] x86/dtb: add early parsing of IO APIC
[not found] ` <1298405266-1624-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
` (2 preceding siblings ...)
2011-02-22 20:07 ` [PATCH 04/11] x86/dtb: add irq domain abstraction Sebastian Andrzej Siewior
@ 2011-02-22 20:07 ` Sebastian Andrzej Siewior
2011-02-22 20:07 ` [PATCH 06/11] x86/dtb: add support hpet Sebastian Andrzej Siewior
` (5 subsequent siblings)
9 siblings, 0 replies; 36+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-02-22 20:07 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A, Sebastian Andrzej Siewior
The apic & ioapic have to be added to system early because
native_init_IRQ() requires it. In order to obtain the address of the
ioapic the device tree has to be unflattened because
of_address_to_resource() has to work.
The device tree is relocated to ensure it is always covered by the
kernel and the boot loader does not have to make assumptions about
kernel's memory layout.
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Cc: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Acked-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
---
arch/x86/include/asm/prom.h | 7 +++
arch/x86/kernel/devicetree.c | 111 +++++++++++++++++++++++++++++++++++++++++-
arch/x86/kernel/irqinit.c | 3 +-
3 files changed, 118 insertions(+), 3 deletions(-)
diff --git a/arch/x86/include/asm/prom.h b/arch/x86/include/asm/prom.h
index 70467d1..5aa2c32 100644
--- a/arch/x86/include/asm/prom.h
+++ b/arch/x86/include/asm/prom.h
@@ -22,10 +22,17 @@
#include <asm/irq_controller.h>
#ifdef CONFIG_OF
+extern int of_ioapic;
+extern u64 initial_dtb;
extern void add_dtb(u64 data);
+void x86_dtb_find_config(void);
+void x86_dtb_get_config(unsigned int unused);
void add_interrupt_host(struct irq_domain *ih);
#else
static inline void add_dtb(u64 data) { }
+#define x86_dtb_find_config x86_init_noop
+#define x86_dtb_get_config x86_init_uint_noop
+#define of_ioapic 0
#endif
extern char cmd_line[COMMAND_LINE_SIZE];
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
index f2f159c..72cc3e2 100644
--- a/arch/x86/kernel/devicetree.c
+++ b/arch/x86/kernel/devicetree.c
@@ -7,15 +7,20 @@
#include <linux/list.h>
#include <linux/of.h>
#include <linux/of_fdt.h>
+#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <linux/slab.h>
#include <asm/irq_controller.h>
+#include <asm/apic.h>
+__initdata u64 initial_dtb;
char __initdata cmd_line[COMMAND_LINE_SIZE];
static LIST_HEAD(irq_domains);
static DEFINE_RAW_SPINLOCK(big_irq_lock);
+int __initdata of_ioapic;
+
void add_interrupt_host(struct irq_domain *ih)
{
unsigned long flags;
@@ -91,6 +96,108 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
void __init add_dtb(u64 data)
{
- initial_boot_params = phys_to_virt((u64) (u32) data +
- offsetof(struct setup_data, data));
+ initial_dtb = data + offsetof(struct setup_data, data);
+}
+
+static void __init dtb_lapic_setup(void)
+{
+#ifdef CONFIG_X86_LOCAL_APIC
+ if (apic_force_enable())
+ return;
+
+ smp_found_config = 1;
+ pic_mode = 1;
+ /* Required for ioapic registration */
+ set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr);
+ if (boot_cpu_physical_apicid == -1U)
+ boot_cpu_physical_apicid = read_apic_id();
+
+ generic_processor_info(boot_cpu_physical_apicid,
+ GET_APIC_VERSION(apic_read(APIC_LVR)));
+#endif
+}
+
+#ifdef CONFIG_X86_IO_APIC
+static unsigned int ioapic_id;
+
+static void __init dtb_add_ioapic(struct device_node *dn)
+{
+ struct resource r;
+ int ret;
+
+ ret = of_address_to_resource(dn, 0, &r);
+ if (ret) {
+ printk(KERN_ERR "Can't obtain address from node %s.\n",
+ dn->full_name);
+ return;
+ }
+ mp_register_ioapic(++ioapic_id, r.start, gsi_top);
+}
+
+static void __init dtb_ioapic_setup(void)
+{
+ struct device_node *dn;
+
+ if (!smp_found_config)
+ return;
+
+ for_each_compatible_node(dn, NULL, "intel,ce4100-ioapic")
+ dtb_add_ioapic(dn);
+
+ if (nr_ioapics) {
+ of_ioapic = 1;
+ return;
+ }
+ printk(KERN_ERR "Error: No information about IO-APIC in OF.\n");
+ smp_found_config = 0;
+}
+#else
+static void __init dtb_ioapic_setup(void) {}
+#endif
+
+static void __init dtb_apic_setup(void)
+{
+ dtb_lapic_setup();
+ dtb_ioapic_setup();
+}
+
+void __init x86_dtb_find_config(void)
+{
+ if (initial_dtb)
+ smp_found_config = 1;
+ else
+ printk(KERN_ERR "Missing device tree!.\n");
+}
+
+void __init x86_dtb_get_config(unsigned int unused)
+{
+ u32 size;
+ u32 map_len;
+ void *new_dtb;
+
+ if (!initial_dtb)
+ return;
+
+ map_len = max(PAGE_SIZE - (initial_dtb & ~PAGE_MASK),
+ (u64)sizeof(struct boot_param_header));
+
+ initial_boot_params = early_memremap(initial_dtb, map_len);
+ size = be32_to_cpu(initial_boot_params->totalsize);
+ if (map_len < size) {
+ early_iounmap(initial_boot_params, map_len);
+ initial_boot_params = early_memremap(initial_dtb, size);
+ map_len = size;
+ }
+
+ new_dtb = alloc_bootmem(size);
+ memcpy(new_dtb, initial_boot_params, size);
+ early_iounmap(initial_boot_params, map_len);
+
+ initial_boot_params = new_dtb;
+
+ /* root level address cells */
+ of_scan_flat_dt(early_init_dt_scan_root, NULL);
+
+ unflatten_device_tree();
+ dtb_apic_setup();
}
diff --git a/arch/x86/kernel/irqinit.c b/arch/x86/kernel/irqinit.c
index c752e97..4cadf86 100644
--- a/arch/x86/kernel/irqinit.c
+++ b/arch/x86/kernel/irqinit.c
@@ -25,6 +25,7 @@
#include <asm/setup.h>
#include <asm/i8259.h>
#include <asm/traps.h>
+#include <asm/prom.h>
/*
* ISA PIC or low IO-APIC triggered (INTA-cycle or APIC) interrupts:
@@ -243,7 +244,7 @@ void __init native_init_IRQ(void)
set_intr_gate(i, interrupt[i-FIRST_EXTERNAL_VECTOR]);
}
- if (!acpi_ioapic)
+ if (!acpi_ioapic && !of_ioapic)
setup_irq(2, &irq2);
#ifdef CONFIG_X86_32
--
1.7.4
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 06/11] x86/dtb: add support hpet
[not found] ` <1298405266-1624-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
` (3 preceding siblings ...)
2011-02-22 20:07 ` [PATCH 05/11] x86/dtb: add early parsing of IO APIC Sebastian Andrzej Siewior
@ 2011-02-22 20:07 ` Sebastian Andrzej Siewior
2011-02-22 20:07 ` [PATCH 07/11] x86/dtb: add support for PCI devices backed by dtb nodes Sebastian Andrzej Siewior
` (4 subsequent siblings)
9 siblings, 0 replies; 36+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-02-22 20:07 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A, Sebastian Andrzej Siewior
Set hpet_address based on information provied form DTB
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Cc: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Acked-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
---
arch/x86/kernel/devicetree.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
index 72cc3e2..8d7a2eb 100644
--- a/arch/x86/kernel/devicetree.c
+++ b/arch/x86/kernel/devicetree.c
@@ -11,6 +11,7 @@
#include <linux/of_platform.h>
#include <linux/slab.h>
+#include <asm/hpet.h>
#include <asm/irq_controller.h>
#include <asm/apic.h>
@@ -99,6 +100,23 @@ void __init add_dtb(u64 data)
initial_dtb = data + offsetof(struct setup_data, data);
}
+static void __init dtb_setup_hpet(void)
+{
+ struct device_node *dn;
+ struct resource r;
+ int ret;
+
+ dn = of_find_compatible_node(NULL, NULL, "intel,ce4100-hpet");
+ if (!dn)
+ return;
+ ret = of_address_to_resource(dn, 0, &r);
+ if (ret) {
+ WARN_ON(1);
+ return;
+ }
+ hpet_address = r.start;
+}
+
static void __init dtb_lapic_setup(void)
{
#ifdef CONFIG_X86_LOCAL_APIC
@@ -199,5 +217,6 @@ void __init x86_dtb_get_config(unsigned int unused)
of_scan_flat_dt(early_init_dt_scan_root, NULL);
unflatten_device_tree();
+ dtb_setup_hpet();
dtb_apic_setup();
}
--
1.7.4
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 07/11] x86/dtb: add support for PCI devices backed by dtb nodes
[not found] ` <1298405266-1624-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
` (4 preceding siblings ...)
2011-02-22 20:07 ` [PATCH 06/11] x86/dtb: add support hpet Sebastian Andrzej Siewior
@ 2011-02-22 20:07 ` Sebastian Andrzej Siewior
2011-02-22 21:08 ` Grant Likely
2011-02-22 20:07 ` [PATCH 08/11] x86/dtb: Add generic bus probe Sebastian Andrzej Siewior
` (3 subsequent siblings)
9 siblings, 1 reply; 36+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-02-22 20:07 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A, Sebastian Andrzej Siewior
x86_of_pci_init() does two things:
- it provides a generic irq enable and disable function. enable queries
the device tree for the interrupt information, calls ->xlate on the
irq host and updates the pci->irq information for the device.
- it walks through PCI buss(es) in the device tree and adds its children
(devices) nodes to appropriate pci_dev nodes in kernel. So the dtb
node information is available at probe time of the PCI device.
Adding a PCI bus based on the information in the device tree is
currently not supported. Right now direct access via ioports is used.
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Tested-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
---
arch/x86/include/asm/prom.h | 14 +++++++
arch/x86/kernel/devicetree.c | 83 ++++++++++++++++++++++++++++++++++++++++++
drivers/of/Kconfig | 2 +-
drivers/of/of_pci.c | 1 +
4 files changed, 99 insertions(+), 1 deletions(-)
diff --git a/arch/x86/include/asm/prom.h b/arch/x86/include/asm/prom.h
index 5aa2c32..3e441b3 100644
--- a/arch/x86/include/asm/prom.h
+++ b/arch/x86/include/asm/prom.h
@@ -16,6 +16,7 @@
#include <linux/of.h>
#include <linux/types.h>
+#include <linux/pci.h>
#include <asm/irq.h>
#include <asm/atomic.h>
#include <asm/setup.h>
@@ -28,8 +29,21 @@ extern void add_dtb(u64 data);
void x86_dtb_find_config(void);
void x86_dtb_get_config(unsigned int unused);
void add_interrupt_host(struct irq_domain *ih);
+void __cpuinit x86_of_pci_init(void);
+
+static inline struct device_node *pci_device_to_OF_node(struct pci_dev *pdev)
+{
+ return pdev ? pdev->dev.of_node : NULL;
+}
+
+static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
+{
+ return pci_device_to_OF_node(bus->self);
+}
+
#else
static inline void add_dtb(u64 data) { }
+static inline void x86_of_pci_init(void) { }
#define x86_dtb_find_config x86_init_noop
#define x86_dtb_get_config x86_init_uint_noop
#define of_ioapic 0
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
index 8d7a2eb..b778ae5 100644
--- a/arch/x86/kernel/devicetree.c
+++ b/arch/x86/kernel/devicetree.c
@@ -9,11 +9,15 @@
#include <linux/of_fdt.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
+#include <linux/of_irq.h>
#include <linux/slab.h>
+#include <linux/pci.h>
+#include <linux/of_pci.h>
#include <asm/hpet.h>
#include <asm/irq_controller.h>
#include <asm/apic.h>
+#include <asm/pci_x86.h>
__initdata u64 initial_dtb;
char __initdata cmd_line[COMMAND_LINE_SIZE];
@@ -100,6 +104,85 @@ void __init add_dtb(u64 data)
initial_dtb = data + offsetof(struct setup_data, data);
}
+#ifdef CONFIG_PCI
+static int x86_of_pci_irq_enable(struct pci_dev *dev)
+{
+ struct of_irq oirq;
+ u32 virq;
+ int ret;
+ u8 pin;
+
+ ret = pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
+ if (ret)
+ return ret;
+ if (!pin)
+ return 0;
+
+ ret = of_irq_map_pci(dev, &oirq);
+ if (ret)
+ return ret;
+
+ virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
+ oirq.size);
+ if (virq == 0)
+ return -EINVAL;
+ dev->irq = virq;
+ return 0;
+}
+
+static void x86_of_pci_irq_disable(struct pci_dev *dev)
+{
+}
+
+void __cpuinit x86_of_pci_init(void)
+{
+ struct device_node *np;
+
+ pcibios_enable_irq = x86_of_pci_irq_enable;
+ pcibios_disable_irq = x86_of_pci_irq_disable;
+
+ for_each_node_by_type(np, "pci") {
+ const void *prop;
+ struct pci_bus *bus;
+ unsigned int bus_min;
+ struct device_node *child;
+
+ prop = of_get_property(np, "bus-range", NULL);
+ if (!prop)
+ continue;
+ bus_min = be32_to_cpup(prop);
+
+ bus = pci_find_bus(0, bus_min);
+ if (!bus) {
+ printk(KERN_ERR "Can't find a node for bus %s.\n",
+ np->full_name);
+ continue;
+ }
+
+ if (bus->self)
+ bus->self->dev.of_node = np;
+ else
+ bus->dev.of_node = np;
+
+ for_each_child_of_node(np, child) {
+ struct pci_dev *dev;
+ u32 devfn;
+
+ prop = of_get_property(child, "reg", NULL);
+ if (!prop)
+ continue;
+
+ devfn = (be32_to_cpup(prop) >> 8) & 0xff;
+ dev = pci_get_slot(bus, devfn);
+ if (!dev)
+ continue;
+ dev->dev.of_node = child;
+ pci_dev_put(dev);
+ }
+ }
+}
+#endif
+
static void __init dtb_setup_hpet(void)
{
struct device_node *dn;
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index efabbf9..d06a637 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -71,7 +71,7 @@ config OF_MDIO
config OF_PCI
def_tristate PCI
- depends on PCI && (PPC || MICROBLAZE)
+ depends on PCI && (PPC || MICROBLAZE || X86)
help
OpenFirmware PCI bus accessors
diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c
index 314535f..ac1ec54 100644
--- a/drivers/of/of_pci.c
+++ b/drivers/of/of_pci.c
@@ -1,5 +1,6 @@
#include <linux/kernel.h>
#include <linux/of_pci.h>
+#include <linux/of_irq.h>
#include <asm/prom.h>
/**
--
1.7.4
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 08/11] x86/dtb: Add generic bus probe
[not found] ` <1298405266-1624-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
` (5 preceding siblings ...)
2011-02-22 20:07 ` [PATCH 07/11] x86/dtb: add support for PCI devices backed by dtb nodes Sebastian Andrzej Siewior
@ 2011-02-22 20:07 ` Sebastian Andrzej Siewior
2011-02-22 20:07 ` [PATCH 09/11] x86/ioapic: Add OF bindings for IO-APIC Sebastian Andrzej Siewior
` (2 subsequent siblings)
9 siblings, 0 replies; 36+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-02-22 20:07 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A, Sebastian Andrzej Siewior
For now we probe these busses and we change is to board dependent probes
once we have to.
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Acked-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
arch/x86/kernel/devicetree.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
index b778ae5..179833f 100644
--- a/arch/x86/kernel/devicetree.c
+++ b/arch/x86/kernel/devicetree.c
@@ -104,6 +104,25 @@ void __init add_dtb(u64 data)
initial_dtb = data + offsetof(struct setup_data, data);
}
+/*
+ * CE4100 ids. Will be moved to machine_device_initcall() once we have it.
+ */
+static struct of_device_id __initdata ce4100_ids[] = {
+ { .compatible = "intel,ce4100-cp", },
+ { .compatible = "isa", },
+ { .compatible = "pci", },
+ {},
+};
+
+static int __init add_bus_probe(void)
+{
+ if (!initial_boot_params)
+ return 0;
+
+ return of_platform_bus_probe(NULL, ce4100_ids, NULL);
+}
+module_init(add_bus_probe);
+
#ifdef CONFIG_PCI
static int x86_of_pci_irq_enable(struct pci_dev *dev)
{
--
1.7.4
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 09/11] x86/ioapic: Add OF bindings for IO-APIC
[not found] ` <1298405266-1624-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
` (6 preceding siblings ...)
2011-02-22 20:07 ` [PATCH 08/11] x86/dtb: Add generic bus probe Sebastian Andrzej Siewior
@ 2011-02-22 20:07 ` Sebastian Andrzej Siewior
2011-02-22 21:14 ` Grant Likely
2011-02-22 20:07 ` [PATCH 10/11] x86/ce4100: use OF for ioapic Sebastian Andrzej Siewior
2011-02-22 20:07 ` [PATCH 11/11] rtc/cmos: add OF bindings Sebastian Andrzej Siewior
9 siblings, 1 reply; 36+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-02-22 20:07 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A, Sebastian Andrzej Siewior
ioapic_xlate provides a translation from the information in device tree
to ioapic related informations. This includes
- obtaining hw irq which is the vector number "=> pin number + gsi"
- obtaining type (level/edge/..)
- programming this information into ioapic
ioapic_add_ofnode adds an irq_domain based on informations from the device
tree. This information (irq_domain) is required in order to map a device to
its proper interrupt controller.
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
arch/x86/include/asm/io_apic.h | 7 +++
arch/x86/include/asm/prom.h | 2 +
arch/x86/kernel/apic/io_apic.c | 99 ++++++++++++++++++++++++++++++++++++++++
arch/x86/kernel/devicetree.c | 13 +++++
arch/x86/kernel/irqinit.c | 6 ++
5 files changed, 127 insertions(+), 0 deletions(-)
diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h
index f327d38..fe88a73 100644
--- a/arch/x86/include/asm/io_apic.h
+++ b/arch/x86/include/asm/io_apic.h
@@ -177,6 +177,13 @@ struct mp_ioapic_gsi{
u32 gsi_base;
u32 gsi_end;
};
+#ifdef CONFIG_OF
+struct mp_of_ioapic {
+ struct device_node *node;
+};
+extern struct mp_of_ioapic mp_of_ioapic[MAX_IO_APICS];
+void __init ioapic_add_ofnode(struct device_node *np);
+#endif
extern struct mp_ioapic_gsi mp_gsi_routing[];
extern u32 gsi_top;
int mp_find_ioapic(u32 gsi);
diff --git a/arch/x86/include/asm/prom.h b/arch/x86/include/asm/prom.h
index 3e441b3..98b9a73 100644
--- a/arch/x86/include/asm/prom.h
+++ b/arch/x86/include/asm/prom.h
@@ -26,6 +26,7 @@
extern int of_ioapic;
extern u64 initial_dtb;
extern void add_dtb(u64 data);
+extern void x86_add_irq_domains(void);
void x86_dtb_find_config(void);
void x86_dtb_get_config(unsigned int unused);
void add_interrupt_host(struct irq_domain *ih);
@@ -43,6 +44,7 @@ static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
#else
static inline void add_dtb(u64 data) { }
+static inline void x86_add_irq_domains(void) { }
static inline void x86_of_pci_init(void) { }
#define x86_dtb_find_config x86_init_noop
#define x86_dtb_get_config x86_init_uint_noop
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index ca9e2a3..c172452 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -43,6 +43,7 @@
#include <linux/bootmem.h>
#include <linux/dmar.h>
#include <linux/hpet.h>
+#include <linux/of_address.h>
#include <asm/idle.h>
#include <asm/io.h>
@@ -60,6 +61,7 @@
#include <asm/irq_remapping.h>
#include <asm/hpet.h>
#include <asm/hw_irq.h>
+#include <asm/irq_controller.h>
#include <asm/apic.h>
@@ -88,6 +90,10 @@ int nr_ioapics;
/* IO APIC gsi routing info */
struct mp_ioapic_gsi mp_gsi_routing[MAX_IO_APICS];
+#ifdef CONFIG_OF
+/* OF -> IO APIC lookup */
+struct mp_of_ioapic mp_of_ioapic[MAX_IO_APICS];
+#endif
/* The one past the highest gsi number used */
u32 gsi_top;
@@ -4083,6 +4089,99 @@ void __init mp_register_ioapic(int id, u32 address, u32 gsi_base)
nr_ioapics++;
}
+#ifdef CONFIG_OF
+static int ioapic_xlate(struct irq_domain *id, const u32 *intspec, u32 intsize,
+ u32 *out_hwirq, u32 *out_type)
+{
+ u32 line;
+ u32 idx;
+ u32 type;
+ u32 trigger;
+ u32 polarity;
+ struct irq_cfg *cfg;
+ struct irq_desc *desc;
+
+ if (intsize < 1)
+ return -EINVAL;
+
+ line = *intspec;
+ idx = (u32) id->priv;
+ *out_hwirq = line + mp_gsi_routing[idx].gsi_base;
+ if (intsize > 1) {
+ intspec++;
+ type = *intspec;
+ switch (type) {
+ case 0:
+ *out_type = IRQ_TYPE_EDGE_RISING;
+ trigger = IOAPIC_EDGE;
+ polarity = 1;
+ break;
+ case 1:
+ *out_type = IRQ_TYPE_LEVEL_LOW;
+ trigger = IOAPIC_LEVEL;
+ polarity = 0;
+ break;
+ case 2:
+ *out_type = IRQ_TYPE_LEVEL_HIGH;
+ trigger = IOAPIC_LEVEL;
+ polarity = 1;
+ break;
+ case 3:
+ *out_type = IRQ_TYPE_EDGE_FALLING;
+ trigger = IOAPIC_EDGE;
+ polarity = 0;
+ break;
+ default:
+ *out_type = IRQ_TYPE_NONE;
+ trigger = IOAPIC_AUTO;
+ polarity = 0;
+ break;
+ };
+ } else {
+ *out_type = IRQ_TYPE_NONE;
+ trigger = IOAPIC_AUTO;
+ polarity = 0;
+ }
+ /* And now tell the IO APIC to make the line ready */
+ desc = irq_to_desc_alloc_node(*out_hwirq, 0);
+ cfg = irq_cfg(*out_hwirq);
+ add_pin_to_irq_node(cfg, 0, idx, line);
+ /* make it edge by default, settype will update it */
+ setup_ioapic_irq(idx, line, *out_hwirq, cfg, trigger, polarity);
+ return 0;
+}
+
+void __init ioapic_add_ofnode(struct device_node *np)
+{
+ int i;
+ int ret;
+ struct resource r;
+
+ ret = of_address_to_resource(np, 0, &r);
+ if (ret) {
+ printk(KERN_ERR "Failed to obtain address for %s\n",
+ np->full_name);
+ return;
+ }
+
+ for (i = 0; i < nr_ioapics; i++) {
+ if (r.start == mp_ioapics[i].apicaddr) {
+ struct irq_domain *id;
+
+ mp_of_ioapic[i].node = np;
+ id = kzalloc(sizeof(*id), GFP_KERNEL);
+ BUG_ON(!id);
+ id->controller = np;
+ id->xlate = ioapic_xlate;
+ id->priv = (void *)i;
+ add_interrupt_host(id);
+ return;
+ }
+ }
+ printk(KERN_ERR "IOxAPIC at %s is not registered.\n", np->full_name);
+}
+#endif
+
/* Enable IOAPIC early just for system timer */
void __init pre_init_apic_IRQ0(void)
{
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
index 179833f..62d0072 100644
--- a/arch/x86/kernel/devicetree.c
+++ b/arch/x86/kernel/devicetree.c
@@ -322,3 +322,16 @@ void __init x86_dtb_get_config(unsigned int unused)
dtb_setup_hpet();
dtb_apic_setup();
}
+
+void __init x86_add_irq_domains(void)
+{
+ struct device_node *dp;
+
+ if (!initial_boot_params)
+ return;
+
+ for_each_node_with_property(dp, "interrupt-controller") {
+ if (of_device_is_compatible(dp, "intel,ce4100-ioapic"))
+ ioapic_add_ofnode(dp);
+ }
+}
diff --git a/arch/x86/kernel/irqinit.c b/arch/x86/kernel/irqinit.c
index 4cadf86..9f76f89 100644
--- a/arch/x86/kernel/irqinit.c
+++ b/arch/x86/kernel/irqinit.c
@@ -119,6 +119,12 @@ void __init init_IRQ(void)
int i;
/*
+ * We probably need a better place for this, but it works for
+ * now ...
+ */
+ x86_add_irq_domains();
+
+ /*
* On cpu 0, Assign IRQ0_VECTOR..IRQ15_VECTOR's to IRQ 0..15.
* If these IRQ's are handled by legacy interrupt-controllers like PIC,
* then this configuration will likely be static after the boot. If
--
1.7.4
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 10/11] x86/ce4100: use OF for ioapic
[not found] ` <1298405266-1624-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
` (7 preceding siblings ...)
2011-02-22 20:07 ` [PATCH 09/11] x86/ioapic: Add OF bindings for IO-APIC Sebastian Andrzej Siewior
@ 2011-02-22 20:07 ` Sebastian Andrzej Siewior
2011-02-22 20:07 ` [PATCH 11/11] rtc/cmos: add OF bindings Sebastian Andrzej Siewior
9 siblings, 0 replies; 36+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-02-22 20:07 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A, Sebastian Andrzej Siewior
and hpet and a few others things....
Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Acked-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
---
arch/x86/platform/ce4100/ce4100.c | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/arch/x86/platform/ce4100/ce4100.c b/arch/x86/platform/ce4100/ce4100.c
index d2c0d51..7877453 100644
--- a/arch/x86/platform/ce4100/ce4100.c
+++ b/arch/x86/platform/ce4100/ce4100.c
@@ -15,21 +15,19 @@
#include <linux/serial_reg.h>
#include <linux/serial_8250.h>
+#include <asm/prom.h>
#include <asm/setup.h>
+#include <asm/i8259.h>
#include <asm/io.h>
+#include <asm/io_apic.h>
static int ce4100_i8042_detect(void)
{
return 0;
}
-static void __init sdv_find_smp_config(void)
-{
-}
-
#ifdef CONFIG_SERIAL_8250
-
static unsigned int mem_serial_in(struct uart_port *p, int offset)
{
offset = offset << p->regshift;
@@ -118,6 +116,13 @@ static void __init sdv_arch_setup(void)
sdv_serial_fixup();
}
+static void __cpuinit sdv_pci_init(void)
+{
+ x86_of_pci_init();
+ /* We can't set this earlier, because we need calibrate the timer */
+ legacy_pic = &null_legacy_pic;
+}
+
/*
* CE4100 specific x86_init function overrides and early setup
* calls.
@@ -127,6 +132,11 @@ void __init x86_ce4100_early_setup(void)
x86_init.oem.arch_setup = sdv_arch_setup;
x86_platform.i8042_detect = ce4100_i8042_detect;
x86_init.resources.probe_roms = x86_init_noop;
- x86_init.mpparse.get_smp_config = x86_init_uint_noop;
- x86_init.mpparse.find_smp_config = sdv_find_smp_config;
+ x86_init.mpparse.get_smp_config = x86_dtb_get_config;
+ x86_init.mpparse.find_smp_config = x86_dtb_find_config;
+
+#ifdef CONFIG_X86_IO_APIC
+ x86_init.pci.init_irq = sdv_pci_init;
+ x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc_nocheck;
+#endif
}
--
1.7.4
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 11/11] rtc/cmos: add OF bindings
[not found] ` <1298405266-1624-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
` (8 preceding siblings ...)
2011-02-22 20:07 ` [PATCH 10/11] x86/ce4100: use OF for ioapic Sebastian Andrzej Siewior
@ 2011-02-22 20:07 ` Sebastian Andrzej Siewior
[not found] ` <1298405266-1624-12-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
9 siblings, 1 reply; 36+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-02-22 20:07 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: Alessandro Zummo, rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A, sodaville-hfZtesqFncYOwBW4kG4KsQ,
Sebastian Andrzej Siewior
This allows to load the OF driver based informations from the device
tree. Systems without BIOS may need to perform some initialization.
PowerPC creates a PNP device from the OF information and performs this
kind of initialization in their private PCI quirk. This looks more
generic.
This patch also avoids registering the platform RTC driver on X86 if we
have a device tree blob. Without it we end up with of this devices. It
is in this hunk in order to remain bisectable.
Cc: rtc-linux-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Cc: Alessandro Zummo <a.zummo-BfzFCNDTiLLj+vYz1yj4TQ@public.gmane.org>
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
Documentation/devicetree/bindings/rtc/rtc-cmos.txt | 28 ++++++++++++
arch/x86/kernel/rtc.c | 3 +
drivers/rtc/rtc-cmos.c | 45 ++++++++++++++++++++
include/linux/of.h | 12 +++++
4 files changed, 88 insertions(+), 0 deletions(-)
create mode 100644 Documentation/devicetree/bindings/rtc/rtc-cmos.txt
diff --git a/Documentation/devicetree/bindings/rtc/rtc-cmos.txt b/Documentation/devicetree/bindings/rtc/rtc-cmos.txt
new file mode 100644
index 0000000..7382989
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/rtc-cmos.txt
@@ -0,0 +1,28 @@
+ Motorola mc146818 compatible RTC
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Required properties:
+ - compatible : "motorola,mc146818"
+ - reg : should contain registers location and length.
+
+Optional properties:
+ - interrupts : should contain interrupt.
+ - interrupt-parent : interrupt source phandle.
+ - ctrl-reg : Contains the initial value of the control register also
+ called "Register B".
+ - freq-reg : Contains the initial value of the frequency register also
+ called "Regsiter A".
+
+"Register A" and "B" are usually initialized by the firmware (BIOS for
+instance). If this is not done, it can be performed by the driver.
+
+ISA Example:
+
+ rtc@70 {
+ compatible = "motorola,mc146818";
+ interrupts = <8 3>;
+ interrupt-parent = <&ioapic1>;
+ ctrl-reg = <2>;
+ freq-reg = <0x26>;
+ reg = <1 0x70 2>;
+ };
diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
index 6f39cab..3f2ad26 100644
--- a/arch/x86/kernel/rtc.c
+++ b/arch/x86/kernel/rtc.c
@@ -6,6 +6,7 @@
#include <linux/acpi.h>
#include <linux/bcd.h>
#include <linux/pnp.h>
+#include <linux/of.h>
#include <asm/vsyscall.h>
#include <asm/x86_init.h>
@@ -236,6 +237,8 @@ static __init int add_rtc_cmos(void)
}
}
#endif
+ if (of_have_populated_dt())
+ return 0;
platform_device_register(&rtc_device);
dev_info(&rtc_device.dev,
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index c7ff8df..159b95e 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -37,6 +37,8 @@
#include <linux/mod_devicetable.h>
#include <linux/log2.h>
#include <linux/pm.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
/* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */
#include <asm-generic/rtc.h>
@@ -1123,6 +1125,47 @@ static struct pnp_driver cmos_pnp_driver = {
#endif /* CONFIG_PNP */
+#ifdef CONFIG_OF
+static const struct of_device_id of_cmos_match[] = {
+ {
+ .compatible = "motorola,mc146818",
+ },
+ { },
+};
+MODULE_DEVICE_TABLE(of, of_cmos_match);
+
+static __init void cmos_of_init(struct platform_device *pdev)
+{
+ struct device_node *node = pdev->dev.of_node;
+ struct rtc_time time;
+ int ret;
+ const __be32 *val;
+
+ if (!node)
+ return;
+
+ val = of_get_property(node, "ctrl-reg", NULL);
+ if (val)
+ CMOS_WRITE(be32_to_cpup(val), RTC_CONTROL);
+
+ val = of_get_property(node, "freq-reg", NULL);
+ if (val)
+ CMOS_WRITE(be32_to_cpup(val), RTC_FREQ_SELECT);
+
+ get_rtc_time(&time);
+ ret = rtc_valid_tm(&time);
+ if (ret) {
+ struct rtc_time def_time = {
+ .tm_year = 1,
+ .tm_mday = 1,
+ };
+ set_rtc_time(&def_time);
+ }
+}
+#else
+static inline void cmos_of_init(struct platform_device *pdev) {}
+#define of_cmos_match NULL
+#endif
/*----------------------------------------------------------------*/
/* Platform setup should have set up an RTC device, when PNP is
@@ -1131,6 +1174,7 @@ static struct pnp_driver cmos_pnp_driver = {
static int __init cmos_platform_probe(struct platform_device *pdev)
{
+ cmos_of_init(pdev);
cmos_wake_setup(&pdev->dev);
return cmos_do_probe(&pdev->dev,
platform_get_resource(pdev, IORESOURCE_IO, 0),
@@ -1162,6 +1206,7 @@ static struct platform_driver cmos_platform_driver = {
#ifdef CONFIG_PM
.pm = &cmos_pm_ops,
#endif
+ .of_match_table = of_cmos_match,
}
};
diff --git a/include/linux/of.h b/include/linux/of.h
index d9dd664..8de7c29 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -70,6 +70,11 @@ extern struct device_node *allnodes;
extern struct device_node *of_chosen;
extern rwlock_t devtree_lock;
+static inline int of_have_populated_dt(void)
+{
+ return allnodes != NULL;
+}
+
static inline bool of_node_is_root(const struct device_node *node)
{
return node && (node->parent == NULL);
@@ -222,5 +227,12 @@ extern void of_attach_node(struct device_node *);
extern void of_detach_node(struct device_node *);
#endif
+#else
+
+static inline int of_have_populated_dt(void)
+{
+ return 0;
+}
+
#endif /* CONFIG_OF */
#endif /* _LINUX_OF_H */
--
1.7.4
^ permalink raw reply related [flat|nested] 36+ messages in thread
* Re: [PATCH 11/11] rtc/cmos: add OF bindings
[not found] ` <1298405266-1624-12-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
@ 2011-02-22 20:50 ` Grant Likely
0 siblings, 0 replies; 36+ messages in thread
From: Grant Likely @ 2011-02-22 20:50 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: Alessandro Zummo, rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
x86-DgEjT+Ai2ygdnm+yROfE0A, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
sodaville-hfZtesqFncYOwBW4kG4KsQ
On Tue, Feb 22, 2011 at 1:07 PM, Sebastian Andrzej Siewior
<bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> wrote:
> This allows to load the OF driver based informations from the device
> tree. Systems without BIOS may need to perform some initialization.
> PowerPC creates a PNP device from the OF information and performs this
> kind of initialization in their private PCI quirk. This looks more
> generic.
> This patch also avoids registering the platform RTC driver on X86 if we
> have a device tree blob. Without it we end up with of this devices. It
> is in this hunk in order to remain bisectable.
>
> Cc: rtc-linux-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> Cc: Alessandro Zummo <a.zummo-BfzFCNDTiLLj+vYz1yj4TQ@public.gmane.org>
> Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
> Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Itty-bitty nit below, but otherwise:
Acked-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
[...]
> diff --git a/include/linux/of.h b/include/linux/of.h
> index d9dd664..8de7c29 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -70,6 +70,11 @@ extern struct device_node *allnodes;
> extern struct device_node *of_chosen;
> extern rwlock_t devtree_lock;
>
> +static inline int of_have_populated_dt(void)
Personally, I'd make this a 'bool' return value.
> +{
> + return allnodes != NULL;
> +}
> +
> static inline bool of_node_is_root(const struct device_node *node)
> {
> return node && (node->parent == NULL);
> @@ -222,5 +227,12 @@ extern void of_attach_node(struct device_node *);
> extern void of_detach_node(struct device_node *);
> #endif
>
> +#else
> +
> +static inline int of_have_populated_dt(void)
> +{
> + return 0;
and then 'return false'; here.
But by *no means* should this patch be delayed by this comment. :-)
g.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 03/11] x86/dtb: Add a device tree for CE4100
2011-02-22 20:07 ` [PATCH 03/11] x86/dtb: Add a device tree for CE4100 Sebastian Andrzej Siewior
@ 2011-02-22 20:59 ` Grant Likely
0 siblings, 0 replies; 36+ messages in thread
From: Grant Likely @ 2011-02-22 20:59 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: linux-kernel, sodaville, devicetree-discuss, x86
On Tue, Feb 22, 2011 at 1:07 PM, Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
> History:
> v1..v2:
> - dropped device_type except for cpu & pci. I have the compatible string
> for pci so I can drop the device_type once it is possible
> - I lowercased all compatible types. I will need to resend some patches
> which have upper case intel
> - The cpu had the same compatible string as the soc node. So I added to
> the soc node -immr for internel memory mapped registers.
> - I added generic names for all parts.
> - I reworked the i2c bars matching the way you suggested. I added a
> compatible node for the PCI device which only the PCI ids in its
> compatible string. The bars (each represents a complete i2c
> controller) have a "intel,ce4100-i2c-controller" compatible node. It
> is not used by the driver.
> The driver is probed via PCI ids (by the pci subsystem not OF) and
> matches the bar address against the ressource in the child node. Once
> there is a hit the node is attached.
> - The SPI driver is also probed via pci. However I also attached a
> compatible property based on PCI ids
>
> v2..v3:
> - intel,ce4100-immr become intel,ce4100-cp. cp stands for core
> peripherals. The Atom data sheet talks here about ACPI devices. Since
> we don't have ACPI this does not apply here.
> - The interrupt map is gone. There are now plenty of device nodes.
> - The "unit address string" got fixed, it uses not DD,V format.
>
> v3..v4:
> - added descriptions for compatible nodes introduced here:
> - intel,ce4100-ioapic
> - intel,ce4100-lapic
> - intel,ce4100-hpet
> - intel,ce4100
> - intel,ce4100-cp
> - intel,ce4100-pci
> - added a description about I2C controller magic.
> - Added gpio-controller and gpio-cells property to gpio devices. Those
> properties are not (yet) used.
>
> Cc: devicetree-discuss@lists.ozlabs.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
plus one note below...
> ---
> .../devicetree/bindings/i2c/ce4100-i2c.txt | 93 +++++
> Documentation/devicetree/bindings/x86/ce4100.txt | 38 ++
> .../devicetree/bindings/x86/interrupt.txt | 29 ++
> Documentation/devicetree/bindings/x86/timer.txt | 6 +
> arch/x86/platform/ce4100/falconfalls.dts | 430 ++++++++++++++++++++
Next step will be to migrate most of the static soc data out of this
file and into a .dts include file so that multiple boards can use it;
but that can be done later (it's a relatively new feature to dtc).
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 04/11] x86/dtb: add irq domain abstraction
2011-02-22 20:07 ` [PATCH 04/11] x86/dtb: add irq domain abstraction Sebastian Andrzej Siewior
@ 2011-02-22 21:06 ` Grant Likely
0 siblings, 0 replies; 36+ messages in thread
From: Grant Likely @ 2011-02-22 21:06 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: linux-kernel, sodaville, devicetree-discuss, x86
On Tue, Feb 22, 2011 at 1:07 PM, Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
> The here introduced irq_domain abstraction represents a generic irq
> controller. It is a subset of powerpc's irq_host which is going to be
> renamed to irq_domain and then become generic. This implementation will
> be removed once it is generic.
>
> The xlate callback is resposible to parse irq informations like irq type
> and number and returns the hardware irq number which is reported by the
> hardware as active.
>
> Cc: devicetree-discuss@lists.ozlabs.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Tested-by: Dirk Brandewie <dirk.brandewie@gmail.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
> ---
> arch/x86/include/asm/irq_controller.h | 12 ++++++++
> arch/x86/include/asm/prom.h | 2 +
> arch/x86/kernel/devicetree.c | 47 ++++++++++++++++++++++++++++++++-
> 3 files changed, 60 insertions(+), 1 deletions(-)
> create mode 100644 arch/x86/include/asm/irq_controller.h
>
> diff --git a/arch/x86/include/asm/irq_controller.h b/arch/x86/include/asm/irq_controller.h
> new file mode 100644
> index 0000000..423bbbd
> --- /dev/null
> +++ b/arch/x86/include/asm/irq_controller.h
> @@ -0,0 +1,12 @@
> +#ifndef __IRQ_CONTROLLER__
> +#define __IRQ_CONTROLLER__
> +
> +struct irq_domain {
> + int (*xlate)(struct irq_domain *h, const u32 *intspec, u32 intsize,
> + u32 *out_hwirq, u32 *out_type);
> + void *priv;
> + struct device_node *controller;
> + struct list_head l;
> +};
> +
> +#endif
> diff --git a/arch/x86/include/asm/prom.h b/arch/x86/include/asm/prom.h
> index 841697d..70467d1 100644
> --- a/arch/x86/include/asm/prom.h
> +++ b/arch/x86/include/asm/prom.h
> @@ -19,9 +19,11 @@
> #include <asm/irq.h>
> #include <asm/atomic.h>
> #include <asm/setup.h>
> +#include <asm/irq_controller.h>
>
> #ifdef CONFIG_OF
> extern void add_dtb(u64 data);
> +void add_interrupt_host(struct irq_domain *ih);
> #else
> static inline void add_dtb(u64 data) { }
> #endif
> diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
> index b86c65e..f2f159c 100644
> --- a/arch/x86/kernel/devicetree.c
> +++ b/arch/x86/kernel/devicetree.c
> @@ -3,19 +3,64 @@
> */
> #include <linux/bootmem.h>
> #include <linux/io.h>
> +#include <linux/interrupt.h>
> #include <linux/list.h>
> #include <linux/of.h>
> #include <linux/of_fdt.h>
> #include <linux/of_platform.h>
> #include <linux/slab.h>
>
> +#include <asm/irq_controller.h>
> +
> char __initdata cmd_line[COMMAND_LINE_SIZE];
> +static LIST_HEAD(irq_domains);
> +static DEFINE_RAW_SPINLOCK(big_irq_lock);
> +
> +void add_interrupt_host(struct irq_domain *ih)
> +{
> + unsigned long flags;
> +
> + raw_spin_lock_irqsave(&big_irq_lock, flags);
> + list_add(&ih->l, &irq_domains);
> + raw_spin_unlock_irqrestore(&big_irq_lock, flags);
> +}
> +
> +static struct irq_domain *get_ih_from_node(struct device_node *controller)
> +{
> + struct irq_domain *ih, *found = NULL;
> + unsigned long flags;
> +
> + raw_spin_lock_irqsave(&big_irq_lock, flags);
> + list_for_each_entry(ih, &irq_domains, l) {
> + if (ih->controller == controller) {
> + found = ih;
> + break;
> + }
> + }
> + raw_spin_unlock_irqrestore(&big_irq_lock, flags);
> + return found;
> +}
>
> unsigned int irq_create_of_mapping(struct device_node *controller,
> const u32 *intspec, unsigned int intsize)
> {
> - return intspec[0];
> + struct irq_domain *ih;
> + u32 virq;
> + u32 type;
> + int ret;
>
> + ih = get_ih_from_node(controller);
> + if (!ih)
> + return 0;
> + ret = ih->xlate(ih, intspec, intsize, &virq, &type);
> + if (ret)
> + return ret;
> + if (type == IRQ_TYPE_NONE)
> + return virq;
> + /* set the mask if it is different from current */
> + if (type == (irq_to_desc(virq)->status & IRQF_TRIGGER_MASK))
> + set_irq_type(virq, type);
> + return virq;
> }
> EXPORT_SYMBOL_GPL(irq_create_of_mapping);
>
> --
> 1.7.4
>
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss
>
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 07/11] x86/dtb: add support for PCI devices backed by dtb nodes
2011-02-22 20:07 ` [PATCH 07/11] x86/dtb: add support for PCI devices backed by dtb nodes Sebastian Andrzej Siewior
@ 2011-02-22 21:08 ` Grant Likely
0 siblings, 0 replies; 36+ messages in thread
From: Grant Likely @ 2011-02-22 21:08 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: linux-kernel, sodaville, devicetree-discuss, x86
On Tue, Feb 22, 2011 at 1:07 PM, Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
> x86_of_pci_init() does two things:
> - it provides a generic irq enable and disable function. enable queries
> the device tree for the interrupt information, calls ->xlate on the
> irq host and updates the pci->irq information for the device.
>
> - it walks through PCI buss(es) in the device tree and adds its children
> (devices) nodes to appropriate pci_dev nodes in kernel. So the dtb
> node information is available at probe time of the PCI device.
>
> Adding a PCI bus based on the information in the device tree is
> currently not supported. Right now direct access via ioports is used.
>
> Cc: devicetree-discuss@lists.ozlabs.org
> Tested-by: Dirk Brandewie <dirk.brandewie@gmail.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
> ---
> arch/x86/include/asm/prom.h | 14 +++++++
> arch/x86/kernel/devicetree.c | 83 ++++++++++++++++++++++++++++++++++++++++++
> drivers/of/Kconfig | 2 +-
> drivers/of/of_pci.c | 1 +
> 4 files changed, 99 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/include/asm/prom.h b/arch/x86/include/asm/prom.h
> index 5aa2c32..3e441b3 100644
> --- a/arch/x86/include/asm/prom.h
> +++ b/arch/x86/include/asm/prom.h
> @@ -16,6 +16,7 @@
>
> #include <linux/of.h>
> #include <linux/types.h>
> +#include <linux/pci.h>
> #include <asm/irq.h>
> #include <asm/atomic.h>
> #include <asm/setup.h>
> @@ -28,8 +29,21 @@ extern void add_dtb(u64 data);
> void x86_dtb_find_config(void);
> void x86_dtb_get_config(unsigned int unused);
> void add_interrupt_host(struct irq_domain *ih);
> +void __cpuinit x86_of_pci_init(void);
> +
> +static inline struct device_node *pci_device_to_OF_node(struct pci_dev *pdev)
> +{
> + return pdev ? pdev->dev.of_node : NULL;
> +}
> +
> +static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
> +{
> + return pci_device_to_OF_node(bus->self);
> +}
> +
> #else
> static inline void add_dtb(u64 data) { }
> +static inline void x86_of_pci_init(void) { }
> #define x86_dtb_find_config x86_init_noop
> #define x86_dtb_get_config x86_init_uint_noop
> #define of_ioapic 0
> diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
> index 8d7a2eb..b778ae5 100644
> --- a/arch/x86/kernel/devicetree.c
> +++ b/arch/x86/kernel/devicetree.c
> @@ -9,11 +9,15 @@
> #include <linux/of_fdt.h>
> #include <linux/of_address.h>
> #include <linux/of_platform.h>
> +#include <linux/of_irq.h>
> #include <linux/slab.h>
> +#include <linux/pci.h>
> +#include <linux/of_pci.h>
>
> #include <asm/hpet.h>
> #include <asm/irq_controller.h>
> #include <asm/apic.h>
> +#include <asm/pci_x86.h>
>
> __initdata u64 initial_dtb;
> char __initdata cmd_line[COMMAND_LINE_SIZE];
> @@ -100,6 +104,85 @@ void __init add_dtb(u64 data)
> initial_dtb = data + offsetof(struct setup_data, data);
> }
>
> +#ifdef CONFIG_PCI
> +static int x86_of_pci_irq_enable(struct pci_dev *dev)
> +{
> + struct of_irq oirq;
> + u32 virq;
> + int ret;
> + u8 pin;
> +
> + ret = pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
> + if (ret)
> + return ret;
> + if (!pin)
> + return 0;
> +
> + ret = of_irq_map_pci(dev, &oirq);
> + if (ret)
> + return ret;
> +
> + virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
> + oirq.size);
> + if (virq == 0)
> + return -EINVAL;
> + dev->irq = virq;
> + return 0;
> +}
> +
> +static void x86_of_pci_irq_disable(struct pci_dev *dev)
> +{
> +}
> +
> +void __cpuinit x86_of_pci_init(void)
> +{
> + struct device_node *np;
> +
> + pcibios_enable_irq = x86_of_pci_irq_enable;
> + pcibios_disable_irq = x86_of_pci_irq_disable;
> +
> + for_each_node_by_type(np, "pci") {
> + const void *prop;
> + struct pci_bus *bus;
> + unsigned int bus_min;
> + struct device_node *child;
> +
> + prop = of_get_property(np, "bus-range", NULL);
> + if (!prop)
> + continue;
> + bus_min = be32_to_cpup(prop);
> +
> + bus = pci_find_bus(0, bus_min);
> + if (!bus) {
> + printk(KERN_ERR "Can't find a node for bus %s.\n",
> + np->full_name);
> + continue;
> + }
> +
> + if (bus->self)
> + bus->self->dev.of_node = np;
> + else
> + bus->dev.of_node = np;
> +
> + for_each_child_of_node(np, child) {
> + struct pci_dev *dev;
> + u32 devfn;
> +
> + prop = of_get_property(child, "reg", NULL);
> + if (!prop)
> + continue;
> +
> + devfn = (be32_to_cpup(prop) >> 8) & 0xff;
> + dev = pci_get_slot(bus, devfn);
> + if (!dev)
> + continue;
> + dev->dev.of_node = child;
> + pci_dev_put(dev);
> + }
> + }
> +}
> +#endif
> +
> static void __init dtb_setup_hpet(void)
> {
> struct device_node *dn;
> diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
> index efabbf9..d06a637 100644
> --- a/drivers/of/Kconfig
> +++ b/drivers/of/Kconfig
> @@ -71,7 +71,7 @@ config OF_MDIO
>
> config OF_PCI
> def_tristate PCI
> - depends on PCI && (PPC || MICROBLAZE)
> + depends on PCI && (PPC || MICROBLAZE || X86)
> help
> OpenFirmware PCI bus accessors
>
> diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c
> index 314535f..ac1ec54 100644
> --- a/drivers/of/of_pci.c
> +++ b/drivers/of/of_pci.c
> @@ -1,5 +1,6 @@
> #include <linux/kernel.h>
> #include <linux/of_pci.h>
> +#include <linux/of_irq.h>
> #include <asm/prom.h>
>
> /**
> --
> 1.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 09/11] x86/ioapic: Add OF bindings for IO-APIC
2011-02-22 20:07 ` [PATCH 09/11] x86/ioapic: Add OF bindings for IO-APIC Sebastian Andrzej Siewior
@ 2011-02-22 21:14 ` Grant Likely
0 siblings, 0 replies; 36+ messages in thread
From: Grant Likely @ 2011-02-22 21:14 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: linux-kernel, sodaville, devicetree-discuss, x86, Dirk Brandewie
On Tue, Feb 22, 2011 at 1:07 PM, Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
> ioapic_xlate provides a translation from the information in device tree
> to ioapic related informations. This includes
> - obtaining hw irq which is the vector number "=> pin number + gsi"
> - obtaining type (level/edge/..)
> - programming this information into ioapic
>
> ioapic_add_ofnode adds an irq_domain based on informations from the device
> tree. This information (irq_domain) is required in order to map a device to
> its proper interrupt controller.
>
> Cc: devicetree-discuss@lists.ozlabs.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
> ---
> arch/x86/include/asm/io_apic.h | 7 +++
> arch/x86/include/asm/prom.h | 2 +
> arch/x86/kernel/apic/io_apic.c | 99 ++++++++++++++++++++++++++++++++++++++++
> arch/x86/kernel/devicetree.c | 13 +++++
> arch/x86/kernel/irqinit.c | 6 ++
> 5 files changed, 127 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h
> index f327d38..fe88a73 100644
> --- a/arch/x86/include/asm/io_apic.h
> +++ b/arch/x86/include/asm/io_apic.h
> @@ -177,6 +177,13 @@ struct mp_ioapic_gsi{
> u32 gsi_base;
> u32 gsi_end;
> };
> +#ifdef CONFIG_OF
> +struct mp_of_ioapic {
> + struct device_node *node;
> +};
> +extern struct mp_of_ioapic mp_of_ioapic[MAX_IO_APICS];
> +void __init ioapic_add_ofnode(struct device_node *np);
> +#endif
> extern struct mp_ioapic_gsi mp_gsi_routing[];
> extern u32 gsi_top;
> int mp_find_ioapic(u32 gsi);
> diff --git a/arch/x86/include/asm/prom.h b/arch/x86/include/asm/prom.h
> index 3e441b3..98b9a73 100644
> --- a/arch/x86/include/asm/prom.h
> +++ b/arch/x86/include/asm/prom.h
> @@ -26,6 +26,7 @@
> extern int of_ioapic;
> extern u64 initial_dtb;
> extern void add_dtb(u64 data);
> +extern void x86_add_irq_domains(void);
> void x86_dtb_find_config(void);
> void x86_dtb_get_config(unsigned int unused);
> void add_interrupt_host(struct irq_domain *ih);
> @@ -43,6 +44,7 @@ static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
>
> #else
> static inline void add_dtb(u64 data) { }
> +static inline void x86_add_irq_domains(void) { }
> static inline void x86_of_pci_init(void) { }
> #define x86_dtb_find_config x86_init_noop
> #define x86_dtb_get_config x86_init_uint_noop
> diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
> index ca9e2a3..c172452 100644
> --- a/arch/x86/kernel/apic/io_apic.c
> +++ b/arch/x86/kernel/apic/io_apic.c
> @@ -43,6 +43,7 @@
> #include <linux/bootmem.h>
> #include <linux/dmar.h>
> #include <linux/hpet.h>
> +#include <linux/of_address.h>
>
> #include <asm/idle.h>
> #include <asm/io.h>
> @@ -60,6 +61,7 @@
> #include <asm/irq_remapping.h>
> #include <asm/hpet.h>
> #include <asm/hw_irq.h>
> +#include <asm/irq_controller.h>
>
> #include <asm/apic.h>
>
> @@ -88,6 +90,10 @@ int nr_ioapics;
> /* IO APIC gsi routing info */
> struct mp_ioapic_gsi mp_gsi_routing[MAX_IO_APICS];
>
> +#ifdef CONFIG_OF
> +/* OF -> IO APIC lookup */
> +struct mp_of_ioapic mp_of_ioapic[MAX_IO_APICS];
> +#endif
> /* The one past the highest gsi number used */
> u32 gsi_top;
>
> @@ -4083,6 +4089,99 @@ void __init mp_register_ioapic(int id, u32 address, u32 gsi_base)
> nr_ioapics++;
> }
>
> +#ifdef CONFIG_OF
> +static int ioapic_xlate(struct irq_domain *id, const u32 *intspec, u32 intsize,
> + u32 *out_hwirq, u32 *out_type)
> +{
> + u32 line;
> + u32 idx;
> + u32 type;
> + u32 trigger;
> + u32 polarity;
> + struct irq_cfg *cfg;
> + struct irq_desc *desc;
> +
> + if (intsize < 1)
> + return -EINVAL;
> +
> + line = *intspec;
> + idx = (u32) id->priv;
> + *out_hwirq = line + mp_gsi_routing[idx].gsi_base;
> + if (intsize > 1) {
> + intspec++;
> + type = *intspec;
> + switch (type) {
> + case 0:
> + *out_type = IRQ_TYPE_EDGE_RISING;
> + trigger = IOAPIC_EDGE;
> + polarity = 1;
> + break;
> + case 1:
> + *out_type = IRQ_TYPE_LEVEL_LOW;
> + trigger = IOAPIC_LEVEL;
> + polarity = 0;
> + break;
> + case 2:
> + *out_type = IRQ_TYPE_LEVEL_HIGH;
> + trigger = IOAPIC_LEVEL;
> + polarity = 1;
> + break;
> + case 3:
> + *out_type = IRQ_TYPE_EDGE_FALLING;
> + trigger = IOAPIC_EDGE;
> + polarity = 0;
> + break;
This seems to beg for a lookup table. :-)
But that can be changed later if you agree.
> + default:
> + *out_type = IRQ_TYPE_NONE;
> + trigger = IOAPIC_AUTO;
> + polarity = 0;
> + break;
> + };
> + } else {
> + *out_type = IRQ_TYPE_NONE;
> + trigger = IOAPIC_AUTO;
> + polarity = 0;
> + }
Actually, if the irq specifier is invalid (both for the default case,
and the case where the size is too small), then this function should
flat out refuse to xlate the irq and complain loudly. Force users to
provide good data. Again, this can be fixed up with a followon patch.
> + /* And now tell the IO APIC to make the line ready */
> + desc = irq_to_desc_alloc_node(*out_hwirq, 0);
> + cfg = irq_cfg(*out_hwirq);
> + add_pin_to_irq_node(cfg, 0, idx, line);
> + /* make it edge by default, settype will update it */
> + setup_ioapic_irq(idx, line, *out_hwirq, cfg, trigger, polarity);
> + return 0;
> +}
> +
> +void __init ioapic_add_ofnode(struct device_node *np)
> +{
> + int i;
> + int ret;
> + struct resource r;
> +
> + ret = of_address_to_resource(np, 0, &r);
> + if (ret) {
> + printk(KERN_ERR "Failed to obtain address for %s\n",
> + np->full_name);
> + return;
> + }
> +
> + for (i = 0; i < nr_ioapics; i++) {
> + if (r.start == mp_ioapics[i].apicaddr) {
> + struct irq_domain *id;
> +
> + mp_of_ioapic[i].node = np;
> + id = kzalloc(sizeof(*id), GFP_KERNEL);
> + BUG_ON(!id);
> + id->controller = np;
> + id->xlate = ioapic_xlate;
> + id->priv = (void *)i;
> + add_interrupt_host(id);
> + return;
> + }
> + }
> + printk(KERN_ERR "IOxAPIC at %s is not registered.\n", np->full_name);
> +}
> +#endif
> +
> /* Enable IOAPIC early just for system timer */
> void __init pre_init_apic_IRQ0(void)
> {
> diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
> index 179833f..62d0072 100644
> --- a/arch/x86/kernel/devicetree.c
> +++ b/arch/x86/kernel/devicetree.c
> @@ -322,3 +322,16 @@ void __init x86_dtb_get_config(unsigned int unused)
> dtb_setup_hpet();
> dtb_apic_setup();
> }
> +
> +void __init x86_add_irq_domains(void)
> +{
> + struct device_node *dp;
> +
> + if (!initial_boot_params)
> + return;
> +
> + for_each_node_with_property(dp, "interrupt-controller") {
> + if (of_device_is_compatible(dp, "intel,ce4100-ioapic"))
> + ioapic_add_ofnode(dp);
> + }
> +}
> diff --git a/arch/x86/kernel/irqinit.c b/arch/x86/kernel/irqinit.c
> index 4cadf86..9f76f89 100644
> --- a/arch/x86/kernel/irqinit.c
> +++ b/arch/x86/kernel/irqinit.c
> @@ -119,6 +119,12 @@ void __init init_IRQ(void)
> int i;
>
> /*
> + * We probably need a better place for this, but it works for
> + * now ...
> + */
> + x86_add_irq_domains();
> +
> + /*
> * On cpu 0, Assign IRQ0_VECTOR..IRQ15_VECTOR's to IRQ 0..15.
> * If these IRQ's are handled by legacy interrupt-controllers like PIC,
> * then this configuration will likely be static after the boot. If
> --
> 1.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Device tree on x86, part v4
2011-02-22 20:07 Device tree on x86, part v4 Sebastian Andrzej Siewior
2011-02-22 20:07 ` [PATCH 01/11] x86/e820: remove conditional early mapping in parse_e820_ext Sebastian Andrzej Siewior
[not found] ` <1298405266-1624-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
@ 2011-02-22 21:16 ` Grant Likely
2 siblings, 0 replies; 36+ messages in thread
From: Grant Likely @ 2011-02-22 21:16 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: linux-kernel, sodaville, devicetree-discuss, x86
On Tue, Feb 22, 2011 at 1:07 PM, Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
> This patchset introduces device tree support on x86. The device tree is
> passed by the bootloader via setup_data. It is used as an additional
> source of information and does not replace the "traditional" x86 boot
> page.
> Right now we get the the following information from it:
> - hpet location
> - apic & ioapic location
> - ioapic's interrupt routing
> - legacy devices which are not initialized by bios
> - devices which are behind a bus which does not support enumeration like
> i2c
Looks good; ship it!
g.
>
> History:
> - v1 initial post
> - v2: Benh took my device tree apart so once this got fixed I refactor a
> lot of code. Here are the changes:
> - device tree is unflattenend before kmalloc() is working,
> alloc_bootmem() is used for that.
> - irq_host got renamed to irq_domain. This custom implementation
> will leave once the powerpc implementation is in generic shape
> - of_irq_map_pci() is moved from ppc & microblaze into drivers/of
> and used also by x86 instead of a tiny subset of it. Bridges are
> not handled at all on x86 (I don't have any so for so I worry
> later)
> - the device tree is relocated from its initial location. That
> means that the boot loader does not need to know anything about
> kernel's memory layout.
> - v3: - rebase on top of current tip. The OLPC merged some OF defines
> which are mostly nops so I replaced them with the code I have.
> irq_create_of_mapping() requires now an irq chip to work. Those
> things are moved into prom.c which is enabled by CONFIG_X86_OF.
> This probably breaks OLPC but I don't know what they need in the
> end.
> - Fixed up Grant's review comments. The most noticeable is the i2c
> controller node which has now three child nodes, representing the
> three controllers indentified by the bar number. Each pci bar
> matches via address translation the correct device tree node.
> - v4: - rebased on top of tip's x86/platform branch.
> - added some documentation about the new compatible properties.
> - merged the two rtc commits.
> - renamed prom.c to devicetree.c
> - renamed CONFIG_X86_OF to CONFIG_USE_OF
> - intel,ce4100-immr become intel,ce4100-cp
> - "standard" hardware like hpet has "ce4100" in its property. If
> further HW is compatible with it, can reuse the property string.
> - converted interrupt map to device nodes with an interrupt property.
>
> The series is based on the tip tree and is also available at
> git://git.linutronix.de/users/bigeasy/soda.git ce_of_v4
>
> Sebastian Andrzej Siewior (11):
> x86/e820: remove conditional early mapping in parse_e820_ext
> x86: Add device tree support
> x86/dtb: Add a device tree for CE4100
> x86/dtb: add irq domain abstraction
> x86/dtb: add early parsing of IO APIC
> x86/dtb: add support hpet
> x86/dtb: add support for PCI devices backed by dtb nodes
> x86/dtb: Add generic bus probe
> x86/ioapic: Add OF bindings for IO-APIC
> x86/ce4100: use OF for ioapic
> rtc/cmos: add OF bindings
>
> .../devicetree/bindings/i2c/ce4100-i2c.txt | 93 +++++
> Documentation/devicetree/bindings/rtc/rtc-cmos.txt | 28 ++
> Documentation/devicetree/bindings/x86/ce4100.txt | 38 ++
> .../devicetree/bindings/x86/interrupt.txt | 29 ++
> Documentation/devicetree/bindings/x86/timer.txt | 6 +
> Documentation/devicetree/booting-without-of.txt | 20 +
> arch/x86/Kconfig | 7 +
> arch/x86/include/asm/bootparam.h | 1 +
> arch/x86/include/asm/e820.h | 2 +-
> arch/x86/include/asm/io_apic.h | 7 +
> arch/x86/include/asm/irq.h | 3 -
> arch/x86/include/asm/irq_controller.h | 12 +
> arch/x86/include/asm/prom.h | 72 ++++-
> arch/x86/kernel/Makefile | 1 +
> arch/x86/kernel/apic/io_apic.c | 99 +++++
> arch/x86/kernel/devicetree.c | 337 +++++++++++++++
> arch/x86/kernel/e820.c | 8 +-
> arch/x86/kernel/irq.c | 9 -
> arch/x86/kernel/irqinit.c | 9 +-
> arch/x86/kernel/rtc.c | 3 +
> arch/x86/kernel/setup.c | 22 +-
> arch/x86/platform/ce4100/ce4100.c | 24 +-
> arch/x86/platform/ce4100/falconfalls.dts | 430 ++++++++++++++++++++
> drivers/of/Kconfig | 2 +-
> drivers/of/of_pci.c | 1 +
> drivers/rtc/rtc-cmos.c | 45 ++
> include/linux/of.h | 12 +
> 27 files changed, 1287 insertions(+), 33 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/i2c/ce4100-i2c.txt
> create mode 100644 Documentation/devicetree/bindings/rtc/rtc-cmos.txt
> create mode 100644 Documentation/devicetree/bindings/x86/ce4100.txt
> create mode 100644 Documentation/devicetree/bindings/x86/interrupt.txt
> create mode 100644 Documentation/devicetree/bindings/x86/timer.txt
> create mode 100644 arch/x86/include/asm/irq_controller.h
> create mode 100644 arch/x86/kernel/devicetree.c
> create mode 100644 arch/x86/platform/ce4100/falconfalls.dts
>
> Sebastian
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
^ permalink raw reply [flat|nested] 36+ messages in thread
end of thread, other threads:[~2011-02-22 21:16 UTC | newest]
Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-22 20:07 Device tree on x86, part v4 Sebastian Andrzej Siewior
2011-02-22 20:07 ` [PATCH 01/11] x86/e820: remove conditional early mapping in parse_e820_ext Sebastian Andrzej Siewior
[not found] ` <1298405266-1624-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2011-02-22 20:07 ` [PATCH 02/11] x86: Add device tree support Sebastian Andrzej Siewior
2011-02-22 20:07 ` [PATCH 03/11] x86/dtb: Add a device tree for CE4100 Sebastian Andrzej Siewior
2011-02-22 20:59 ` Grant Likely
2011-02-22 20:07 ` [PATCH 04/11] x86/dtb: add irq domain abstraction Sebastian Andrzej Siewior
2011-02-22 21:06 ` Grant Likely
2011-02-22 20:07 ` [PATCH 05/11] x86/dtb: add early parsing of IO APIC Sebastian Andrzej Siewior
2011-02-22 20:07 ` [PATCH 06/11] x86/dtb: add support hpet Sebastian Andrzej Siewior
2011-02-22 20:07 ` [PATCH 07/11] x86/dtb: add support for PCI devices backed by dtb nodes Sebastian Andrzej Siewior
2011-02-22 21:08 ` Grant Likely
2011-02-22 20:07 ` [PATCH 08/11] x86/dtb: Add generic bus probe Sebastian Andrzej Siewior
2011-02-22 20:07 ` [PATCH 09/11] x86/ioapic: Add OF bindings for IO-APIC Sebastian Andrzej Siewior
2011-02-22 21:14 ` Grant Likely
2011-02-22 20:07 ` [PATCH 10/11] x86/ce4100: use OF for ioapic Sebastian Andrzej Siewior
2011-02-22 20:07 ` [PATCH 11/11] rtc/cmos: add OF bindings Sebastian Andrzej Siewior
[not found] ` <1298405266-1624-12-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2011-02-22 20:50 ` Grant Likely
2011-02-22 21:16 ` Device tree on x86, part v4 Grant Likely
[not found] <1290706801-7323-1-git-send-email-bigeasy@linutronix.de>
[not found] ` <1290706801-7323-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-11-25 17:39 ` [PATCH 03/11] x86/dtb: Add a device tree for CE4100 Sebastian Andrzej Siewior
[not found] ` <1290706801-7323-4-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-11-26 21:57 ` Benjamin Herrenschmidt
2010-11-28 16:04 ` Sebastian Andrzej Siewior
[not found] ` <20101128160449.GC30784-Hfxr4Dq0UpYb1SvskN2V4Q@public.gmane.org>
2010-11-28 22:53 ` Benjamin Herrenschmidt
2010-11-29 1:34 ` Mitch Bradley
2010-11-29 19:07 ` Scott Wood
2010-11-29 20:05 ` Benjamin Herrenschmidt
2010-11-29 20:32 ` Mitch Bradley
2010-11-29 23:42 ` Alan Cox
[not found] ` <4CF40DF4.9060204-D5eQfiDGL7eakBO8gow8eQ@public.gmane.org>
2010-11-29 20:44 ` Benjamin Herrenschmidt
2010-11-29 21:32 ` Mitch Bradley
2010-11-29 23:47 ` Alan Cox
[not found] ` <20101129234735.4ce3a933-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2010-11-30 2:50 ` Benjamin Herrenschmidt
2010-11-30 11:20 ` Sebastian Andrzej Siewior
2010-11-30 11:51 ` Sebastian Andrzej Siewior
[not found] ` <4CF4E54D.5040403-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-11-30 20:31 ` Benjamin Herrenschmidt
[not found] ` <20101129130720.7d060e1c-N/eSCTBpGwP7j4BuCOFQISmX4OfbXNuMKnGXBo5VDl8@public.gmane.org>
2010-11-29 23:58 ` David Gibson
2010-11-29 2:22 ` David Gibson
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).