From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADBB1C07E95 for ; Fri, 2 Jul 2021 18:10:50 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BB9A161402 for ; Fri, 2 Jul 2021 18:10:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB9A161402 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 53CC582859; Fri, 2 Jul 2021 20:10:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1625249447; bh=uv1iNakCW+p+hi7S9cmjd/NCqnTEnuTlKst2sIAAW1M=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=IQKr6sZYHphJebdxhza+pRUJMPwk9UQAVSSyg7FcNHgwvnIlXjAgIm8TUWx9Msb2C L18Z71adEeewTXtd5VEsyG4S9Y+CucYAs9iBOSzWfXDvgt0gkv3wudi3QGjuUGd/v3 ih8LMONP6pxWXfhn/tLZMgI13yu7BVXGsHuZ1YfazhNkSyBTvp9RWxOW6E/CUpFCo7 On/zlqtjNit6Gcbslob1MspGVlBH9Tdpr5tQCvi08fQagG7vGs/x1DCLH8B2YWwE0L J4aprcPdrWRE22sGWilcaBiUZwf72Vf9HXRu2HZd0I4sPgVjxN6A5HQDhp6Hslef9r LYfl+NS21PVGg== Received: from [IPv6:::1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 784C380A22; Fri, 2 Jul 2021 20:10:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1625249445; bh=uv1iNakCW+p+hi7S9cmjd/NCqnTEnuTlKst2sIAAW1M=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=A+jybQxXmGKlIwwlwF+apmCxo5yhVKlm+DttvfiH++iOXuJvNvgauVQgyeOy5sXnr musYSkR7HCbmGJZBA/EjiWPHWMgcRzoQsjEbHPj5eIwXH8Lo10pm1fhl/cIqnuGpxg NenGlaEPMR5cpB17/sjzo2QQZXxVNeT17MZXQ9laxlOXEOn3PQfKCEZeov/suNORIR 7mrg6ez6M6Vr/12+I6TcgpTltnDUJND2L2g6HI+9wsauyi6rUeuSX+m6eUAmYELxSu 4GuGGmrIb1og922G+ZaTp2QNpglNpDF9cINo66KSi/a1UeFs5yVNdqfM+8e6uymKYI 0UqGEbUxnRcYw== Subject: Re: [PATCH V2] spi: Update speed/mode on change To: Da Xue , "u-boot@lists.denx.de" Cc: Neil Armstrong References: <20210610120000.5147-1-marex@denx.de> <20210630164943.GG9516@bill-the-cat> <912308c5-3493-badb-36ba-55e5c265b2c9@denx.de> From: Marek Vasut Message-ID: <41e7bf52-227c-fe87-f249-6d2df8d16aba@denx.de> Date: Fri, 2 Jul 2021 20:10:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 7/2/21 8:03 PM, Da Xue wrote: > SF: Detected gd25lq128 with page size 256 Bytes, erase size 64 KiB, total > 16 MiB > SPI mode: 3 > meson_spifc spi@8c80: Cannot set mode (err=-19) > Failed to initialize SPI flash at 0:0 (error -19) > > I added spi-rx-bus-width = <1> and spi-tx-bus-width = <1> > > On Fri, Jul 2, 2021 at 1:44 PM Marek Vasut wrote: > >> On 7/2/21 7:24 PM, Da Xue wrote: >>> Hi Marek, >>> >>> This patch breaks meson_spifc: >>> >>> SF: Detected gd25lq128 with page size 256 Bytes, erase size 64 KiB, total >>> 16 MiB >>> meson_spifc spi@8c80: Cannot set mode (err=-19) >>> Failed to initialize SPI flash at 0:0 (error -19) >>> >>> Best, >>> >>> Da >>> >>> On Wed, Jun 30, 2021 at 12:49 PM Tom Rini wrote: >>> >>>> On Thu, Jun 10, 2021 at 02:00:00PM +0200, Marek Vasut wrote: >>>> >>>>> The spi_get_bus_and_cs() may be called on the same bus and chipselect >>>>> with different frequency or mode. This is valid usecase, but the code >>>>> fails to notify the controller of such a configuration change. Call >>>>> spi_set_speed_mode() in case bus frequency or bus mode changed to let >>>>> the controller update the configuration. >>>>> >>>>> The problem can easily be triggered using the sspi command: >>>>> => sspi 0:0@1000 >>>>> => sspi 0:0@2000 >>>>> Without this patch, both transfers happen at 1000 Hz. With this patch, >>>>> the later transfer happens correctly at 2000 Hz. >>>>> >>>>> Signed-off-by: Marek Vasut >>>>> Cc: Jagan Teki >>>>> Cc: Patrick Delaunay >>>> >>>> Applied to u-boot/master, thanks! >>>> >>>> -- >>>> Tom >> >> Seems like you're hitting this code in drivers/spi/meson_spifc.c >> >> 250 static int meson_spifc_set_mode(struct udevice *dev, uint mode) >> 251 { >> 252 struct meson_spifc_priv *spifc = dev_get_priv(dev); >> 253 >> 254 if (mode & (SPI_CPHA | SPI_RX_QUAD | SPI_RX_DUAL | >> 255 SPI_TX_QUAD | SPI_TX_DUAL)) >> 256 return -ENODEV; >> >> (the -ENODEV code doesn't look right, it should be some -EOPNOTSUP or so) >> >> Can you check which of the mode bits is set and triggers the condition ? >> >> I think you might be missing something like >> spi-rx-bus-width = <1>; >> spi-tx-bus-width = <1>; >> in your DT, but that's a guess. Can you check which of the mode bits is set and triggers the condition ? Also, where in the DT did you add spi-rx-bus-width = <1> and spi-tx-bus-width = <1> ? Finally, please do not top-post and keep the list on CC.