From patchwork Fri Jul 21 22:00:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 108516 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1320804qge; Fri, 21 Jul 2017 15:02:23 -0700 (PDT) X-Received: by 10.99.119.76 with SMTP id s73mr8731942pgc.374.1500674543205; Fri, 21 Jul 2017 15:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500674543; cv=none; d=google.com; s=arc-20160816; b=UTYM7sKF0eVhzxCQhUcfc7pOcV7iqmypD+Q6D3SXV6IJNXGtt7lo/hSED5eOccN/4U 6zVD3PXl1umpjUaVFFBHQ3VFYAdpWWdV1GM/QvCxIniXGH3z0pTRnh1yle4nvFBWItNn EmENflwC7N49Go2qVAVQ829cuxuaAcjOZn44IZv+e4SRlNl0rozVrUMS+/0CMdooJl9C 6NwIq1LoOowG5h+HbYxgCiCEEhzPXENqjglkZQi1pJ7qPNhiWCsVshdHbE2xX9q2siAN feqOy+6Fbh4GUtDs52TCxsN6v1viudyARCH24V3+iGSgomH8ffiihuHlO8t568GVlSMp OlDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ieWjW9jZgHj5fcvwTOWGpmdkALQAUwGdsJfUUjPhrjM=; b=D1BiKYGJWDfIe3YwPh24fYX7x1p93ppRDDNVLIgv5Aqb+EijCwzZAXq4XZScx1OdnV F2MU2PyDk5epK2NiQdYrdKIzcOE+W6pHv0cwCky32skoWDafUmsrwEedN2Z3zMZRc318 NNWB/oxkhqhQ7v1GbWkFZSywiOA0x3aPDyR3adEEiV5/BMwqnZ9scKVU5xHxnCW+9FLS e9arfo2tu2ZZw9XIoYmyvWoXXjX8Y4RDPNf65CrhkGfIRGIgfSeTMhgKJtNVFXCNwUZE ZTOzB/Er1KK9qeoENazuntVPyZ1acNztmcymP5ZMhY/08echlz6Mf6fw2ULDqsc6q6v0 3PHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12si3618511pgd.337.2017.07.21.15.02.23 for ; Fri, 21 Jul 2017 15:02:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753111AbdGUWCW (ORCPT ); Fri, 21 Jul 2017 18:02:22 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:65136 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754740AbdGUWB5 (ORCPT ); Fri, 21 Jul 2017 18:01:57 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.129]) with ESMTPA (Nemesis) id 0MWvXU-1d4rVv3dSe-00W0f6; Sat, 22 Jul 2017 00:01:47 +0200 From: Arnd Bergmann To: Mark Brown Cc: Arnd Bergmann , Cyrille Pitchen , Geert Uytterhoeven , Hauke Mehrtens , Kamal Dasu , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] spi: document broadcom qspi driver as broken Date: Sat, 22 Jul 2017 00:00:20 +0200 Message-Id: <20170721220142.3400093-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:yPi4kOLL+TgJu+pCEOnxxy9zqB5mJygpamT8c6qZ0sWbyylHMrI /A+xGDOoZQVtkB9vng3+9BcfCZXqnrLOFDBhYaxZ5un8Ir4RICWtLFbgms3PSAX5DbgPcR7 gxrgsKjoiHwhI3OjTHMyhPT2e+tTJhoGBzeq++umCPGpLb6/IYbeIU+ogh4+dLvin23CacA yTz9VW+RrLjSwhrfmU22w== X-UI-Out-Filterresults: notjunk:1; V01:K0:2UeG5CDeY9A=:MqwA3T+VJDqB50qLs2IXW0 br0/NRr0yUiLXJJDK6RmeHy2AxSxzF+jPSSoYZtznq3SKjpc6VdS9I56yJMhLmqpeghtijApG yKjPAbaf+I4d1V7WwG1qps2lN7NJJg9GquekYBO/G7qYCNpPFm0z1FaS0h5CDh6m1AGHNdsyh 6EF9xeM0+qEFvcvZzgMnTZXUIR3NCJLTEo6cWRNrEsJ29U0Hv9QOFFtDX6ooqnLzITkWAT892 4yCRguR0XpDHpF095T4yacki33CWwt+0FZl11xMe4WY7o/7YEsIzxqO9O1h+Jr5iMstd9J0Ua b3xXh2lbQIEOdaHb6N9xIdGBvsG+YDz/fVFmedzzTTMmh1Lnj73URFcTsyQ3xE3soKmBqz42/ ZV0p5VXaUbC6ovw22sq1kMsePYT0wn64LauVoOpjxmHOehWpTTPyUZaaeZDwv53ecRAK3lDLg pqhcEwH7fbe5ZDozBZWxcWB86jmWvZ054Qu7Fw+3VvCNxQUfQuhlE+ZxIRPDUA0UZm/SWsYqx Y7LEFoNwboKeYRtzA6Tmo1VEzxpLDLgUuFOSLDfC6cK93ojnCtp1dwVVtXzehpUc55DpW0CHY vqSbCMoL2KSVgckm6Fq9RFIcdIwSRMGuzzRofLtxyd1IIf1PWr4u8KTLhZ3nB8KZDZDUu2Io1 Mp1ihE3+viV5t0BdH0OpzgAzEFl2PXpvJCVi2fKkoAiZQNzX7g01TztBZPmaJUHVr6oEmXSt6 PXa7ZJObzU0tJwlXRo/UFrdj7GCzRluelLRZAw== Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The newly broadcom qspi driver in drivers/spi produces a build warning when CONFIG_MTD is disabled: include/linux/mtd/cfi.h:76:2: #warning No CONFIG_MTD_CFI_Ix selected. No NOR chip support can work. [-Werror=cpp] I had suggested a workaround earlier, but Cyrille Pitchen explained that actually the broadcom qspi is broken here and needs to be fixed, see the lenghthy reply in patchwork. As nothing has happened on that driver, this tries to at least avoid the build failure, by marking the driver as broken unless CONFIG_MTD is enabled. Also, I add a WARN_ON_ONCE runtime that triggers when the spi-nor framework and the driver disagree about the command opcode, which was one of several issues that Cyrille pointed out. My patch does not attempt to fix any of the actual bugs though, it just tries to avoid the build error while highlighting the problems. Ideally, someone would step up to create a tested fix. If that doesn't happen, please merge my version instead as a workaround. Fixes: fa236a7ef240 ("spi: bcm-qspi: Add Broadcom MSPI driver") Link: https://patchwork.kernel.org/patch/9334097/ Link: https://patchwork.kernel.org/patch/9624585/ Signed-off-by: Arnd Bergmann Cc: Cyrille Pitchen --- --- drivers/spi/Kconfig | 1 + drivers/spi/spi-bcm-qspi.c | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) -- 2.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 9b31351fe429..c7a80f9d6dd0 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -164,6 +164,7 @@ config SPI_BCM_QSPI tristate "Broadcom BSPI and MSPI controller support" depends on ARCH_BRCMSTB || ARCH_BCM || ARCH_BCM_IPROC || \ BMIPS_GENERIC || COMPILE_TEST + depends on BROKEN || MTD default ARCH_BCM_IPROC help Enables support for the Broadcom SPI flash and MSPI controller. diff --git a/drivers/spi/spi-bcm-qspi.c b/drivers/spi/spi-bcm-qspi.c index b19722ba908c..a388a3873552 100644 --- a/drivers/spi/spi-bcm-qspi.c +++ b/drivers/spi/spi-bcm-qspi.c @@ -349,12 +349,13 @@ static void bcm_qspi_bspi_set_xfer_params(struct bcm_qspi *qspi, u8 cmd_byte, bcm_qspi_write(qspi, BSPI, BSPI_FLEX_MODE_ENABLE, flex_mode); } -static int bcm_qspi_bspi_set_flex_mode(struct bcm_qspi *qspi, int width, - int addrlen, int hp) +static int bcm_qspi_bspi_set_flex_mode(struct bcm_qspi *qspi, + struct spi_flash_read_message *msg, + int width, int addrlen, int hp) { int bpc = 0, bpp = 0; u8 command = SPINOR_OP_READ_FAST; - int flex_mode = 1, rv = 0; + int flex_mode = 1; bool spans_4byte = false; dev_dbg(&qspi->pdev->dev, "set flex mode w %x addrlen %x hp %d\n", @@ -405,15 +406,14 @@ static int bcm_qspi_bspi_set_flex_mode(struct bcm_qspi *qspi, int width, } break; default: - rv = -EINVAL; - break; + return -EINVAL; } - if (rv == 0) - bcm_qspi_bspi_set_xfer_params(qspi, command, bpp, bpc, - flex_mode); + WARN_ON_ONCE(command != msg->read_opcode); - return rv; + bcm_qspi_bspi_set_xfer_params(qspi, command, bpp, bpc, + flex_mode); + return 0; } static int bcm_qspi_bspi_set_override(struct bcm_qspi *qspi, int width, @@ -461,6 +461,7 @@ static int bcm_qspi_bspi_set_override(struct bcm_qspi *qspi, int width, } static int bcm_qspi_bspi_set_mode(struct bcm_qspi *qspi, + struct spi_flash_read_message *msg, int width, int addrlen, int hp) { int error = 0; @@ -491,7 +492,7 @@ static int bcm_qspi_bspi_set_mode(struct bcm_qspi *qspi, } if (qspi->xfer_mode.flex_mode) - error = bcm_qspi_bspi_set_flex_mode(qspi, width, addrlen, hp); + error = bcm_qspi_bspi_set_flex_mode(qspi, msg, width, addrlen, hp); if (error) { dev_warn(&qspi->pdev->dev, @@ -1012,7 +1013,7 @@ static int bcm_qspi_flash_read(struct spi_device *spi, io_width = msg->data_nbits ? msg->data_nbits : SPI_NBITS_SINGLE; addrlen = msg->addr_width; - ret = bcm_qspi_bspi_set_mode(qspi, io_width, addrlen, -1); + ret = bcm_qspi_bspi_set_mode(qspi, msg, io_width, addrlen, -1); if (!ret) ret = bcm_qspi_bspi_flash_read(spi, msg);