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 42F57C61DA4 for ; Thu, 2 Feb 2023 18:16:09 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E769085E2A; Thu, 2 Feb 2023 19:15: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=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="QV76b+ca"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 72AC685DDC; Thu, 2 Feb 2023 19:14:32 +0100 (CET) Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (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 00ED985DF3 for ; Thu, 2 Feb 2023 19:14:24 +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-x333.google.com with SMTP id k16so2100803wms.2 for ; Thu, 02 Feb 2023 10:14:24 -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=QV76b+cav34dr+PZ4N8Bp/cThuL35VOza1Gz9CQBrQfOreETMrk9+BipljqeL87xrl SEBbgj0yqkVcrJ7uM4Ma1F+AkwM1YDk817qPrfV4jJrcvsbFrfs1QFspbhQctg7SwOcp RkgLU67b1E2iac4Mj+NhDhOnmIzhPt8ZtzMZQkg+q1AMuik2mpoIMRybmyCPZJcm75k/ 8R2MqZUwKWejYvUQ7yBC+7ndLJclRnk7aUsaeV7gpqyI+Q0GlwVG8Rs6Rnef8LUMs3QP mDn/HCdX7WBWJ3RuYJSSlKhG4eR9CPKY2j1+GYBdDRbMBjtrUvDuDxLzrnWXbd4gix5E gWHg== 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=W6PEpuP2mfJYVqKVdm1plaUGK1v8MaRJZp316ufTdYW6BjEVTTQv/eqhd3c4LVlN0O UcPQeBBfM7ku6TOJXDdi4LN5xZUQj93Hq7peTFDEgsi3ZCIwV0g34DzhNpSdSSiSZKa2 x0pUHfrmC6D48QauzwlOzuFyuEydKW0D26BW+OO3WLYTLx3zrWJTc5R/DTk2bdWaemOL 5/n+cBlq6323Ij0Ag1CBySd3ptVr2j2UCiRy7++YmDDUpRV7L1thjNFxbsJDvsiaTDdF 03JJAvAwkDFdlaM5dm+Xh2Z7rd2Kn9p/DF1DA6dqwvxMdN3UylDvL9FJfgnFCMl/DbMP N+Fw== X-Gm-Message-State: AO0yUKVP05ub+U7apDLB50597pApISahzRWCWGoVxqKJ9GmfT0tp8DQt wEUvysVE//kxCv6yUHJ+MaU= X-Google-Smtp-Source: AK7set8afRVwlt5rUHtnteo2KiUKmmrSjMUaYtTS2u9AVYAPPR+Tuq9kwXKR1AcgP6IOdNek6Wxj/A== X-Received: by 2002:a05:600c:43c5:b0:3dc:5674:66e6 with SMTP id f5-20020a05600c43c500b003dc567466e6mr7086009wmn.25.1675361664324; Thu, 02 Feb 2023 10:14:24 -0800 (PST) Received: from xeon.. ([188.163.112.54]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003daffc2ecdesm5516543wmc.13.2023.02.02.10.14.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:14:24 -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 v2 07/16] spi: tegra20_slink: accept any word length Date: Thu, 2 Feb 2023 20:13:48 +0200 Message-Id: <20230202181357.4455-8-clamor95@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230202181357.4455-1-clamor95@gmail.com> References: <20230202181357.4455-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