Skip to contentSkip to conversation

Device tree on x86, part v3

PATCH In review Sebastian Andrzej Siewior 5 participants 50 messages Jan 24, 2011 – Feb 22, 2011

Subsystems (7)
Documentation x86 PowerPC PCI +3 more subsystems
lore
Share & tools
lore
#0 lore raw

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.

The series is based on the tip tree and is also available at
git://git.linutronix.de/users/bigeasy/soda.git ce_of_v3

Sebastian Andrzej Siewior (14):
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 APIC and IO APIC x86/dtb: add support hpet
of: move of_irq_map_pci() into generic code 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
x86/rtc: don't register rtc if we the DT blob rtc/cmos: add OF bindings
x86/pci: remove warning

 Documentation/powerpc/dts-bindings/rtc-cmos.txt |   28 ++
 Documentation/x86/boot_with_dtb.txt             |   26 ++
 arch/microblaze/include/asm/pci-bridge.h        |   12 +
 arch/microblaze/include/asm/prom.h              |   15 -
 arch/microblaze/kernel/prom_parse.c             |   77 -----
 arch/microblaze/pci/pci-common.c                |    1 +
 arch/powerpc/include/asm/pci-bridge.h           |   10 +
 arch/powerpc/include/asm/prom.h                 |   15 -
 arch/powerpc/kernel/pci-common.c                |    1 +
 arch/powerpc/kernel/prom_parse.c                |   84 ------
 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                     |   88 ++++++-
 arch/x86/kernel/Makefile                        |    1 +
 arch/x86/kernel/apic/io_apic.c                  |   99 +++++++
 arch/x86/kernel/e820.c                          |    8 +-
 arch/x86/kernel/irq.c                           |    9 -
 arch/x86/kernel/irqinit.c                       |    9 +-
 arch/x86/kernel/prom.c                          |  337 +++++++++++++++++++++++
 arch/x86/kernel/rtc.c                           |    3 +
 arch/x86/kernel/setup.c                         |   22 ++-
 arch/x86/pci/ce4100.c                           |    2 +-
 arch/x86/platform/ce4100/ce4100.c               |   24 ++-
 arch/x86/platform/ce4100/falconfalls.dts        |  228 +++++++++++++++
 drivers/of/Kconfig                              |    6 +
 drivers/of/Makefile                             |    1 +
 drivers/of/of_pci.c                             |   80 ++++++
 drivers/rtc/rtc-cmos.c                          |   46 +++
 include/linux/of.h                              |   12 +
 include/linux/of_pci.h                          |   20 ++
 34 files changed, 1072 insertions(+), 224 deletions(-)
 create mode 100644 Documentation/powerpc/dts-bindings/rtc-cmos.txt
 create mode 100644 Documentation/x86/boot_with_dtb.txt
 create mode 100644 arch/x86/include/asm/irq_controller.h
 create mode 100644 arch/x86/kernel/prom.c
 create mode 100644 arch/x86/platform/ce4100/falconfalls.dts
 create mode 100644 drivers/of/of_pci.c
 create mode 100644 include/linux/of_pci.h

Sebastian

#1 lore raw

PATCH 1/14 x86/e820: remove conditional early mapping in parse_e820_ext

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.

---
 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(-)
arch/x86/include/asm/e820.h +1 -1
index e99d55d..908b969 100644
@@ -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))
arch/x86/kernel/e820.c +1 -7
index 294f26d..5fad626 100644
@@ -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");
 }
arch/x86/kernel/setup.c +15 -3
index d3cfe26..f8e7152 100644
@@ -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);
 	}
 }
 
Signature · 1 line
1.7.3.2
#2 lore raw

Re: [PATCH TIP 01/14] x86/e820: remove conditional early mapping in parse_e820_ext

Quoted 9 lines · Sebastian Andrzej Siewior

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.

I'm going through the dt patches now. If I decide they are ready to go, should I pick this one up too? hpa, does this look like something you can ack?

g.

Quoted 89 lines
---
 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(-)
arch/x86/include/asm/e820.h +1 -1
index e99d55d..908b969 100644
@@ -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))
arch/x86/kernel/e820.c +1 -7
index 294f26d..5fad626 100644
@@ -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");
 }
arch/x86/kernel/setup.c +15 -3
index d3cfe26..f8e7152 100644
@@ -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);
 	}
 }
 
Signature · 6 lines
1.7.3.2

_______________________________________________
devicetree-discuss mailing list
[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss
#3 lore raw

PATCH 2/14 x86: Add device tree support

In reply to 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?

---
 Documentation/x86/boot_with_dtb.txt |   26 +++++++++++++++
 arch/x86/Kconfig                    |    7 ++++
 arch/x86/include/asm/bootparam.h    |    1 +
 arch/x86/include/asm/irq.h          |    3 --
 arch/x86/include/asm/prom.h         |   60 ++++++++++++++++++++++++++++++++++-
 arch/x86/kernel/Makefile            |    1 +
 arch/x86/kernel/irq.c               |    9 -----
 arch/x86/kernel/irqinit.c           |    1 +
 arch/x86/kernel/prom.c              |   51 +++++++++++++++++++++++++++++
 arch/x86/kernel/setup.c             |    4 ++
 10 files changed, 150 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/x86/boot_with_dtb.txt
 create mode 100644 arch/x86/kernel/prom.c
Documentation/x86/boot_with_dtb.txt new file +26 -0
new file mode 100644
index 0000000..6a357aa
@@ -0,0 +1,26 @@
+  Booting x86 with device tree
+=================================
+
+1. Introduction
+~~~~~~~~~~~~~~~
+This document contains device tree information which are specific to
+the x86 platform. Generic informations as bindings can be found in
+Documentation/powerpc/dts-bindings/
+
+2. Passing the device tree
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+The pointer to the device tree block (dtb) is passed via setup_data
+(see [0]) which requires at least boot protocol 2.09. The type filed is
+defined as
+
+#define SETUP_DTB                      2
+
+3. Purpose
+~~~~~~~~~~~
+The device tree is used as an extension to the "boot page". As such it does not
+parse / consider data which are already covered by the boot page. This includes
+memory size, 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.
+
+[0] Documentation/x86/boot.txt
arch/x86/Kconfig +7 -0
index d5ed94d..5d21095 100644
@@ -297,6 +297,13 @@ config X86_BIGSMP
 	---help---
 	  This option is needed for the systems that have more than 8 CPUs
 
+config X86_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"
arch/x86/include/asm/bootparam.h +1 -0
index c8bfe63..e020d88 100644
@@ -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 {
arch/x86/include/asm/irq.h +0 -3
index c704b38..ba870bb 100644
@@ -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);
arch/x86/include/asm/prom.h +59 -1

60 lines not on this page · raw message

arch/x86/kernel/Makefile +1 -0
index 34244b2..50ff982 100644
@@ -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_X86_OF)			+= prom.o
 
 ###
 # 64 bit specific files
arch/x86/kernel/irq.c +0 -9
index 52945da..45cdc62 100644
@@ -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)
arch/x86/kernel/irqinit.c +1 -0
index c752e97..149c87f 100644
@@ -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:
arch/x86/kernel/prom.c new file +51 -0

51 lines not on this page · raw message

arch/x86/kernel/setup.c +4 -0
index f8e7152..87396d2 100644
@@ -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;
 		}
Signature · 1 line
1.7.3.2
#4 lore raw

Re: [PATCH TIP 02/14] x86: Add device tree support

Quoted 4 lines · * Sebastian Andrzej Siewior | 2011-01-24 09:58:50 [+0530]:

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

Quoted 9 lines

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?

Andres, this patch moves some of the OF defines you added for OLPC from irq.c to prom.c which requires CONFIG_X86_OF to be enabled. A later patch changes irq_create_of_mapping() from returning intspec[0] to actually doing something. Could you please check how of OLPC gets broken and what we could do about it? :)

Sebastian

#5 lore raw

Re: [PATCH TIP 02/14] x86: Add device tree support

Quoted 16 lines · Sebastian Andrzej Siewior
Quoted 4 lines · * Sebastian Andrzej Siewior | 2011-01-24 09:58:50 [+0530]:

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

Quoted 9 lines

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?

Quoted 2 lines

Andres, this patch moves some of the OF defines you added for OLPC from irq.c to prom.c which requires CONFIG_X86_OF to be enabled. A later

Why not simply make prom.c depend on CONFIG_OF? There is no need to have an x86 specific config value for enabling devicetree code.

Quoted 9 lines

patch changes irq_create_of_mapping() from returning intspec[0] to actually doing something. Could you please check how of OLPC gets broken and what we could do about it? :)

Sebastian
_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

#6 lore raw

Re: [sodaville] [PATCH TIP 02/14] x86: Add device tree support

Quoted 5 lines · * Grant Likely | 2011-02-16 14:27:46 [-0700]:
Quoted 2 lines

Andres, this patch moves some of the OF defines you added for OLPC from irq.c to prom.c which requires CONFIG_X86_OF to be enabled. A later

Why not simply make prom.c depend on CONFIG_OF? There is no need to have an x86 specific config value for enabling devicetree code.

renamed it to CONFIG_OF

Sebastian

Acked-by on v1 2/14
#7 lore raw

Re: [PATCH TIP 02/14] x86: Add device tree support

In reply to Sebastian Andrzej Siewior
Quoted 13 lines · 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?

Quoted 3 lines

Hi Sebastian,

Relatively minor comments below. You can go ahead and add the following when you respin:

Quoted 37 lines
---
 Documentation/x86/boot_with_dtb.txt |   26 +++++++++++++++
 arch/x86/Kconfig                    |    7 ++++
 arch/x86/include/asm/bootparam.h    |    1 +
 arch/x86/include/asm/irq.h          |    3 --
 arch/x86/include/asm/prom.h         |   60 ++++++++++++++++++++++++++++++++++-
 arch/x86/kernel/Makefile            |    1 +
 arch/x86/kernel/irq.c               |    9 -----
 arch/x86/kernel/irqinit.c           |    1 +
 arch/x86/kernel/prom.c              |   51 +++++++++++++++++++++++++++++
 arch/x86/kernel/setup.c             |    4 ++
 10 files changed, 150 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/x86/boot_with_dtb.txt
 create mode 100644 arch/x86/kernel/prom.c
Documentation/x86/boot_with_dtb.txt new file +16 -0
new file mode 100644
index 0000000..6a357aa
@@ -0,0 +1,26 @@
+  Booting x86 with device tree
+=================================
+
+1. Introduction
+~~~~~~~~~~~~~~~
+This document contains device tree information which are specific to
+the x86 platform. Generic informations as bindings can be found in
+Documentation/powerpc/dts-bindings/
+
+2. Passing the device tree
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+The pointer to the device tree block (dtb) is passed via setup_data
+(see [0]) which requires at least boot protocol 2.09. The type filed is
+defined as
+
+#define SETUP_DTB                      2

Documentation/x86/boot_with_dtb.txt line 26

Quoted 10 lines
Documentation/x86/boot_with_dtb.txt new file +10 -0
+
+3. Purpose
+~~~~~~~~~~~
+The device tree is used as an extension to the "boot page". As such it does not
+parse / consider data which are already covered by the boot page. This includes
+memory size, 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.
+
+[0] Documentation/x86/boot.txt

Please also add a brief description to section I of Documentation/devicetree/booting-without-of.txt

Quoted 71 lines
arch/x86/Kconfig +7 -0
index d5ed94d..5d21095 100644
@@ -297,6 +297,13 @@ config X86_BIGSMP
 	---help---
 	  This option is needed for the systems that have more than 8 CPUs
 
+config X86_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"
arch/x86/include/asm/bootparam.h +1 -0
index c8bfe63..e020d88 100644
@@ -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 {
arch/x86/include/asm/irq.h +0 -3
index c704b38..ba870bb 100644
@@ -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);
arch/x86/include/asm/prom.h +21 -1
index b4ec95f..b227ba7 100644
@@ -1 +1,59 @@
-/* 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>

arch/x86/include/asm/prom.h line 31

Quoted 10 lines
arch/x86/include/asm/prom.h +10 -0
+
+#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];
+/* This number is used when no interrupt has been assigned */
+#define NO_IRQ		(0)

This line should no longer be necessary. drivers/of/irq.c defines NO_IRQ if it isn't already defined by the architecture. I'm trying to limit the exposure of NO_IRQ in dt code.

arch/x86/include/asm/prom.h line 41

Quoted 10 lines
arch/x86/include/asm/prom.h +10 -0
+
+#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.

Lennert Buytenhek is working on this. It actually shouldn't be too bad.

Quoted 6 lines
arch/x86/include/asm/prom.h +6 -0
+ */
+static inline void irq_dispose_mapping(unsigned int virq) { }
+
+#define HAVE_ARCH_DEVTREE_FIXUPS
+
+#endif /* __ASSEMBLY__ */

arch/x86/include/asm/prom.h line 57

Quoted 10 lines
arch/x86/include/asm/prom.h +10 -0
+
+/*
+ * These includes are put at the bottom because they may contain things
+ * that are overridden by this file.  Ideally they shouldn't be included
+ * by this file, but there are a bunch of .c files that currently depend
+ * on it.  Eventually they will be cleaned up.
+ */
+#include <linux/of_fdt.h>
+#include <linux/of_irq.h>
+#include <linux/platform_device.h>

You should be able to remove these includes. The problems described in the header are mostly with device drivers and architecture code. You shouldn't run into any of those issue, and if you do they should be fixed at the source.

Quoted 39 lines
arch/x86/include/asm/prom.h +2 -0
+
+#endif
arch/x86/kernel/Makefile +1 -0
index 34244b2..50ff982 100644
@@ -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_X86_OF)			+= prom.o
 
 ###
 # 64 bit specific files
arch/x86/kernel/irq.c +0 -9
index 52945da..45cdc62 100644
@@ -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)
arch/x86/kernel/irqinit.c +0 -0
index c752e97..149c87f 100644

arch/x86/kernel/irqinit.c line 28

Quoted 4 lines
arch/x86/kernel/irqinit.c +1 -0
@@ -25,6 +25,7 @@
 #include <asm/setup.h>
 #include <asm/i8259.h>
 #include <asm/traps.h>
+#include <asm/prom.h>

I'm probably missing something. I don't see any changes to irqinit.c other than this. What symbol definition has been moved to prom.h that irqinit.c needs?

arch/x86/kernel/prom.c

