From 0223078e91d0016ae751b7e460b979d1d67d05c7 Mon Sep 17 00:00:00 2001 From: cepetr Date: Thu, 19 Dec 2024 14:04:02 +0100 Subject: [PATCH] WIP - optiga --- core/embed/sec/optiga/inc/sec/optiga_hal.h | 20 ++++++++++++++++++++ core/embed/sec/optiga/stm32/optiga_hal.c | 18 ++++++++++++++++++ core/embed/sec/optiga/unix/optiga_hal.c | 4 ++++ 3 files changed, 42 insertions(+) diff --git a/core/embed/sec/optiga/inc/sec/optiga_hal.h b/core/embed/sec/optiga/inc/sec/optiga_hal.h index c744c1c09b..f581a9e6e0 100644 --- a/core/embed/sec/optiga/inc/sec/optiga_hal.h +++ b/core/embed/sec/optiga/inc/sec/optiga_hal.h @@ -1,3 +1,21 @@ +/* + * This file is part of the Trezor project, https://trezor.io/ + * + * Copyright (c) SatoshiLabs + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #ifndef CORE_OPTIGA_HAL_H #define CORE_OPTIGA_HAL_H @@ -6,6 +24,8 @@ void optiga_hal_init(void); +void optiga_hal_deinit(void); + void optiga_reset(void); #endif // CORE_OPTIGA_HAL_H diff --git a/core/embed/sec/optiga/stm32/optiga_hal.c b/core/embed/sec/optiga/stm32/optiga_hal.c index 7cc5919d16..607c312fbf 100644 --- a/core/embed/sec/optiga/stm32/optiga_hal.c +++ b/core/embed/sec/optiga/stm32/optiga_hal.c @@ -38,6 +38,24 @@ void optiga_hal_init(void) { hal_delay(20); } +void optiga_hal_deinit(void) { + GPIO_InitTypeDef GPIO_InitStructure = {0}; + + GPIO_InitStructure.Mode = GPIO_MODE_ANALOG; + GPIO_InitStructure.Pull = GPIO_NOPULL; + GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStructure.Pin = OPTIGA_RST_PIN; + HAL_GPIO_Init(OPTIGA_RST_PORT, &GPIO_InitStructure); + +#ifdef OPTIGA_PWR_PIN + GPIO_InitStructure.Mode = GPIO_MODE_ANALOG; + GPIO_InitStructure.Pull = GPIO_NOPULL; + GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStructure.Pin = OPTIGA_PWR_PIN; + HAL_GPIO_Init(OPTIGA_PWR_PORT, &GPIO_InitStructure); +#endif +} + void optiga_reset(void) { HAL_GPIO_WritePin(OPTIGA_RST_PORT, OPTIGA_RST_PIN, GPIO_PIN_RESET); hal_delay(10); diff --git a/core/embed/sec/optiga/unix/optiga_hal.c b/core/embed/sec/optiga/unix/optiga_hal.c index 9bf346f028..6a817db42e 100644 --- a/core/embed/sec/optiga/unix/optiga_hal.c +++ b/core/embed/sec/optiga/unix/optiga_hal.c @@ -21,6 +21,10 @@ void optiga_hal_init(void) { // nothing to do } +void optiga_hal_deinit(void) { + // nothing to do +} + void optiga_reset(void) { // nothing to do }