Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp188537lqz; Fri, 29 Mar 2024 12:57:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVnAmDJoKEmJpKfQOk5d9qjqebu9Z/Bg62gQXw9KfF/pcWSt4p97l64nWgfnqID3xi55LPYnYm20jLBwoxfkIM4lfKEpa2Gvv+Dg+1KoQ== X-Google-Smtp-Source: AGHT+IFfrGnbq/rr58oc3gcpD3QPTMFwO2WmUz0+oGCxrgyO/UrIfuMVZLdcpaJUSKAErZVFNcih X-Received: by 2002:a05:6402:3549:b0:568:cec0:2f84 with SMTP id f9-20020a056402354900b00568cec02f84mr2023629edd.22.1711742223839; Fri, 29 Mar 2024 12:57:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711742223; cv=pass; d=google.com; s=arc-20160816; b=YVxrhRviYqg5psFAHTY33JyfwVUfMo25NIZ7Pt1PkOhdqX5b4MYm4e97jphDmQHhVv u/JlRCHSnDxaMFHKaeLkiD1ge78yj6HzI85qjzzT+HGRQpjZsDL+5UZwayvScz5i3fAw y7fCWWt8SNnezySohpVzZaArs6RafGO9wYJtPU/03CHnIIeKFKsyrbJT4588q41oN4rh KvUFcWNjSRmQg6d46hjynUTNiUEH5oEG4jO0QViXv4KGKbmfSddCUENokKF4sbWx+blW Qz81DJNmDa0FOElrjtn7xCfVEywS8j0cfOsFtRY9tGhNWn1Dvd/PmaK4+Al4qqCG4wnF NJ0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=8fNMtZ9/pgFp6oVd4lQW8G2fv7HD8rCT8GxycTl6jyg=; fh=v5g/jM8LtXkxdDOZiY0auDT0qARIn/b9mdOLf8qLaog=; b=DqZbUdj5Ldxob7VymyC3N2a1XRNQDTJ972T9uacGXdrVXQSxRhatRnxYXNyygsWSeV u2pKSWKFJskj8xOwaqEmdKgQw7feJVk7QnGs1Tw+z18C5K/ml3/L7PLykJdBf0GI9YWc XpHyMjrKPYvR3BM/rTiDRBLu2+RnMuMFh58a1VPmIcVkVIsGydgbqNNgVIKRSNWgYUma 727fnrnJYHW1IUql7Kd9AA496+gc5uQHlkIg7OMSQxPqGiXAx6zSceN6ukf6Fw8WH8Bz D/vGBTv3vT8cWTkvX2HM/w68fW25bAgt7wvz9nANAS4E/KjPydnwUb4X3VZ9g0MXpxqg B1Cw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=iICQQBo4; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-125358-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125358-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id v19-20020a056402349300b005687fdb435fsi2144163edc.411.2024.03.29.12.57.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 12:57:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-125358-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=iICQQBo4; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-125358-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125358-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D75E51F271B0 for ; Fri, 29 Mar 2024 19:50:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A20113A3E7; Fri, 29 Mar 2024 19:49:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="iICQQBo4" Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA5E813B5AC; Fri, 29 Mar 2024 19:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711741754; cv=none; b=HRq4cxA9BtPjv5DQeSUwDWP2ml+qWQpGxWtP3DAA1Sle+5KWO1i4g52qJR7NaNCOPLhZRvQliDNBcJbD+FA6ugacISp5fPcQ+CKWYAGLmFcGqIJYV905sTCZ3cy1jYf0O5fIYqQqdyuzhR5uiYHHD3rJmwLraHPTwAqYhgFjuXY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711741754; c=relaxed/simple; bh=47Oz1nPvAac9zh3peIwuv/tnQiJpEQqRqnRuiL+lSGQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F7T8Ru36Fqw3yUtodJokTNb7EZz7F2Feo6Y4adHwlxL3fkoYTtOWMO2vkiGPmSrsO2UHa7/g+G2IUU2aOTTqtQlm/znrTujvY3RGaiDfeeaRHXY1ceHUhwlPoQQUAfkpdrLes29FHUP4heqF+3pkGPUlqZGnfid9wyNjwhYdZmw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=iICQQBo4; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42TE0cl4014374; Fri, 29 Mar 2024 12:49:07 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= pfpt0220; bh=8fNMtZ9/pgFp6oVd4lQW8G2fv7HD8rCT8GxycTl6jyg=; b=iIC QQBo4S3Y5PyGsmjeT4dEpJMQ5C0hu1sy1ugTmMmIiB3zRdAZdgaxUrg0CGpGlyJt nqQVVQW2ChIzHLAr6I3PNONThdhKC9tsyZTWcnlexqpc6GJKekZ4B9EVL0GpPItK zkNFEUr8tlzyPl3BXPIxNctQ+OqSwBK7m92QeHf/b2eDq7zK8ZdhveUu9WNfip86 cE5o6XukTzEExupZM3FVlWsYaPBBexUhN3VH7Y8KQun9xiiFuqiEjWBZIu9L8+Vq mTCr5AoVH17Ngeh7iIHMLmvPQkGux9eR4TM4JTWIL7vJ8TbmJvowEx07V92LJh1L d0+16Y1MZ3YhQWBXiFQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3x5gm3krq6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Mar 2024 12:49:07 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 29 Mar 2024 12:49:06 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 29 Mar 2024 12:49:06 -0700 Received: from localhost.localdomain (unknown [10.110.150.170]) by maili.marvell.com (Postfix) with ESMTP id 02B983F707A; Fri, 29 Mar 2024 12:49:05 -0700 (PDT) From: Witold Sadowski To: , , CC: , , , , , Witold Sadowski Subject: [PATCH 3/5] spi: cadence: Force single modebyte Date: Fri, 29 Mar 2024 12:48:47 -0700 Message-ID: <20240329194849.25554-4-wsadowski@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240329194849.25554-1-wsadowski@marvell.com> References: <20240329194849.25554-1-wsadowski@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: sfyKqSIEWUN9qXI62K_B1BGNxxwymHOL X-Proofpoint-ORIG-GUID: sfyKqSIEWUN9qXI62K_B1BGNxxwymHOL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-29_13,2024-03-28_01,2023-05-22_02 During dummy-cycles xSPI will switch GPIO into Hi-Z mode. To prevent unforeseen consequences of that behaviour, force send single modebyte(0x00). Modebyte will be send only if number of dummy-cycles is not equal to 0. Code must also reduce dummycycle byte count by one - as one byte is send as modebyte. Signed-off-by: Witold Sadowski --- drivers/spi/spi-cadence-xspi.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c index f570b2920b18..cce14473e88e 100644 --- a/drivers/spi/spi-cadence-xspi.c +++ b/drivers/spi/spi-cadence-xspi.c @@ -145,6 +145,9 @@ #define CDNS_XSPI_STIG_DONE_FLAG BIT(0) #define CDNS_XSPI_TRD_STATUS 0x0104 +#define MODE_NO_OF_BYTES GENMASK(25, 24) +#define MODEBYTES_COUNT 1 + /* Helper macros for filling command registers */ #define CDNS_XSPI_CMD_FLD_P1_INSTR_CMD_1(op, data_phase) ( \ FIELD_PREP(CDNS_XSPI_CMD_INSTR_TYPE, (data_phase) ? \ @@ -157,9 +160,10 @@ FIELD_PREP(CDNS_XSPI_CMD_P1_R2_ADDR3, ((op)->addr.val >> 24) & 0xFF) | \ FIELD_PREP(CDNS_XSPI_CMD_P1_R2_ADDR4, ((op)->addr.val >> 32) & 0xFF)) -#define CDNS_XSPI_CMD_FLD_P1_INSTR_CMD_3(op) ( \ +#define CDNS_XSPI_CMD_FLD_P1_INSTR_CMD_3(op, modebytes) ( \ FIELD_PREP(CDNS_XSPI_CMD_P1_R3_ADDR5, ((op)->addr.val >> 40) & 0xFF) | \ FIELD_PREP(CDNS_XSPI_CMD_P1_R3_CMD, (op)->cmd.opcode) | \ + FIELD_PREP(MODE_NO_OF_BYTES, modebytes) | \ FIELD_PREP(CDNS_XSPI_CMD_P1_R3_NUM_ADDR_BYTES, (op)->addr.nbytes)) #define CDNS_XSPI_CMD_FLD_P1_INSTR_CMD_4(op, chipsel) ( \ @@ -173,12 +177,12 @@ #define CDNS_XSPI_CMD_FLD_DSEQ_CMD_2(op) \ FIELD_PREP(CDNS_XSPI_CMD_DSEQ_R2_DCNT_L, (op)->data.nbytes & 0xFFFF) -#define CDNS_XSPI_CMD_FLD_DSEQ_CMD_3(op) ( \ +#define CDNS_XSPI_CMD_FLD_DSEQ_CMD_3(op, dummybytes) ( \ FIELD_PREP(CDNS_XSPI_CMD_DSEQ_R3_DCNT_H, \ ((op)->data.nbytes >> 16) & 0xffff) | \ FIELD_PREP(CDNS_XSPI_CMD_DSEQ_R3_NUM_OF_DUMMY, \ (op)->dummy.buswidth != 0 ? \ - (((op)->dummy.nbytes * 8) / (op)->dummy.buswidth) : \ + (((dummybytes) * 8) / (op)->dummy.buswidth) : \ 0)) #define CDNS_XSPI_CMD_FLD_DSEQ_CMD_4(op, chipsel) ( \ @@ -609,6 +613,7 @@ static int cdns_xspi_send_stig_command(struct cdns_xspi_dev *cdns_xspi, u32 cmd_regs[6]; u32 cmd_status; int ret; + int dummybytes = op->dummy.nbytes; ret = cdns_xspi_wait_for_controller_idle(cdns_xspi); if (ret < 0) @@ -623,7 +628,12 @@ static int cdns_xspi_send_stig_command(struct cdns_xspi_dev *cdns_xspi, memset(cmd_regs, 0, sizeof(cmd_regs)); cmd_regs[1] = CDNS_XSPI_CMD_FLD_P1_INSTR_CMD_1(op, data_phase); cmd_regs[2] = CDNS_XSPI_CMD_FLD_P1_INSTR_CMD_2(op); - cmd_regs[3] = CDNS_XSPI_CMD_FLD_P1_INSTR_CMD_3(op); + if (dummybytes != 0) { + cmd_regs[3] = CDNS_XSPI_CMD_FLD_P1_INSTR_CMD_3(op, 1); + dummybytes--; + } else { + cmd_regs[3] = CDNS_XSPI_CMD_FLD_P1_INSTR_CMD_3(op, 0); + } cmd_regs[4] = CDNS_XSPI_CMD_FLD_P1_INSTR_CMD_4(op, cdns_xspi->cur_cs); @@ -633,7 +643,7 @@ static int cdns_xspi_send_stig_command(struct cdns_xspi_dev *cdns_xspi, cmd_regs[0] = CDNS_XSPI_STIG_DONE_FLAG; cmd_regs[1] = CDNS_XSPI_CMD_FLD_DSEQ_CMD_1(op); cmd_regs[2] = CDNS_XSPI_CMD_FLD_DSEQ_CMD_2(op); - cmd_regs[3] = CDNS_XSPI_CMD_FLD_DSEQ_CMD_3(op); + cmd_regs[3] = CDNS_XSPI_CMD_FLD_DSEQ_CMD_3(op, dummybytes); cmd_regs[4] = CDNS_XSPI_CMD_FLD_DSEQ_CMD_4(op, cdns_xspi->cur_cs); -- 2.17.1