spapr_pci: add set-indicator RTAS interface

Authored-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
spapr_pci: add get/set-power-level RTAS interfaces

Authored-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
spapr_pci: add get-sensor-state RTAS interface

Authored-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
spapr_pci: add ibm,configure-connector RTAS interface

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
spapr: populate DRC entries for root dt node

Authored-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
spapr_pci: populate DRC dt entries for PHBs

Reserve 32 entries of type PCI in each PHB's initial FDT. This
is necessary for allowing hotplugging of devices to it later.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
spapr: add helper to retrieve a PHB/device DrcEntry

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
memory: add memory_region_find_subregion

Similar to memory_region_find, but only search for overlaps among
regions that are a child of the region passed in. This is useful
for finding free ranges within a parent range to map to, in
addition to the use-cases similarly served by memory_region_find.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
pci: make pci_bar useable outside pci.c

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
pci: allow 0 address for PCI IO regions

Some kernels program a 0 address for memory regions.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
spapr_pci: enable basic hotplug operations

Authored-by: Mike Day <ncmike@ncultra.org>
Signed-off-by: Mike Day <ncmike@ncultra.org>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
spapr_pci: add dt entries for hotplugged devices at boot time

This is necessary for hotplugged devices to be detected by kernel
hotplug module and userspace tools as removable after a reboot.

Ideally, SLOF would do this for us, or merge pre-existing nodes/entries
into what it discovers via probing. Currently, we end up with 2 nodes in
the boot-time DT: pci@<slotno> entries added by us, and <class>@<slotno>
entries added by firmware. Kernel/drmgr ends up picking up our version,
so we need to create entries exhaustively as with hotplug rather than
letting firmware handle it after a reboot.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
spapr_events: re-use EPOW event infrastructure for hotplug events

This should be moved after all the other infrastructure, somewhere
before or after event-scan stuff.

Authored-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
spapr_events: event-scan RTAS interface

Authored-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
spapr_pci: emit hotplug add/remove events during hotplug

Guest tools will use these events to automate device setup/teardown.

Note: this interface is undocumented, and potentially racey with
'physical' removal. We can remove the race by tying actual removal
to set-indicator RTAS calls, but should finalize it and document
meant it in SPAPR at some point. For now we restrict this to being
a drmgr-specific extention.

Authored-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>