Quoted 8 lines
arch/x86/kernel/irqinit.c +0 -0
 /*
  * ISA PIC or low IO-APIC triggered (INTA-cycle or APIC) interrupts:
arch/x86/kernel/prom.c new file +0 -0
new file mode 100644
index 0000000..4969ffa

You don't need to name this prom.c. devicetree.c would make more sense. prom is a legacy name from when only Open Firmware systems were using the dt code.

Quoted 41 lines
arch/x86/kernel/prom.c new file +40 -0
@@ -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_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();
+}
+

arch/x86/kernel/prom.c line 50

Quoted 10 lines
arch/x86/kernel/prom.c new file +10 -0
+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 = (struct boot_param_header *)
+		phys_to_virt((u64) (u32) data +
+				offsetof(struct setup_data, data));

(struct boot_param_header *) cast unnecessary since phys_to_virt should return a void*.

Quoted 30 lines
arch/x86/kernel/prom.c new file +1 -0
+}
arch/x86/kernel/setup.c +4 -0
index f8e7152..87396d2 100644
@@ -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;
 		}
Signature · 6 lines
1.7.3.2

_______________________________________________
devicetree-discuss mailing list
[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss
#8 lore raw

Re: [PATCH TIP 02/14] x86: Add device tree support

Quoted 1 line · Grant Likely

Hi Sebastian,

Hi Grant,

Quoted 5 lines

Relatively minor comments below. You can go ahead and add the following when you respin:

Cool.

Quoted 27 lines
Quoted 27 lines
Documentation/x86/boot_with_dtb.txt new file +21 -0
new file mode 100644
index 0000000..6a357aa
@@ -0,0 +1,26 @@
+  Booting x86 with device tree
+=================================
+
+1. Introduction
+~~~~~~~~~~~~~~~
+This document contains device tree information which are specific to
+the x86 platform. Generic informations as bindings can be found in
+Documentation/powerpc/dts-bindings/
+
+2. Passing the device tree
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+The pointer to the device tree block (dtb) is passed via setup_data
+(see [0]) which requires at least boot protocol 2.09. The type filed is
+defined as
+
+#define SETUP_DTB                      2
+
+3. Purpose
+~~~~~~~~~~~
+The device tree is used as an extension to the "boot page". As such it does not
+parse / consider data which are already covered by the boot page. This includes
Quoted 8 lines

Documentation/x86/boot_with_dtb.txt line 26

Quoted 5 lines
Documentation/x86/boot_with_dtb.txt new file +5 -0
+memory size, 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.
+
+[0] Documentation/x86/boot.txt

Please also add a brief description to section I of Documentation/devicetree/booting-without-of.txt

I assumed this file is powerpc only. Since you added arm there I have no problem to move this content there.

Quoted 33 lines
Quoted 33 lines
arch/x86/include/asm/prom.h +27 -1
index b4ec95f..b227ba7 100644
@@ -1 +1,59 @@
-/* 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
Quoted 8 lines

arch/x86/include/asm/prom.h line 31

Quoted 4 lines
arch/x86/include/asm/prom.h +4 -0
+
+extern char cmd_line[COMMAND_LINE_SIZE];
+/* This number is used when no interrupt has been assigned */
+#define NO_IRQ		(0)

This line should no longer be necessary. drivers/of/irq.c defines NO_IRQ if it isn't already defined by the architecture. I'm trying to limit the exposure of NO_IRQ in dt code.

okay, I will to remove that.

Quoted 8 lines
Quoted 8 lines
arch/x86/include/asm/prom.h +8 -0
+#endif /* __ASSEMBLY__ */
+
+/*
+ * These includes are put at the bottom because they may contain things
+ * that are overridden by this file.  Ideally they shouldn't be included
+ * by this file, but there are a bunch of .c files that currently depend
+ * on it.  Eventually they will be cleaned up.
+ */
Quoted 8 lines

arch/x86/include/asm/prom.h line 57

Quoted 3 lines
arch/x86/include/asm/prom.h +3 -0
+#include <linux/of_fdt.h>
+#include <linux/of_irq.h>
+#include <linux/platform_device.h>

You should be able to remove these includes. The problems described in the header are mostly with device drivers and architecture code. You shouldn't run into any of those issue, and if you do they should be fixed at the source.

okay.

Quoted 4 lines
Quoted 4 lines

index c752e97..149c87f 100644

arch/x86/kernel/irqinit.c +0 -0
@@ -25,6 +25,7 @@
Quoted 8 lines

arch/x86/kernel/irqinit.c line 28

Quoted 4 lines
arch/x86/kernel/irqinit.c +1 -0
 #include <asm/setup.h>
 #include <asm/i8259.h>
 #include <asm/traps.h>
+#include <asm/prom.h>

I'm probably missing something. I don't see any changes to irqinit.c other than this. What symbol definition has been moved to prom.h that irqinit.c needs?

This hunk was folded into the wrong patch. It should been folded into "x86/ioapic: Add OF bindings for IO-APIC".

Quoted 11 lines

arch/x86/kernel/prom.c

Quoted 7 lines
arch/x86/kernel/irqinit.c +0 -0
 /*
  * ISA PIC or low IO-APIC triggered (INTA-cycle or APIC) interrupts:
arch/x86/kernel/prom.c new file +0 -0
new file mode 100644
index 0000000..4969ffa

You don't need to name this prom.c. devicetree.c would make more sense. prom is a legacy name from when only Open Firmware systems were using the dt code.

okay.

Quoted 11 lines

arch/x86/kernel/prom.c line 50

Quoted 8 lines
arch/x86/kernel/prom.c new file +6 -0
@@ -0,0 +1,51 @@
 
+
+void __init add_dtb(u64 data)
+{
+	initial_boot_params = (struct boot_param_header *)
+		phys_to_virt((u64) (u32) data +
+				offsetof(struct setup_data, data));

(struct boot_param_header *) cast unnecessary since phys_to_virt should return a void*.

removed.

Quoted 1 line
Quoted 1 line

+}

Sebastian

#9 lore raw

Re: [PATCH TIP 02/14] x86: Add device tree support

In reply to Sebastian Andrzej Siewior
Quoted 17 lines · 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?

---

[...]

Quoted 5 lines
arch/x86/Kconfig +0 -0
index d5ed94d..5d21095 100644

arch/x86/Kconfig config X86_BIGSMP · line 306

Quoted 10 lines
arch/x86/Kconfig +7 -0
@@ -297,6 +297,13 @@ config X86_BIGSMP
 	---help---
 	  This option is needed for the systems that have more than 8 CPUs
 
+config X86_OF
+	bool "Support for device tree"
+	select OF
+	select OF_EARLY_FLATTREE
+	---help---
+	  Device tree support on X86.
+

On ARM and MIPS, this is called 'config USE_OF'. It would be nice to have some commonality. Maybe I should move the user-visible option to drivers/of/Kconfig. Or perhaps I should just make CONFIG_OF itself user visible.

thoughts?

g.

#10 lore raw

Re: [sodaville] [PATCH TIP 02/14] x86: Add device tree support

Quoted 13 lines · * Grant Likely | 2011-02-16 14:31:26 [-0700]:

arch/x86/Kconfig config X86_BIGSMP · line 306

Quoted 7 lines
arch/x86/Kconfig +7 -0
+config X86_OF
+	bool "Support for device tree"
+	select OF
+	select OF_EARLY_FLATTREE
+	---help---
+	  Device tree support on X86.
+

On ARM and MIPS, this is called 'config USE_OF'. It would be nice to have some commonality. Maybe I should move the user-visible option to drivers/of/Kconfig. Or perhaps I should just make CONFIG_OF itself user visible.

Quoted 1 line

thoughts?

We could make CONFIG_OF depend on CONFIG_HAVE_OF_SUPPORT and let OF select OF_EARLY_FLATTREE if ARCH_WANT_EARLY_FLATTREE for instance. So that part would work in a generic way.

For OF-only platforms you would have to go to drivers/of before you can enable the specific SoC/board. So it could lead to something like "first enable scsi disk before you can enable usb storage".

I like it :) For now I rename to USE_OF.

Quoted 2 lines

g.

Sebastian

#11 lore raw

Re: [sodaville] [PATCH TIP 02/14] x86: Add device tree support

Quoted 17 lines · Sebastian Andrzej Siewior
Quoted 13 lines · * Grant Likely | 2011-02-16 14:31:26 [-0700]:

arch/x86/Kconfig config X86_BIGSMP · line 306

Quoted 7 lines
arch/x86/Kconfig +7 -0
+config X86_OF
+    bool "Support for device tree"
+    select OF
+    select OF_EARLY_FLATTREE
+    ---help---
+      Device tree support on X86.
+

On ARM and MIPS, this is called 'config USE_OF'.  It would be nice to have some commonality.  Maybe I should move the user-visible option to drivers/of/Kconfig.  Or perhaps I should just make CONFIG_OF itself user visible.

Quoted 1 line

thoughts?

Quoted 8 lines

We could make CONFIG_OF depend on CONFIG_HAVE_OF_SUPPORT and let OF select OF_EARLY_FLATTREE if ARCH_WANT_EARLY_FLATTREE for instance. So that part would work in a generic way.

For OF-only platforms you would have to go to drivers/of before you can enable the specific SoC/board. So it could lead to something like "first enable scsi disk before you can enable usb storage".

That's definitely not desirable. Currently ARM and MIPS boards that need it are force-selecting USE_OF which pretty much solves the problem. The option is always user-

Quoted 2 lines

I like it :) For now I rename to USE_OF.

okay.

g.

#12 lore raw

PATCH 3/14 x86/dtb: Add a device tree for CE4100

In reply to Sebastian Andrzej Siewior
---
 arch/x86/platform/ce4100/falconfalls.dts |  228 ++++++++++++++++++++++++++++++
 1 files changed, 228 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/platform/ce4100/falconfalls.dts
arch/x86/platform/ce4100/falconfalls.dts new file +228 -0
new file mode 100644
index 0000000..c2df5c8
@@ -0,0 +1,228 @@
+/*
+ * 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-immr";
+		ranges;
+
+		ioapic1: pic@fec00000 {
+			#interrupt-cells = <2>;
+			compatible = "intel,ioapic-ce4100", "intel,ioapic";
+			interrupt-controller;
+			reg = <0xfec00000 0x1000>;
+		};
+
+		timer@fed00000 {
+			compatible = "intel,hpet-ce4100", "intel,hpet";
+			reg = <0xfed00000 0x200>;
+		};
+
+		lapic0: interrupt-controller@fee00000 {
+			compatible = "intel,lapic-ce4100", "intel,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>;
+
+			isa@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>;
+				};
+			};
+
+			/* Secondary IO-APIC */
+			ioapic2: pic@bffff000 {
+				#interrupt-cells = <2>;
+				compatible = "intel,ioapic-ce4100", "intel,ioapic";
+				interrupt-controller;
+				reg = <0x100 0x0 0x0 0x0 0x0>;
+				assigned-addresses = <0x02000000 0x0 0xbffff000 0x0 0x1000>;
+			};
+
+			pci@av {
+				#address-cells = <3>;
+				#interrupt-cells = <1>;
+				#size-cells = <2>;
+				compatible = "intel,ce4100-pci";
+				device_type = "pci";
+				bus-range = <1 1>;
+				ranges = <0x2000000 0 0xdffe0000 0x2000000 0 0xdffe0000 0 0x1000>;
+
+				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-controller@15a00,0,0 {
+					#address-cells = <2>;
+					#size-cells = <1>;
+					compatible = "pci8086,2e68.2",
+						   "pci8086,2e68",
+						   "pciclass,ff0000",
+						   "pciclass,ff00";
+
+					reg = <0x15a00 0x0 0x0 0x0 0x0>;
+					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 {
+							compatible = "ti,pcf8575";
+							reg = <0x26>;
+						};
+					};
+
+					i2c@2 {
+						#address-cells = <1>;
+						#size-cells = <0>;
+						compatible = "intel,ce4100-i2c-controller";
+						reg = <2 0 0x100>;
+
+						gpio@26 {
+							compatible = "ti,pcf8575";
+							reg = <0x26>;
+						};
+					};
+				};
+
+				spi-controller@15c00,0,0 {
+					#address-cells = <1>;
+					#size-cells = <0>;
+					compatible =
+						"pci8086,2e6a.2",
+						"pci8086,2e6a",
+						"pciclass,ff0000",
+						"pciclass,ff00";
+
+					reg = <0x15c00 0x0 0x0 0x0 0x0>;
+
+					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>;
+					};
+				};
+			};
+		};
+	};
+};
Signature · 1 line
1.7.3.2
#13 lore raw

Re: [PATCH TIP 03/14] x86/dtb: Add a device tree for CE4100

Quoted 37 lines · Sebastian Andrzej Siewior
---
 arch/x86/platform/ce4100/falconfalls.dts |  228 ++++++++++++++++++++++++++++++
 1 files changed, 228 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/platform/ce4100/falconfalls.dts
