From: Miroslav Ondra Date: Tue, 13 Jul 2021 16:20:14 +0000 (+0200) Subject: Use spi_delay for interframe spaces for kernel>=5.9.0 X-Git-Url: http://git.graph-it.com/?a=commitdiff_plain;h=cf0f7cafd7feb3809da3e0ea315c3443e9426ac9;p=graphit%2Funipi-kernel.git Use spi_delay for interframe spaces for kernel>=5.9.0 --- diff --git a/modules/unipi/src/unipi_common.h b/modules/unipi/src/unipi_common.h index b9cd1a9..997f644 100644 --- a/modules/unipi/src/unipi_common.h +++ b/modules/unipi/src/unipi_common.h @@ -52,7 +52,7 @@ #if NEURONSPI_SCHED_REQUIRED > 0 #include #endif -#define NEURONSPI_MAJOR_VERSIONSTRING "Version 1.61:2021:02:06" +#define NEURONSPI_MAJOR_VERSIONSTRING "Version 1.61:2021:07:13" #define NEURONSPI_MAX_DEVS 3 #define NEURONSPI_MAX_UART 16 diff --git a/modules/unipi/src/unipi_spi.c b/modules/unipi/src/unipi_spi.c index 9ad77d3..4114a7a 100644 --- a/modules/unipi/src/unipi_spi.c +++ b/modules/unipi/src/unipi_spi.c @@ -122,7 +122,7 @@ static struct neuronspi_op_buffer UNIPISPI_IDLE_MESSAGE = { ***********************************************************/ - +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,9,0) static unsigned long loop_per_us = 24; u16 unipi_spi_master_flag = 0; void (*unipi_spi_master_set_cs)(struct spi_device *spi, bool enable) = NULL; @@ -130,6 +130,7 @@ static struct neuronspi_op_buffer UNIPISPI_IDLE_MESSAGE = { #ifdef USE_UNIPI_CPUFREQ_PATCH static struct cpufreq_policy * current_policy = NULL; #endif +#endif static void unipi_spi_set_cs(struct spi_device *spi, bool enable) { @@ -1227,6 +1228,10 @@ s32 neuronspi_spi_probe(struct spi_device *spi) u32 always_create_uart = 0; struct kthread_worker *worker; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0) + struct spi_delay inactive_delay; +#endif + unsigned long flags; n_spi = kzalloc(sizeof *n_spi, GFP_ATOMIC); @@ -1330,6 +1335,7 @@ s32 neuronspi_spi_probe(struct spi_device *spi) return ret; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,9,0) if (spi->controller->set_cs != unipi_spi_set_cs) { unipi_spi_master_set_cs = spi->controller->set_cs; unipi_spi_master_flag = spi->controller->flags; @@ -1339,6 +1345,11 @@ s32 neuronspi_spi_probe(struct spi_device *spi) if (gpio_is_valid(spi->cs_gpio)) { spi->cs_gpio = -spi->cs_gpio; } +#else + inactive_delay.value = 40; + inactive_delay.unit = SPI_DELAY_UNIT_USECS; + spi_set_cs_timing(spi, NULL, NULL, &inactive_delay); +#endif // Prepare worker for interrupt, LEDs, UARTs worker = kthread_create_worker(0, "unipispi%d", n_spi->neuron_index); @@ -1429,6 +1440,7 @@ s32 neuronspi_spi_remove(struct spi_device *spi) struct neuronspi_driver_data *n_spi = spi_get_drvdata(spi); if (n_spi) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,9,0) if ((spi->cs_gpio < 0) && (spi->cs_gpio != -ENOENT)) { spi->cs_gpio = -spi->cs_gpio; } if (spi->controller->set_cs == unipi_spi_set_cs) { spi->controller->set_cs = unipi_spi_master_set_cs; @@ -1438,7 +1450,7 @@ s32 neuronspi_spi_remove(struct spi_device *spi) spi->controller->flags &= ~SPI_MASTER_GPIO_SS; } } - +#endif neuron_index = n_spi->neuron_index; if (n_spi->no_irq) { hrtimer_cancel(&n_spi->poll_timer);