From e9aed8dd7a1e66ff8a5855cc662d7056db10dc93 Mon Sep 17 00:00:00 2001 From: dron0gus Date: Sun, 21 Apr 2019 17:35:13 +0300 Subject: [PATCH] Smart gpio error path and minor fixes (#772) * smart_gpio: fix error path If chip driver disable in FW, disabled in settings or failed to init we still need to ocupy its gpio range. * smart_gpio: get tle6240 CS from config * smart_gpio: fix debug messaging --- firmware/hw_layer/smart_gpio.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/firmware/hw_layer/smart_gpio.cpp b/firmware/hw_layer/smart_gpio.cpp index c3b1bc8d15..d9362c2c09 100644 --- a/firmware/hw_layer/smart_gpio.cpp +++ b/firmware/hw_layer/smart_gpio.cpp @@ -129,14 +129,16 @@ struct tle8888_config tle8888_cfg = { void initSmartGpio() { startSmartCsPins(); - int ret; + int ret = -1; #if (BOARD_TLE6240_COUNT > 0) if (engineConfiguration->tle6240_cs != GPIO_UNASSIGNED) { + tle6240.spi_config.ssport = getHwPort("tle6240 CS", engineConfiguration->tle6240_cs); + tle6240.spi_config.sspad = getHwPin("tle6240 CS", engineConfiguration->tle6240_cs); tle6240.spi_bus = getSpiDevice(engineConfiguration->tle6240spiDevice); ret = tle6240_add(0, &tle6240); } else { - ret = 0; + ret = -1; } if (ret < 0) #endif /* (BOARD_TLE6240_COUNT > 0) */ @@ -146,13 +148,13 @@ void initSmartGpio() { #if (BOARD_MC33972_COUNT > 0) if (boardConfiguration->mc33972_cs != GPIO_UNASSIGNED) { // todo: reuse initSpiCs method? - mc33972.spi_config.ssport = getHwPort("tle8888 CS", boardConfiguration->mc33972_cs); - mc33972.spi_config.sspad = getHwPin("tle8888 CS", boardConfiguration->mc33972_cs); + mc33972.spi_config.ssport = getHwPort("mc33972 CS", boardConfiguration->mc33972_cs); + mc33972.spi_config.sspad = getHwPin("mc33972 CS", boardConfiguration->mc33972_cs); mc33972.spi_bus = getSpiDevice(engineConfiguration->mc33972spiDevice); // todo: propogate 'basePinOffset' parameter ret = mc33972_add(0, &mc33972); } else { - ret = 0; + ret = -1; } if (ret < 0) #endif /* (BOARD_MC33972_COUNT > 0) */ @@ -173,7 +175,7 @@ void initSmartGpio() { efiAssertVoid(OBD_PCM_Processor_Fault, ret == TLE8888_PIN_1, "tle8888"); } else { - ret = 0; + ret = -1; } if (ret < 0) #endif /* (BOARD_TLE6240_COUNT > 0) */