arch/x86/platform/ce4100/falconfalls.dts new file +23 -0
new file mode 100644
index 0000000..c2df5c8
@@ -0,0 +1,228 @@
+/*
+ * 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";

arch/x86/platform/ce4100/falconfalls.dts line 33

Quoted 10 lines
arch/x86/platform/ce4100/falconfalls.dts new file +10 -0
+			reg = <0>;
+			lapic = <&lapic0>;
+		};
+	};
+
+	soc@0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "intel,ce4100-immr";
+		ranges;

IMMR is probably not the name you want. I'm guessing you're taking this by anology with the IMMR thingies in Freescale chips. However in that case the name is coming from the IMMR register which can physically relocate the batch of IOs represented by the node. You should probably name it something appropriate to your chip instead.

arch/x86/platform/ce4100/falconfalls.dts line 35

Quoted 1 line
arch/x86/platform/ce4100/falconfalls.dts new file +1 -0
+		ioapic1: pic@fec00000 {

The name should be "interrupt-controller" rather than pic.

Quoted 31 lines
arch/x86/platform/ce4100/falconfalls.dts new file +31 -0
+			#interrupt-cells = <2>;
+			compatible = "intel,ioapic-ce4100", "intel,ioapic";
+			interrupt-controller;
+			reg = <0xfec00000 0x1000>;
+		};
+
+		timer@fed00000 {
+			compatible = "intel,hpet-ce4100", "intel,hpet";
+			reg = <0xfed00000 0x200>;
+		};
+
+		lapic0: interrupt-controller@fee00000 {
+			compatible = "intel,lapic-ce4100", "intel,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>;
+
+			isa@0 {
+				#address-cells = <2>;
+				#size-cells = <1>;
+				compatible = "isa";

arch/x86/platform/ce4100/falconfalls.dts line 76

Quoted 10 lines
arch/x86/platform/ce4100/falconfalls.dts new file +10 -0
+				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>;
+				};

Is the rtc really wired directly to the ioapic without going through the cascaded i8259 which usually inhabits isa busses?

arch/x86/platform/ce4100/falconfalls.dts line 85

Quoted 9 lines
arch/x86/platform/ce4100/falconfalls.dts new file +9 -0
+			};
+
+			/* Secondary IO-APIC */
+			ioapic2: pic@bffff000 {
+				#interrupt-cells = <2>;
+				compatible = "intel,ioapic-ce4100", "intel,ioapic";
+				interrupt-controller;
+				reg = <0x100 0x0 0x0 0x0 0x0>;
+				assigned-addresses = <0x02000000 0x0 0xbffff000 0x0 0x1000>;

If this is a cascaded interrupt controller, then it should have an interrupts and interrupt-parent property to point at the correct cascade interrupt on the master ioapic.

Quoted 53 lines
arch/x86/platform/ce4100/falconfalls.dts new file +53 -0
+			};
+
+			pci@av {
+				#address-cells = <3>;
+				#interrupt-cells = <1>;
+				#size-cells = <2>;
+				compatible = "intel,ce4100-pci";
+				device_type = "pci";
+				bus-range = <1 1>;
+				ranges = <0x2000000 0 0xdffe0000 0x2000000 0 0xdffe0000 0 0x1000>;
+
+				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 */

arch/x86/platform/ce4100/falconfalls.dts line 148

Quoted 10 lines
arch/x86/platform/ce4100/falconfalls.dts new file +10 -0
+					/* 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

Are all these interrupt map entries representing on-board PCI devices that have their interrupts wired direct to the APIC, instead of via the PCI INTA..D lines? If so, it might be better to create device nodes for those devices with interrupts and interrupt-parent properties giving their interrupt routing, leaving the PCI bus's interrupt-map to describe only the routing for slotted PCI devices with their INTA..D wired with the rest of the PCI lines.

arch/x86/platform/ce4100/falconfalls.dts line 151

Quoted 3 lines
arch/x86/platform/ce4100/falconfalls.dts new file +3 -0
+					>;
+
+				i2c-controller@15a00,0,0 {

Uh.. that unit address does not look right. The encoding of PCI 3-cell addresses into a unit address string is not simply comma separated cells. I forget the details, so you'll need to check the OF PCI binding.

Signature · 4 lines
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
#14 lore raw

Re: [PATCH TIP 03/14] x86/dtb: Add a device tree for CE4100

Quoted 11 lines · * David Gibson | 2011-01-27 15:00:27 [+1000]:

arch/x86/platform/ce4100/falconfalls.dts line 33

Quoted 5 lines
arch/x86/platform/ce4100/falconfalls.dts new file +5 -0
+	soc@0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "intel,ce4100-immr";
+		ranges;

IMMR is probably not the name you want. I'm guessing you're taking this by anology with the IMMR thingies in Freescale chips. However in that case the name is coming from the IMMR register which can physically relocate the batch of IOs represented by the node. You should probably name it something appropriate to your chip instead.

I though IMMR stands for "internel memory mapped regisgters". The spec does not say anything about a name. In fact there are just devices popping up. Some of them are part of a group but lapic or the primary ioapic are just there.
Let me look, maybe I find something more appropriate. Would -soc be better?

Quoted 4 lines

arch/x86/platform/ce4100/falconfalls.dts line 35

Quoted 2 lines
arch/x86/platform/ce4100/falconfalls.dts new file +1 -0
+		ioapic1: pic@fec00000 {

The name should be "interrupt-controller" rather than pic.

okay.

Quoted 10 lines
Quoted 10 lines
arch/x86/platform/ce4100/falconfalls.dts new file +10 -0
+
+			isa@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>;
Quoted 8 lines

arch/x86/platform/ce4100/falconfalls.dts line 76

Quoted 5 lines
arch/x86/platform/ce4100/falconfalls.dts new file +5 -0
+					interrupt-parent = <&ioapic1>;
+					ctrl-reg = <2>;
+					freq-reg = <0x26>;
+					reg = <1 0x70 2>;
+				};

Is the rtc really wired directly to the ioapic without going through the cascaded i8259 which usually inhabits isa busses?

I don't see it anywhere in the spec describing like that but that is the way it behaves. In the non-apic mode it goes through the cascaded i8259. Once we are in apic mode, the i8259 is switched off and the rtc's interrupt apears on ioapic. If the entry for pin 8 on ioapic is not configured, then the interrupt does not appear.
The spec says that the rtc is part of the legacy cluster which contains all the "legacy" devices like i8259 or rtc. The uart for instance is not part of it. This legacy cluster is behind PCI, behind the isa bridge. And I belive this device is also in-core.

Quoted 5 lines
Quoted 5 lines
arch/x86/platform/ce4100/falconfalls.dts new file +5 -0
+			};
+
+			/* Secondary IO-APIC */
+			ioapic2: pic@bffff000 {
+				#interrupt-cells = <2>;
Quoted 8 lines

arch/x86/platform/ce4100/falconfalls.dts line 85

Quoted 4 lines
arch/x86/platform/ce4100/falconfalls.dts new file +4 -0
+				compatible = "intel,ioapic-ce4100", "intel,ioapic";
+				interrupt-controller;
+				reg = <0x100 0x0 0x0 0x0 0x0>;
+				assigned-addresses = <0x02000000 0x0 0xbffff000 0x0 0x1000>;

If this is a cascaded interrupt controller, then it should have an interrupts and interrupt-parent property to point at the correct cascade interrupt on the master ioapic.

No, it is not cascaded. It is the second ioapic (interrupt controller). This ioapic communicates via the apic bus with the lapic in order to generate an interrupt. The primary ioapic is not involved.

Quoted 60 lines
Quoted 60 lines
arch/x86/platform/ce4100/falconfalls.dts new file +59 -0
+			};
+
+			pci@av {
+				#address-cells = <3>;
+				#interrupt-cells = <1>;
+				#size-cells = <2>;
+				compatible = "intel,ce4100-pci";
+				device_type = "pci";
+				bus-range = <1 1>;
+				ranges = <0x2000000 0 0xdffe0000 0x2000000 0 0xdffe0000 0 0x1000>;
+
+				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
Quoted 8 lines

arch/x86/platform/ce4100/falconfalls.dts line 148

Quoted 4 lines
arch/x86/platform/ce4100/falconfalls.dts new file +4 -0
+					/* USB1: 0x2E70 */
+					0x16900 0x0 0x0 0x0 &ioapic2 22 0x3
+					/* SATA: 0x2E71 */
+					0x17000 0x0 0x0 0x0 &ioapic2 23 0x3

Are all these interrupt map entries representing on-board PCI devices that have their interrupts wired direct to the APIC, instead of via the PCI INTA..D lines?

To some degree yes. There are three modes in which the system can operate. The legacy mode where all devices end up sharing one interrupt line, the multi mode which uses the interrupt pin (INTA..D) are used and the inetrrupt is also routed to the legacy pic. In APIC mode (which is used) each device is routed directly to the ioapic.
However, all of these devices are in-core, there is no external PCI bus where you can plug in cards. This internal PCI bus looks more or less like an emulated PCI bus.

Quoted 5 lines

If so, it might be better to create device
nodes for those devices with interrupts and interrupt-parent properties giving their interrupt routing, leaving the PCI bus's interrupt-map to describe only the routing for slotted PCI devices with their INTA..D wired with the rest of the PCI lines.

The INTA..D information is not part of the address and I hoped to get away with this. There are no slotted pci devies.
So if I come up with nodes for the devices then I would need the reg property and a compatible property.

Quoted 9 lines

arch/x86/platform/ce4100/falconfalls.dts line 151

Quoted 4 lines
arch/x86/platform/ce4100/falconfalls.dts new file +3 -0
+					>;
+
+				i2c-controller@15a00,0,0 {

Uh.. that unit address does not look right. The encoding of PCI 3-cell addresses into a unit address string is not simply comma separated cells. I forget the details, so you'll need to check the OF PCI binding.

Grant wrote [0]:

|You'll also note that I added ',0,0' to the end of the address.
|That's because the node address reflects the parent bus address format
|which uses 3 cells in this case.

I try to look that part up in the pci binding.

[0]
http://www.mail-archive.com/devicetree-discuss-uLR06cmDAlY/[email protected]/msg02806.html

Sebastian

#15 lore raw

Re: [PATCH TIP 03/14] x86/dtb: Add a device tree for CE4100

Quoted 10 lines · Sebastian Andrzej Siewior
Quoted 8 lines · * David Gibson | 2011-01-27 15:00:27 [+1000]:

arch/x86/platform/ce4100/falconfalls.dts line 151

Quoted 3 lines
arch/x86/platform/ce4100/falconfalls.dts new file +3 -0
+					>;
+
+				i2c-controller@15a00,0,0 {

Uh.. that unit address does not look right. The encoding of PCI 3-cell addresses into a unit address string is not simply comma separated cells. I forget the details, so you'll need to check the OF PCI binding.

Quoted 4 lines

Grant wrote [0]:

|You'll also note that I added ',0,0' to the end of the address.
|That's because the node address reflects the parent bus address format
|which uses 3 cells in this case.

It is quite possible I was mistaken on this point. The PCI binding is not my area of strength.

g.

#16 lore raw

Re: [PATCH TIP 03/14] x86/dtb: Add a device tree for CE4100

Quoted 11 lines · Grant Likely
Quoted 10 lines · Sebastian Andrzej Siewior
Quoted 8 lines · * David Gibson | 2011-01-27 15:00:27 [+1000]:

arch/x86/platform/ce4100/falconfalls.dts line 151

Quoted 3 lines
arch/x86/platform/ce4100/falconfalls.dts new file +3 -0
+					>;
+
+				i2c-controller@15a00,0,0 {

Uh.. that unit address does not look right. The encoding of PCI 3-cell addresses into a unit address string is not simply comma separated cells. I forget the details, so you'll need to check the OF PCI binding.

Quoted 7 lines
Quoted 4 lines

Grant wrote [0]:

|You'll also note that I added ',0,0' to the end of the address.
|That's because the node address reflects the parent bus address format
|which uses 3 cells in this case.

It is quite possible I was mistaken on this point. The PCI binding is not my area of strength.

In real OF, the unit address of a PCI device is the first entry in the reg property, which is the config space address. For the config space address, only the most significant of the three cells is significant; the other two must be 0.

The numerical representation of that cell in binary is 0000.0000.0000.0000.dddd.dfff.0000.0000, where d is the device number on its bus segment and fff is the function number.

The text representation is "D,F" , where D is the hexadecimal ASCII representation of the binary number ddddd and F is the hexadecimal ASCII representation of the binary number fff . So "show-devs" will display names like "/pci/ethernet@12,e" - device number 0x12, function number 0xe.

(In the general case, there are more fields in both the numerical and text representations, but the unit address usage is restricted to just the device and function numbers. Bus numbers are handled by the hierarchy of PCI-to-PCI bridges.)

In real OF, there are "encode-unit" and "decode-unit" methods in the parent (PCI bus) node to convert between the numerical and text representations.

I don't know how this plays out in the flattened DT world, but the above is a summary of what the PCI bus binding stipulates.

Quoted 8 lines

g.

_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

#17 lore raw

Re: [PATCH TIP 03/14] x86/dtb: Add a device tree for CE4100

Quoted 1 line · Mitch Bradley

The text representation is "D,F" , where D is the hexadecimal ASCII representation of the binary number ddddd and F is the hexadecimal ASCII representation of the binary number fff . So "show-devs" will display names like "/pci/ethernet@12,e" - device number 0x12, function number 0xe.

[snip more of it]

Quoted 1 line

I don't know how this plays out in the flattened DT world, but the above is a summary of what the PCI bus binding stipulates.

Thanks for clearing it up. After David pointed it out I looked it up in the PCI spec and it seems to match what you saying here.

Sebastian

#18 lore raw

PATCH v2 3/14 x86/dtb: Add a device tree for CE4100

In reply to David Gibson

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

 arch/x86/platform/ce4100/falconfalls.dts |  424 ++++++++++++++++++++++++++++++
 1 files changed, 424 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/platform/ce4100/falconfalls.dts
arch/x86/platform/ce4100/falconfalls.dts new file +424 -0
new file mode 100644
index 0000000..e888657
@@ -0,0 +1,424 @@
+/*
+ * 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,ioapic-ce4100", "intel,ioapic";
+			interrupt-controller;
+			reg = <0xfec00000 0x1000>;
+		};
+
+		timer@fed00000 {
+			compatible = "intel,hpet-ce4100", "intel,hpet";
+			reg = <0xfed00000 0x200>;
+		};
+
+		lapic0: interrupt-controller@fee00000 {
+			compatible = "intel,lapic-ce4100", "intel,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,ioapic-ce4100", "intel,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";
+
+					reg = <0x15900 0x0 0x0 0x0 0x0>;
+					interrupts = <15 1>;
+				};
+
+				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 {
+							compatible = "ti,pcf8575";
+							reg = <0x26>;
+						};
+					};
+
+					i2c@2 {
+						#address-cells = <1>;
+						#size-cells = <0>;
+						compatible = "intel,ce4100-i2c-controller";
+						reg = <2 0 0x100>;
+
+						gpio@26 {
+							compatible = "ti,pcf8575";
+							reg = <0x26>;
+						};
+					};
+				};
+
+				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>;
+				};
+			};
+		};
+	};
+};
Signature · 1 line
1.7.3.2
#19 lore raw

Re: [PATCH TIP v2 03/14] x86/dtb: Add a device tree for CE4100

Quoted 9 lines · Sebastian Andrzej Siewior

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

You can go ahead and keep the revision history above the s-o-b and --- lines. It turns out that having the revision history in the commit text is actually useful when trying to figure out what version of a patch actually got applied.

Quoted 32 lines
 arch/x86/platform/ce4100/falconfalls.dts |  424 ++++++++++++++++++++++++++++++
 1 files changed, 424 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/platform/ce4100/falconfalls.dts
arch/x86/platform/ce4100/falconfalls.dts new file +22 -0
new file mode 100644
index 0000000..e888657
@@ -0,0 +1,424 @@
+/*
+ * 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";

arch/x86/platform/ce4100/falconfalls.dts line 32

Quoted 10 lines
arch/x86/platform/ce4100/falconfalls.dts new file +10 -0
+			compatible = "intel,ce4100";
+			reg = <0>;
+			lapic = <&lapic0>;
+		};
+	};
+
+	soc@0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "intel,ce4100-cp";

You'll need to add blurbs to Documentation/devicetree/bindings (Documentation/powerpc/dts-bindings in Linus' tree; renamed in linux-next) for each of these new compatible bindings to document the part that they describe and any special properties that go with each compatible value (if any). You can send it as a followup patch.

arch/x86/platform/ce4100/falconfalls.dts line 220

Quoted 9 lines
arch/x86/platform/ce4100/falconfalls.dts new file +9 -0
+				gpio@b,1 {
+					compatible = "pci8086,2e67.2",
+						   "pci8086,2e67",
+						   "pciclassff0000",
+						   "pciclassff00";
+
+					reg = <0x15900 0x0 0x0 0x0 0x0>;
+					interrupts = <15 1>;
+				};

You'll probably want to make use of the gpio-controller binding for the gpio nodes so that other nodes can reference it. Not a showstopper for this patch though.

Otherwise looks good to me.
g.

#20 lore raw

Re: [PATCH TIP v2 03/14] x86/dtb: Add a device tree for CE4100

Quoted 4 lines · Grant Likely

You can go ahead and keep the revision history above the s-o-b and --- lines. It turns out that having the revision history in the commit text is actually useful when trying to figure out what version of a patch actually got applied.

Okay.

Quoted 7 lines
Quoted 6 lines
arch/x86/platform/ce4100/falconfalls.dts new file +0 -0
new file mode 100644
index 0000000..e888657
@@ -0,0 +1,424 @@
Quoted 10 lines

arch/x86/platform/ce4100/falconfalls.dts line 32

Quoted 4 lines
arch/x86/platform/ce4100/falconfalls.dts new file +4 -0
+	soc@0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "intel,ce4100-cp";

You'll need to add blurbs to Documentation/devicetree/bindings (Documentation/powerpc/dts-bindings in Linus' tree; renamed in linux-next) for each of these new compatible bindings to document the part that they describe and any special properties that go with each compatible value (if any). You can send it as a followup patch.

Good point, will do.

Quoted 5 lines
Quoted 5 lines
arch/x86/platform/ce4100/falconfalls.dts new file +5 -0
+				gpio@b,1 {
+					compatible = "pci8086,2e67.2",
+						   "pci8086,2e67",
+						   "pciclassff0000",
+						   "pciclassff00";
Quoted 8 lines

arch/x86/platform/ce4100/falconfalls.dts line 220

Quoted 4 lines
arch/x86/platform/ce4100/falconfalls.dts new file +4 -0
+
+					reg = <0x15900 0x0 0x0 0x0 0x0>;
+					interrupts = <15 1>;
+				};

You'll probably want to make use of the gpio-controller binding for the gpio nodes so that other nodes can reference it. Not a showstopper for this patch though.

Right. I'll make it follow-up once I get to the gpio functionality.

Quoted 1 line

Otherwise looks good to me.

thanks.

Quoted 1 line

g.

Sebastian

#21 lore raw

Re: [PATCH TIP v2 03/14] x86/dtb: Add a device tree for CE4100

In reply to Sebastian Andrzej Siewior
Quoted 9 lines · Sebastian Andrzej Siewior

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

It's actually useful to have this revision history as part of the patch description itself so that when it is committed we've got a record of exactly which version got committed.

g.

Quoted 33 lines
 arch/x86/platform/ce4100/falconfalls.dts |  424 ++++++++++++++++++++++++++++++
 1 files changed, 424 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/platform/ce4100/falconfalls.dts
arch/x86/platform/ce4100/falconfalls.dts new file +22 -0
new file mode 100644
index 0000000..e888657
@@ -0,0 +1,424 @@
+/*
+ * 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";

arch/x86/platform/ce4100/falconfalls.dts line 32

Quoted 10 lines
arch/x86/platform/ce4100/falconfalls.dts new file +10 -0
+			compatible = "intel,ce4100";
+			reg = <0>;
+			lapic = <&lapic0>;
+		};
+	};
+
+	soc@0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "intel,ce4100-cp";

You *must* include documentation for each of these new compatible values before merging this patch. At the very least it acts as a placeholder and describes exactly what the string describes.

arch/x86/platform/ce4100/falconfalls.dts line 37

Quoted 5 lines
arch/x86/platform/ce4100/falconfalls.dts new file +5 -0
+		ranges;
+
+		ioapic1: interrupt-controller@fec00000 {
+			#interrupt-cells = <2>;
+			compatible = "intel,ioapic-ce4100", "intel,ioapic";

"intel,ioapic" is probably too generic and can be dropped. Newer devices can claim compatibility with "intel,ioapic-ce4100" if they are indeed compatible so that device drivers don't need to be modified. It is better to anchor compatible values to real implementations that try to come up with 'generic' or wildcard strings. Ditto through the rest of the file.

"intel,ce4100-ioapic" (instead of intel,ioapic-ce4100) would follow current convention better of specifying the chip first, followed by the on-chip device.

Quoted 44 lines
arch/x86/platform/ce4100/falconfalls.dts new file +44 -0
+			interrupt-controller;
+			reg = <0xfec00000 0x1000>;
+		};
+
+		timer@fed00000 {
+			compatible = "intel,hpet-ce4100", "intel,hpet";
+			reg = <0xfed00000 0x200>;
+		};
+
+		lapic0: interrupt-controller@fee00000 {
+			compatible = "intel,lapic-ce4100", "intel,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,ioapic-ce4100", "intel,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>;

arch/x86/platform/ce4100/falconfalls.dts line 91

Quoted 10 lines
arch/x86/platform/ce4100/falconfalls.dts new file +10 -0
+
+				display@2,0 {
+					compatible = "pci8086,2e5b.2",
+						   "pci8086,2e5b",
+						   "pciclass038000",
+						   "pciclass0380";
+
+					reg = <0x11000 0x0 0x0 0x0 0x0>;
+					interrupts = <0 1>;
+				};

Here's where things get a little sticky for PCI child devices (probably should have thought about this earlier, sorry). Are these devices runtime detectable? ie. does reading the PCI BARs and irq configuration registers reflect reality?

In general, if something can be *reliably* detected then it should not be listed in the device tree. However, if there is some horrid gotcha that prevents it being detected reliably, then it definitely should appear here.

I cannot answer this question for you since I don't know the hardware. It's a judgement call that you'll need to make on whether or not these PCI (or pseudo pci?) devices should be listed in the dt.

One of the things that does need to be improved is partial probing of PCI busses so that only the messy PCI devices get listed in the device tree, and the rest of the devices can get detected in the normal manner.

Quoted 130 lines
arch/x86/platform/ce4100/falconfalls.dts new file +130 -0
+
+				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";
+
+					reg = <0x15900 0x0 0x0 0x0 0x0>;
+					interrupts = <15 1>;
+				};
+

arch/x86/platform/ce4100/falconfalls.dts line 231

Quoted 10 lines
arch/x86/platform/ce4100/falconfalls.dts new file +10 -0
+				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>;

Yeah, this would be an example of a device which must appear in the dt since there is no way to detect the set of child i2c devices.

Quoted 47 lines
arch/x86/platform/ce4100/falconfalls.dts new file +47 -0
+					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 {
+							compatible = "ti,pcf8575";
+							reg = <0x26>;
+						};
+					};
+
+					i2c@2 {
+						#address-cells = <1>;
+						#size-cells = <0>;
+						compatible = "intel,ce4100-i2c-controller";
+						reg = <2 0 0x100>;
+
+						gpio@26 {
+							compatible = "ti,pcf8575";
+							reg = <0x26>;
+						};
+					};
+				};
+
+				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 {

arch/x86/platform/ce4100/falconfalls.dts line 288

Quoted 10 lines
arch/x86/platform/ce4100/falconfalls.dts new file +10 -0
+					#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>;

Ditto here.

Quoted 143 lines
arch/x86/platform/ce4100/falconfalls.dts new file +136 -0
+
+					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>;
+				};
+			};
+		};
+	};
+};
Signature · 6 lines
1.7.3.2

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss
#22 lore raw

Re: [sodaville] [PATCH TIP v2 03/14] x86/dtb: Add a device tree for CE4100

Quoted 6 lines · * Grant Likely | 2011-02-16 14:44:28 [-0700]:
Quoted 6 lines
arch/x86/platform/ce4100/falconfalls.dts new file +0 -0
new file mode 100644
index 0000000..e888657
@@ -0,0 +1,424 @@
Quoted 8 lines

arch/x86/platform/ce4100/falconfalls.dts line 32

Quoted 4 lines
arch/x86/platform/ce4100/falconfalls.dts new file +4 -0
+	soc@0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "intel,ce4100-cp";

You *must* include documentation for each of these new compatible values before merging this patch. At the very least it acts as a placeholder and describes exactly what the string describes.

I added something.

Quoted 13 lines

arch/x86/platform/ce4100/falconfalls.dts line 37

Quoted 5 lines
arch/x86/platform/ce4100/falconfalls.dts new file +5 -0
+		ranges;
+
+		ioapic1: interrupt-controller@fec00000 {
+			#interrupt-cells = <2>;
+			compatible = "intel,ioapic-ce4100", "intel,ioapic";

"intel,ioapic" is probably too generic and can be dropped. Newer devices can claim compatibility with "intel,ioapic-ce4100" if they are indeed compatible so that device drivers don't need to be modified. It is better to anchor compatible values to real implementations that try to come up with 'generic' or wildcard strings. Ditto through the rest of the file.

Quoted 4 lines

"intel,ce4100-ioapic" (instead of intel,ioapic-ce4100) would follow current convention better of specifying the chip first, followed by the on-chip device.

Done.

Quoted 17 lines
Quoted 17 lines
arch/x86/platform/ce4100/falconfalls.dts new file +17 -0
+			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";
+
Quoted 8 lines

arch/x86/platform/ce4100/falconfalls.dts line 91

Quoted 3 lines
arch/x86/platform/ce4100/falconfalls.dts new file +3 -0
+					reg = <0x11000 0x0 0x0 0x0 0x0>;
+					interrupts = <0 1>;
+				};

Here's where things get a little sticky for PCI child devices (probably should have thought about this earlier, sorry). Are these devices runtime detectable? ie. does reading the PCI BARs and irq configuration registers reflect reality?

Bar yes (no assigned-property here), IRQ no.

This devices are runtime detectable via the PCI bus. However the interrupt number is no longer correct. The PCI bus reports the legacy number which is irq 4 (if I remember correctly) for all devices here. Which is correct for the legacy mode. Those interrupts are routed to the legacy interrupt controller. Once we activate the IO APIC for interrupt routing the legacy controller is no longer in use. With the IO APIC there is a different interrupt routing which is described here by the interrupt property.
On systems with ACPI this kind of information is read fron there. You see during boot-up "PCI->APIC IRQ transform: ...".

Quoted 4 lines

In general, if something can be *reliably* detected then it should not be listed in the device tree. However, if there is some horrid gotcha that prevents it being detected reliably, then it definitely should appear here.

The first edition used the interrupt-map property to describe this mapping. David Gibson [0] recommended then to create device nodes because the PCI INTA..D lines were not used.

Quoted 3 lines

I cannot answer this question for you since I don't know the hardware. It's a judgement call that you'll need to make on whether or not these PCI (or pseudo pci?) devices should be listed in the dt.

Most of the devices can be detected reliably. I2C and SPI need some additional information. I believe more of this things will pop up once someone adds the GPIO wires which are not there yet. I know that the smartcard thingy uses one GPIO for card detect. So I would need to extend the device property later for that :)

Quoted 4 lines

One of the things that does need to be improved is partial probing of PCI busses so that only the messy PCI devices get listed in the device tree, and the rest of the devices can get detected in the normal manner.

I did not add any "special" compatible properties just the pci ids. So they should not be probed via DT just PCI unless one adds this to the driver.

[0] http://lists.ozlabs.org/pipermail/devicetree-discuss/2011-January/004137.html

Sebastian

#23 lore raw

PATCH 4/14 x86/dtb: add irq domain abstraction

In reply to 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.

---
 arch/x86/include/asm/irq_controller.h |   12 ++++++++
 arch/x86/include/asm/prom.h           |    2 +
 arch/x86/kernel/prom.c                |   47 ++++++++++++++++++++++++++++++++-
 3 files changed, 60 insertions(+), 1 deletions(-)
 create mode 100644 arch/x86/include/asm/irq_controller.h
arch/x86/include/asm/irq_controller.h new file +12 -0
new file mode 100644
index 0000000..423bbbd
@@ -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
arch/x86/include/asm/prom.h +2 -0
index b227ba7..ed7bb62 100644
@@ -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
arch/x86/kernel/prom.c +46 -1

64 lines not on this page · raw message

Signature · 1 line
1.7.3.2
#24 lore raw

PATCH 5/14 x86/dtb: add early parsing of APIC and IO APIC

In reply to 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/[email protected]
Cc Dirk Brandewie <[email protected]>
---
 arch/x86/include/asm/prom.h |    7 +++
 arch/x86/kernel/irqinit.c   |    2 +-
 arch/x86/kernel/prom.c      |  112 +++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 117 insertions(+), 4 deletions(-)
arch/x86/include/asm/prom.h +7 -0
index ed7bb62..bd67ab2 100644
@@ -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];
arch/x86/kernel/irqinit.c +1 -1
index 149c87f..4cadf86 100644
@@ -244,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
arch/x86/kernel/prom.c +109 -3

131 lines not on this page · raw message

Signature · 1 line
1.7.3.2
Acked-by on v1 5/14
#25 lore raw

Re: [PATCH TIP 05/14] x86/dtb: add early parsing of APIC and IO APIC

Quoted 4 lines · 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.

There is some work being done to provide a flattree version of of_address_to_resource, but that code isn't ready yet.

Quoted 7 lines

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/[email protected]
Cc Dirk Brandewie <[email protected]>

Looks okay to me

Quoted 185 lines
---
 arch/x86/include/asm/prom.h |    7 +++
 arch/x86/kernel/irqinit.c   |    2 +-
 arch/x86/kernel/prom.c      |  112 +++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 117 insertions(+), 4 deletions(-)
arch/x86/include/asm/prom.h +7 -0
index ed7bb62..bd67ab2 100644
@@ -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];
arch/x86/kernel/irqinit.c +1 -1
index 149c87f..4cadf86 100644
@@ -244,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
arch/x86/kernel/prom.c +109 -3
index 95f9551..e4d53bf 100644
@@ -6,15 +6,20 @@
 #include <linux/interrupt.h>
 #include <linux/list.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/of_platform.h>
 #include <linux/slab.h>
 
 #include <asm/irq_controller.h>
+#include <asm/io_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;
@@ -90,7 +95,108 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
 
 void __init add_dtb(u64 data)
 {
-	initial_boot_params = (struct boot_param_header *)
-		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,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();
 }
Signature · 6 lines
1.7.3.2

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss
#26 lore raw

PATCH 6/14 x86/dtb: add support hpet

In reply to Sebastian Andrzej Siewior

Set hpet_address based on information provied form DTB

---
 arch/x86/kernel/prom.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
arch/x86/kernel/prom.c +19 -0
index e4d53bf..16c124e 100644
@@ -10,6 +10,7 @@
 #include <linux/of_platform.h>
 #include <linux/slab.h>
 
+#include <asm/hpet.h>
 #include <asm/irq_controller.h>
 #include <asm/io_apic.h>
 
@@ -98,6 +99,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,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
@@ -198,5 +216,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();
 }
Signature · 1 line
1.7.3.2
#27 lore raw

PATCH 7/14 of: move of_irq_map_pci() into generic code

In reply to Sebastian Andrzej Siewior

From: Sebastian Andrzej Siewior <[email protected]>

There is a tiny difference between PPC32 and PPC64. Microblaze uses the PPC32 variant.

Cc devicetree-discuss-uLR06cmDAlY/[email protected]
Cc Benjamin Herrenschmidt <[email protected]>
---
 arch/microblaze/include/asm/pci-bridge.h |   12 ++++
 arch/microblaze/include/asm/prom.h       |   15 -----
 arch/microblaze/kernel/prom_parse.c      |   77 ---------------------------
 arch/microblaze/pci/pci-common.c         |    1 +
 arch/powerpc/include/asm/pci-bridge.h    |   10 ++++
 arch/powerpc/include/asm/prom.h          |   15 -----
 arch/powerpc/kernel/pci-common.c         |    1 +
 arch/powerpc/kernel/prom_parse.c         |   84 ------------------------------
 drivers/of/Kconfig                       |    6 ++
 drivers/of/Makefile                      |    1 +
 drivers/of/of_pci.c                      |   80 ++++++++++++++++++++++++++++
 include/linux/of_pci.h                   |   20 +++++++
 12 files changed, 131 insertions(+), 191 deletions(-)
 create mode 100644 drivers/of/of_pci.c
 create mode 100644 include/linux/of_pci.h
arch/microblaze/include/asm/pci-bridge.h +12 -0
index 0c68764..c2a40a4 100644
@@ -104,11 +104,22 @@ struct pci_controller {
 	int global_number;	/* PCI domain number */
 };
 
+#ifdef CONFIG_PCI
 static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
 {
 	return bus->sysdata;
 }
 
+static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
+{
+	struct pci_controller *host;
+
+	if (bus->self)
+		return pci_device_to_OF_node(bus->self);
+	host = pci_bus_to_host(bus);
+	return host ? host->dn : NULL;
+}
+
 static inline int isa_vaddr_is_ioport(void __iomem *address)
 {
 	/* No specific ISA handling on ppc32 at this stage, it
@@ -116,6 +127,7 @@ static inline int isa_vaddr_is_ioport(void __iomem *address)
 	 */
 	return 0;
 }
+#endif
 
 /* These are used for config access before all the PCI probing
    has been done. */
arch/microblaze/include/asm/prom.h +0 -15
index 2e72af0..d0890d3 100644
@@ -64,21 +64,6 @@ extern void kdump_move_device_tree(void);
 /* CPU OF node matching */
 struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
 
-/**
- * of_irq_map_pci - Resolve the interrupt for a PCI device
- * @pdev:	the device whose interrupt is to be resolved
- * @out_irq:	structure of_irq filled by this function
- *
- * This function resolves the PCI interrupt for a given PCI device. If a
- * device-node exists for a given pci_dev, it will use normal OF tree
- * walking. If not, it will implement standard swizzling and walk up the
- * PCI tree until an device-node is found, at which point it will finish
- * resolving using the OF tree walking.
- */
-struct pci_dev;
-struct of_irq;
-extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
-
 #endif /* __ASSEMBLY__ */
 #endif /* __KERNEL__ */
 
arch/microblaze/kernel/prom_parse.c +0 -77

88 lines not on this page · raw message

arch/microblaze/pci/pci-common.c +1 -0
index e363615..1e01a12 100644
@@ -29,6 +29,7 @@
 #include <linux/slab.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_pci.h>
 
 #include <asm/processor.h>
 #include <asm/io.h>
arch/powerpc/include/asm/pci-bridge.h +10 -0
index 51e9e6f..edeb80f 100644
@@ -171,6 +171,16 @@ static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
 	return bus->sysdata;
 }
 
+static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
+{
+	struct pci_controller *host;
+
+	if (bus->self)
+		return pci_device_to_OF_node(bus->self);
+	host = pci_bus_to_host(bus);
+	return host ? host->dn : NULL;
+}
+
 static inline int isa_vaddr_is_ioport(void __iomem *address)
 {
 	/* No specific ISA handling on ppc32 at this stage, it
arch/powerpc/include/asm/prom.h +0 -15
index d727575..c189aa5 100644
@@ -70,21 +70,6 @@ static inline int of_node_to_nid(struct device_node *device) { return 0; }
 #endif
 #define of_node_to_nid of_node_to_nid
 
-/**
- * of_irq_map_pci - Resolve the interrupt for a PCI device
- * @pdev:	the device whose interrupt is to be resolved
- * @out_irq:	structure of_irq filled by this function
- *
- * This function resolves the PCI interrupt for a given PCI device. If a
- * device-node exists for a given pci_dev, it will use normal OF tree
- * walking. If not, it will implement standard swizzling and walk up the
- * PCI tree until an device-node is found, at which point it will finish
- * resolving using the OF tree walking.
- */
-struct pci_dev;
-struct of_irq;
-extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
-
 extern void of_instantiate_rtc(void);
 
 /* These includes are put at the bottom because they may contain things
arch/powerpc/kernel/pci-common.c +1 -0
index 10a44e6..eb341be 100644
@@ -22,6 +22,7 @@
 #include <linux/init.h>
 #include <linux/bootmem.h>
 #include <linux/of_address.h>
+#include <linux/of_pci.h>
 #include <linux/mm.h>
 #include <linux/list.h>
 #include <linux/syscalls.h>
arch/powerpc/kernel/prom_parse.c +0 -84

95 lines not on this page · raw message

drivers/of/Kconfig +6 -0
index 3c6e100..c71cff1 100644
@@ -69,4 +69,10 @@ config OF_MDIO
 	help
 	  OpenFirmware MDIO bus (Ethernet PHY) accessors
 
+config OF_PCI
+	def_tristate PCI
+	depends on PCI && !SPARC
+	help
+	  OpenFirmware PCI bus accessors
+
 endmenu # OF
drivers/of/Makefile +1 -0
index 3ab21a0..f7861ed 100644
@@ -9,3 +9,4 @@ obj-$(CONFIG_OF_I2C)	+= of_i2c.o
 obj-$(CONFIG_OF_NET)	+= of_net.o
 obj-$(CONFIG_OF_SPI)	+= of_spi.o
 obj-$(CONFIG_OF_MDIO)	+= of_mdio.o
+obj-$(CONFIG_OF_PCI)	+= of_pci.o
drivers/of/of_pci.c new file +80 -0

80 lines not on this page · raw message

include/linux/of_pci.h new file +20 -0
new file mode 100644
index 0000000..9b0ba67
@@ -0,0 +1,20 @@
+#ifndef __OF_PCI_H
+#define __OF_PCI_H
+
+#include <linux/pci.h>
+
+/**
+ * of_irq_map_pci - Resolve the interrupt for a PCI device
+ * @pdev:       the device whose interrupt is to be resolved
+ * @out_irq:    structure of_irq filled by this function
+ *
+ * This function resolves the PCI interrupt for a given PCI device. If a
+ * device-node exists for a given pci_dev, it will use normal OF tree
+ * walking. If not, it will implement standard swizzling and walk up the
+ * PCI tree until an device-node is found, at which point it will finish
+ * resolving using the OF tree walking.
+ */
+struct pci_dev;
+struct of_irq;
+int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
+#endif
Signature · 1 line
1.7.3.2
maintainer
#28 lore raw

Re: [PATCH OF 07/14] of: move of_irq_map_pci() into generic code

Quoted 9 lines · Sebastian Andrzej Siewior

From: Sebastian Andrzej Siewior <[email protected]>

There is a tiny difference between PPC32 and PPC64. Microblaze uses the PPC32 variant.

Quoted 5 lines
---
 arch/microblaze/include/asm/pci-bridge.h |   12 ++++
 arch/microblaze/include/asm/prom.h       |   15 -----
 arch/microblaze/kernel/prom_parse.c      |   77 ---------------------------
 arch/microblaze/pci/pci-common.c         |    1 +

Please always CC me for Microblaze changes. I want to at least compile it.

Thanks,
Michal

Signature · 4 lines
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian
#29 lore raw

Re: [PATCH OF 07/14] of: move of_irq_map_pci() into generic code

In reply to Sebastian Andrzej Siewior
Quoted 8 lines · Sebastian Andrzej Siewior

From: Sebastian Andrzej Siewior <[email protected]>

There is a tiny difference between PPC32 and PPC64. Microblaze uses the PPC32 variant.

I've got this one in my devicetree/next branch which is pulled into linux-next. I've not received an ack from Ben yet. Michal, is this okay by you?

http://git.secretlab.ca/?p=linux-2.6.git;a=commit;h=04bea68b2f0eeebb089ecc67b618795925268b4a

g.

Quoted 486 lines

---
 arch/microblaze/include/asm/pci-bridge.h |   12 ++++ arch/microblaze/include/asm/prom.h       |   15 ----- arch/microblaze/kernel/prom_parse.c      |   77 --------------------------- arch/microblaze/pci/pci-common.c         |    1 + arch/powerpc/include/asm/pci-bridge.h    |   10 ++++ arch/powerpc/include/asm/prom.h          |   15 ----- arch/powerpc/kernel/pci-common.c         |    1 + arch/powerpc/kernel/prom_parse.c         |   84 ------------------------------

 drivers/of/Kconfig                       |    6 ++
 drivers/of/Makefile                      |    1 +
 drivers/of/of_pci.c                      |   80 ++++++++++++++++++++++++++++
 include/linux/of_pci.h                   |   20 +++++++
 12 files changed, 131 insertions(+), 191 deletions(-)

 create mode 100644 drivers/of/of_pci.c
 create mode 100644 include/linux/of_pci.h

arch/microblaze/include/asm/pci-bridge.h +0 -0
index 0c68764..c2a40a4 100644
@@ -104,11 +104,22 @@ struct pci_controller {

       int global_number;      /* PCI domain number */ };

+#ifdef CONFIG_PCI
 static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus) {
       return bus->sysdata;
 }

arch/microblaze/include/asm/pci-bridge.h +10 -0
+static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
+{
+       struct pci_controller *host;
+
+       if (bus->self)
+               return pci_device_to_OF_node(bus->self);
+       host = pci_bus_to_host(bus);
+       return host ? host->dn : NULL;
+}
+

 static inline int isa_vaddr_is_ioport(void __iomem *address) {
       /* No specific ISA handling on ppc32 at this stage, it

arch/microblaze/include/asm/pci-bridge.h +1 -0
@@ -116,6 +127,7 @@ static inline int isa_vaddr_is_ioport(void __iomem *address)
         */
        return 0;
  }
+#endif
 
  /* These are used for config access before all the PCI probing

   has been done. */

arch/microblaze/include/asm/prom.h +0 -15
index 2e72af0..d0890d3 100644
@@ -64,21 +64,6 @@ extern void kdump_move_device_tree(void);
  /* CPU OF node matching */
  struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
 
-/**
- * of_irq_map_pci - Resolve the interrupt for a PCI device
- * @pdev:      the device whose interrupt is to be resolved
- * @out_irq:   structure of_irq filled by this function
- *
- * This function resolves the PCI interrupt for a given PCI device. If a
- * device-node exists for a given pci_dev, it will use normal OF tree
- * walking. If not, it will implement standard swizzling and walk up the
- * PCI tree until an device-node is found, at which point it will finish
- * resolving using the OF tree walking.
- */
-struct pci_dev;
-struct of_irq;
-extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
-
  #endif /* __ASSEMBLY__ */
  #endif /* __KERNEL__ */
 
arch/microblaze/kernel/prom_parse.c +0 -77
index 9ae24f4..47187cc 100644
@@ -2,88 +2,11 @@
 
  #include <linux/kernel.h>
  #include <linux/string.h>
-#include <linux/pci_regs.h>
  #include <linux/module.h>
  #include <linux/ioport.h>
  #include <linux/etherdevice.h>
  #include <linux/of_address.h>
  #include <asm/prom.h>
-#include <asm/pci-bridge.h>
-
-#ifdef CONFIG_PCI
-int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq)
-{
-       struct device_node *dn, *ppnode;
-       struct pci_dev *ppdev;
-       u32 lspec;
-       u32 laddr[3];
-       u8 pin;
-       int rc;
-
-       /* Check if we have a device node, if yes, fallback to standard OF
-        * parsing
-        */
-       dn = pci_device_to_OF_node(pdev);
-       if (dn)
-               return of_irq_map_one(dn, 0, out_irq);
-
-       /* Ok, we don't, time to have fun. Let's start by building up an
-        * interrupt spec.  we assume #interrupt-cells is 1, which is standard
-        * for PCI. If you do different, then don't use that routine.
-        */
-       rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);
-       if (rc != 0)
-               return rc;
-       /* No pin, exit */
-       if (pin == 0)
-               return -ENODEV;
-
-       /* Now we walk up the PCI tree */
-       lspec = pin;
-       for (;;) {
-               /* Get the pci_dev of our parent */
-               ppdev = pdev->bus->self;
-
-               /* Ouch, it's a host bridge... */
-               if (ppdev == NULL) {
-                       struct pci_controller *host;
-                       host = pci_bus_to_host(pdev->bus);
-                       ppnode = host ? host->dn : NULL;
-                       /* No node for host bridge ? give up */
-                       if (ppnode == NULL)
-                               return -EINVAL;
-               } else
-                       /* We found a P2P bridge, check if it has a node */
-                       ppnode = pci_device_to_OF_node(ppdev);
-
-               /* Ok, we have found a parent with a device-node, hand over to
-                * the OF parsing code.
-                * We build a unit address from the linux device to be used for
-                * resolution. Note that we use the linux bus number which may
-                * not match your firmware bus numbering.
-                * Fortunately, in most cases, interrupt-map-mask doesn't
-                * include the bus number as part of the matching.
-                * You should still be careful about that though if you intend
-                * to rely on this function (you ship  a firmware that doesn't
-                * create device nodes for all PCI devices).
-                */
-               if (ppnode)
-                       break;
-
-               /* We can only get here if we hit a P2P bridge with no node,
-                * let's do standard swizzling and try again
-                */
-               lspec = pci_swizzle_interrupt_pin(pdev, lspec);
-               pdev = ppdev;
-       }
-
-       laddr[0] = (pdev->bus->number << 16)
-               | (pdev->devfn << 8);
-       laddr[1]  = laddr[2] = 0;
-       return of_irq_map_raw(ppnode, &lspec, 1, laddr, out_irq);
-}
-EXPORT_SYMBOL_GPL(of_irq_map_pci);
-#endif /* CONFIG_PCI */
 
  void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
                unsigned long *busno, unsigned long *phys, unsigned long *size)
