diff options
Diffstat (limited to 'board-qemu/slof')
-rw-r--r-- | board-qemu/slof/pci-capabilities.fs | 4 | ||||
-rw-r--r-- | board-qemu/slof/pci-interrupts.fs | 8 | ||||
-rw-r--r-- | board-qemu/slof/pci-phb.fs | 88 | ||||
-rw-r--r-- | board-qemu/slof/rtas.fs | 5 | ||||
-rw-r--r-- | board-qemu/slof/tree.fs | 2 |
5 files changed, 86 insertions, 21 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 |