From patchwork Fri Jan 6 20:08:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Zhang X-Patchwork-Id: 40240 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1006520wrt; Fri, 6 Jan 2023 12:12:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXuTseFxAyYh75uhcuX696ZSZxPM4otlYEPzVgNdnXOyN4eJi3Q1U0uGCHbfJuoaAIJtsyF3 X-Received: by 2002:a17:906:8a58:b0:7c1:6981:d062 with SMTP id gx24-20020a1709068a5800b007c16981d062mr49900697ejc.72.1673035952563; Fri, 06 Jan 2023 12:12:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673035952; cv=none; d=google.com; s=arc-20160816; b=GmaSDQWmhGUbaTr5aiof3eYw5V2dAe0s62f5mWqG/KVjO+M9vu2/Y3AkXlNZQHGeq4 r9kg29O6DPlDw5rTKV9w1CwJttRbBwSawdniCiuqE14KT4meStTeCSyanmpizBcCDgpU wu5oxTQGOrQhnRlHYRLrShJ+fVot2j8MmC3aTF1QKn3XTnNdP97icbWqF+a5sok5m7V6 N7JoqmApl9CHHeqmhGTApe/r1DINvGfhogavjAiYWdjWJ/QWVUYWRVXj0x4fssyZXUFQ jXjUA2S3xEVMkYlnGdTa4KMRXabC6WXD1/ugKMk0C+p4PXAVL96ULb0uB1ZspghvIZCF 1wOQ== 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:dkim-filter; bh=st0EA8HqRQn4ry/Ey+XSOXkwR07jrKA7+GlhoKjAAB4=; b=EbkpPGCcK7VwUmYignovPezl0hsn5zuZMU6kvcKpQCLab/M6XC7zt9chIJdyTA2Eii FvA38SO9p96rAzV6fCK0Qcg0C47Bmt4SKjxVLr5CpP1J/4b7adjSo8+r7k6jxsEad4CB 8pTusNrJ/YM5BTI+XWX3WCb5Hfyy5VCwbRb+/qezfBnQhlOR1QAzlcxsNKU7bhdLiwq2 lT1zjtcQLq7QW8vQQPwkfPgorE6JNGuJANCCis8enVDts3uoBHjny/8O8DG0/HpHhBtD fn+h+tRYmPFjaMgCBCynNcbTqpNs2qRjS8ZoclYbEGEE4YR7KcWcdwGp82wA5y8Jfe7S NKYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=oopxl0l0; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sz15-20020a1709078b0f00b007ae30b550e5si1829977ejc.854.2023.01.06.12.12.08; Fri, 06 Jan 2023 12:12:32 -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=@broadcom.com header.s=dkimrelay header.b=oopxl0l0; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236290AbjAFUK1 (ORCPT + 99 others); Fri, 6 Jan 2023 15:10:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236287AbjAFUKN (ORCPT ); Fri, 6 Jan 2023 15:10:13 -0500 Received: from relay.smtp-ext.broadcom.com (lpdvsmtp09.broadcom.com [192.19.166.228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25BBC8408B; Fri, 6 Jan 2023 12:10:12 -0800 (PST) Received: from mail-lvn-it-01.lvn.broadcom.net (mail-lvn-it-01.lvn.broadcom.net [10.75.146.107]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id CEBA9C0000E5; Fri, 6 Jan 2023 12:10:11 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com CEBA9C0000E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1673035811; bh=5BERIlcA8JzJwkeyjt1ucRTPCFChZtPk/WPUu85nbtk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oopxl0l0RyXwtIlpWOxkb8UsK5cP960dZ2Hs4NnG8K3M17cJlr1hSbCMej5KX0HTI /9+kR1DxAd5UhBqFQoKo8uS+NyoSU04fd1IPvYZnqA4Rcvu3cMr6suGv4G+10jtbEi sLYCGhf6kmPMnLfwHuyQnBGjlA8oX1+/ZG7EVmtg= Received: from bcacpedev-irv-3.lvn.broadcom.net (bcacpedev-irv-3.lvn.broadcom.net [10.75.138.105]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail-lvn-it-01.lvn.broadcom.net (Postfix) with ESMTPS id CCC5818041CAC6; Fri, 6 Jan 2023 12:10:11 -0800 (PST) Received: by bcacpedev-irv-3.lvn.broadcom.net (Postfix, from userid 28376) id 184DB101B3C; Fri, 6 Jan 2023 12:10:05 -0800 (PST) From: William Zhang To: Linux SPI List , Broadcom Kernel List Cc: anand.gore@broadcom.com, tomer.yacoby@broadcom.com, dan.beygelman@broadcom.com, joel.peshkin@broadcom.com, f.fainelli@gmail.com, jonas.gorski@gmail.com, kursad.oney@broadcom.com, dregan@mail.com, William Zhang , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 09/16] spi: bcm63xx-hsspi: Fix multi-bit mode setting Date: Fri, 6 Jan 2023 12:08:01 -0800 Message-Id: <20230106200809.330769-10-william.zhang@broadcom.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230106200809.330769-1-william.zhang@broadcom.com> References: <20230106200809.330769-1-william.zhang@broadcom.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754305346931941976?= X-GMAIL-MSGID: =?utf-8?q?1754305346931941976?= Currently the driver always sets the controller to dual data bit mode for both tx and rx data in the profile mode control register even for single data bit transfer. Luckily the opcode is set correctly according to SPI transfer data bit width so it does not actually cause issues. This change fixes the problem by setting tx and rx data bit mode field correctly according to the actual SPI transfer tx and rx data bit width. Fixes: 142168eba9dc ("spi: bcm63xx-hsspi: add bcm63xx HSSPI driver") Signed-off-by: William Zhang --- drivers/spi/spi-bcm63xx-hsspi.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-bcm63xx-hsspi.c b/drivers/spi/spi-bcm63xx-hsspi.c index f2b1b83bd6d4..398c412dcc3e 100644 --- a/drivers/spi/spi-bcm63xx-hsspi.c +++ b/drivers/spi/spi-bcm63xx-hsspi.c @@ -166,7 +166,7 @@ static int bcm63xx_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t) int step_size = HSSPI_BUFFER_LEN; const u8 *tx = t->tx_buf; u8 *rx = t->rx_buf; - u32 val; + u32 val = 0; unsigned long limit; bcm63xx_hsspi_set_clk(bs, spi, t->speed_hz); @@ -183,11 +183,16 @@ static int bcm63xx_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t) step_size -= HSSPI_OPCODE_LEN; if ((opcode == HSSPI_OP_READ && t->rx_nbits == SPI_NBITS_DUAL) || - (opcode == HSSPI_OP_WRITE && t->tx_nbits == SPI_NBITS_DUAL)) + (opcode == HSSPI_OP_WRITE && t->tx_nbits == SPI_NBITS_DUAL)) { opcode |= HSSPI_OP_MULTIBIT; - __raw_writel(1 << MODE_CTRL_MULTIDATA_WR_SIZE_SHIFT | - 1 << MODE_CTRL_MULTIDATA_RD_SIZE_SHIFT | 0xff, + if (t->rx_nbits == SPI_NBITS_DUAL) + val |= 1 << MODE_CTRL_MULTIDATA_RD_SIZE_SHIFT; + if (t->tx_nbits == SPI_NBITS_DUAL) + val |= 1 << MODE_CTRL_MULTIDATA_WR_SIZE_SHIFT; + } + + __raw_writel(val | 0xff, bs->regs + HSSPI_PROFILE_MODE_CTRL_REG(chip_select)); while (pending > 0) {