arch/microblaze/pci/pci-common.c +1 -0
index e363615..1e01a12 100644
@@ -29,6 +29,7 @@
  #include <linux/slab.h>
  #include <linux/of.h>
  #include <linux/of_address.h>
+#include <linux/of_pci.h>
 
  #include <asm/processor.h>
  #include <asm/io.h>
arch/powerpc/include/asm/pci-bridge.h +10 -0
index 51e9e6f..edeb80f 100644
@@ -171,6 +171,16 @@ static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
        return bus->sysdata;
  }
 
+static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
+{
+       struct pci_controller *host;
+
+       if (bus->self)
+               return pci_device_to_OF_node(bus->self);
+       host = pci_bus_to_host(bus);
+       return host ? host->dn : NULL;
+}
+
  static inline int isa_vaddr_is_ioport(void __iomem *address)
  {
        /* No specific ISA handling on ppc32 at this stage, it
arch/powerpc/include/asm/prom.h +0 -15
index d727575..c189aa5 100644
@@ -70,21 +70,6 @@ static inline int of_node_to_nid(struct device_node *device) { return 0; }
  #endif
  #define of_node_to_nid of_node_to_nid
 
-/**
- * of_irq_map_pci - Resolve the interrupt for a PCI device
- * @pdev:      the device whose interrupt is to be resolved
- * @out_irq:   structure of_irq filled by this function
- *
- * This function resolves the PCI interrupt for a given PCI device. If a
- * device-node exists for a given pci_dev, it will use normal OF tree
- * walking. If not, it will implement standard swizzling and walk up the
- * PCI tree until an device-node is found, at which point it will finish
- * resolving using the OF tree walking.
- */
-struct pci_dev;
-struct of_irq;
-extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
-
  extern void of_instantiate_rtc(void);
 
  /* These includes are put at the bottom because they may contain things
arch/powerpc/kernel/pci-common.c +1 -0
index 10a44e6..eb341be 100644
@@ -22,6 +22,7 @@
  #include <linux/init.h>
  #include <linux/bootmem.h>
  #include <linux/of_address.h>
+#include <linux/of_pci.h>
  #include <linux/mm.h>
  #include <linux/list.h>
  #include <linux/syscalls.h>
arch/powerpc/kernel/prom_parse.c +0 -84
index c2b7a07..47187cc 100644
@@ -2,95 +2,11 @@
 
  #include <linux/kernel.h>
  #include <linux/string.h>
-#include <linux/pci_regs.h>
  #include <linux/module.h>
  #include <linux/ioport.h>
  #include <linux/etherdevice.h>
  #include <linux/of_address.h>
  #include <asm/prom.h>
-#include <asm/pci-bridge.h>
-
-#ifdef CONFIG_PCI
-int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq)
-{
-       struct device_node *dn, *ppnode;
-       struct pci_dev *ppdev;
-       u32 lspec;
-       u32 laddr[3];
-       u8 pin;
-       int rc;
-
-       /* Check if we have a device node, if yes, fallback to standard OF
-        * parsing
-        */
-       dn = pci_device_to_OF_node(pdev);
-       if (dn) {
-               rc = of_irq_map_one(dn, 0, out_irq);
-               if (!rc)
-                       return rc;
-       }
-
-       /* Ok, we don't, time to have fun. Let's start by building up an
-        * interrupt spec.  we assume #interrupt-cells is 1, which is standard
-        * for PCI. If you do different, then don't use that routine.
-        */
-       rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);
-       if (rc != 0)
-               return rc;
-       /* No pin, exit */
-       if (pin == 0)
-               return -ENODEV;
-
-       /* Now we walk up the PCI tree */
-       lspec = pin;
-       for (;;) {
-               /* Get the pci_dev of our parent */
-               ppdev = pdev->bus->self;
-
-               /* Ouch, it's a host bridge... */
-               if (ppdev == NULL) {
-#ifdef CONFIG_PPC64
-                       ppnode = pci_bus_to_OF_node(pdev->bus);
-#else
-                       struct pci_controller *host;
-                       host = pci_bus_to_host(pdev->bus);
-                       ppnode = host ? host->dn : NULL;
-#endif
-                       /* No node for host bridge ? give up */
-                       if (ppnode == NULL)
-                               return -EINVAL;
-               } else
-                       /* We found a P2P bridge, check if it has a node */
-                       ppnode = pci_device_to_OF_node(ppdev);
-
-               /* Ok, we have found a parent with a device-node, hand over to
-                * the OF parsing code.
-                * We build a unit address from the linux device to be used for
-                * resolution. Note that we use the linux bus number which may
-                * not match your firmware bus numbering.
-                * Fortunately, in most cases, interrupt-map-mask doesn't include
-                * the bus number as part of the matching.
-                * You should still be careful about that though if you intend
-                * to rely on this function (you ship  a firmware that doesn't
-                * create device nodes for all PCI devices).
-                */
-               if (ppnode)
-                       break;
-
-               /* We can only get here if we hit a P2P bridge with no node,
-                * let's do standard swizzling and try again
-                */
-               lspec = pci_swizzle_interrupt_pin(pdev, lspec);
-               pdev = ppdev;
-       }
-
-       laddr[0] = (pdev->bus->number << 16)
-               | (pdev->devfn << 8);
-       laddr[1]  = laddr[2] = 0;
-       return of_irq_map_raw(ppnode, &lspec, 1, laddr, out_irq);
-}
-EXPORT_SYMBOL_GPL(of_irq_map_pci);
-#endif /* CONFIG_PCI */
 
  void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
                unsigned long *busno, unsigned long *phys, unsigned long *size)
