Branch data Line data Source code
1 : : /* 2 : : * Copyright (c) 2019-2020 Nordic Semiconductor ASA 3 : : * 4 : : * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause 5 : : */ 6 : : 7 : : #include <zephyr/init.h> 8 : : #include <stdio.h> 9 : : #include <stdlib.h> 10 : : #include <string.h> 11 : : 12 : : #include <zephyr/kernel.h> 13 : : #include <zephyr/irq.h> 14 : : #include <zephyr/device.h> 15 : : 16 : : #include <nrf_cc3xx_platform.h> 17 : : 18 : : #if CONFIG_HW_CC3XX 19 : : 20 : 2 : static int hw_cc3xx_init_internal(const struct device *dev) 21 : : { 22 : : ARG_UNUSED(dev); 23 : : 24 : : int res; 25 : : 26 : : /* Initialize the cc3xx HW with or without RNG support */ 27 : : #if CONFIG_ENTROPY_CC3XX 28 : : res = nrf_cc3xx_platform_init(); 29 : : #else 30 : 2 : res = nrf_cc3xx_platform_init_no_rng(); 31 : : #endif 32 : : 33 : 2 : return res; 34 : : } 35 : : 36 : 1 : static int hw_cc3xx_init(const struct device *dev) 37 : : { 38 : : int res; 39 : : 40 : : /* Set the RTOS abort APIs */ 41 : 1 : nrf_cc3xx_platform_abort_init(); 42 : : 43 : : /* Set the RTOS mutex APIs */ 44 : 1 : nrf_cc3xx_platform_mutex_init(); 45 : : 46 : : /* Enable the hardware */ 47 : 1 : res = hw_cc3xx_init_internal(dev); 48 : 1 : return res; 49 : : } 50 : : 51 : : /* Driver initalization done when mutex is not usable (pre kernel) */ 52 : : SYS_INIT(hw_cc3xx_init_internal, PRE_KERNEL_1, 53 : : CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); 54 : : 55 : : /* Driver initialization when mutex is usable (post kernel) */ 56 : : SYS_INIT(hw_cc3xx_init, POST_KERNEL, 57 : : CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); 58 : : 59 : : #endif /* CONFIG_HW_CC3XX */ 60 : : 61 : : #if CONFIG_HW_CC3XX_INTERRUPT 62 : : 63 : : void hw_cc3XX_interrupt_init(void) 64 : : { 65 : : IRQ_CONNECT(DT_ARM_CRYPTOCELL_310_ARM_CRYPTOCELL_310_IRQ_0, 66 : : DT_ARM_CRYPTOCELL_310_ARM_CRYPTOCELL_310_IRQ_0_PRIORITY, 67 : : CRYPTOCELL_IRQHandler, NULL, 0); 68 : : irq_enable(DT_ARM_CRYPTOCELL_310_ARM_CRYPTOCELL_310_IRQ_0); 69 : : } 70 : : 71 : : #endif /* CONFIG_HW_CC3XX_INTERRUPT */