Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp961025pxb; Fri, 1 Apr 2022 00:20:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvHC0zLyY7sdc52zImg54HKIvY+h4eOUqqjPZCjzi5kkqUGYfykQ4CMbVqPhZF/dA74OSj X-Received: by 2002:a17:903:3013:b0:154:34ae:b093 with SMTP id o19-20020a170903301300b0015434aeb093mr9219987pla.63.1648797617067; Fri, 01 Apr 2022 00:20:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648797617; cv=none; d=google.com; s=arc-20160816; b=ICRpoDR9YseC2Oepd+y3D0UuY9vZH8bIxWMUQyKRAr3YoO9/14k4WJNFRqhnlAVh3A HVLN9YqpwPtd1KiY2JNvQC6slXP08CdT4QwZg+K89cvy3HC+jyjMgQjP+K6yJMxGuAIW IWl3x9FXp3QRZaj9hHYjyUzrP9L9zVxmGnw4to31nNYULrIOGvViw9M9OIrsKkTTpf9b P90gXj1v+Sf0Zsi1LtE/JN7S6qOm59X1EBp8U4eWUyX9T5P/z1cnzxPibjFy6hPjpOHv DN0IDvuetBC16R4rDu/SpIgA9NL2AA12U/WZFlcHwFAx59SLH+cSghAcJORnhD57VBhd DdfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=q4I8OmbE9lpXlZiTsZ65bC0HGywDTKwPLArPoG/uE2k=; b=JRVDrVWEeTx8EPfJyB+XuPniwYIbXSbQFMr+zh0JXv/U910hwzuw7GLs89F0+aKH+E xQOUYc4aM/zZR73ztzzObyDhUp9NThXxhCSuutXuBtsQTQjxihp1T5/nLHrSX9BSjiUH KsWQhHZXLeL/xG8a/1eapNNaxK3LZiQ2UEXCn1drKBRIYEW0nWiX4RzjYu5a2zbCo6kS 7FGc1YKMswoylcZAU4LAjzR12QeEv4Se70ZPdIUovu0yaZeZ57hah7bYbouiPNHzuZ1s yoccP1i+F/SUhlmik5X0PciAiWkt0YEb29vAm01UGcMGKUtRdzF46K3umvdG+e2m2QtM +AJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=q0Xzj8+b; 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=NONE dis=NONE) header.from=ti.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b123-20020a633481000000b0038251581ab5si1779636pga.291.2022.04.01.00.20.04; Fri, 01 Apr 2022 00:20:17 -0700 (PDT) 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=@ti.com header.s=ti-com-17Q1 header.b=q0Xzj8+b; 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=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240160AbiCaQoE (ORCPT + 99 others); Thu, 31 Mar 2022 12:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232615AbiCaQoC (ORCPT ); Thu, 31 Mar 2022 12:44:02 -0400 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9E0420E947; Thu, 31 Mar 2022 09:42:13 -0700 (PDT) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 22VGfHbT077632; Thu, 31 Mar 2022 11:41:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1648744877; bh=q4I8OmbE9lpXlZiTsZ65bC0HGywDTKwPLArPoG/uE2k=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=q0Xzj8+bwKSW6n1SqCu0ajMaUE0JPYpjhHRhw91vS23GJPbmNB2y4KvnSyMwK4b0G tICwB/nlIKOZogc7v+AgBb7Nkgi4L+dNaEnoD/OTRXYvqtb41WlnIaWJh/1ja6UlnB Z/18XT7txfkmCyGW5GBJXH9G+eMWUZRcGGK66ZrM= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 22VGfHo6024529 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 31 Mar 2022 11:41:17 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 31 Mar 2022 11:41:17 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Thu, 31 Mar 2022 11:41:17 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 22VGfG1R087297; Thu, 31 Mar 2022 11:41:16 -0500 Date: Thu, 31 Mar 2022 22:11:15 +0530 From: Pratyush Yadav To: =?utf-8?Q?C=C3=A9dric?= Le Goater CC: , , Mark Brown , Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , , Joel Stanley , Andrew Jeffery , Chin-Ting Kuo , , Rob Herring , , , Tao Ren Subject: Re: [PATCH v4 08/11] spi: aspeed: Calibrate read timings Message-ID: <20220331164115.w5q3wxlmwcg3w4ns@ti.com> References: <20220325100849.2019209-1-clg@kaod.org> <20220325100849.2019209-9-clg@kaod.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220325100849.2019209-9-clg@kaod.org> X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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. I think an explicit API to mark flash as "ready for calibration" would be a better idea. Tudor/Mark/Miquel, what do you think? > dev_info(aspi->dev, "CE%d read buswidth:%d [0x%08x]\n", > chip->cs, op->data.buswidth, chip->ctl_val[ASPEED_SPI_READ]); > [...] -- Regards, Pratyush Yadav Texas Instruments Inc.