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 90DC7C61DA4 for ; Tue, 14 Feb 2023 17:37:49 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 85500859E0; Tue, 14 Feb 2023 18:36:35 +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="D1ud6KAR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 663AD85997; Tue, 14 Feb 2023 18:36:14 +0100 (CET) Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) (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 084AF8597D for ; Tue, 14 Feb 2023 18:36:08 +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-x32c.google.com with SMTP id j29-20020a05600c1c1d00b003dc52fed235so12195123wms.1 for ; Tue, 14 Feb 2023 09:36:07 -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=wp28/xkeLmwbhh2riWd4DCrf5Sy7liDDt0TXBFUSbTM=; b=D1ud6KAR/a5+X4pDO1y4SvN1BvUML72VT1onsgI5v6B/A/xk3Dg2m6SdEMzhMz6XwJ sZnx4c+sWblNiKLmnNExuQTCQ2/htLKlXLST3mgon2yssnAr9fVQGr9bXUORXbWMGa3C +TscxgLoOTA1HewVqaCQIuHOzdYleIxX8OFyOMki8wnh4SeCMJ0f2seXKsKiNkzxlkFf w6R8D5dVSISFpSIq5nHOoZp0w2tXonDKfFrYBW/+ugAg6GxLpTrq+Y2hSUO0bNFrX5zz G54h1znJmVQuS0A4NNR/PbQafCIwETNIsRyTHZ8AvMVqnu6JL3sqluxVky5m/FTR2V5m chKA== 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=wp28/xkeLmwbhh2riWd4DCrf5Sy7liDDt0TXBFUSbTM=; b=h5v+HJ/VnCmaMpQ0pt+/mXAFbnHltCrZ1Q1hWycCy4m3ruGRf3cQgmTM+Sae6u8Vsr xww99nn2iTQXZ1UmSHL9qVZzMHrXTTWHQHhiKjTNc+5aEWxWpEKwTZGOD9RbSYZuKPBP 8ScNL3mz9KHKhnsFu+c865a/zP7CcFuZlMnuJedHlmyVV4Ylb1PJrULemcHEwmQ8AypW C02xZ9j4UMrrNHrWnUpr34X/gx9LTkWkfaDU4OHPCK7f2PTLh9nQZd+o0FfsKDnbcOS8 NvDbRU/9EFlwsF/+GY92wk9AKzEPNByMwDEYEGgNq4mq3alcHo08pE0ztiJhnT8a9vdP rfdQ== X-Gm-Message-State: AO0yUKWNKSwgDqT4tYLl8BL1iCVPfcyCfwmlgv4CEef6Z/RaxLM7/Gfi qXy8tJG1ACBubKITWZCY68M= X-Google-Smtp-Source: AK7set/BVi7Q4QFQZ+RBR70VZhk16tohTeVpGJ3ym4KeH7bixKaMzmpO73UyINbubOB5HRxJUildMA== X-Received: by 2002:a05:600c:a0b:b0:3e1:e149:b67b with SMTP id z11-20020a05600c0a0b00b003e1e149b67bmr384797wmp.18.1676396167089; Tue, 14 Feb 2023 09:36:07 -0800 (PST) Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Feb 2023 09:36:06 -0800 (PST) From: Svyatoslav Ryhel To: Tom Warren , Marcel Ziswiler , Allen Martin , Jagan Teki , Lukasz Majewski , Marek Vasut , Svyatoslav Ryhel , Ramin Khonsari , Thierry Reding , Maxim Schwalm , Dmitry Osipenko , Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH v4 07/16] spi: tegra20_slink: accept any word length Date: Tue, 14 Feb 2023 19:35:29 +0200 Message-Id: <20230214173538.6242-8-clamor95@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com> References: <20230214173538.6242-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 Tested-by: Thierry Reding # T30 and T124 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