drivers/of/Kconfig +0 -0
index 3c6e100..c71cff1 100644
@@ -69,4 +69,10 @@ config OF_MDIO

       help
         OpenFirmware MDIO bus (Ethernet PHY) accessors

drivers/of/Kconfig +6 -0
+config OF_PCI
+       def_tristate PCI
+       depends on PCI && !SPARC
+       help
+         OpenFirmware PCI bus accessors
+

 endmenu # OF

drivers/of/Makefile +0 -0
index 3ab21a0..f7861ed 100644
@@ -9,3 +9,4 @@ obj-$(CONFIG_OF_I2C)    += of_i2c.o

 obj-$(CONFIG_OF_NET)   += of_net.o
 obj-$(CONFIG_OF_SPI)   += of_spi.o
 obj-$(CONFIG_OF_MDIO)  += of_mdio.o

drivers/of/Makefile +1 -0
+obj-$(CONFIG_OF_PCI)   += of_pci.o
drivers/of/of_pci.c new file +80 -0
new file mode 100644
index 0000000..dd862d2
@@ -0,0 +1,80 @@
+#include <linux/kernel.h>
+#include <linux/of_pci.h>
+#include <asm/prom.h>
+
+int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq)
+{
+       struct device_node *dn, *ppnode;
+       struct pci_dev *ppdev;
+       u32 lspec;
+       __be32 lspec_be;
+       __be32 laddr[3];
+       u8 pin;
+       int rc;
+
+       /* Check if we have a device node, if yes, fallback to standard OF
+        * parsing
+        */
+       dn = pci_device_to_OF_node(pdev);
+       if (dn) {
+               rc = of_irq_map_one(dn, 0, out_irq);
+               if (!rc)
+                       return rc;
+       }
+
+       /* Ok, we don't, time to have fun. Let's start by building up an
+        * interrupt spec.  we assume #interrupt-cells is 1, which is standard
+        * for PCI. If you do different, then don't use that routine.
+        */
+       rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);
+       if (rc != 0)
+               return rc;
+       /* No pin, exit */
+       if (pin == 0)
+               return -ENODEV;
+
+       /* Now we walk up the PCI tree */
+       lspec = pin;
+       for (;;) {
+               /* Get the pci_dev of our parent */
+               ppdev = pdev->bus->self;
+
+               /* Ouch, it's a host bridge... */
+               if (ppdev == NULL) {
+                       ppnode = pci_bus_to_OF_node(pdev->bus);
+
+                       /* No node for host bridge ? give up */
+                       if (ppnode == NULL)
+                               return -EINVAL;
+               } else {
+                       /* We found a P2P bridge, check if it has a node */
+                       ppnode = pci_device_to_OF_node(ppdev);
+               }
+
+               /* Ok, we have found a parent with a device-node, hand over to
+                * the OF parsing code.
+                * We build a unit address from the linux device to be used for
+                * resolution. Note that we use the linux bus number which may
+                * not match your firmware bus numbering.
+                * Fortunately, in most cases, interrupt-map-mask doesn't
+                * include the bus number as part of the matching.
+                * You should still be careful about that though if you intend
+                * to rely on this function (you ship  a firmware that doesn't
+                * create device nodes for all PCI devices).
+                */
+               if (ppnode)
+                       break;
+
+               /* We can only get here if we hit a P2P bridge with no node,
+                * let's do standard swizzling and try again
+                */
+               lspec = pci_swizzle_interrupt_pin(pdev, lspec);
+               pdev = ppdev;
+       }
+
+       lspec_be = cpu_to_be32(lspec);
+       laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8));
+       laddr[1]  = laddr[2] = cpu_to_be32(0);
+       return of_irq_map_raw(ppnode, &lspec_be, 1, laddr, out_irq);
+}
+EXPORT_SYMBOL_GPL(of_irq_map_pci);
include/linux/of_pci.h new file +20 -1
new file mode 100644
index 0000000..9b0ba67
@@ -0,0 +1,20 @@
+#ifndef __OF_PCI_H
+#define __OF_PCI_H
+
+#include <linux/pci.h>
+
+/**
+ * of_irq_map_pci - Resolve the interrupt for a PCI device
+ * @pdev:       the device whose interrupt is to be resolved
+ * @out_irq:    structure of_irq filled by this function
+ *
+ * This function resolves the PCI interrupt for a given PCI device. If a
+ * device-node exists for a given pci_dev, it will use normal OF tree
+ * walking. If not, it will implement standard swizzling and walk up the
+ * PCI tree until an device-node is found, at which point it will finish
+ * resolving using the OF tree walking.
+ */
+struct pci_dev;
+struct of_irq;
+int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
+#endif
--

