diff options
Diffstat (limited to 'drivers/crypto/ccp/ccp-dev.c')
| -rw-r--r-- | drivers/crypto/ccp/ccp-dev.c | 48 | 
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c index 2c7816149b01..c6e6171eb6d3 100644 --- a/drivers/crypto/ccp/ccp-dev.c +++ b/drivers/crypto/ccp/ccp-dev.c @@ -20,7 +20,9 @@  #include <linux/delay.h>  #include <linux/hw_random.h>  #include <linux/cpu.h> +#ifdef CONFIG_X86  #include <asm/cpu_device_id.h> +#endif  #include <linux/ccp.h>  #include "ccp-dev.h" @@ -53,6 +55,20 @@ static inline void ccp_del_device(struct ccp_device *ccp)  }  /** + * ccp_present - check if a CCP device is present + * + * Returns zero if a CCP device is present, -ENODEV otherwise. + */ +int ccp_present(void) +{ +	if (ccp_get_device()) +		return 0; + +	return -ENODEV; +} +EXPORT_SYMBOL_GPL(ccp_present); + +/**   * ccp_enqueue_cmd - queue an operation for processing by the CCP   *   * @cmd: ccp_cmd struct to be processed @@ -360,6 +376,12 @@ int ccp_init(struct ccp_device *ccp)  		/* Build queue interrupt mask (two interrupts per queue) */  		qim |= cmd_q->int_ok | cmd_q->int_err; +#ifdef CONFIG_ARM64 +		/* For arm64 set the recommended queue cache settings */ +		iowrite32(ccp->axcache, ccp->io_regs + CMD_Q_CACHE_BASE + +			  (CMD_Q_CACHE_INC * i)); +#endif +  		dev_dbg(dev, "queue #%u available\n", i);  	}  	if (ccp->cmd_q_count == 0) { @@ -558,12 +580,15 @@ bool ccp_queues_suspended(struct ccp_device *ccp)  }  #endif +#ifdef CONFIG_X86  static const struct x86_cpu_id ccp_support[] = {  	{ X86_VENDOR_AMD, 22, },  }; +#endif  static int __init ccp_mod_init(void)  { +#ifdef CONFIG_X86  	struct cpuinfo_x86 *cpuinfo = &boot_cpu_data;  	int ret; @@ -589,12 +614,30 @@ static int __init ccp_mod_init(void)  		break;  	} +#endif + +#ifdef CONFIG_ARM64 +	int ret; + +	ret = ccp_platform_init(); +	if (ret) +		return ret; + +	/* Don't leave the driver loaded if init failed */ +	if (!ccp_get_device()) { +		ccp_platform_exit(); +		return -ENODEV; +	} + +	return 0; +#endif  	return -ENODEV;  }  static void __exit ccp_mod_exit(void)  { +#ifdef CONFIG_X86  	struct cpuinfo_x86 *cpuinfo = &boot_cpu_data;  	switch (cpuinfo->x86) { @@ -602,6 +645,11 @@ static void __exit ccp_mod_exit(void)  		ccp_pci_exit();  		break;  	} +#endif + +#ifdef CONFIG_ARM64 +	ccp_platform_exit(); +#endif  }  module_init(ccp_mod_init);  |