From patchwork Fri Jan 6 20:08:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Zhang X-Patchwork-Id: 40242 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1006526wrt; Fri, 6 Jan 2023 12:12:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXviMWhZ0AJnOXvdx9OtW7PnI+p2VqhwYnJN8S18+DeY+0mKrKkBo7bw890wwapzC8c+EDXV X-Received: by 2002:a17:906:5dad:b0:7c0:dfba:54d3 with SMTP id n13-20020a1709065dad00b007c0dfba54d3mr9023649ejv.20.1673035953674; Fri, 06 Jan 2023 12:12:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673035953; cv=none; d=google.com; s=arc-20160816; b=faG06XUyvdC+CtLwAJ43qwkVtlcXpctioqABal1KGe3HZ+SyvwCRNDsoX7q6fap2Zl FnoA9iMt99aauzBwpgUnG/7vub0JhmWkmnjp7bKKW+5FxalItSC1U/XMs2fsQ9Troihx aWyRZVUYsBkXChKvZV33pzP4xZmXmMQxTXk8bAWfS9Iq+FaaK1sXWP6rYgYEnzlCr88e Cb38Hxtt9W4eqm7UGGgdqhFost9sjKhY+0mMWAsnI96hFyA7kLjV5nVR7J9dMfvWutsB KdGMlhbOmy+08d+asX9AugniAF0pq/h6IxlF+vlBQSdHy1/f7kKhGXxKWP86u7sa9+d9 3p8g== 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=CIxtXVLXHbIkdvY0q8kWHS0WTLY1RTpc54DLksBM/q0=; b=l+jS0XZod2gfBz/yfmSVS5plKOzt8HfjStQEI3eSIe/PRGEcKfOjz+Gk7TB27yBWay JxAr5++qr9myFIR/KijyBEp3qUHQJJQCY4Usq4+nOzLr3Ws+19uSNxRe2NCeGd3e6/02 gCJ7V6X5rEB1fxRdnVuMzmlujycPzol/2HWRH5G2mPIswsc7r5dTEkUR4xkx+xbZyvY9 Qqy0HF5pfzUs5eefKCWssWpM1SemzOf8+XFrPuPqMee0yIHW3tHr979tEz5pl+XXzdPv wY+l6jmjlBOW4SgWd9krLRqBkby0R5TM+TkCsBmxsakz72ch95bWgECjAjEtHps+c/IB sviQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=n+9M+jMp; 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 ds4-20020a170907724400b0081a9c3ca4bcsi2427480ejc.379.2023.01.06.12.12.09; Fri, 06 Jan 2023 12:12:33 -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=n+9M+jMp; 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 S236379AbjAFUKe (ORCPT + 99 others); Fri, 6 Jan 2023 15:10:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236305AbjAFUKR (ORCPT ); Fri, 6 Jan 2023 15:10:17 -0500 Received: from relay.smtp-ext.broadcom.com (lpdvacalvio01.broadcom.com [192.19.166.228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EFB28408F; Fri, 6 Jan 2023 12:10:17 -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 BC54AC0000E5; Fri, 6 Jan 2023 12:10:16 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com BC54AC0000E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1673035816; bh=+uD5a54icoUzLx5d+NsDh5T2zoEiPm+PP/DVulvOk6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n+9M+jMpQjjfxocTaKLvIc6d8q5QAICaG6Wcmk8aAoFA4r14syS0Vi8oQkhutuCnl DxKE3a7B1vdJ5+uH2epxyHsxhtV5T475h26o6uOC/r80wWBi20EjxX9+QoO8Ymwt8g Iw17eLWw3Bw9C5GXhQ/3kmZLIM0Ashg23dgf1jTA= 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 BA66A18041CAC6; Fri, 6 Jan 2023 12:10:16 -0800 (PST) Received: by bcacpedev-irv-3.lvn.broadcom.net (Postfix, from userid 28376) id B86B1101B3C; Fri, 6 Jan 2023 12:10:16 -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 14/16] spi: bcm63xx-hsspi: prepend: Disable spi mem dual io read op support Date: Fri, 6 Jan 2023 12:08:06 -0800 Message-Id: <20230106200809.330769-15-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?1754305347670585543?= X-GMAIL-MSGID: =?utf-8?q?1754305347670585543?= In general the controller supports SPI dual mode operation but the particular SPI flash dual io read op switches from single mode in cmd phase to dual mode in address and data phase. This is not compatible with prepend operation where cmd and address are sent out through the prepend buffer and they must use same the number of io pins. This patch disables these SPI flash dual io read ops through the mem_ops supports_op interface when prepend mode is used. This makes sure the SPI flash driver selects the compatible read ops at run time. Signed-off-by: William Zhang --- drivers/spi/spi-bcm63xx-hsspi.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/spi/spi-bcm63xx-hsspi.c b/drivers/spi/spi-bcm63xx-hsspi.c index be4ca01f332a..7ede7f02ba2c 100644 --- a/drivers/spi/spi-bcm63xx-hsspi.c +++ b/drivers/spi/spi-bcm63xx-hsspi.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -596,6 +597,26 @@ static int bcm63xx_hsspi_transfer_one(struct spi_master *master, return 0; } +static bool bcm63xx_hsspi_mem_supports_op(struct spi_mem *mem, + const struct spi_mem_op *op) +{ + struct bcm63xx_hsspi *bs = spi_master_get_devdata(mem->spi->master); + + if (!spi_mem_default_supports_op(mem, op)) + return false; + + /* Controller doesn't support spi mem dual/quad read cmd in prepend mode */ + if (!bs->use_cs_workaround && + ((op->cmd.opcode == 0xbb) || (op->cmd.opcode == 0xeb))) + return false; + + return true; +} + +static const struct spi_controller_mem_ops bcm63xx_hsspi_mem_ops = { + .supports_op = bcm63xx_hsspi_mem_supports_op, +}; + static irqreturn_t bcm63xx_hsspi_interrupt(int irq, void *dev_id) { struct bcm63xx_hsspi *bs = (struct bcm63xx_hsspi *)dev_id; @@ -692,6 +713,7 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev) mutex_init(&bs->bus_mutex); init_completion(&bs->done); + master->mem_ops = &bcm63xx_hsspi_mem_ops; master->dev.of_node = dev->of_node; if (!dev->of_node) { master->bus_num = HSSPI_BUS_NUM;