diff options
author | Gavin Shan <gwshan@linux.vnet.ibm.com> | 2016-08-11 12:12:38 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2016-09-02 15:31:42 +1000 |
commit | 0736df56df7c457f4cdfe3e4ad85180877d00569 (patch) | |
tree | be82e089a1bb23d738e3e345bf75566bc85a4aca /hw/npu-hw-procedures.c | |
parent | 85daa7f00c5001593f28eb0e975b94921f3cd023 (diff) | |
download | skiboot-0736df56df7c457f4cdfe3e4ad85180877d00569.zip skiboot-0736df56df7c457f4cdfe3e4ad85180877d00569.tar.gz skiboot-0736df56df7c457f4cdfe3e4ad85180877d00569.tar.bz2 |
hw/npu: Use PCI virtual device
This rmoves the codes for emulated PCI config space as it can be
supported by generic PCI virtual device:
* The PCI virtual device and NPU device are created at same time.
* Uses PCI virtual device and filter to access NPU (PCI) device's
config space.
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Reviewed-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw/npu-hw-procedures.c')
-rw-r--r-- | hw/npu-hw-procedures.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/hw/npu-hw-procedures.c b/hw/npu-hw-procedures.c index cc3dcad..85f09a1 100644 --- a/hw/npu-hw-procedures.c +++ b/hw/npu-hw-procedures.c @@ -17,6 +17,7 @@ #include <io.h> #include <timebase.h> #include <pci.h> +#include <pci-virt.h> #include <interrupts.h> #include <npu-regs.h> #include <npu.h> @@ -506,12 +507,9 @@ static uint32_t get_procedure_status(struct npu_dev *dev) return dev->procedure_status; } -int64_t npu_dev_procedure_read(struct npu_dev_trap *trap, - uint32_t offset, - uint32_t size, - uint32_t *data) +static int64_t npu_dev_procedure_read(struct npu_dev *dev, uint32_t offset, + uint32_t size, uint32_t *data) { - struct npu_dev *dev = trap->dev; int64_t rc = OPAL_SUCCESS; if (size != 4) { @@ -520,7 +518,6 @@ int64_t npu_dev_procedure_read(struct npu_dev_trap *trap, return OPAL_PARAMETER; } - offset -= trap->start; *data = 0; switch (offset) { @@ -546,12 +543,9 @@ int64_t npu_dev_procedure_read(struct npu_dev_trap *trap, return rc; } -int64_t npu_dev_procedure_write(struct npu_dev_trap *trap, - uint32_t offset, - uint32_t size, - uint32_t data) +static int64_t npu_dev_procedure_write(struct npu_dev *dev, uint32_t offset, + uint32_t size, uint32_t data) { - struct npu_dev *dev = trap->dev; const char *name; int64_t rc = OPAL_SUCCESS; @@ -562,8 +556,6 @@ int64_t npu_dev_procedure_write(struct npu_dev_trap *trap, return OPAL_PARAMETER; } - offset -= trap->start; - switch (offset) { case 0: /* We ignore writes to the status register */ @@ -600,3 +592,17 @@ int64_t npu_dev_procedure_write(struct npu_dev_trap *trap, return rc; } + +int64_t npu_dev_procedure(void *dev, struct pci_cfg_reg_filter *pcrf, + uint32_t offset, uint32_t len, uint32_t *data, + bool write) +{ + struct pci_virt_device *pvd = dev; + struct npu_dev *ndev = pvd->data; + + if (write) + return npu_dev_procedure_write(ndev, offset - pcrf->start, + len, *data); + + return npu_dev_procedure_read(ndev, offset - pcrf->start, len, data); +} |