Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2323868pxy; Tue, 3 Aug 2021 03:41:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzweXdlmwzVOev60Gd/xX5t4PZ7WN7NV83y/Tpxo/v0kL95AdcueeFeYNkDXJ8cl9Qm80S5 X-Received: by 2002:a02:a40f:: with SMTP id c15mr6851231jal.38.1627987294294; Tue, 03 Aug 2021 03:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627987294; cv=none; d=google.com; s=arc-20160816; b=BpJRzja2Ni4dju+sGT5kHAwAfgKY0ppzAF6axvs6/IcgUWtEDVuPSj88TQcAHcD4um iKoxHmzP5gjYV9QJ4okVycdOw2iJ2HZ8VOgIX8sQxEVQx+rpfM2w1LaB1nr0B/WadCvG o7T931GfIalueRGXqEZtgpG2SHAssdGn2uBJoOdQ1GmzFY1l0CpZ3UxhQqyuMjNBS9Ca gOFZNMPjvO74xygez3wEP/uLBw7CUZoNxK0IzuXdNyqLTCrxL8u+Vz7BfhPwzRnnzv7C KziTPK3jQig3TR4tDnxhIHzCGMjM0mAANDjo+QB8RQukM9Q10RbHzhOsjAzbVLun+9iw laaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=X0vlgDJr2ZM+T0csaYannXjhUm3fFgFf1R0Wc8BrVGc=; b=v6zN26U+t2R4Bm6twPTTYiqaF0OExIIV9CUQlx8wXN100HIjyQ20GlP2POl9zI4KDW y00EfPzaUGtWSQhAPSX1Uj8ZX6k9edrhRtmCvua7vQ/LoRf5a9V+xuAKJb5r8N9SXM3J 3BJCf90X/ANWtJ/fk8HJAgp0uNFdzBnZAgVAvKkYnCSFyUxqtfSCtld51e0Os6RZPKHv FzlhptzvJxASf+ceaLyAPXl7ZsA/wYRwnI4Uy4fbS8a375dqV954gHfdn9N0vXpdbRI4 qjZCG9V30N4YZ8le3/rhKzuMAtSfkKBQFpbIkJw9TGyW9P9mZutQraKgW8UotEiNkk6N Q/1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y17si20666239iov.62.2021.08.03.03.41.22; Tue, 03 Aug 2021 03:41:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234821AbhHCKk1 (ORCPT + 99 others); Tue, 3 Aug 2021 06:40:27 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:56142 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S235505AbhHCKkZ (ORCPT ); Tue, 3 Aug 2021 06:40:25 -0400 X-UUID: 4a1a8d6d54d74848a57a09f339b1a5b0-20210803 X-UUID: 4a1a8d6d54d74848a57a09f339b1a5b0-20210803 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 2001468748; Tue, 03 Aug 2021 18:40:11 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 3 Aug 2021 18:40:10 +0800 Received: from localhost.localdomain (10.15.20.246) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 3 Aug 2021 18:40:09 +0800 From: Mason Zhang To: Mark Brown , Matthias Brugger CC: Laxman Dewangan , , , , , , Mason Zhang Subject: [PATCH v2 1/4] spi: move cs spi_delay to spi_device Date: Tue, 3 Aug 2021 18:23:34 +0800 Message-ID: <20210803102333.22568-1-Mason.Zhang@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As we know, spi core layer has removed spi_set_cs_timing() API. So this patch moved spi_delay for cs_timing from spi_controller to spi_device, because cs timing should be set by spi_device but not controller. Signed-off-by: Mason Zhang --- drivers/spi/spi.c | 6 +++--- include/linux/spi/spi.h | 20 +++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index c99181165321..5d68e6cd2a18 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -842,9 +842,9 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force) if (spi->cs_gpiod || gpio_is_valid(spi->cs_gpio) || !spi->controller->set_cs_timing) { if (activate) - spi_delay_exec(&spi->controller->cs_setup, NULL); + spi_delay_exec(&spi->cs_setup, NULL); else - spi_delay_exec(&spi->controller->cs_hold, NULL); + spi_delay_exec(&spi->cs_hold, NULL); } if (spi->mode & SPI_CS_HIGH) @@ -887,7 +887,7 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force) if (spi->cs_gpiod || gpio_is_valid(spi->cs_gpio) || !spi->controller->set_cs_timing) { if (!activate) - spi_delay_exec(&spi->controller->cs_inactive, NULL); + spi_delay_exec(&spi->cs_inactive, NULL); } } diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 97b8d12b5f2b..651e19ba3415 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -147,7 +147,11 @@ extern int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer); * not using a GPIO line) * @word_delay: delay to be inserted between consecutive * words of a transfer - * + * @cs_setup: delay to be introduced by the controller after CS is asserted + * @cs_hold: delay to be introduced by the controller before CS is deasserted + * @cs_inactive: delay to be introduced by the controller after CS is + * deasserted. If @cs_change_delay is used from @spi_transfer, then the + * two delays will be added up. * @statistics: statistics for the spi_device * * A @spi_device is used to interchange data between an SPI slave @@ -188,6 +192,10 @@ struct spi_device { int cs_gpio; /* LEGACY: chip select gpio */ struct gpio_desc *cs_gpiod; /* chip select gpio desc */ struct spi_delay word_delay; /* inter-word delay */ + /* CS delays */ + struct spi_delay cs_setup; + struct spi_delay cs_hold; + struct spi_delay cs_inactive; /* the statistics */ struct spi_statistics statistics; @@ -412,11 +420,6 @@ extern struct spi_device *spi_new_ancillary_device(struct spi_device *spi, u8 ch * controller has native support for memory like operations. * @unprepare_message: undo any work done by prepare_message(). * @slave_abort: abort the ongoing transfer request on an SPI slave controller - * @cs_setup: delay to be introduced by the controller after CS is asserted - * @cs_hold: delay to be introduced by the controller before CS is deasserted - * @cs_inactive: delay to be introduced by the controller after CS is - * deasserted. If @cs_change_delay is used from @spi_transfer, then the - * two delays will be added up. * @cs_gpios: LEGACY: array of GPIO descs to use as chip select lines; one per * CS number. Any individual value may be -ENOENT for CS lines that * are not GPIOs (driven by the SPI controller itself). Use the cs_gpiods @@ -638,11 +641,6 @@ struct spi_controller { /* Optimized handlers for SPI memory-like operations. */ const struct spi_controller_mem_ops *mem_ops; - /* CS delays */ - struct spi_delay cs_setup; - struct spi_delay cs_hold; - struct spi_delay cs_inactive; - /* gpio chip select */ int *cs_gpios; struct gpio_desc **cs_gpiods; -- 2.18.0