Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3496553pxb; Mon, 4 Apr 2022 18:51:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxM8Ct8R6Ry/bmIgO+hcqwlzWLScAIBCx/V8CZakq/torXcisV8ux9CP0oYI6e9nqZyiEC9 X-Received: by 2002:a63:eb0b:0:b0:382:a08a:8809 with SMTP id t11-20020a63eb0b000000b00382a08a8809mr883326pgh.47.1649123506758; Mon, 04 Apr 2022 18:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649123506; cv=none; d=google.com; s=arc-20160816; b=K9Ouh1H7RRaQjTaR5viTKmyR07Jy3GKN3DRWqAs7DVe1Oo4snLo2oxou/NaTnmIAd1 ZDV/Y4U08jAwEFYsj7tV2evrLi5zGVr/4jsoJxvnEvoyaTfxR6m86LeCn7Ydzyy0JnO5 2saKPWVQpQYFAz3HifBKbVxkjmpXXmdG+YU9XNV/0d5TukhRqNDT8UBjB6K6vyX62vpz aQRJtxehuRfmpl+NUuYpXz+ROrUiDZ6lNdaue+iMZ+Et2rwKDm2QPyt32gICLYDXcMk6 WnxWFre/rNpKWuzG8dCYboyx835Wk1OZkpDdCcy4L3w5HDLuXgz2X3CMmxCkBUksGrC+ TIWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=tCyZl56w0FLDNTC9ZpuT9oOkaheHqwTOe7S9YavUtY8=; b=ZrIrflyZ9iMgr4tC6W1rejdhsf1H/ChvPeS0xovmOFVPpcWXgFuIsoyHA8NJu/SLB5 2xGmEc0xWAtxhupTglEpecj7aCo6LB31yohXv7Pgsb6Sz+fiwfbOBQB9T/ehW6yRD0CZ Q98Zq/0OqobINfKWI4y1CzqgqF1eVl/DAaiBQoq1HWiaOI1+i6mr7jg4+zHdJaqXzmTs Kf0m01Um9ltoprYNX7R25ZxU8kp/ofP/fna2+OzM4+MhNwjK+zqUQTpCZbp0PGbUHXwE SIbNDF4pWwCpZHTtsPZtY0qnHKtPp+fRBn5c3++ZlhxQnK9YXWx+OnJQ/RGDijOgM4kY S+Bw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b2-20020a170902d88200b00153b2d165e4si11415644plz.492.2022.04.04.18.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 18:51:46 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D8E3A3767D4; Mon, 4 Apr 2022 17:54:13 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376377AbiDDHcb (ORCPT + 99 others); Mon, 4 Apr 2022 03:32:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347284AbiDDHc1 (ORCPT ); Mon, 4 Apr 2022 03:32:27 -0400 Received: from 1.mo552.mail-out.ovh.net (1.mo552.mail-out.ovh.net [178.32.96.117]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9A61377D9 for ; Mon, 4 Apr 2022 00:30:30 -0700 (PDT) Received: from mxplan5.mail.ovh.net (unknown [10.109.146.192]) by mo552.mail-out.ovh.net (Postfix) with ESMTPS id 13CB5224F4; Mon, 4 Apr 2022 07:30:27 +0000 (UTC) Received: from kaod.org (37.59.142.101) by DAG4EX1.mxp5.local (172.16.2.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 4 Apr 2022 09:30:26 +0200 Authentication-Results: garm.ovh; auth=pass (GARM-101G0041c6325e6-010e-462f-a9ff-e43c6fe6fcff, 193BEDB8EED17CFBFC1316EE01F9191BF107EB6B) smtp.auth=clg@kaod.org X-OVh-ClientIp: 82.64.250.170 Message-ID: <8c88e726-0ddb-e2ba-35df-676cfc3d0475@kaod.org> Date: Mon, 4 Apr 2022 09:30:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v4 08/11] spi: aspeed: Calibrate read timings Content-Language: en-US To: Pratyush Yadav CC: , , Mark Brown , Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , , Joel Stanley , Andrew Jeffery , Chin-Ting Kuo , , Rob Herring , , , Tao Ren References: <20220325100849.2019209-1-clg@kaod.org> <20220325100849.2019209-9-clg@kaod.org> <20220331164115.w5q3wxlmwcg3w4ns@ti.com> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= In-Reply-To: <20220331164115.w5q3wxlmwcg3w4ns@ti.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [37.59.142.101] X-ClientProxiedBy: DAG4EX1.mxp5.local (172.16.2.31) To DAG4EX1.mxp5.local (172.16.2.31) X-Ovh-Tracer-GUID: 06f63634-85ae-4b96-a96f-c3ad2ae45158 X-Ovh-Tracer-Id: 11426476679860161351 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvvddrudejuddguddvvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfhfhfgjtgfgihesthekredttdefjeenucfhrhhomhepveorughrihgtpgfnvggpifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucggtffrrghtthgvrhhnpeeigedvffekgeeftedutddttdevudeihfegudffkeeitdekkeetkefhffelveelleenucfkpheptddrtddrtddrtddpfeejrdehledrudegvddruddtudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphhouhhtpdhhvghlohepmhigphhlrghnhedrmhgrihhlrdhovhhhrdhnvghtpdhinhgvtheptddrtddrtddrtddpmhgrihhlfhhrohhmpegtlhhgsehkrghougdrohhrghdpnhgspghrtghpthhtohepuddprhgtphhtthhopehrvghnthgrohdrsghuphhtsehgmhgrihhlrdgtohhm X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 3/31/22 18:41, Pratyush Yadav wrote: > Hi, > > On 25/03/22 11:08AM, Cédric Le Goater wrote: >> To accommodate the different response time of SPI transfers on different >> boards and different SPI NOR devices, the Aspeed controllers provide a >> set of Read Timing Compensation registers to tune the timing delays >> depending on the frequency being used. The AST2600 SoC has one of these >> registers per device. On the AST2500 and AST2400 SoCs, the timing >> register is shared by all devices which is problematic to get good >> results other than for one device. >> >> The algorithm first reads a golden buffer at low speed and then performs >> reads with different clocks and delay cycle settings to find a breaking >> point. This selects a default good frequency for the CEx control register. >> The current settings are a bit optimistic as we pick the first delay giving >> good results. A safer approach would be to determine an interval and >> choose the middle value. >> >> Calibration is performed when the direct mapping for reads is created. >> Since the underlying spi-nor object needs to be initialized to create >> the spi_mem operation for direct mapping, we should be fine. Having a >> specific API would clarify the requirements though. >> >> Cc: Pratyush Yadav >> Reviewed-by: Joel Stanley >> Tested-by: Joel Stanley >> Tested-by: Tao Ren >> Signed-off-by: Cédric Le Goater >> --- >> drivers/spi/spi-aspeed-smc.c | 281 +++++++++++++++++++++++++++++++++++ >> 1 file changed, 281 insertions(+) >> > [...] >> @@ -517,6 +527,8 @@ static int aspeed_spi_chip_adjust_window(struct aspeed_spi_chip *chip, >> return 0; >> } >> >> +static int aspeed_spi_do_calibration(struct aspeed_spi_chip *chip); >> + >> static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc) >> { >> struct aspeed_spi *aspi = spi_controller_get_devdata(desc->mem->spi->master); >> @@ -565,6 +577,8 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc) >> chip->ctl_val[ASPEED_SPI_READ] = ctl_val; >> writel(chip->ctl_val[ASPEED_SPI_READ], chip->ctl); >> >> + ret = aspeed_spi_do_calibration(chip); >> + > > I am still not convinced this is a good idea. The API does not say > anywhere what dirmap_create must be called after the flash is completely > initialized, though that is what is done currently in practice. Yes because we wouldn't have a correct 'spi_mem_dirmap_info' if it wasn't the case. May be change the documentation ? > I think > an explicit API to mark flash as "ready for calibration" would be a > better idea. OK. Since the above is a oneliner, it should not be a problem to move it under a new handler if needed. The dirmap_create() handler expects the spi-mem descriptor and the field 'desc->info.op_tmpl' to be correctly initialized in order to compute the control register value, which is a requirement for dirmap_read(). The calibration sequence simply comes after. AFAICT, there is nothing incorrect today. > Tudor/Mark/Miquel, what do you think? Thanks, C.