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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 93CD5C61D97 for ; Sun, 29 Jan 2023 18:44:24 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DD968855A9; Sun, 29 Jan 2023 19:43:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="M9cp2GDi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0D9E985754; Sun, 29 Jan 2023 19:42:15 +0100 (CET) Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1713E8574A for ; Sun, 29 Jan 2023 19:41:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=clamor95@gmail.com Received: by mail-wr1-x432.google.com with SMTP id bk16so9179725wrb.11 for ; Sun, 29 Jan 2023 10:41:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qus0niAIi6zZY5VcwBV5jUHOp42B6eziC83a1pBdBdw=; b=M9cp2GDi6GAH2GWaCmF6CbYAB8Rfd61aESOdrfMW/5wWqST1QaE1+iXiuOAvgde2U4 +FCjWebCKb9NFVI/CERPjoT6MsUiGQXZWL4uZQKfNMb9VE5UCtQ7shv0GkmCmyfnHzJl KJwK5Yw8Fq/4nY6voe+qMdMHDNz+LXEZ/7uL95m1g+VZ0sNwzm3nEXGm2UB2O5cwY19y a4iBUobNmSe6E/aS1IRJsF1hAOLn7S7/2uLoekp1xwNRRaQrblNa124peN5D4T5OTFU/ Ugr8MC68VgcRFzAsfrAe0OiWL71haiJ/SCWkl//dKNBQAwxdx/klRsmhcE0ndZVhvTrZ L1Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qus0niAIi6zZY5VcwBV5jUHOp42B6eziC83a1pBdBdw=; b=ao7GOFsQEj/CmssPDUAPwiTw6lE6hMsG3u4h2ua5NF+UnyTF53zvC/c1AlezxLJdKQ /jaIbovSok2otZLw2l9vD4nKcmiE1QNDkTMqive0lFjerHZMuixd+OGTqilUsg4gF0FR Kh/HYyTV3i+X1CI8GO5zSvG9G8BI88D5xa594olHoOIX2ba04idwB+BVI+7pkVBBW9Xo aRDdxwKPUhFSWfgatqfM50kUcKfZm0knKHCZm86Fr39d5bBb2SnEP0OLHkDBw3Ps+jJj o5UcxYs5Pcli3CxUZQDLqY8ExwZNro9Rlsxe/3YUm3nsnQAxQS+rwZD7+MbUGapM2Kto 2kdg== X-Gm-Message-State: AO0yUKXhUD9NUaOboFVLMCTC7SGMt4G8NjM1yEXMn/PiF+W+557JqnqV Hh7YXRG5rYFfvhtCe5Sh244= X-Google-Smtp-Source: AK7set9HwpcpOJ3RDNvcJrtiyuX8Ni2R2+6olEaDm6wzmME1wQSrBsCqwnXSNVm0mkBgoROznaBRHQ== X-Received: by 2002:a5d:558a:0:b0:2bf:d6fc:580d with SMTP id i10-20020a5d558a000000b002bfd6fc580dmr7558355wrv.69.1675017711001; Sun, 29 Jan 2023 10:41:51 -0800 (PST) Received: from xeon.. ([188.163.112.54]) by smtp.gmail.com with ESMTPSA id y8-20020adfdf08000000b002bfb31bda06sm10321010wrl.76.2023.01.29.10.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jan 2023 10:41:50 -0800 (PST) From: Svyatoslav Ryhel To: Tom Warren , Alban Bedel , Stephen Warren , Marcel Ziswiler , Allen Martin , Jagan Teki , Lukasz Majewski , Marek Vasut , Svyatoslav Ryhel , Ramin Khonsari , Thierry Reding , Maxim Schwalm , Dmitry Osipenko Cc: u-boot@lists.denx.de Subject: [PATCH v1 07/16] spi: tegra20_slink: accept any word length Date: Sun, 29 Jan 2023 20:41:14 +0200 Message-Id: <20230129184123.36001-8-clamor95@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230129184123.36001-1-clamor95@gmail.com> References: <20230129184123.36001-1-clamor95@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Original t20 slink could work with commands only fully divisible by 8. This patch removes such restriction, so commands of any bitlength now can be passed and processed. Tested-by: Andreas Westman Dorcsak # ASUS TF600T T30 Tested-by: Svyatoslav Ryhel # LG P895 T30 Signed-off-by: Svyatoslav Ryhel --- drivers/spi/tegra20_slink.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/spi/tegra20_slink.c b/drivers/spi/tegra20_slink.c index 209ba8b0cc..d0e788539e 100644 --- a/drivers/spi/tegra20_slink.c +++ b/drivers/spi/tegra20_slink.c @@ -208,16 +208,14 @@ static int tegra30_spi_xfer(struct udevice *dev, unsigned int bitlen, u32 reg, tmpdout, tmpdin = 0; const u8 *dout = data_out; u8 *din = data_in; - int num_bytes; - int ret; + int num_bytes, overflow; + int ret = 0; debug("%s: slave %u:%u dout %p din %p bitlen %u\n", __func__, dev_seq(bus), spi_chip_select(dev), dout, din, bitlen); - if (bitlen % 8) - return -1; - num_bytes = bitlen / 8; - ret = 0; + num_bytes = DIV_ROUND_UP(bitlen, 8); + overflow = bitlen % 8; reg = readl(®s->status); writel(reg, ®s->status); /* Clear all SPI events via R/W */ @@ -254,8 +252,13 @@ static int tegra30_spi_xfer(struct udevice *dev, unsigned int bitlen, num_bytes -= bytes; - clrsetbits_le32(®s->command, SLINK_CMD_BIT_LENGTH_MASK, - bytes * 8 - 1); + if (overflow && !num_bytes) + clrsetbits_le32(®s->command, SLINK_CMD_BIT_LENGTH_MASK, + (bytes - 1) * 8 + overflow - 1); + else + clrsetbits_le32(®s->command, SLINK_CMD_BIT_LENGTH_MASK, + bytes * 8 - 1); + writel(tmpdout, ®s->tx_fifo); setbits_le32(®s->command, SLINK_CMD_GO); -- 2.37.2