1.7.3.2

_______________________________________________
devicetree-discuss mailing list
[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
maintainer Acked-by
#30 lore raw

Re: [PATCH OF 07/14] of: move of_irq_map_pci() into generic code

Quoted 7 lines · Grant Likely
Quoted 5 lines · Sebastian Andrzej Siewior

From: Sebastian Andrzej Siewior <[email protected]>

There is a tiny difference between PPC32 and PPC64. Microblaze uses the PPC32 variant.

Quoted 7 lines
Quoted 3 lines
Cc devicetree-discuss-uLR06cmDAlY/[email protected]
Cc Benjamin Herrenschmidt <[email protected]>

I've got this one in my devicetree/next branch which is pulled into linux-next. I've not received an ack from Ben yet. Michal, is this okay by you?

yep. No problem. I don't have pci hw for testing but compilation is fine.

If you like:

Thanks,
Michal

Quoted 494 lines

http://git.secretlab.ca/?p=linux-2.6.git;a=commit;h=04bea68b2f0eeebb089ecc67b618795925268b4a

g.

Quoted 486 lines
---
 arch/microblaze/include/asm/pci-bridge.h |   12 ++++
 arch/microblaze/include/asm/prom.h       |   15 -----
 arch/microblaze/kernel/prom_parse.c      |   77 ---------------------------
 arch/microblaze/pci/pci-common.c         |    1 +
 arch/powerpc/include/asm/pci-bridge.h    |   10 ++++
 arch/powerpc/include/asm/prom.h          |   15 -----
 arch/powerpc/kernel/pci-common.c         |    1 +
 arch/powerpc/kernel/prom_parse.c         |   84 ------------------------------
 drivers/of/Kconfig                       |    6 ++
 drivers/of/Makefile                      |    1 +
 drivers/of/of_pci.c                      |   80 ++++++++++++++++++++++++++++
 include/linux/of_pci.h                   |   20 +++++++
 12 files changed, 131 insertions(+), 191 deletions(-)
 create mode 100644 drivers/of/of_pci.c
 create mode 100644 include/linux/of_pci.h
arch/microblaze/include/asm/pci-bridge.h +12 -0
index 0c68764..c2a40a4 100644
@@ -104,11 +104,22 @@ struct pci_controller {
       int global_number;      /* PCI domain number */
 };
 
+#ifdef CONFIG_PCI
 static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
 {
       return bus->sysdata;
 }
 
+static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
+{
+       struct pci_controller *host;
+
+       if (bus->self)
+               return pci_device_to_OF_node(bus->self);
+       host = pci_bus_to_host(bus);
+       return host ? host->dn : NULL;
+}
+
 static inline int isa_vaddr_is_ioport(void __iomem *address)
 {
       /* No specific ISA handling on ppc32 at this stage, it
@@ -116,6 +127,7 @@ static inline int isa_vaddr_is_ioport(void __iomem *address)
        */
       return 0;
 }
+#endif
 
 /* These are used for config access before all the PCI probing
   has been done. */
arch/microblaze/include/asm/prom.h +0 -15
index 2e72af0..d0890d3 100644
@@ -64,21 +64,6 @@ extern void kdump_move_device_tree(void);
 /* CPU OF node matching */
 struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
 
-/**
- * of_irq_map_pci - Resolve the interrupt for a PCI device
- * @pdev:      the device whose interrupt is to be resolved
- * @out_irq:   structure of_irq filled by this function
- *
- * This function resolves the PCI interrupt for a given PCI device. If a
- * device-node exists for a given pci_dev, it will use normal OF tree
- * walking. If not, it will implement standard swizzling and walk up the
- * PCI tree until an device-node is found, at which point it will finish
- * resolving using the OF tree walking.
- */
-struct pci_dev;
-struct of_irq;
-extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
-
 #endif /* __ASSEMBLY__ */
 #endif /* __KERNEL__ */
 
arch/microblaze/kernel/prom_parse.c +0 -77
index 9ae24f4..47187cc 100644
@@ -2,88 +2,11 @@
 
 #include <linux/kernel.h>
 #include <linux/string.h>
-#include <linux/pci_regs.h>
 #include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/etherdevice.h>
 #include <linux/of_address.h>
 #include <asm/prom.h>
-#include <asm/pci-bridge.h>
-
-#ifdef CONFIG_PCI
-int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq)
-{
-       struct device_node *dn, *ppnode;
-       struct pci_dev *ppdev;
-       u32 lspec;
-       u32 laddr[3];
-       u8 pin;
-       int rc;
-
-       /* Check if we have a device node, if yes, fallback to standard OF
-        * parsing
-        */
-       dn = pci_device_to_OF_node(pdev);
-       if (dn)
-               return of_irq_map_one(dn, 0, out_irq);
-
-       /* Ok, we don't, time to have fun. Let's start by building up an
-        * interrupt spec.  we assume #interrupt-cells is 1, which is standard
-        * for PCI. If you do different, then don't use that routine.
-        */
-       rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);
-       if (rc != 0)
-               return rc;
-       /* No pin, exit */
-       if (pin == 0)
-               return -ENODEV;
-
-       /* Now we walk up the PCI tree */
-       lspec = pin;
-       for (;;) {
-               /* Get the pci_dev of our parent */
-               ppdev = pdev->bus->self;
-
-               /* Ouch, it's a host bridge... */
-               if (ppdev == NULL) {
-                       struct pci_controller *host;
-                       host = pci_bus_to_host(pdev->bus);
-                       ppnode = host ? host->dn : NULL;
-                       /* No node for host bridge ? give up */
-                       if (ppnode == NULL)
-                               return -EINVAL;
-               } else
-                       /* We found a P2P bridge, check if it has a node */
-                       ppnode = pci_device_to_OF_node(ppdev);
-
-               /* Ok, we have found a parent with a device-node, hand over to
-                * the OF parsing code.
-                * We build a unit address from the linux device to be used for
-                * resolution. Note that we use the linux bus number which may
-                * not match your firmware bus numbering.
-                * Fortunately, in most cases, interrupt-map-mask doesn't
-                * include the bus number as part of the matching.
-                * You should still be careful about that though if you intend
-                * to rely on this function (you ship  a firmware that doesn't
-                * create device nodes for all PCI devices).
-                */
-               if (ppnode)
-                       break;
-
-               /* We can only get here if we hit a P2P bridge with no node,
-                * let's do standard swizzling and try again
-                */
-               lspec = pci_swizzle_interrupt_pin(pdev, lspec);
-               pdev = ppdev;
-       }
-
-       laddr[0] = (pdev->bus->number << 16)
-               | (pdev->devfn << 8);
-       laddr[1]  = laddr[2] = 0;
-       return of_irq_map_raw(ppnode, &lspec, 1, laddr, out_irq);
-}
-EXPORT_SYMBOL_GPL(of_irq_map_pci);
-#endif /* CONFIG_PCI */
 
 void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
               unsigned long *busno, unsigned long *phys, unsigned long *size)
