From e51ceb7a8006998c5d3e3a6ae8508584a4dcc7db Mon Sep 17 00:00:00 2001 From: Dino Li Date: Wed, 19 May 2021 12:05:33 +0800 Subject: zephyr: shi/it8xxx2: Ensure spi chip select alt function is enabled. BUG=b:188577674, b:180980668 BRANCH=none TEST=boot to kernel on Asurada. (with connecting both AC and battery) Signed-off-by: Dino Li Change-Id: Icbcdfbad611eed4b7684c05133a4a20fed245353 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2905038 Reviewed-by: Denis Brockus --- zephyr/drivers/cros_shi/cros_shi_it8xxx2.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/zephyr/drivers/cros_shi/cros_shi_it8xxx2.c b/zephyr/drivers/cros_shi/cros_shi_it8xxx2.c index 1fd3cc4e96..0c0391afe7 100644 --- a/zephyr/drivers/cros_shi/cros_shi_it8xxx2.c +++ b/zephyr/drivers/cros_shi/cros_shi_it8xxx2.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include "console.h" #include "host_command.h" @@ -258,6 +260,10 @@ static void shi_ite_int_handler(const void *arg) } +/* + * SHI init priority is behind CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY to + * overwrite GPIO_INPUT setting of spi chip select pin. + */ static int cros_shi_ite_init(const struct device *dev) { /* Set FIFO data target count */ @@ -314,13 +320,20 @@ static int cros_shi_ite_init(const struct device *dev) /* SPI slave controller enable (after settings are ready) */ IT83XX_SPI_SPISGCR = IT83XX_SPI_SPISCEN; +#if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxm), okay) + const struct device *portm = DEVICE_DT_GET(DT_NODELABEL(pinmuxm)); + + /* Ensure spi chip select alt function is enabled. */ + pinmux_pin_set(portm, 5, IT8XXX2_PINMUX_FUNC_1); +#endif + /* Enable SPI slave interrupt */ IRQ_CONNECT(DT_INST_IRQN(0), 0, shi_ite_int_handler, 0, 0); irq_enable(DT_INST_IRQN(0)); return 0; } -SYS_INIT(cros_shi_ite_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); +SYS_INIT(cros_shi_ite_init, POST_KERNEL, 52); /* Get protocol information */ enum ec_status spi_get_protocol_info(struct host_cmd_handler_args *args) -- cgit v1.2.1