pci-properties: add properties to enable hotplug for spapr

drmgr expects ibm,my-drc-index and ibm,loc-code OF properties in
the corresponding device tree node to determine whether a
pre-populated slot is hotpluggable/unpluggable. This is also
stated as a boot-time requirement for DR-capable devices in SPAPR,
though it does not specify there how these entries are to be generated.

In the case of QEMU, hotpluggable slots are allocated entries based on
bus/slotno values, so we can determine these entries statically at
boot-time, rather than relying on RTAS calls as we would during
OS-driven configuration.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
diff --git a/board-qemu/slof/pci-phb.fs b/board-qemu/slof/pci-phb.fs
index 57e778a..4f8e702 100644
--- a/board-qemu/slof/pci-phb.fs
+++ b/board-qemu/slof/pci-phb.fs
@@ -283,6 +283,7 @@
    puid >r                          \ Save old value of puid
    my-puid TO puid                  \ Set current puid
    phb-parse-ranges
+   1 TO pci-hotplug-enabled
    1 0 (probe-pci-host-bridge)
    r> TO puid                       \ Restore previous puid
 ;
diff --git a/slof/fs/pci-properties.fs b/slof/fs/pci-properties.fs
index 7816a22..f88a571 100644
--- a/slof/fs/pci-properties.fs
+++ b/slof/fs/pci-properties.fs
@@ -589,6 +589,20 @@
         dup pci-sub-vendor@ ?dup IF encode-int s" subsystem-vendor-id" property THEN
         dup pci-device-assigned-addresses-prop
         pci-reg-props
+        pci-hotplug-enabled IF
+            \ QEMU uses static assignments for my-drc-index:
+            \ 40000000h + $bus << 8 + $slot << 3
+            dup dup pci-addr2bus 8 lshift
+            swap pci-addr2dev 3 lshift or
+            40000000 + encode-int s" ibm,my-drc-index" property
+            \ QEMU uses "Slot $bus*32$slotno" for loc-code
+            dup dup pci-addr2bus 20 *
+            swap pci-addr2dev +
+            a base !
+            s" Slot " rot $cathex
+            hex
+            encode-string s" ibm,loc-code" property
+        THEN
 ;
 
 \ set up bridge only properties
diff --git a/slof/fs/pci-scan.fs b/slof/fs/pci-scan.fs
index 99eeef2..ec9bd27 100644
--- a/slof/fs/pci-scan.fs
+++ b/slof/fs/pci-scan.fs
@@ -36,6 +36,8 @@
 \       the 3rd slot on the HostBridge bus
 here 100 allot CONSTANT pci-device-vec
 0 VALUE pci-device-vec-len
+\ enable/disable creation of hotplug-specific properties
+0 VALUE pci-hotplug-enabled
 
 
 \ Fixme Glue to the pci-devices ... remove this later