From patchwork Tue Jan 24 22:12:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Zhang X-Patchwork-Id: 47936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2405562wrn; Tue, 24 Jan 2023 14:36:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXsL2F2sXfVMI2TfQhYuW2+y9tI5Iq07Fmzn0uwZfnmGZd0goDKfxbQ4a75LuExtqd/v4RBG X-Received: by 2002:a05:6a00:1d23:b0:58d:a91d:e9f8 with SMTP id a35-20020a056a001d2300b0058da91de9f8mr25584284pfx.18.1674599766609; 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=v6Izi+yKQZLKnnXmGCql4c+OnCkdQ+6O2HAmLp/FHXBwQCAl1PqDrg4VJMiaqIHA/O qpFZBEfJgxHH/MkJsfRZXtzp9SP9fAk3tHkEKDekmoTW2NK4ouP/PTxzqmdI1985DF27 Sx2e1io9fEWdg2GESUoz3JlhjpLmD3AFCZz6KCuFYEl6QbShBE0swGPp80Js4RJ3BCgR Q/yhgF7mJHlZhU/KeBC3TZSjFqgD4ua5oA4uINdQRcWLLxO7KOITNvikmf3y9UAo6S6L 2OHUlsauXngiYihEOKCwPO3itHVW/811pHRn0Aa+XnNyDLqsVL9lwopFh/VzzMNh6NvZ 3m1w== 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=K89rUslcxYtXixXHQ9D6aV8VOfZ+TpJACnZP+0OZx+s=; b=HvoGTYcbwTjDjbkLWAxxcCULc50TvYCQggjIHThAOPJyT2lOw97Bnx004pVkltHiNL hX+PMxB+KA+x5Avx58XoE51p/bXM+8K8ORs40bffsiqXlEdd274kS/jmSjub/6i/DW2Y uYhQYANt9K8AN4IKsVss+aEZcFOKPQr0AGtPOKruc6f1AAhntVrZcv9aHuWU+93UjK5O J0xLpIKRbu2/vBEHVVim0D2s8tgAIciUx8187PFrHxilqvfxbneCQYY+Pl5E0wyiOR96 k1vC8jpKG7ihMLi9ZZVnOnHtddNet6xXtegnA3C7oDV9MPbFAfVlXJcc2a6P5CY8xcUX uHRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=NsMHtHYW; 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 z28-20020aa7959c000000b0058dc0251248si3493724pfj.179.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=NsMHtHYW; 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 S235000AbjAXWdy (ORCPT + 99 others); Tue, 24 Jan 2023 17:33:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233167AbjAXWdf (ORCPT ); Tue, 24 Jan 2023 17:33:35 -0500 Received: from relay.smtp-ext.broadcom.com (saphodev.broadcom.com [192.19.144.205]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C797F5355E; Tue, 24 Jan 2023 14:33:11 -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 B429BC0000F1; Tue, 24 Jan 2023 14:33:10 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com B429BC0000F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1674599590; bh=ZMcNyYfsZaAO6exRgOHHB5ZhDg4jeLeziD96VQjZ4vM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NsMHtHYWXQamk1DJWH9ya6bXgVAso5UeTT+XqTQOeVQEleQJMOa67xKyJk0PwuUsD PaLaMsx++xqsPvms58PXizwu5X5iijGQa4aTd+MzdgUiBbAmlRVqPdHf2AGLLVVFCS VWw6JuRfaWhmVNsuWfFV8MFiOICb7Iid+DCsuCTE= 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 7E97418041CAC6; Tue, 24 Jan 2023 14:33:10 -0800 (PST) Received: by bcacpedev-irv-3.lvn.broadcom.net (Postfix, from userid 28376) id 7C6F9101ACF; Tue, 24 Jan 2023 14:33:10 -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 12/14] spi: bcm63xx-hsspi: Disable spi mem dual io Date: Tue, 24 Jan 2023 14:12:15 -0800 Message-Id: <20230124221218.341511-13-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?1755945124953047148?= X-GMAIL-MSGID: =?utf-8?q?1755945124953047148?= 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. This makes sure the SPI flash driver selects the compatible read ops at run time. Signed-off-by: William Zhang --- Changes in v2: - Remove the code that uses the deprecated flag use_cs_workaround - Always disable dual io read ops as prepend is the default mode drivers/spi/spi-bcm63xx-hsspi.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/spi/spi-bcm63xx-hsspi.c b/drivers/spi/spi-bcm63xx-hsspi.c index 2a0bef943967..dd320fda7611 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 @@ -663,6 +664,23 @@ 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) +{ + if (!spi_mem_default_supports_op(mem, op)) + return false; + + /* Controller doesn't support spi mem dual/quad read cmd in prepend mode */ + if ((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; @@ -760,6 +778,7 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev) mutex_init(&bs->msg_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;