Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp2707312rwj; Mon, 19 Dec 2022 07:56:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf6FtGTvTR36kqdW1Ti92ZOZh//NWrn/+RyFZTtAnESk4kkCAS4nxmY1yQhhx3oJPzalOsw4 X-Received: by 2002:a17:90a:c24f:b0:223:1c2c:edd8 with SMTP id d15-20020a17090ac24f00b002231c2cedd8mr26126801pjx.23.1671465417054; Mon, 19 Dec 2022 07:56:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671465417; cv=none; d=google.com; s=arc-20160816; b=yTmtNRkI0njG0FdGj3ZTnBGvB6apDhBNvn0GRxngZ4iQuruKjJt6BMUotlb4CXC0Y7 zvInE+z25aJ1JKCfB3lh4Twy+h9DD5Ijt2iiMzaqibHZp0wlBg5dggIFcjOwFrR9YwnX 8FRqFUfx99rlU2uoJjiKRA9qcJ0SpX3b5DnELBZ3ZboJ8M4wMA7YnnWJMzy5zYaifHqq NHmJ2PjHg0Ttw56ZzoIZgOg6lcJTclrZn+NeVCSqwjNADy5lr9InAz1By128JpwJcHoi zeO0ayPU/Ss3aC+i6BiBmzIp1co0az8gDbiPRmaLkY7WNjfJDvy5CW6NplUhhel4V9VF aB7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b1xFk9nbe6M6noaw8W0OCy7ceqiE5RxralDc8B4HjwA=; b=TPUigWYx4oYIFKIdEHkfI8gepbCm+cr1MjXhThR2xCc7lzNILwibepgndX2ET5Zrq8 qczejOLBzWjx0bH04kkfvI/Z0lWeyBppcYFvKmy09ZzUOdHdJgNbWn6pIjUNgroQpKx5 KdHOIE1WnW32bmWSDNd2kJRtJg/5UH5ryHe6PD36oLaguO4E1EXisA6vwILIpZk3QVgk Z5QDDwAq9FqumKrM4fv5cb2MPt80S54Fzy5dqYMBabEVWBq8L17mAv9iQQq0HFr3wOaO er1YP7CPg0p1aaczhMKbpw00Bug+lw9RuzQU+haGwvB6W2t60Ag16h9JkbXGcWwwzZLZ pjhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=jO0ebExx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id em5-20020a17090b014500b0020ae29877besi10648284pjb.20.2022.12.19.07.56.48; Mon, 19 Dec 2022 07:56:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=jO0ebExx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232372AbiLSOnb (ORCPT + 71 others); Mon, 19 Dec 2022 09:43:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231881AbiLSOnT (ORCPT ); Mon, 19 Dec 2022 09:43:19 -0500 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4589863C7; Mon, 19 Dec 2022 06:43:18 -0800 (PST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BJAR3av006554; Mon, 19 Dec 2022 06:43:14 -0800 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=b1xFk9nbe6M6noaw8W0OCy7ceqiE5RxralDc8B4HjwA=; b=jO0ebExxH6Ay7NoR2Tf1RihykwYRxfjFjrz/0MjdChFYTQPvDCT6G5OcOaXseauHQppI G7x7QoHin9t9sY2Z2UILhPLdJJOlOwaPe1jet6HLZ6ugYmnCBJ56Ea/jCHtnzdqiM1aT hA2LB2MrQXExCd7BZJATr2WTET1niSnD/3mP0hZeIajlV3Nej2OAz5aMUMX+ESIgs2Vh avyorgCPNBxSddnw0OpjnHzJUZuJXA6ffOybdFCwstRenlnPB+Miu1Zec0qaJYl+FW3t 527Ip/s8WSGExxI7oZC/DLk7HOEJnEFDKYSoXxTs74sqH+3mmwe0CdxCzK7E75D8R7WC xg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3mjnans4hu-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 19 Dec 2022 06:43:13 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 19 Dec 2022 06:43:12 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Mon, 19 Dec 2022 06:43:12 -0800 Received: from localhost.localdomain (unknown [10.110.150.170]) by maili.marvell.com (Postfix) with ESMTP id 06B973F7087; Mon, 19 Dec 2022 06:43:12 -0800 (PST) From: Witold Sadowski To: CC: , , , , , , , , Subject: [PATCH 7/7] spi: cadence: Force single modebyte Date: Mon, 19 Dec 2022 06:42:54 -0800 Message-ID: <20221219144254.20883-8-wsadowski@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221219144254.20883-1-wsadowski@marvell.com> References: <20221219144254.20883-1-wsadowski@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: po9GJS0Ptej4WzyagKvGAkmlOGm7ofJD X-Proofpoint-ORIG-GUID: po9GJS0Ptej4WzyagKvGAkmlOGm7ofJD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-19_01,2022-12-15_02,2022-06-22_01 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Chandrakala Chavva --- 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 c73faf6b0546..7d467169f62b 100644 --- a/drivers/spi/spi-cadence-xspi.c +++ b/drivers/spi/spi-cadence-xspi.c @@ -146,6 +146,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) ? \ @@ -158,9 +161,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) ( \ @@ -174,12 +178,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) ( \ @@ -607,6 +611,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) @@ -621,7 +626,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); @@ -631,7 +641,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