From patchwork Tue Jan 24 22:12:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Zhang X-Patchwork-Id: 47937 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2405567wrn; Tue, 24 Jan 2023 14:36:07 -0800 (PST) X-Google-Smtp-Source: AK7set/Yup67bAJpzD7Mm4+Zm1U+zTSKbXJLxunPKtlEkrtecYKIyj4WE7znNjYJSoY7nZa2U2zp X-Received: by 2002:a17:902:e542:b0:196:d0a:fa46 with SMTP id n2-20020a170902e54200b001960d0afa46mr6978097plf.27.1674599766955; Tue, 24 Jan 2023 14:36:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674599766; cv=none; d=google.com; s=arc-20160816; b=pPU44A0TsQvWXXlIwBdfttNDgxIZyNzkKJlx7FdcZAW7XZMVpke48fcApmZjc+XHTI jujRjbpi7UEiqK3p8SyC8LGC9kgLt3WhDhGGEPS3uoJKP+qvzIaJW3AC87XUKZBwPsth JTL+leh1jFtJ2/jKZPs/AhWah0i9jkfY7O/zmM2sirT87eCY9PlGYcngIP2fiaJRd2ut et5I2paLTrIkrGJCFmF9JbAa2YkPNu3eKb5w0u64sZPBlUIQDwGL4jDd2ejyf9ouQfH9 rayXljlxdsuvW24/g1IEJ3ZD7uesrGEJ2AqcToMz4/shPatnF4FnBgn8YEBj3YH2bF4M HTrA== 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=vgoPoYdT5G3BkG9BfGYnt7iQHxE8BvPBDMHPRPg1Xlc=; b=yibggQ5tOQAYj63oJVIewUcuAiE04fOno0liSb3deY89A4PNxwEMX7knUcSnLXCBPB 9ldc0Ztqxc7a6VNCGCXHzzi5llMEV0+dgkwpR5r4sTx1t8fUYhap9bJbEymWggr+jwA/ 5eu1BWXjJbHBTwjJQJu0hjww+Ijl3scuiw4wNR6qzK3xFpWgsWee9Ea8rzoKEB8zNnGb 63vjsvhaN1PjPXgeELLcYrrXDdzvzBZIG8uxfoU8SUwwZT6lDOP9P9XxEFiajhWAJQhk YjSe/Dr6X2fMI7nhqY8TXexuI74J9BZFDiU9bHgHEAxI+O3zcLp4gytrYGK4pOkAzDsh VRwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=HERIvobJ; 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 l12-20020a170902f68c00b0018940a4bbcbsi4313294plg.250.2023.01.24.14.35.54; Tue, 24 Jan 2023 14:36:06 -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=HERIvobJ; 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 S235154AbjAXWdz (ORCPT + 99 others); Tue, 24 Jan 2023 17:33:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233524AbjAXWdf (ORCPT ); Tue, 24 Jan 2023 17:33:35 -0500 Received: from relay.smtp-ext.broadcom.com (lpdvsmtp11.broadcom.com [192.19.166.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5304753558; Tue, 24 Jan 2023 14:33:10 -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 436CAC0000FC; Tue, 24 Jan 2023 14:33:10 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 436CAC0000FC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1674599590; bh=uCIT4WkEwESkcQXbcHTvT/VVmK1L0H4DtPalP4EYkAY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HERIvobJNoEP23NMiuRvOaMiX3m1KuIdgh4WRmES88fsRNU3dWbHVvAighsBgJlqg 6W5/QtPOuX52Y2XLihpIhlGuftYcAXUe4DFZZyKrJ9/GCjKS3DtOL8uhBn+ZobrJSp P2dmMgJXzPjdgGl6/K7hSX4Wfpv/CSz1mzs8Yhn0= 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 41DFF18041CAC6; Tue, 24 Jan 2023 14:33:10 -0800 (PST) Received: by bcacpedev-irv-3.lvn.broadcom.net (Postfix, from userid 28376) id 790B1101B56; Tue, 24 Jan 2023 14:33:03 -0800 (PST) From: William Zhang To: Linux SPI List , Broadcom Kernel List Cc: tomer.yacoby@broadcom.com, kursad.oney@broadcom.com, dregan@mail.com, f.fainelli@gmail.com, anand.gore@broadcom.com, jonas.gorski@gmail.com, dan.beygelman@broadcom.com, joel.peshkin@broadcom.com, William Zhang , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH v2 09/14] spi: bcm63xx-hsspi: Fix multi-bit mode setting Date: Tue, 24 Jan 2023 14:12:12 -0800 Message-Id: <20230124221218.341511-10-william.zhang@broadcom.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230124221218.341511-1-william.zhang@broadcom.com> References: <20230124221218.341511-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?1755945124927251457?= X-GMAIL-MSGID: =?utf-8?q?1755945124927251457?= 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 --- (no changes since v1) 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 696e14abba2d..8f0d31764f98 100644 --- a/drivers/spi/spi-bcm63xx-hsspi.c +++ b/drivers/spi/spi-bcm63xx-hsspi.c @@ -215,7 +215,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); @@ -232,11 +232,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) {