arch/microblaze/pci/pci-common.c +1 -0
index e363615..1e01a12 100644
@@ -29,6 +29,7 @@
 #include <linux/slab.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_pci.h>
 
 #include <asm/processor.h>
 #include <asm/io.h>
arch/powerpc/include/asm/pci-bridge.h +10 -0
index 51e9e6f..edeb80f 100644
@@ -171,6 +171,16 @@ static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
       return bus->sysdata;
 }
 
+static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
+{
+       struct pci_controller *host;
+
+       if (bus->self)
+               return pci_device_to_OF_node(bus->self);
+       host = pci_bus_to_host(bus);
+       return host ? host->dn : NULL;
+}
+
 static inline int isa_vaddr_is_ioport(void __iomem *address)
 {
       /* No specific ISA handling on ppc32 at this stage, it
arch/powerpc/include/asm/prom.h +0 -15
index d727575..c189aa5 100644
@@ -70,21 +70,6 @@ static inline int of_node_to_nid(struct device_node *device) { return 0; }
 #endif
 #define of_node_to_nid of_node_to_nid
 
-/**
- * of_irq_map_pci - Resolve the interrupt for a PCI device
- * @pdev:      the device whose interrupt is to be resolved
- * @out_irq:   structure of_irq filled by this function
- *
- * This function resolves the PCI interrupt for a given PCI device. If a
- * device-node exists for a given pci_dev, it will use normal OF tree
- * walking. If not, it will implement standard swizzling and walk up the
- * PCI tree until an device-node is found, at which point it will finish
- * resolving using the OF tree walking.
- */
-struct pci_dev;
-struct of_irq;
-extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
-
 extern void of_instantiate_rtc(void);
 
 /* These includes are put at the bottom because they may contain things
arch/powerpc/kernel/pci-common.c +1 -0
index 10a44e6..eb341be 100644
@@ -22,6 +22,7 @@
 #include <linux/init.h>
 #include <linux/bootmem.h>
 #include <linux/of_address.h>
+#include <linux/of_pci.h>
 #include <linux/mm.h>
 #include <linux/list.h>
 #include <linux/syscalls.h>
arch/powerpc/kernel/prom_parse.c +0 -84
index c2b7a07..47187cc 100644
@@ -2,95 +2,11 @@
 
 #include <linux/kernel.h>
 #include <linux/string.h>
-#include <linux/pci_regs.h>
 #include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/etherdevice.h>
 #include <linux/of_address.h>
 #include <asm/prom.h>
-#include <asm/pci-bridge.h>
-
-#ifdef CONFIG_PCI
-int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq)
-{
-       struct device_node *dn, *ppnode;
-       struct pci_dev *ppdev;
-       u32 lspec;
-       u32 laddr[3];
-       u8 pin;
-       int rc;
-
-       /* Check if we have a device node, if yes, fallback to standard OF
-        * parsing
-        */
-       dn = pci_device_to_OF_node(pdev);
-       if (dn) {
-               rc = of_irq_map_one(dn, 0, out_irq);
-               if (!rc)
-                       return rc;
-       }
-
-       /* Ok, we don't, time to have fun. Let's start by building up an
-        * interrupt spec.  we assume #interrupt-cells is 1, which is standard
-        * for PCI. If you do different, then don't use that routine.
-        */
-       rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);
-       if (rc != 0)
-               return rc;
-       /* No pin, exit */
-       if (pin == 0)
-               return -ENODEV;
-
-       /* Now we walk up the PCI tree */
-       lspec = pin;
-       for (;;) {
-               /* Get the pci_dev of our parent */
-               ppdev = pdev->bus->self;
-
-               /* Ouch, it's a host bridge... */
-               if (ppdev == NULL) {
-#ifdef CONFIG_PPC64
-                       ppnode = pci_bus_to_OF_node(pdev->bus);
-#else
-                       struct pci_controller *host;
-                       host = pci_bus_to_host(pdev->bus);
-                       ppnode = host ? host->dn : NULL;
-#endif
-                       /* No node for host bridge ? give up */
-                       if (ppnode == NULL)
-                               return -EINVAL;
-               } else
-                       /* We found a P2P bridge, check if it has a node */
-                       ppnode = pci_device_to_OF_node(ppdev);
-
-               /* Ok, we have found a parent with a device-node, hand over to
-                * the OF parsing code.
-                * We build a unit address from the linux device to be used for
-                * resolution. Note that we use the linux bus number which may
-                * not match your firmware bus numbering.
-                * Fortunately, in most cases, interrupt-map-mask doesn't include
-                * the bus number as part of the matching.
-                * You should still be careful about that though if you intend
-                * to rely on this function (you ship  a firmware that doesn't
-                * create device nodes for all PCI devices).
-                */
-               if (ppnode)
-                       break;
-
-               /* We can only get here if we hit a P2P bridge with no node,
-                * let's do standard swizzling and try again
-                */
-               lspec = pci_swizzle_interrupt_pin(pdev, lspec);
-               pdev = ppdev;
-       }
-
-       laddr[0] = (pdev->bus->number << 16)
-               | (pdev->devfn << 8);
-       laddr[1]  = laddr[2] = 0;
-       return of_irq_map_raw(ppnode, &lspec, 1, laddr, out_irq);
-}
-EXPORT_SYMBOL_GPL(of_irq_map_pci);
-#endif /* CONFIG_PCI */
 
 void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
               unsigned long *busno, unsigned long *phys, unsigned long *size)
drivers/of/Kconfig +6 -0
index 3c6e100..c71cff1 100644
@@ -69,4 +69,10 @@ config OF_MDIO
       help
         OpenFirmware MDIO bus (Ethernet PHY) accessors
 
+config OF_PCI
+       def_tristate PCI
+       depends on PCI && !SPARC
+       help
+         OpenFirmware PCI bus accessors
+
 endmenu # OF
drivers/of/Makefile +1 -0
index 3ab21a0..f7861ed 100644
@@ -9,3 +9,4 @@ obj-$(CONFIG_OF_I2C)    += of_i2c.o
 obj-$(CONFIG_OF_NET)   += of_net.o
 obj-$(CONFIG_OF_SPI)   += of_spi.o
 obj-$(CONFIG_OF_MDIO)  += of_mdio.o
+obj-$(CONFIG_OF_PCI)   += of_pci.o
drivers/of/of_pci.c new file +80 -0
new file mode 100644
index 0000000..dd862d2
@@ -0,0 +1,80 @@
+#include <linux/kernel.h>
+#include <linux/of_pci.h>
+#include <asm/prom.h>
+
+int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq)
+{
+       struct device_node *dn, *ppnode;
+       struct pci_dev *ppdev;
+       u32 lspec;
+       __be32 lspec_be;
+       __be32 laddr[3];
+       u8 pin;
+       int rc;
+
+       /* Check if we have a device node, if yes, fallback to standard OF
+        * parsing
+        */
+       dn = pci_device_to_OF_node(pdev);
+       if (dn) {
+               rc = of_irq_map_one(dn, 0, out_irq);
+               if (!rc)
+                       return rc;
+       }
+
+       /* Ok, we don't, time to have fun. Let's start by building up an
+        * interrupt spec.  we assume #interrupt-cells is 1, which is standard
+        * for PCI. If you do different, then don't use that routine.
+        */
+       rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);
+       if (rc != 0)
+               return rc;
+       /* No pin, exit */
+       if (pin == 0)
+               return -ENODEV;
+
+       /* Now we walk up the PCI tree */
+       lspec = pin;
+       for (;;) {
+               /* Get the pci_dev of our parent */
+               ppdev = pdev->bus->self;
+
+               /* Ouch, it's a host bridge... */
+               if (ppdev == NULL) {
+                       ppnode = pci_bus_to_OF_node(pdev->bus);
+
+                       /* No node for host bridge ? give up */
+                       if (ppnode == NULL)
+                               return -EINVAL;
+               } else {
+                       /* We found a P2P bridge, check if it has a node */
+                       ppnode = pci_device_to_OF_node(ppdev);
+               }
+
+               /* Ok, we have found a parent with a device-node, hand over to
+                * the OF parsing code.
+                * We build a unit address from the linux device to be used for
+                * resolution. Note that we use the linux bus number which may
+                * not match your firmware bus numbering.
+                * Fortunately, in most cases, interrupt-map-mask doesn't
+                * include the bus number as part of the matching.
+                * You should still be careful about that though if you intend
+                * to rely on this function (you ship  a firmware that doesn't
+                * create device nodes for all PCI devices).
+                */
+               if (ppnode)
+                       break;
+
+               /* We can only get here if we hit a P2P bridge with no node,
+                * let's do standard swizzling and try again
+                */
+               lspec = pci_swizzle_interrupt_pin(pdev, lspec);
+               pdev = ppdev;
+       }
+
+       lspec_be = cpu_to_be32(lspec);
+       laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8));
+       laddr[1]  = laddr[2] = cpu_to_be32(0);
+       return of_irq_map_raw(ppnode, &lspec_be, 1, laddr, out_irq);
+}
+EXPORT_SYMBOL_GPL(of_irq_map_pci);
include/linux/of_pci.h new file +20 -1
new file mode 100644
index 0000000..9b0ba67
@@ -0,0 +1,20 @@
+#ifndef __OF_PCI_H
+#define __OF_PCI_H
+
+#include <linux/pci.h>
+
+/**
+ * of_irq_map_pci - Resolve the interrupt for a PCI device
+ * @pdev:       the device whose interrupt is to be resolved
+ * @out_irq:    structure of_irq filled by this function
+ *
+ * This function resolves the PCI interrupt for a given PCI device. If a
+ * device-node exists for a given pci_dev, it will use normal OF tree
+ * walking. If not, it will implement standard swizzling and walk up the
+ * PCI tree until an device-node is found, at which point it will finish
+ * resolving using the OF tree walking.
+ */
+struct pci_dev;
+struct of_irq;
+int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
+#endif
--

1.7.3.2

_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

Signature · 4 lines
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian
#31 lore raw

PATCH 8/14 x86/dtb: add support for PCI devices backed by dtb nodes

In reply to 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.

---
 arch/x86/include/asm/prom.h |   17 +++++++++
 arch/x86/kernel/prom.c      |   82 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 99 insertions(+), 0 deletions(-)
arch/x86/include/asm/prom.h +17 -0
index bd67ab2..3ed0bd6 100644
@@ -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,24 @@ 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->dev.of_node;
+}
+
+static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
+{
+	if (bus->self)
+		return pci_device_to_OF_node(bus->self);
+	else
+		return NULL;
+}
+
 #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
arch/x86/kernel/prom.c +82 -0

98 lines not on this page · raw message

Signature · 1 line
1.7.3.2
#32 lore raw

Re: [PATCH TIP 08/14] x86/dtb: add support for PCI devices backed by dtb nodes

Quoted 40 lines · 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.

---
 arch/x86/include/asm/prom.h |   17 +++++++++ arch/x86/kernel/prom.c      |   82 +++++++++++++++++++++++++++++++++++++++++++

 2 files changed, 99 insertions(+), 0 deletions(-)
arch/x86/include/asm/prom.h +5 -0
index bd67ab2..3ed0bd6 100644
@@ -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,24 @@ 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)
+{

arch/x86/include/asm/prom.h extern void add_dtb(u64 data); · line 45

Quoted 10 lines
arch/x86/include/asm/prom.h +10 -0
+       return pdev->dev.of_node;
+}
+
+static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
+{
+       if (bus->self)
+               return pci_device_to_OF_node(bus->self);
+       else
+               return NULL;
+}

Nit: could simply be:

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);
}
Quoted 119 lines
arch/x86/include/asm/prom.h +2 -0
+
  #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
arch/x86/kernel/prom.c +82 -1
index 16c124e..8525ca0 100644
@@ -9,10 +9,13 @@
  #include <linux/of_address.h>
  #include <linux/of_platform.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/io_apic.h>
+#include <asm/pci_x86.h>
 
  __initdata u64 initial_dtb;
  char __initdata cmd_line[COMMAND_LINE_SIZE];
@@ -99,6 +102,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;
--

1.7.3.2

_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#33 lore raw

Re: [sodaville] [PATCH TIP 08/14] x86/dtb: add support for PCI devices backed by dtb nodes

Quoted 26 lines · * Grant Likely | 2011-02-16 14:59:15 [-0700]:
Quoted 12 lines
arch/x86/include/asm/prom.h +4 -0
index bd67ab2..3ed0bd6 100644
@@ -28,8 +29,24 @@ 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)
+{

arch/x86/include/asm/prom.h extern void add_dtb(u64 data); · line 45

Quoted 10 lines
arch/x86/include/asm/prom.h +10 -0
+       return pdev->dev.of_node;
+}
+
+static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
+{
+       if (bus->self)
+               return pci_device_to_OF_node(bus->self);
+       else
+               return NULL;
+}

Nit: could simply be:

static inline struct device_node *pci_device_to_OF_node(struct pci_dev *pdev)

Quoted 9 lines
{
      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);
}

done.

Sebastian

#34 lore raw

PATCH 9/14 x86/dtb: Add generic bus probe

In reply to Sebastian Andrzej Siewior

For now we probe these busses and we change is to board dependent probes once we have to.

---
 arch/x86/kernel/prom.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
