aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2012-01-10 22:39:42 +1100
committerDavid Gibson <david@gibson.dropbear.id.au>2012-01-11 12:48:40 +1100
commitc1394c3d2a8af1b64dd677f3b572236109fe453d (patch)
tree031a565ed80e194b585851512605785a7575f81d
parentc90d5abd0d047acb7c37fc5b67ccc9f3a9a942e5 (diff)
downloadSLOF-qemu-slof-20120111.1.zip
SLOF-qemu-slof-20120111.1.tar.gz
SLOF-qemu-slof-20120111.1.tar.bz2
Support new-style PCI for qemu boardqemu-slof-20120111.1
We now support populating the device-nodes ourselves when using a newer qemu which doesn't do it anymore. Note: I have removed the support for working with the existing device nodes, so qemu needs to be updated in sync with slof Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r--board-qemu/slof/pci-capabilities.fs4
-rw-r--r--board-qemu/slof/pci-interrupts.fs8
-rw-r--r--board-qemu/slof/pci-phb.fs88
-rw-r--r--board-qemu/slof/rtas.fs5
-rw-r--r--board-qemu/slof/tree.fs2
-rw-r--r--slof/fs/pci-properties.fs4
-rw-r--r--slof/fs/pci-scan.fs17
7 files changed, 100 insertions, 28 deletions
diff --git a/board-qemu/slof/pci-capabilities.fs b/board-qemu/slof/pci-capabilities.fs
new file mode 100644
index 0000000..9ac580d
--- /dev/null
+++ b/board-qemu/slof/pci-capabilities.fs
@@ -0,0 +1,4 @@
+\ Set up all known capabilities for this board to the plugged devices
+: pci-set-capabilities ( config-addr -- )
+ drop
+;
diff --git a/board-qemu/slof/pci-interrupts.fs b/board-qemu/slof/pci-interrupts.fs
new file mode 100644
index 0000000..11db05f
--- /dev/null
+++ b/board-qemu/slof/pci-interrupts.fs
@@ -0,0 +1,8 @@
+: pci-gen-irq-entry ( prop-addr prop-len config-addr -- prop-addr prop-len )
+ ." SHOULD NOT GET THERE !" cr
+ drop
+;
+
+: pci-set-irq-line ( config-addr -- )
+ drop
+;
diff --git a/board-qemu/slof/pci-phb.fs b/board-qemu/slof/pci-phb.fs
index 62bc281..5b63eb2 100644
--- a/board-qemu/slof/pci-phb.fs
+++ b/board-qemu/slof/pci-phb.fs
@@ -107,12 +107,18 @@ setup-puid
0 VALUE dma-window-size \ Size of the window
\ Read helper variables (LIOBN, DMA window base and size) from the
-\ "ibm,dma-window" property. This property is unfortunately currently located
-\ in the PCI device node instead of the bus node, so we've got to use the
+\ "ibm,dma-window" property. This property can be either located
+\ in the PCI device node or in the bus node, so we've got to use the
\ "calling-child" variable here to get to the node that initiated the call.
+\ XXX We should search all the way up the tree to the PHB ...
: (init-dma-window-vars) ( -- )
- s" ibm,dma-window" calling-child
- get-property ABORT" no dma-window property available"
+\ ." Foo called in " pwd cr
+\ ." calling child is " calling-child .node cr
+\ ." parent is " calling-child parent .node cr
+ s" ibm,dma-window" calling-child get-property IF
+ s" ibm,dma-window" calling-child parent get-property
+ ABORT" no dma-window property available"
+ THEN
decode-int TO dma-window-liobn
decode-64 TO dma-window-base
decode-64 TO dma-window-size
@@ -179,25 +185,69 @@ setup-puid
: open true ;
: close ;
+\ Parse the "ranges" property of the root pci node to decode the available
+\ memory ranges. See "PCI Bus Binding to IEEE Std 1275-1994" for details.
+\ The memory ranges are then used for setting up the device bars (if necessary)
+: phb-parse-ranges ( -- )
+ \ First clear everything, in case there is something missing in the ranges
+ 0 pci-next-io !
+ 0 pci-max-io !
+ 0 pci-next-mem !
+ 0 pci-max-mem !
+ 0 pci-next-mmio !
+ 0 pci-max-mmio !
+
+ \ Now get the "ranges" property
+ s" ranges" get-node get-property 0<> ABORT" ranges property not found"
+ ( prop-addr prop-len )
+ BEGIN
+ dup
+ WHILE
+ decode-int \ Decode phys.hi
+ 3000000 AND \ Filter out address space in phys.hi
+ CASE
+ 1000000 OF \ I/O space?
+ decode-64 dup >r pci-next-io ! \ Decode PCI base address
+ decode-64 drop \ Forget the parent address
+ decode-64 r> + pci-max-io ! \ Decode size & calc max address
+ pci-next-io @ 0= IF
+ pci-next-io @ 10 + pci-next-io ! \ BARs must not be set to zero
+ THEN
+ ENDOF
+ 2000000 OF \ 32-bit memory space?
+ decode-64 pci-next-mem ! \ Decode mem base address
+ decode-64 drop \ Forget the parent address
+ decode-64 2 / dup >r \ Decode and calc size/2
+ pci-next-mem @ + dup pci-max-mem ! \ and calc max mem address
+ dup pci-next-mmio ! \ which is the same as MMIO base
+ r> + pci-max-mmio ! \ calc max MMIO address
+ ENDOF
+ 3000000 OF \ 64-bit memory space?
+ cr ." Warning: 64-bit PCI space not supported yet! "
+ decode-64 . decode-64 . cr
+ ENDOF
+ ENDCASE
+ REPEAT
+ ( prop-addr prop-len )
+ 2drop
+
+ phb-debug? IF
+ ." pci-next-io = " pci-next-io @ . cr
+ ." pci-max-io = " pci-max-io @ . cr
+ ." pci-next-mem = " pci-next-mem @ . cr
+ ." pci-max-mem = " pci-max-mem @ . cr
+ ." pci-next-mmio = " pci-next-mmio @ . cr
+ ." pci-max-mmio = " pci-max-mmio @ . cr
+ THEN
+;
\ Scan the child nodes of the pci root node to assign bars, fixup
\ properties etc.
-: setup-children
+: phb-setup-children
puid >r \ Save old value of puid
my-puid TO puid \ Set current puid
- get-node child
- BEGIN
- dup \ Continue as long as there are children
- WHILE
- \ ." Working on " dup node>path type cr
- \ Set child node as current node:
- dup set-node
- \ Include the PCI device functions:
- s" pci-device.fs" included
- peer ( next-child-phandle )
- REPEAT
- drop
+ phb-parse-ranges
+ ff 0 (probe-pci-host-bridge)
r> TO puid \ Restore previous puid
;
-
-setup-children
+phb-setup-children
diff --git a/board-qemu/slof/rtas.fs b/board-qemu/slof/rtas.fs
index e1c357a..a366ad7 100644
--- a/board-qemu/slof/rtas.fs
+++ b/board-qemu/slof/rtas.fs
@@ -122,8 +122,9 @@ find-qemu-rtas
( addr ) rtas-cb rtas>args0 l!
enter-rtas
rtas-cb rtas>args4 l@ dup IF
- ." RTAS config err " . cr
- ffffffff
+ \ Do not warn on error as this is part of the
+ \ normal PCI probing pass
+ drop ffffffff
ELSE
drop rtas-cb rtas>args5 l@
THEN
diff --git a/board-qemu/slof/tree.fs b/board-qemu/slof/tree.fs
index 6b7b961..533fc95 100644
--- a/board-qemu/slof/tree.fs
+++ b/board-qemu/slof/tree.fs
@@ -95,6 +95,8 @@ populate-vios
5a0 cp
+#include "pci-scan.fs"
+
: populate-pci-busses ( -- )
\ Populate the /pci* children with their methods
" /" find-device get-node child
diff --git a/slof/fs/pci-properties.fs b/slof/fs/pci-properties.fs
index 312f431..0e67a18 100644
--- a/slof/fs/pci-properties.fs
+++ b/slof/fs/pci-properties.fs
@@ -604,7 +604,11 @@
pci-device-slots encode-int s" slot-names" property
dup pci-bridge-range-props
dup pci-bridge-assigned-addresses-prop
+ \ Only create interrupt-map when it doesn't already exist
+ \ (it can be provided by qemu)
+ s" interrupt-map" get-node get-property IF
pci-bridge-interrupt-map
+ ELSE 2drop THEN
pci-reg-props
;
diff --git a/slof/fs/pci-scan.fs b/slof/fs/pci-scan.fs
index 9114670..1132751 100644
--- a/slof/fs/pci-scan.fs
+++ b/slof/fs/pci-scan.fs
@@ -297,6 +297,15 @@ DEFER func-pci-probe-bus
LOOP \ else next bus
;
+: (probe-pci-host-bridge) ( bus-max bus-min -- )
+ 0d emit ." Adapters on " puid 10 0.r cr \ print the puid we're looking at
+ ( bus-max bus-min ) pci-probe-all \ and walk the bus
+ pci-device-number 0= IF \ IF no devices found
+ 15 spaces \ | indent the output
+ ." None" cr \ | tell the world our result
+ THEN \ FI
+;
+
\ probe the hostbridge that is specified in my-puid
\ for the mmio mem and io addresses:
\ base is the least available address
@@ -309,13 +318,7 @@ DEFER func-pci-probe-bus
pci-max-mem ! \ save the max mem-space address
pci-next-mmio ! \ save the next mmio-base address
pci-max-mmio ! \ save the max mmio-space address
-
- 0d emit ." Adapters on " puid 10 0.r cr \ print the puid we're looking at
- ( bus-max bus-min ) pci-probe-all \ and walk the bus
- pci-device-number 0= IF \ IF no devices found
- 15 spaces \ | indent the output
- ." None" cr \ | tell the world our result
- THEN \ FI
+ (probe-pci-host-bridge)
r> TO puid \ restore puid
;