Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp850646lqo; Wed, 8 May 2024 18:06:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWsLqXH3K6e/fIroKYAXao/MQdIMniyX17eZPT2Tr9OFHQ5FJhyBUSkeriheUzKbTkDgpHqzdHsddJF0ejrSdCgRXp12TrxCNqNEcqcFQ== X-Google-Smtp-Source: AGHT+IFE9SV+3aDCPXJn0pUn8zgfT9oM0f6x/ItVrm96tkSZ6pyCNsyFtQOBYFDkCMAmwZbIMMRO X-Received: by 2002:adf:ea10:0:b0:343:e52a:f51e with SMTP id ffacd0b85a97d-34fca623134mr2606748f8f.47.1715216778077; Wed, 08 May 2024 18:06:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715216778; cv=pass; d=google.com; s=arc-20160816; b=kAj/oRBBjV+qwIAaJG4sIFaDPR2UNwoDDu6VoDGtZU7mIJB+2QOML+z97Q32MFC3zB dabXpZWi1RPz+Mj3jnmUF7PS6Ch8TScxWAzwOd/ifNTM+cTsj3r2gK0v+5Azb3sEUgDS AkyCqoccMyJFidugPXqxoJvLJIumZsCBjXYu8zz1lCJyasifl38lzN+8LD9pZnXdEjAL OZfDPoKPQ4sxHnQhFX3YLJAwpEX2ABbHMUrfMC5OGKxJQOvn5fwLfNEEGqxB/tISu6To 0H+/FvIZpQp9AL0ZK0uuOlKcmv/jXI72PBPOU3TxUTPfmDhInP9dMER/QPbZLbsDn2Dl 9mEw== 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=3y7USUWFIL48Kqj676CFLy76yOo1qxAqx2O8QrwalVM=; fh=v5g/jM8LtXkxdDOZiY0auDT0qARIn/b9mdOLf8qLaog=; b=wJ0AZDidj0jwUgvruQgvjQqWL67h4Pj+WySr1MOvwmUXdEurgqvDBsNAFAhiyTJQYt a4AnR7spHjE4R/Rzi/vd44ijMybjrFURqcyq9QHFqOJycb4KK3x9Bmlcuv2XqbdnzIgz 3wbCWBpiGRE2WDGH4BIXJqdAGSN97rffsaKWw8IZRLBLACIOQpkITTkBJfmh0tpe9Zfs 0K28DxSpUmGyiQE7u4GoaYfqnZjsy4f3AtdhyIPD3NybgwiZQsk11yB5ngJWqBSm5cqr 2NRxcGYRa4WMzU7mR6HtqknmtmHjNcnGuuVHn922irfxPZxvtDCn7YQcW2n0dP///pf5 QeFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=c932OJBn; 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-173993-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173993-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 a640c23a62f3a-a5a17be70ccsi19689966b.788.2024.05.08.18.06.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 18:06:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173993-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=c932OJBn; 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-173993-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173993-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 752BB1F21C72 for ; Thu, 9 May 2024 01:06:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4F4A13A865; Thu, 9 May 2024 01:05:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="c932OJBn" Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (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 8B9D913A40B; Thu, 9 May 2024 01:05:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715216758; cv=none; b=ikKD6zS5lHGokJabsHUog1tyDPAje45JdNecCaQ8igBB6RN92gr2vyAc5ZvZbF6zHiFJUmKvatQ0fAYsSxlMAxpRir2UEl9Jj85WRMcKfBg35MT8jo/0lzrT1HeN9vdHtvzZ6dVIfpwcAxewmumfbHk4SqPjhKgq+R6SdUJHZG4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715216758; c=relaxed/simple; bh=BmWczAvYIeY9VwvByXvG9gzCDUlCbbCoQ+eCq6ftLcc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FgqbsDbDVYPXODRIVNwPWPjLl48hPa5H/ZjWDptU4eAEm761om8W8luHQE3i5jfqHLqtrs7UwZLHFBY4i5s/UWbuUwFgb+k9BNbgN12sq6UXRh6UQZUqZVW8a9U3wjc8qm2qW2QoytWsHkB77tIHNiZwzWpoAdaUk3zg1w3oILw= 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=c932OJBn; arc=none smtp.client-ip=67.231.148.174 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 (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 448NXnkW002999; Wed, 8 May 2024 18:05:52 -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=3y7USUWFIL48Kqj676CFLy76yOo1qxAqx2O8QrwalVM=; b=c93 2OJBnuRcb+Evi+oGEKGyXT6/BABf12u7MKNtusONQ5yZz51rxACLy+6wkicxvHtM WYw54vkEDHbOB3hmIjXSxLvZWFM5y7X30on8d5/Y90bdbR1PjzOqNxX+ay3eE/pz +FmhJOB1A9nW98Rm0luS5+ABtkD1j0jQ/oIp7nVKqn7jsuzMuiQfZ7Jz1Y0aNbiM whTkaCycYRAMzjGrputVTmUT4YQ46iZQH1wA/4OtspU6ht++BRaqOut6BpdzSlnl wcWZHWSy15bZX4R8aoX/xUnXQbTSN3jnNKWiiwMF/D753zXt38VE7cF87jckiVZw 0k+yms9Q6YJlMTEUiiA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3y0b2d2g16-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 May 2024 18:05:51 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 8 May 2024 18:05:51 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 8 May 2024 18:05:51 -0700 Received: from Dell2s-9.sclab.marvell.com (unknown [10.110.150.250]) by maili.marvell.com (Postfix) with ESMTP id 7FEB75B694B; Wed, 8 May 2024 18:05:50 -0700 (PDT) From: Witold Sadowski To: , , CC: , , , , , Witold Sadowski Subject: [PATCH v4 1/5] spi: cadence: Ensure data lines set to low during dummy-cycle period Date: Wed, 8 May 2024 18:05:19 -0700 Message-ID: <20240509010523.3152264-2-wsadowski@marvell.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240509010523.3152264-1-wsadowski@marvell.com> References: <20240509010523.3152264-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: NtaO670gh1TG85byhP6Oqk6NTFLv_Tja X-Proofpoint-ORIG-GUID: NtaO670gh1TG85byhP6Oqk6NTFLv_Tja X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-08_10,2024-05-08_01,2023-05-22_02 During dummy-cycles xSPI will switch GPIO into Hi-Z mode. In that dummy period voltage on data lines will slowly drop, what can cause unintentional modebyte transmission. Value send to SPI memory chip will depend on last address, and clock frequency. 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 8648b8eb080d..cdce2e280f66 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) ( \ @@ -351,6 +355,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) @@ -365,7 +370,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); @@ -375,7 +385,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.43.0