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 1192CC61DA4 for ; Fri, 3 Feb 2023 09:28:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BACEB85EDA; Fri, 3 Feb 2023 10:27:36 +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="gGygE94R"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E857F85F1A; Fri, 3 Feb 2023 10:27:21 +0100 (CET) Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (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 28C3085ECC for ; Fri, 3 Feb 2023 10:27:14 +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-wm1-x32f.google.com with SMTP id o36so3380475wms.1 for ; Fri, 03 Feb 2023 01:27:14 -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=gGygE94RBbSnNw7qWkJv8Qa/6yXb4N0KNuoUSen2eCLNVFzu/6c1wjKdNFx3Ykatd4 ojIAOgQ+BoXWEtOovogO6hS7/8iDKKVkqhS3Ps28J3eWGkyb+gBXBqHLuv89DOj6zHf9 QFmBb7erqgpNXCGEucXtf2fGgSFvWb43U4ljmZLby/8ntjoObWBg4aKdrQbRsNLr6/5C XN22650Xb5vARKSpa2EhgEfaqVqOrEKVZbFsdK4VS7daDaLVcK9/EmdSq2tL59bwm0iN Xm+3hP5myRLtrMX31D200Xu4XEiCyH8H1/neYLo1bdQzAasbGB/G4nQWFpvqGn0SFaJI JW4g== 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=OMSYFEPv92B0GHbwfBpwk86xW/hkgD/k6vaY84A5J6RwEZJCgFj8zPLt89AaA8aDDP EUjx4kbp1XeANJFu0zChZDqZUGW4oIl0qcuez8/YVR0YGIXWMawJlABzeG6TJ4y/IPBX 77NzSXut4TIN7+9b1YoCvwxpJ1pp3ouBfWW8e86q1QCyYie+oe60kdshVVp440pkMq+D mSQcsAZ2/c7Yqfywtt/KJLhSk4PjJr6gmCacLWoP0TP8wNyF2HjlGFbGfqCTs6nOEyBs PxAVHB1y30rGNw5e2RHc2U/zYfM5mvmN2IlroPZhe3vh+LdO63xFzC1cfNQeZ1bKn9P4 CGiQ== X-Gm-Message-State: AO0yUKXEynBxh/VWvYXWFiY7EiV4uoRyT6MJaSYVpOWtthAeWm+IhPx/ p3LqslkIJwdtaela/wZyPyPCyLsqkqyYJfr6 X-Google-Smtp-Source: AK7set/n9SszSTDpPwsf00uaCoJKHT9hIaKUsF3d1qaSwLsI4fDRatcXSPXLbZGW1HaNhRjq3aA2bw== X-Received: by 2002:a05:600c:210a:b0:3df:12db:2779 with SMTP id u10-20020a05600c210a00b003df12db2779mr7980021wml.3.1675416433527; Fri, 03 Feb 2023 01:27:13 -0800 (PST) Received: from xeon.. ([188.163.112.54]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c46c600b003dc54344764sm7865025wmo.48.2023.02.03.01.27.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 01:27:13 -0800 (PST) From: Svyatoslav Ryhel To: Tom Warren , 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 v3 07/16] spi: tegra20_slink: accept any word length Date: Fri, 3 Feb 2023 11:26:31 +0200 Message-Id: <20230203092640.40821-8-clamor95@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230203092640.40821-1-clamor95@gmail.com> References: <20230203092640.40821-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