arch/x86/kernel/prom.c +19 -0
index 8525ca0..8215e8a 100644
@@ -102,6 +102,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-immr", },
+	{ .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)
 {
Signature · 1 line
1.7.3.2
#35 lore raw

PATCH v2 9/14 x86/dtb: Add generic bus probe

For now we probe these busses and we change is to board dependent probes once we have to.

---

renamed -immr to -cp

 arch/x86/kernel/prom.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
arch/x86/kernel/prom.c +19 -0
index 8525ca0..3eaab43 100644
@@ -102,6 +102,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)
 {
Signature · 1 line
1.7.3.2
Acked-by on v2 9/14
#36 lore raw

Re: [PATCH v2 TIP 09/14] x86/dtb: Add generic bus probe

Quoted 7 lines · Sebastian Andrzej Siewior

For now we probe these busses and we change is to board dependent probes once we have to.

Historically for embedded platforms we leave calling of_platform_bus_probe() to the bsp code so that weird boards can still do weird stuff on the probe order. However, I'm all for making more code common, so we can start with this and switch to per-board (or per-SoC) calls only if it becomes necessary.

g.

Quoted 44 lines

---

renamed -immr to -cp

 arch/x86/kernel/prom.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
arch/x86/kernel/prom.c +19 -0
index 8525ca0..3eaab43 100644
@@ -102,6 +102,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)
 {
Signature · 6 lines
1.7.3.2

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss
#37 lore raw

PATCH 10/14 x86/ioapic: Add OF bindings for IO-APIC

In reply to 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.

---
 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/irqinit.c      |    6 ++
 arch/x86/kernel/prom.c         |   15 ++++++
 5 files changed, 129 insertions(+), 0 deletions(-)
arch/x86/include/asm/io_apic.h +7 -0
index f327d38..5a8b950 100644
@@ -177,6 +177,13 @@ struct mp_ioapic_gsi{
 	u32 gsi_base;
 	u32 gsi_end;
 };
+#ifdef CONFIG_X86_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);
arch/x86/include/asm/prom.h +2 -0
index 3ed0bd6..eea2839 100644
@@ -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);
@@ -46,6 +47,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
arch/x86/kernel/apic/io_apic.c +99 -0

123 lines not on this page · raw message

arch/x86/kernel/irqinit.c +6 -0
index 4cadf86..9f76f89 100644
@@ -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
arch/x86/kernel/prom.c +15 -0
index 8215e8a..83ab00a 100644
@@ -11,9 +11,11 @@
 #include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/of_pci.h>
+#include <linux/of_fdt.h>
 
 #include <asm/hpet.h>
 #include <asm/irq_controller.h>
+#include <asm/apic.h>
 #include <asm/io_apic.h>
 #include <asm/pci_x86.h>
 
@@ -320,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,ioapic"))
+			ioapic_add_ofnode(dp);
+	}
+}
Signature · 1 line
1.7.3.2
#38 lore raw

Re: [PATCH TIP 10/14] x86/ioapic: Add OF bindings for IO-APIC

Quoted 6 lines · 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

Quoted 7 lines

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.

Looks fine to me.

g.

Quoted 234 lines
---
 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/irqinit.c      |    6 ++
 arch/x86/kernel/prom.c         |   15 ++++++
 5 files changed, 129 insertions(+), 0 deletions(-)
arch/x86/include/asm/io_apic.h +7 -0
index f327d38..5a8b950 100644
@@ -177,6 +177,13 @@ struct mp_ioapic_gsi{
 	u32 gsi_base;
 	u32 gsi_end;
 };
+#ifdef CONFIG_X86_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);
arch/x86/include/asm/prom.h +2 -0
index 3ed0bd6..eea2839 100644
@@ -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);
@@ -46,6 +47,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
arch/x86/kernel/apic/io_apic.c +99 -0
index 697dc34..be7417f 100644
@@ -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_X86_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;
 
@@ -4080,6 +4086,99 @@ void __init mp_register_ioapic(int id, u32 address, u32 gsi_base)
 	nr_ioapics++;
 }
 
+#ifdef CONFIG_X86_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)
 {
arch/x86/kernel/irqinit.c +6 -0
index 4cadf86..9f76f89 100644
@@ -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
arch/x86/kernel/prom.c +15 -0
index 8215e8a..83ab00a 100644
@@ -11,9 +11,11 @@
 #include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/of_pci.h>
+#include <linux/of_fdt.h>
 
 #include <asm/hpet.h>
 #include <asm/irq_controller.h>
+#include <asm/apic.h>
 #include <asm/io_apic.h>
 #include <asm/pci_x86.h>
 
@@ -320,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,ioapic"))
+			ioapic_add_ofnode(dp);
+	}
+}
Signature · 6 lines
1.7.3.2

_______________________________________________
devicetree-discuss mailing list
[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss
#39 lore raw

PATCH 11/14 x86/ce4100: use OF for ioapic

In reply to Sebastian Andrzej Siewior

and hpet and a few others things....

---
 arch/x86/platform/ce4100/ce4100.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)
arch/x86/platform/ce4100/ce4100.c +17 -7
index d2c0d51..7877453 100644
@@ -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
 }
Signature · 1 line
1.7.3.2
#40 lore raw

PATCH 12/14 x86/rtc: don't register rtc if we the DT blob

In reply to Sebastian Andrzej Siewior

or we might end up with two device nodes for the same hardware.

---
 arch/x86/kernel/rtc.c |    3 +++
 include/linux/of.h    |   12 ++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
arch/x86/kernel/rtc.c +3 -0
index 6f39cab..3f2ad26 100644
@@ -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,
include/linux/of.h +12 -0
index cad7cf0..016968d 100644
@@ -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 */
Signature · 1 line
1.7.3.2
Acked-by on v1 12/14
#41 lore raw

Re: [PATCH OF 12/14] x86/rtc: don't register rtc if we the DT blob

Quoted 4 lines · Sebastian Andrzej Siewior

or we might end up with two device nodes for the same hardware.

I'm okay with this one being merged via the x86 tree.

Quoted 62 lines
---
 arch/x86/kernel/rtc.c |    3 +++
 include/linux/of.h    |   12 ++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
arch/x86/kernel/rtc.c +3 -0
index 6f39cab..3f2ad26 100644
@@ -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,
include/linux/of.h +12 -0
index cad7cf0..016968d 100644
@@ -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 */
Signature · 6 lines
1.7.3.2

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss
#42 lore raw

Re: [PATCH OF 12/14] x86/rtc: don't register rtc if we the DT blob

In reply to Sebastian Andrzej Siewior
Quoted 22 lines · Sebastian Andrzej Siewior

or we might end up with two device nodes for the same hardware.

---
 arch/x86/kernel/rtc.c |    3 +++
 include/linux/of.h    |   12 ++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
arch/x86/kernel/rtc.c +1 -0
index 6f39cab..3f2ad26 100644
@@ -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>

arch/x86/kernel/rtc.c static __init int add_rtc_cmos(void) · line 241

Quoted 5 lines
arch/x86/kernel/rtc.c +2 -0
@@ -236,6 +237,8 @@ static __init int add_rtc_cmos(void)
 		}
 	}
 #endif
+	if (of_have_populated_dt())
+		return 0;

Hmmm, should this hunk be moved to the next patch to preserve bisectability?

g.

#43 lore raw

Re: [sodaville] [PATCH OF 12/14] x86/rtc: don't register rtc if we the DT blob

Quoted 8 lines · * Grant Likely | 2011-02-16 15:09:21 [-0700]:

arch/x86/kernel/rtc.c static __init int add_rtc_cmos(void) · line 241

Quoted 6 lines
arch/x86/kernel/rtc.c +2 -0
@@ -236,6 +237,8 @@ static __init int add_rtc_cmos(void)
 		}
 	}
 #endif
+	if (of_have_populated_dt())
+		return 0;

Hmmm, should this hunk be moved to the next patch to preserve bisectability?

Makes sense. Without this chunk it is simply adding of_have_populated_dt(). So I merge with the next patch.

Quoted 1 line

g.

Sebastian

#44 lore raw

PATCH 13/14 rtc/cmos: add OF bindings

In reply to 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.

Cc rtc-linux-/[email protected]
Cc Alessandro Zummo <[email protected]>
Cc devicetree-discuss-uLR06cmDAlY/[email protected]
---
 Documentation/powerpc/dts-bindings/rtc-cmos.txt |   28 ++++++++++++++
 drivers/rtc/rtc-cmos.c                          |   46 +++++++++++++++++++++++
 2 files changed, 74 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/powerpc/dts-bindings/rtc-cmos.txt
Documentation/powerpc/dts-bindings/rtc-cmos.txt new file +28 -0
new file mode 100644
index 0000000..7382989
@@ -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>;
+	 };
drivers/rtc/rtc-cmos.c +46 -0

70 lines not on this page · raw message

Signature · 1 line
1.7.3.2
#45 lore raw

Re: [PATCH OF 13/14] rtc/cmos: add OF bindings

Quoted 5 lines · * Sebastian Andrzej Siewior | 2011-01-24 09:59:01 [+0530]:
drivers/rtc/rtc-cmos.c +0 -0
index c7ff8df..2709e00 100644

drivers/rtc/rtc-cmos.c static struct pnp_driver cmos_pnp_driver = { · line 1134

Quoted 10 lines
drivers/rtc/rtc-cmos.c +7 -0
@@ -1123,6 +1125,46 @@ 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",
+	},
+	{ },
+};

Andreas, this is the compatible string I'm using. Could you please tell me what is OLPC using? So maybe we could stick to the same compatible string.

Sebastian

#46 lore raw

Re: [PATCH OF 13/14] rtc/cmos: add OF bindings

In reply to Sebastian Andrzej Siewior

Documentation/powerpc/dts-bindings/rtc-cmos.txt

Quoted 22 lines · 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.

Cc rtc-linux-/[email protected]
Cc Alessandro Zummo <[email protected]>
Cc devicetree-discuss-uLR06cmDAlY/[email protected]
---
 Documentation/powerpc/dts-bindings/rtc-cmos.txt |   28 ++++++++++++++
 drivers/rtc/rtc-cmos.c                          |   46 +++++++++++++++++++++++
 2 files changed, 74 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/powerpc/dts-bindings/rtc-cmos.txt
Documentation/powerpc/dts-bindings/rtc-cmos.txt new file +0 -0
new file mode 100644
index 0000000..7382989

Move to Documentation/devicetree/bindings/rtc/

Quoted 98 lines
Documentation/powerpc/dts-bindings/rtc-cmos.txt new file +28 -0
@@ -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>;
+	 };
drivers/rtc/rtc-cmos.c +43 -0
index c7ff8df..2709e00 100644
@@ -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,46 @@ 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) {}
+#endif
 /*----------------------------------------------------------------*/
 
 /* Platform setup should have set up an RTC device, when PNP is
@@ -1131,6 +1173,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),

drivers/rtc/rtc-cmos.c static struct platform_driver cmos_platform_driver = { · line 1210

Quoted 6 lines
drivers/rtc/rtc-cmos.c +3 -0
@@ -1162,6 +1205,9 @@ static struct platform_driver cmos_platform_driver = {
 #ifdef CONFIG_PM
 		.pm		= &cmos_pm_ops,
 #endif
+#if defined(CONFIG_OF)
+		.of_match_table = of_cmos_match,
+#endif

The #if defined(CONFIG_OF) is no longer necessary around .of_match_table, particularly if you have a #else above that #defines of_cmos_match to NULL.

Quoted 10 lines
drivers/rtc/rtc-cmos.c +0 -0
 	}
 };
 
Signature · 6 lines
1.7.3.2

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss
#47 lore raw

Re: [sodaville] [PATCH OF 13/14] rtc/cmos: add OF bindings

Quoted 7 lines · * Grant Likely | 2011-02-16 15:11:08 [-0700]:

Documentation/powerpc/dts-bindings/rtc-cmos.txt

Quoted 5 lines
Documentation/powerpc/dts-bindings/rtc-cmos.txt new file +0 -0
new file mode 100644
index 0000000..7382989

Move to Documentation/devicetree/bindings/rtc/

moved.

Quoted 7 lines
Quoted 7 lines
drivers/rtc/rtc-cmos.c +0 -0
index c7ff8df..2709e00 100644
@@ -1162,6 +1205,9 @@ static struct platform_driver cmos_platform_driver = {
 #ifdef CONFIG_PM
 		.pm		= &cmos_pm_ops,
Quoted 8 lines

drivers/rtc/rtc-cmos.c static struct platform_driver cmos_platform_driver = { · line 1210

Quoted 4 lines
drivers/rtc/rtc-cmos.c +3 -0
 #endif
+#if defined(CONFIG_OF)
+		.of_match_table = of_cmos_match,
+#endif

The #if defined(CONFIG_OF) is no longer necessary around .of_match_table, particularly if you have a #else above that #defines of_cmos_match to NULL.

Kinda does not work. I get here:
|drivers/rtc/rtc-cmos.c:1209:3: error: unknown field ‘of_match_table’ specified in initializer

I rebased on top of -rc5. Is this something new you describing?

Sebastian

#48 lore raw

Re: [sodaville] [PATCH OF 13/14] rtc/cmos: add OF bindings

Quoted 27 lines · Sebastian Andrzej Siewior
Quoted 7 lines · * Grant Likely | 2011-02-16 15:11:08 [-0700]:

Documentation/powerpc/dts-bindings/rtc-cmos.txt

Quoted 5 lines
Documentation/powerpc/dts-bindings/rtc-cmos.txt new file +0 -0
new file mode 100644
index 0000000..7382989

Move to Documentation/devicetree/bindings/rtc/

moved.

Quoted 7 lines
Quoted 7 lines
drivers/rtc/rtc-cmos.c +0 -0
index c7ff8df..2709e00 100644
@@ -1162,6 +1205,9 @@ static struct platform_driver cmos_platform_driver = {
  #ifdef CONFIG_PM
              .pm             = &cmos_pm_ops,
Quoted 8 lines

drivers/rtc/rtc-cmos.c static struct platform_driver cmos_platform_driver = { · line 1210

Quoted 4 lines
drivers/rtc/rtc-cmos.c +3 -0
  #endif
+#if defined(CONFIG_OF)
+            .of_match_table = of_cmos_match,
+#endif

The #if defined(CONFIG_OF) is no longer necessary around .of_match_table, particularly if you have a #else above that #defines of_cmos_match to NULL.

Quoted 4 lines

Kinda does not work. I get here:
|drivers/rtc/rtc-cmos.c:1209:3: error: unknown field â  of_match_tableâ   specified in initializer

I rebased on top of -rc5. Is this something new you describing?

Base your patch on top of my devicetree/next branch. That's the branch that tglx will be applying them on top of them to get your changes to generic pci dt support code.

g.

#49 lore raw

PATCH 14/14 x86/pci: remove warning

In reply to Sebastian Andrzej Siewior

|arch/x86/pci/ce4100.c: In function `ce4100_conf_read':
|arch/x86/pci/ce4100.c:257:9: warning: unused variable `retval'

---
 arch/x86/pci/ce4100.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/pci/ce4100.c +1 -1
index 85b68ef..c63c6d3 100644
@@ -254,7 +254,7 @@ int bridge_read(unsigned int devfn, int reg, int len, u32 *value)
 static int ce4100_conf_read(unsigned int seg, unsigned int bus,
 			    unsigned int devfn, int reg, int len, u32 *value)
 {
-	int i, retval = 1;
+	int i;
 
 	if (bus == 1) {
 		for (i = 0; i < ARRAY_SIZE(bus1_fixups); i++) {
Signature · 1 line
1.7.3.2