aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/ccp
diff options
context:
space:
mode:
authorTom Lendacky <thomas.lendacky@amd.com>2014-06-05 11:17:45 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2014-06-20 09:26:11 -0400
commit3d77565ba5e5b9075a4f6d7d6d15996f5e582659 (patch)
treea1b04023142a3f0c46d03868509fb40e8bb44cc6 /drivers/crypto/ccp
parent64d1cdfbe20c50877576045145313c9b062c50f7 (diff)
crypto: ccp - Modify PCI support in prep for arm64 support
Modify the PCI device support in prep for supporting the CCP as a platform device for arm64. Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/ccp')
-rw-r--r--drivers/crypto/ccp/ccp-dev.h3
-rw-r--r--drivers/crypto/ccp/ccp-pci.c39
2 files changed, 15 insertions, 27 deletions
diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
index 7ec536e702ec..72bf1536b653 100644
--- a/drivers/crypto/ccp/ccp-dev.h
+++ b/drivers/crypto/ccp/ccp-dev.h
@@ -23,8 +23,6 @@
23#include <linux/hw_random.h> 23#include <linux/hw_random.h>
24 24
25 25
26#define IO_OFFSET 0x20000
27
28#define MAX_DMAPOOL_NAME_LEN 32 26#define MAX_DMAPOOL_NAME_LEN 32
29 27
30#define MAX_HW_QUEUES 5 28#define MAX_HW_QUEUES 5
@@ -194,6 +192,7 @@ struct ccp_device {
194 void *dev_specific; 192 void *dev_specific;
195 int (*get_irq)(struct ccp_device *ccp); 193 int (*get_irq)(struct ccp_device *ccp);
196 void (*free_irq)(struct ccp_device *ccp); 194 void (*free_irq)(struct ccp_device *ccp);
195 unsigned int irq;
197 196
198 /* 197 /*
199 * I/O area used for device communication. The register mapping 198 * I/O area used for device communication. The register mapping
diff --git a/drivers/crypto/ccp/ccp-pci.c b/drivers/crypto/ccp/ccp-pci.c
index 0d746236df5e..180cc87b4dbb 100644
--- a/drivers/crypto/ccp/ccp-pci.c
+++ b/drivers/crypto/ccp/ccp-pci.c
@@ -12,8 +12,10 @@
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/device.h>
15#include <linux/pci.h> 16#include <linux/pci.h>
16#include <linux/pci_ids.h> 17#include <linux/pci_ids.h>
18#include <linux/dma-mapping.h>
17#include <linux/kthread.h> 19#include <linux/kthread.h>
18#include <linux/sched.h> 20#include <linux/sched.h>
19#include <linux/interrupt.h> 21#include <linux/interrupt.h>
@@ -24,6 +26,8 @@
24#include "ccp-dev.h" 26#include "ccp-dev.h"
25 27
26#define IO_BAR 2 28#define IO_BAR 2
29#define IO_OFFSET 0x20000
30
27#define MSIX_VECTORS 2 31#define MSIX_VECTORS 2
28 32
29struct ccp_msix { 33struct ccp_msix {
@@ -89,7 +93,8 @@ static int ccp_get_msi_irq(struct ccp_device *ccp)
89 if (ret) 93 if (ret)
90 return ret; 94 return ret;
91 95
92 ret = request_irq(pdev->irq, ccp_irq_handler, 0, "ccp", dev); 96 ccp->irq = pdev->irq;
97 ret = request_irq(ccp->irq, ccp_irq_handler, 0, "ccp", dev);
93 if (ret) { 98 if (ret) {
94 dev_notice(dev, "unable to allocate MSI IRQ (%d)\n", ret); 99 dev_notice(dev, "unable to allocate MSI IRQ (%d)\n", ret);
95 goto e_msi; 100 goto e_msi;
@@ -136,7 +141,7 @@ static void ccp_free_irqs(struct ccp_device *ccp)
136 dev); 141 dev);
137 pci_disable_msix(pdev); 142 pci_disable_msix(pdev);
138 } else { 143 } else {
139 free_irq(pdev->irq, dev); 144 free_irq(ccp->irq, dev);
140 pci_disable_msi(pdev); 145 pci_disable_msi(pdev);
141 } 146 }
142} 147}
@@ -147,21 +152,12 @@ static int ccp_find_mmio_area(struct ccp_device *ccp)
147 struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); 152 struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
148 resource_size_t io_len; 153 resource_size_t io_len;
149 unsigned long io_flags; 154 unsigned long io_flags;
150 int bar;
151 155
152 io_flags = pci_resource_flags(pdev, IO_BAR); 156 io_flags = pci_resource_flags(pdev, IO_BAR);
153 io_len = pci_resource_len(pdev, IO_BAR); 157 io_len = pci_resource_len(pdev, IO_BAR);
154 if ((io_flags & IORESOURCE_MEM) && (io_len >= (IO_OFFSET + 0x800))) 158 if ((io_flags & IORESOURCE_MEM) && (io_len >= (IO_OFFSET + 0x800)))
155 return IO_BAR; 159 return IO_BAR;
156 160
157 for (bar = 0; bar < PCI_STD_RESOURCE_END; bar++) {
158 io_flags = pci_resource_flags(pdev, bar);
159 io_len = pci_resource_len(pdev, bar);
160 if ((io_flags & IORESOURCE_MEM) &&
161 (io_len >= (IO_OFFSET + 0x800)))
162 return bar;
163 }
164
165 return -EIO; 161 return -EIO;
166} 162}
167 163
@@ -214,20 +210,13 @@ static int ccp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
214 } 210 }
215 ccp->io_regs = ccp->io_map + IO_OFFSET; 211 ccp->io_regs = ccp->io_map + IO_OFFSET;
216 212
217 ret = dma_set_mask(dev, DMA_BIT_MASK(48)); 213 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
218 if (ret == 0) { 214 if (ret) {
219 ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(48)); 215 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
220 if (ret) { 216 if (ret) {
221 dev_err(dev, 217 dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n",
222 "pci_set_consistent_dma_mask failed (%d)\n",
223 ret); 218 ret);
224 goto e_bar0; 219 goto e_iomap;
225 }
226 } else {
227 ret = dma_set_mask(dev, DMA_BIT_MASK(32));
228 if (ret) {
229 dev_err(dev, "pci_set_dma_mask failed (%d)\n", ret);
230 goto e_bar0;
231 } 220 }
232 } 221 }
233 222
@@ -235,13 +224,13 @@ static int ccp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
235 224
236 ret = ccp_init(ccp); 225 ret = ccp_init(ccp);
237 if (ret) 226 if (ret)
238 goto e_bar0; 227 goto e_iomap;
239 228
240 dev_notice(dev, "enabled\n"); 229 dev_notice(dev, "enabled\n");
241 230
242 return 0; 231 return 0;
243 232
244e_bar0: 233e_iomap:
245 pci_iounmap(pdev, ccp->io_map); 234 pci_iounmap(pdev, ccp->io_map);
246 235
247e_device: 236e_device: