diff options
author | Brijesh Singh <brijesh.singh@amd.com> | 2017-07-06 17:59:14 +0300 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2017-07-18 12:51:19 +0300 |
commit | 720419f01832f7e697cb80480b97b2a1e96045cd (patch) | |
tree | 1275fa5e6cf63b7bb9db6ab2e191d4b7d076ca4f /drivers/crypto/ccp/ccp-platform.c | |
parent | 970e8303cb8d6d8e77402345abbdd83862e800ac (diff) | |
download | linux-720419f01832f7e697cb80480b97b2a1e96045cd.tar.xz |
crypto: ccp - Introduce the AMD Secure Processor device
The CCP device is part of the AMD Secure Processor. In order to expand
the usage of the AMD Secure Processor, create a framework that allows
functional components of the AMD Secure Processor to be initialized and
handled appropriately.
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Acked-by: Gary R Hook <gary.hook@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/ccp/ccp-platform.c')
-rw-r--r-- | drivers/crypto/ccp/ccp-platform.c | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/drivers/crypto/ccp/ccp-platform.c b/drivers/crypto/ccp/ccp-platform.c index 613188c5a624..419e00ccf532 100644 --- a/drivers/crypto/ccp/ccp-platform.c +++ b/drivers/crypto/ccp/ccp-platform.c @@ -35,26 +35,26 @@ struct ccp_platform { static const struct acpi_device_id ccp_acpi_match[]; static const struct of_device_id ccp_of_match[]; -static struct ccp_vdata *ccp_get_of_version(struct platform_device *pdev) +static struct sp_dev_vdata *ccp_get_of_version(struct platform_device *pdev) { #ifdef CONFIG_OF const struct of_device_id *match; match = of_match_node(ccp_of_match, pdev->dev.of_node); if (match && match->data) - return (struct ccp_vdata *)match->data; + return (struct sp_dev_vdata *)match->data; #endif return NULL; } -static struct ccp_vdata *ccp_get_acpi_version(struct platform_device *pdev) +static struct sp_dev_vdata *ccp_get_acpi_version(struct platform_device *pdev) { #ifdef CONFIG_ACPI const struct acpi_device_id *match; match = acpi_match_device(ccp_acpi_match, &pdev->dev); if (match && match->driver_data) - return (struct ccp_vdata *)match->driver_data; + return (struct sp_dev_vdata *)match->driver_data; #endif return NULL; } @@ -73,7 +73,7 @@ static int ccp_get_irq(struct ccp_device *ccp) ccp->irq = ret; ret = request_irq(ccp->irq, ccp->vdata->perform->irqhandler, 0, - ccp->name, dev); + ccp->name, ccp); if (ret) { dev_notice(dev, "unable to allocate IRQ (%d)\n", ret); return ret; @@ -99,14 +99,12 @@ static int ccp_get_irqs(struct ccp_device *ccp) static void ccp_free_irqs(struct ccp_device *ccp) { - struct device *dev = ccp->dev; - - free_irq(ccp->irq, dev); + free_irq(ccp->irq, ccp); } static int ccp_platform_probe(struct platform_device *pdev) { - struct ccp_device *ccp; + struct sp_device *sp; struct ccp_platform *ccp_platform; struct device *dev = &pdev->dev; enum dev_dma_attr attr; @@ -114,32 +112,31 @@ static int ccp_platform_probe(struct platform_device *pdev) int ret; ret = -ENOMEM; - ccp = ccp_alloc_struct(dev); - if (!ccp) + sp = sp_alloc_struct(dev); + if (!sp) goto e_err; ccp_platform = devm_kzalloc(dev, sizeof(*ccp_platform), GFP_KERNEL); if (!ccp_platform) goto e_err; - ccp->dev_specific = ccp_platform; - ccp->vdata = pdev->dev.of_node ? ccp_get_of_version(pdev) + sp->dev_specific = ccp_platform; + sp->dev_vdata = pdev->dev.of_node ? ccp_get_of_version(pdev) : ccp_get_acpi_version(pdev); - if (!ccp->vdata || !ccp->vdata->version) { + if (!sp->dev_vdata) { ret = -ENODEV; dev_err(dev, "missing driver data\n"); goto e_err; } - ccp->get_irq = ccp_get_irqs; - ccp->free_irq = ccp_free_irqs; + sp->get_irq = ccp_get_irqs; + sp->free_irq = ccp_free_irqs; ior = platform_get_resource(pdev, IORESOURCE_MEM, 0); - ccp->io_map = devm_ioremap_resource(dev, ior); - if (IS_ERR(ccp->io_map)) { - ret = PTR_ERR(ccp->io_map); + sp->io_map = devm_ioremap_resource(dev, ior); + if (IS_ERR(sp->io_map)) { + ret = PTR_ERR(sp->io_map); goto e_err; } - ccp->io_regs = ccp->io_map; attr = device_get_dma_attr(dev); if (attr == DEV_DMA_NOT_SUPPORTED) { @@ -149,9 +146,9 @@ static int ccp_platform_probe(struct platform_device *pdev) ccp_platform->coherent = (attr == DEV_DMA_COHERENT); if (ccp_platform->coherent) - ccp->axcache = CACHE_WB_NO_ALLOC; + sp->axcache = CACHE_WB_NO_ALLOC; else - ccp->axcache = CACHE_NONE; + sp->axcache = CACHE_NONE; ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48)); if (ret) { @@ -159,9 +156,9 @@ static int ccp_platform_probe(struct platform_device *pdev) goto e_err; } - dev_set_drvdata(dev, ccp); + dev_set_drvdata(dev, sp); - ret = ccp_dev_init(ccp); + ret = sp_init(sp); if (ret) goto e_err; @@ -177,9 +174,9 @@ e_err: static int ccp_platform_remove(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct ccp_device *ccp = dev_get_drvdata(dev); + struct sp_device *sp = dev_get_drvdata(dev); - ccp_dev_destroy(ccp); + sp_destroy(sp); dev_notice(dev, "disabled\n"); @@ -191,23 +188,32 @@ static int ccp_platform_suspend(struct platform_device *pdev, pm_message_t state) { struct device *dev = &pdev->dev; - struct ccp_device *ccp = dev_get_drvdata(dev); + struct sp_device *sp = dev_get_drvdata(dev); - return ccp_dev_suspend(ccp, state); + return sp_suspend(sp, state); } static int ccp_platform_resume(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct ccp_device *ccp = dev_get_drvdata(dev); + struct sp_device *sp = dev_get_drvdata(dev); - return ccp_dev_resume(ccp); + return sp_resume(sp); } #endif +static const struct sp_dev_vdata dev_vdata[] = { + { + .bar = 0, +#ifdef CONFIG_CRYPTO_DEV_SP_CCP + .ccp_vdata = &ccpv3_platform, +#endif + }, +}; + #ifdef CONFIG_ACPI static const struct acpi_device_id ccp_acpi_match[] = { - { "AMDI0C00", (kernel_ulong_t)&ccpv3 }, + { "AMDI0C00", (kernel_ulong_t)&dev_vdata[0] }, { }, }; MODULE_DEVICE_TABLE(acpi, ccp_acpi_match); @@ -216,7 +222,7 @@ MODULE_DEVICE_TABLE(acpi, ccp_acpi_match); #ifdef CONFIG_OF static const struct of_device_id ccp_of_match[] = { { .compatible = "amd,ccp-seattle-v1a", - .data = (const void *)&ccpv3_platform }, + .data = (const void *)&dev_vdata[0] }, { }, }; MODULE_DEVICE_TABLE(of, ccp_of_match); |