Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 40566C433EF for ; Tue, 15 Mar 2022 02:11:06 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 79199839AA; Tue, 15 Mar 2022 03:11:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=rock-chips.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id D967C839AE; Tue, 15 Mar 2022 03:10:57 +0100 (CET) Received: from mail-m17661.qiye.163.com (mail-m17661.qiye.163.com [59.111.176.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 672B78399D for ; Tue, 15 Mar 2022 03:10:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=rock-chips.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jon.lin@rock-chips.com Received: from [172.16.12.167] (unknown [58.22.7.114]) by mail-m17661.qiye.163.com (Hmail) with ESMTPA id 441BD1DF7F3; Tue, 15 Mar 2022 10:10:39 +0800 (CST) Message-ID: <4e2f69d6-fe5a-947e-cf74-155f727f7f4c@rock-chips.com> Date: Tue, 15 Mar 2022 10:10:38 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v1 04/11] spi: rockchip-sfc: sanity check minimum freq To: Kever Yang , Peter Geis , Jagan Teki Cc: u-boot@lists.denx.de References: <20220222013131.3114990-1-pgwipeout@gmail.com> <20220222013131.3114990-5-pgwipeout@gmail.com> From: Jon Lin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgPGg8OCBgUHx5ZQUlOS1dZCBgUCR5ZQVlLVUtZV1 kWDxoPAgseWUFZKDYvK1lXWShZQUlKS0tKN1dZLVlBSVdZDwkaFQgSH1lBWUMaQxlWQ0xKGUNLTB oYGRkeVRMBExYaEhckFA4PWVdZFhoPEhUdFFlBWU9LSFVKSktISkNVS1kG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Pk06Dgw6ED4CLy8KARg3FkwC ChwaCTZVSlVKTU9MSEpLSUhCTUpKVTMWGhIXVREUFVUXEhU7CRQYEFYYExILCFUYFBZFWVdZEgtZ QVlOQ1VJSVVMVUpKT1lXWQgBWUFISU9ONwY+ X-HM-Tid: 0a7f8b57769cda2bkuws441bd1df7f3 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.5 at phobos.denx.de X-Virus-Status: Clean 在 2022/3/14 16:53, Kever Yang 写道: > + Jon Lin, > > Hi Jon, > >     Please help to review this patch. > > > Thanks, > - Kever > On 2022/2/22 09:31, Peter Geis wrote: >> The rockchip-sfc driver sanity checks the maximum frequency, but not the >> minimum frequency. >> This causes the probe to fail when a frequency isn't defined, such as >> with `sf probe 0`. >> Clamp the minimum frequency to the rockchip default clock rate. >> >> Signed-off-by: Peter Geis >> --- >>   drivers/spi/rockchip_sfc.c | 5 +++++ >>   1 file changed, 5 insertions(+) >> >> diff --git a/drivers/spi/rockchip_sfc.c b/drivers/spi/rockchip_sfc.c >> index 851a6482985b..d0d2dc70a417 100644 >> --- a/drivers/spi/rockchip_sfc.c >> +++ b/drivers/spi/rockchip_sfc.c >> @@ -164,6 +164,8 @@ >>   /* DMA is only enabled for large data transmission */ >>   #define SFC_DMA_TRANS_THRETHOLD        (0x40) >> +#define SFC_MIN_SPEED        (24 * 1000 * 1000) >> + >>   /* Maximum clock values from datasheet suggest keeping clock value >> under >>    * 150MHz. No minimum or average value is suggested. >>    */ >> @@ -596,6 +598,9 @@ static int rockchip_sfc_set_speed(struct udevice >> *bus, uint speed) >>       if (speed > sfc->max_freq) >>           speed = sfc->max_freq; >> +    if (speed < SFC_MIN_SPEED) >> +        speed = SFC_MIN_SPEED; >> + >>       if (speed == sfc->speed) >>           return 0; As I know, spi-uclass.c set SPI_DEFAULT_SPEED_HZ as default value when detect the param speed is 0. And I think, For SF probe, error reporting can better remind users to use the correct speed configuration instead of directly using the default configuration.