From patchwork Wed Dec 22 05:59:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Oskari_Lemmel=C3=A4?= X-Patchwork-Id: 12691127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98ADFC433F5 for ; Wed, 22 Dec 2021 06:07:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242659AbhLVGHv (ORCPT ); Wed, 22 Dec 2021 01:07:51 -0500 Received: from mail1.kuutio.org ([54.37.79.207]:41812 "EHLO mail1.kuutio.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230383AbhLVGHu (ORCPT ); Wed, 22 Dec 2021 01:07:50 -0500 X-Greylist: delayed 456 seconds by postgrey-1.27 at vger.kernel.org; Wed, 22 Dec 2021 01:07:50 EST Received: from localhost (localhost [127.0.0.1]) by mail1.kuutio.org (Postfix) with ESMTP id 3345B1FD6F; Wed, 22 Dec 2021 07:00:13 +0100 (CET) Authentication-Results: mail1.kuutio.org (amavisd-new); dkim=pass (4096-bit key) reason="pass (just generated, assumed good)" header.d=lemmela.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lemmela.net; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=dkim; t=1640152810; x=1642744811; bh=xUgpP ol+J/D01YMKJk7xdnyh/EKXctA1f/i5dPqKCDs=; b=PU73Tc5zX1XAWhfaqY6cQ tydHxlioF+UnhHG2xF0xrnsks8LdRcr/F6zMc1C+9FO4YdkELflP8d5iVdqKKl+0 M7NzvJiodkxm/hjPaCAsErC9ZhRynGEBQrRPvOBjeskX/u73LYkb1cV9dzB0lB7h Fy5QzmQxiCproyieIKPkTzPel3XV0T6Xk5EjMZtjwVBaW2awOxUBTUF8PIWuPj/l /yHwBWaIn5Rdfq+ABh+4+OYFJmAdxOwvbqFYmwITlsF74uNSoQqV4fB8QHgbn2sb Pd7v4QGYVfLBqpq34bm1N0jgbGNDf5gpQkubhy/8irA/Z6Of7ZMa8qeP+qodmulO rU41Atvdhlqz8aEshT/lm6L6euOK4iq1MXO1bj/3l7mUlySmAc4PFQy1P+wYtujC glTtsGtLOnEadQdssCFKdF88oUYngQLsxKomo0a/9d7fJkikdyyfVadCdDTEdBEo NGblTAQZmvNic2BRBxgKv4LUCLCaAPXI2saVTp8YZhvQHJuf07FIfSK/bOzT9vaq AGyQ6EWw/ZNLd4spZeAQndos1nWGoMGYDbL0jXiZURXfSVH+oIHD6IkI16vnWuS3 jf7IyidMAsoz0TT9Gx1HDFZkK/CBtW4bDA/1f7YQp7Mq4AH1cy7Hk9H1/WbJpAk+ suaxKLO0cCm+mRuABV7FEI= X-Virus-Scanned: amavisd-new at kuutio.org Received: from mail1.kuutio.org ([127.0.0.1]) by localhost (mail1.kuutio.org [127.0.0.1]) (amavisd-new, port 10024) with LMTP id HbmWohE7PNsa; Wed, 22 Dec 2021 07:00:10 +0100 (CET) Received: from build.kuutio.org (unknown [IPv6:2001:998:13:e4::69]) by mail1.kuutio.org (Postfix) with ESMTPSA id 977111FE00; Wed, 22 Dec 2021 07:00:10 +0100 (CET) From: Oskari Lemmela To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Oskari Lemmela Subject: [PATCH 1/2] spi: ar934x: fix transfer size Date: Wed, 22 Dec 2021 07:59:57 +0200 Message-Id: <20211222055958.1383233-2-oskari@lemmela.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211222055958.1383233-1-oskari@lemmela.net> References: <20211222055958.1383233-1-oskari@lemmela.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org If bits_per_word is configured, transfer only word amount of data per iteration. Signed-off-by: Oskari Lemmela --- drivers/spi/spi-ar934x.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-ar934x.c b/drivers/spi/spi-ar934x.c index def32e0aaefe..a2cf37aca234 100644 --- a/drivers/spi/spi-ar934x.c +++ b/drivers/spi/spi-ar934x.c @@ -82,7 +82,7 @@ static int ar934x_spi_transfer_one_message(struct spi_controller *master, struct spi_device *spi = m->spi; unsigned long trx_done, trx_cur; int stat = 0; - u8 term = 0; + u8 bpw, term = 0; int div, i; u32 reg; const u8 *tx_buf; @@ -90,6 +90,11 @@ static int ar934x_spi_transfer_one_message(struct spi_controller *master, m->actual_length = 0; list_for_each_entry(t, &m->transfers, transfer_list) { + if (t->bits_per_word >= 8 && t->bits_per_word < 32) + bpw = t->bits_per_word >> 3; + else + bpw = 4; + if (t->speed_hz) div = ar934x_spi_clk_div(sp, t->speed_hz); else @@ -105,10 +110,10 @@ static int ar934x_spi_transfer_one_message(struct spi_controller *master, iowrite32(reg, sp->base + AR934X_SPI_REG_CTRL); iowrite32(0, sp->base + AR934X_SPI_DATAOUT); - for (trx_done = 0; trx_done < t->len; trx_done += 4) { + for (trx_done = 0; trx_done < t->len; trx_done += bpw) { trx_cur = t->len - trx_done; - if (trx_cur > 4) - trx_cur = 4; + if (trx_cur > bpw) + trx_cur = bpw; else if (list_is_last(&t->transfer_list, &m->transfers)) term = 1; @@ -191,7 +196,8 @@ static int ar934x_spi_probe(struct platform_device *pdev) ctlr->mode_bits = SPI_LSB_FIRST; ctlr->setup = ar934x_spi_setup; ctlr->transfer_one_message = ar934x_spi_transfer_one_message; - ctlr->bits_per_word_mask = SPI_BPW_MASK(8); + ctlr->bits_per_word_mask = SPI_BPW_MASK(32) | SPI_BPW_MASK(24) | + SPI_BPW_MASK(16) | SPI_BPW_MASK(8); ctlr->dev.of_node = pdev->dev.of_node; ctlr->num_chipselect = 3; From patchwork Wed Dec 22 05:59:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Oskari_Lemmel=C3=A4?= X-Patchwork-Id: 12691129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B65D2C433FE for ; Wed, 22 Dec 2021 06:07:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230384AbhLVGHv (ORCPT ); Wed, 22 Dec 2021 01:07:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242656AbhLVGHu (ORCPT ); Wed, 22 Dec 2021 01:07:50 -0500 X-Greylist: delayed 455 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 21 Dec 2021 22:07:50 PST Received: from mail1.kuutio.org (mail1.kuutio.org [IPv6:2001:41d0:701:1000::88b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A393EC061574; Tue, 21 Dec 2021 22:07:50 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail1.kuutio.org (Postfix) with ESMTP id 72F361FE04; Wed, 22 Dec 2021 07:00:12 +0100 (CET) Authentication-Results: mail1.kuutio.org (amavisd-new); dkim=pass (4096-bit key) reason="pass (just generated, assumed good)" header.d=lemmela.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lemmela.net; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=dkim; t=1640152811; x=1642744812; bh=7goCQ RK56252j1Vuv1LAm+D12SpIRIPvTknwjB0fb40=; b=L3xSOpPzd7ix3OoZfvwCi gXtJGAbgoazxwmCSvxK1/Oin4x+jnk8kWsFwaW3mhdw8S8PIo8IkOzKnn//M4Rcr 2CthnBBWnInVo70dX58yWUHMzEryYEoYYWWkm8ZBarUQlJGQmI6Vj7yoLK5nta8G OGJPw89G3Too2ep31gxpG4t4nUNQT9yTwZsY4BKki8BivsW07fzS2lchdl2w0CTT GIv2IUc07DtNSVbRnJwVWQJySUJtN+wtunO8x+gnvmIi64PQSnt8n8CRfYHLe/E/ ktMU2NlpKEsqmPsXOpkw4Y7yiv+nzB39Zt52WmdCZTAJehpKvgS519GffWelrUFO Zd49upDVPO1003WMQuyP0kd/fkNnhFxf2ghZdZShL28knj53JTdWTDU6sOURRjga C3L06fi9VVdKEir9VXQJuC80Y8VfjiSic3kdZmIch1S6ZAWi8JaUrvYL37JrAfHl HYilXsYTrvqhv5PYj1xq0VIoVaUNeB1fjHRtrHlFntqRL0kI9LFV0Igk9wPpIkz6 YNucU6s4gLLJ/TTb0UraLFRlqA8ZDSZWzol39ZviKaq5jwCbwb+g/oCABrlr+fov rNKJGNV9LMHVhljzMfLFrx0B/gy5LQ4oDvHxm27IudtiluYuixq7pRUlvhkKj2NR O+3NLU8itizNzb/pPTXvE4= X-Virus-Scanned: amavisd-new at kuutio.org Received: from mail1.kuutio.org ([127.0.0.1]) by localhost (mail1.kuutio.org [127.0.0.1]) (amavisd-new, port 10024) with LMTP id PJZ97WVEY7Kj; Wed, 22 Dec 2021 07:00:11 +0100 (CET) Received: from build.kuutio.org (unknown [IPv6:2001:998:13:e4::69]) by mail1.kuutio.org (Postfix) with ESMTPSA id D50001FDDB; Wed, 22 Dec 2021 07:00:10 +0100 (CET) From: Oskari Lemmela To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Oskari Lemmela Subject: [PATCH 2/2] spi: ar934x: fix transfer and word delays Date: Wed, 22 Dec 2021 07:59:58 +0200 Message-Id: <20211222055958.1383233-3-oskari@lemmela.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211222055958.1383233-1-oskari@lemmela.net> References: <20211222055958.1383233-1-oskari@lemmela.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Add missing delay between transferred messages and words. Signed-off-by: Oskari Lemmela --- drivers/spi/spi-ar934x.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/spi/spi-ar934x.c b/drivers/spi/spi-ar934x.c index a2cf37aca234..ec7250c4c810 100644 --- a/drivers/spi/spi-ar934x.c +++ b/drivers/spi/spi-ar934x.c @@ -142,8 +142,10 @@ static int ar934x_spi_transfer_one_message(struct spi_controller *master, reg >>= 8; } } + spi_delay_exec(&t->word_delay, t); } m->actual_length += t->len; + spi_transfer_delay_exec(t); } msg_done: