From 815fe672a75d569df584c1399a749f75ae5a25a2 Mon Sep 17 00:00:00 2001 From: Ian Pozella Date: Mon, 5 Dec 2016 13:27:38 +0000 Subject: [PATCH 1/4] move pistachio watchdog init to common location Signed-off-by: Ian Pozella --- board/imgtec/pistachio_bub/pistachio.c | 3 --- common/board_f.c | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/board/imgtec/pistachio_bub/pistachio.c b/board/imgtec/pistachio_bub/pistachio.c index e0113028ca..02f80edbf7 100644 --- a/board/imgtec/pistachio_bub/pistachio.c +++ b/board/imgtec/pistachio_bub/pistachio.c @@ -201,9 +201,6 @@ int board_late_init(void) printf("Failed to enable tpm!\n"); return 1; } -#endif -#ifdef CONFIG_PISTACHIO_WATCHDOG - hw_watchdog_init(); #endif return 0; } diff --git a/common/board_f.c b/common/board_f.c index 99b4d8eba2..fffb2772e6 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -115,7 +115,7 @@ static int init_func_watchdog_init(void) # if defined(CONFIG_HW_WATCHDOG) && (defined(CONFIG_BLACKFIN) || \ defined(CONFIG_M68K) || defined(CONFIG_MICROBLAZE) || \ defined(CONFIG_SH) || defined(CONFIG_AT91SAM9_WATCHDOG) || \ - defined(CONFIG_IMX_WATCHDOG)) + defined(CONFIG_IMX_WATCHDOG) || defined(CONFIG_PISTACHIO_WATCHDOG)) hw_watchdog_init(); # endif puts(" Watchdog enabled\n"); From 5d39860c9d0a4dfd16a9a154ffa116f2d25db61a Mon Sep 17 00:00:00 2001 From: Ian Pozella Date: Wed, 7 Dec 2016 12:00:52 +0000 Subject: [PATCH 2/4] pistachio: enable command tpmtest Signed-off-by: Ian Pozella --- include/configs/pistachio_bub.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/configs/pistachio_bub.h b/include/configs/pistachio_bub.h index c8c21fa77c..b15abbb5d3 100644 --- a/include/configs/pistachio_bub.h +++ b/include/configs/pistachio_bub.h @@ -233,6 +233,7 @@ #define CONFIG_TPM_TIS_I2C_SLAVE_ADDRESS 0x20 #define CONFIG_TPM_TIS_I2C #define CONFIG_CMD_TPM +#define CONFIG_CMD_TPM_TEST /* MMC - Sdhost */ #define CONFIG_MMC From 6ee24785d94e787ec8afbbe114821ad21b72e372 Mon Sep 17 00:00:00 2001 From: Ian Pozella Date: Mon, 5 Dec 2016 14:35:23 +0000 Subject: [PATCH 3/4] pistachio: enable board late init We define some empty implementations of the board_*_init functions but don't actually have them enabled. This is confusing as if used they won't actually do anything. Therefore have enabled any that we actually use and removed empty definitions of disabled ones. Signed-off-by: Ian Pozella --- board/imgtec/pistachio_bub/pistachio.c | 5 ----- include/configs/pistachio_bub.h | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/board/imgtec/pistachio_bub/pistachio.c b/board/imgtec/pistachio_bub/pistachio.c index 02f80edbf7..d1b431d917 100644 --- a/board/imgtec/pistachio_bub/pistachio.c +++ b/board/imgtec/pistachio_bub/pistachio.c @@ -205,11 +205,6 @@ int board_late_init(void) return 0; } -int misc_init_r(void) -{ - return 0; -} - #ifndef DM_SERIAL struct serial_device *default_serial_console(void) { diff --git a/include/configs/pistachio_bub.h b/include/configs/pistachio_bub.h index b15abbb5d3..fedd629db3 100644 --- a/include/configs/pistachio_bub.h +++ b/include/configs/pistachio_bub.h @@ -21,6 +21,7 @@ #define CONFIG_PISTACHIO #define PISTACHIO_BOARD_NAME CONFIG_SYS_CONFIG_NAME #define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_BOARD_LATE_INIT #define CONFIG_DISPLAY_BOARDINFO #define CONFIG_WINBOND_OTP #define CONFIG_OF_LIBFDT From 6777381bf9f65fcf49336b3d691fd1668bef1e0e Mon Sep 17 00:00:00 2001 From: Ian Pozella Date: Mon, 5 Dec 2016 14:44:26 +0000 Subject: [PATCH 4/4] marduk: reset the tpm The current version of the board has the tpm reset line connected to a gpio. This causes security issues meaning we need a new HW spin but to make do with what we have at least reset the tpm on boot. Therfore have added mfio_setup_tpm function and call it as part of tpm initialisation. This is certainly not the best place to put this but considering the current arch of 'pistachio_bub is king' there isn't much else we can do without refactoring everything. Signed-off-by: Ian Pozella --- board/imgtec/pistachio_bub/mfio.c | 14 ++++++++++++++ board/imgtec/pistachio_bub/mfio.h | 4 ++++ board/imgtec/pistachio_bub/pistachio.c | 11 +++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/board/imgtec/pistachio_bub/mfio.c b/board/imgtec/pistachio_bub/mfio.c index 7e960faff9..17251f8996 100644 --- a/board/imgtec/pistachio_bub/mfio.c +++ b/board/imgtec/pistachio_bub/mfio.c @@ -5,6 +5,7 @@ * SPDX-License-Identifier: GPL-2.0+ */ +#include #include #include #include "mfio.h" @@ -327,3 +328,16 @@ void mfio_setup_led(void) pistachio_set_gpio_output_state(76, 1); } #endif + +#if defined(CONFIG_TARGET_PISTACHIO_MARDUK) +void mfio_setup_tpm(void) +{ + /* Reset the TPM, first versions of the board + have the tpm reset connected to gpio 42 instead + of directly connected to system reset */ + pistachio_configure_gpio(42, 1); + pistachio_set_gpio_output_state(42, 0); + udelay(100); + pistachio_set_gpio_output_state(42, 1); +} +#endif diff --git a/board/imgtec/pistachio_bub/mfio.h b/board/imgtec/pistachio_bub/mfio.h index e7d4d68e13..e6c7b54563 100644 --- a/board/imgtec/pistachio_bub/mfio.h +++ b/board/imgtec/pistachio_bub/mfio.h @@ -189,3 +189,7 @@ void mfio_setup_usb_pwr(void); #if defined(CONFIG_TARGET_PISTACHIO_MARDUK) void mfio_setup_led(void); #endif + +#if defined(CONFIG_TARGET_PISTACHIO_MARDUK) +void mfio_setup_tpm(void); +#endif diff --git a/board/imgtec/pistachio_bub/pistachio.c b/board/imgtec/pistachio_bub/pistachio.c index d1b431d917..285e389093 100644 --- a/board/imgtec/pistachio_bub/pistachio.c +++ b/board/imgtec/pistachio_bub/pistachio.c @@ -197,10 +197,17 @@ int board_early_init_f(void) int board_late_init(void) { #ifdef CONFIG_TPM - if (tpm_init() || tpm_startup(TPM_ST_CLEAR)) { - printf("Failed to enable tpm!\n"); + uint32_t result; + + mfio_setup_tpm(); + udelay(10000); + tpm_init(); + result = tpm_startup(TPM_ST_CLEAR); + if (result != 0) { + printf("tpm startup failed with 0x%x\n", result); return 1; } + printf("TPM: Infineon (1.2)\n"); #endif return 0; }