Commit fba8855c authored by Gary R Hook's avatar Gary R Hook Committed by Herbert Xu

crypto: ccp - Abstract PCI info for the CCP

Device-specific values for the BAR and offset should be found
in the version data structure.
Signed-off-by: default avatarGary R Hook <gary.hook@amd.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent fa242e80
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Copyright (C) 2013,2016 Advanced Micro Devices, Inc. * Copyright (C) 2013,2016 Advanced Micro Devices, Inc.
* *
* Author: Tom Lendacky <thomas.lendacky@amd.com> * Author: Tom Lendacky <thomas.lendacky@amd.com>
* Author: Gary R Hook <gary.hook@amd.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
...@@ -541,4 +542,6 @@ static const struct ccp_actions ccp3_actions = { ...@@ -541,4 +542,6 @@ static const struct ccp_actions ccp3_actions = {
struct ccp_vdata ccpv3 = { struct ccp_vdata ccpv3 = {
.version = CCP_VERSION(3, 0), .version = CCP_VERSION(3, 0),
.perform = &ccp3_actions, .perform = &ccp3_actions,
.bar = 2,
.offset = 0x20000,
}; };
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Copyright (C) 2013,2016 Advanced Micro Devices, Inc. * Copyright (C) 2013,2016 Advanced Micro Devices, Inc.
* *
* Author: Tom Lendacky <thomas.lendacky@amd.com> * Author: Tom Lendacky <thomas.lendacky@amd.com>
* Author: Gary R Hook <gary.hook@amd.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
...@@ -163,6 +164,8 @@ struct ccp_actions { ...@@ -163,6 +164,8 @@ struct ccp_actions {
struct ccp_vdata { struct ccp_vdata {
unsigned int version; unsigned int version;
const struct ccp_actions *perform; const struct ccp_actions *perform;
const unsigned int bar;
const unsigned int offset;
}; };
extern struct ccp_vdata ccpv3; extern struct ccp_vdata ccpv3;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Copyright (C) 2013,2016 Advanced Micro Devices, Inc. * Copyright (C) 2013,2016 Advanced Micro Devices, Inc.
* *
* Author: Tom Lendacky <thomas.lendacky@amd.com> * Author: Tom Lendacky <thomas.lendacky@amd.com>
* Author: Gary R Hook <gary.hook@amd.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
...@@ -25,9 +26,6 @@ ...@@ -25,9 +26,6 @@
#include "ccp-dev.h" #include "ccp-dev.h"
#define IO_BAR 2
#define IO_OFFSET 0x20000
#define MSIX_VECTORS 2 #define MSIX_VECTORS 2
struct ccp_msix { struct ccp_msix {
...@@ -156,10 +154,11 @@ static int ccp_find_mmio_area(struct ccp_device *ccp) ...@@ -156,10 +154,11 @@ static int ccp_find_mmio_area(struct ccp_device *ccp)
resource_size_t io_len; resource_size_t io_len;
unsigned long io_flags; unsigned long io_flags;
io_flags = pci_resource_flags(pdev, IO_BAR); io_flags = pci_resource_flags(pdev, ccp->vdata->bar);
io_len = pci_resource_len(pdev, IO_BAR); io_len = pci_resource_len(pdev, ccp->vdata->bar);
if ((io_flags & IORESOURCE_MEM) && (io_len >= (IO_OFFSET + 0x800))) if ((io_flags & IORESOURCE_MEM) &&
return IO_BAR; (io_len >= (ccp->vdata->offset + 0x800)))
return ccp->vdata->bar;
return -EIO; return -EIO;
} }
...@@ -216,7 +215,7 @@ static int ccp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -216,7 +215,7 @@ static int ccp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
dev_err(dev, "pci_iomap failed\n"); dev_err(dev, "pci_iomap failed\n");
goto e_device; goto e_device;
} }
ccp->io_regs = ccp->io_map + IO_OFFSET; ccp->io_regs = ccp->io_map + ccp->vdata->offset;
ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48)); ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
if (ret) { if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment