From patchwork Tue May 3 06:06:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 12835017 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A008AC433EF for ; Tue, 3 May 2022 06:08:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=h6gh60/2o9oUU25Vph14fuEXrt0da5oXpUAZfWZ38pY=; b=UnqX6znKbhzl8w JqtYl9oUm7+pOBzncCzvemF8JGyzqp3dZSY3ax5Uo9r8DsENlCRjGIVUq2MGcervtDeKGgN4hjdcN 4hfWfJwd5ga8q2h3fC5LV5EzY9H8WBzEJVjyt4CHkmhDx685MzxYTcxhvNgTP92FkY4k4d+rlEq/d GhGqsx5pD1J2Gv6KPTjdHho6xt/zdcqrIlOWwbGCAmxtQjMJKKAW1F4qpGCglE1fT8lk6FvlROkkK Plp6AOh9hI91VO3Abn1pVuBEH4XMwQWx0O6T+IgExQWJAqALmdK7BTSiv8+LnjInvc96GFGQiHZlG BMUuuPBmBftF/VNEGxjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nllgY-003owW-5C; Tue, 03 May 2022 06:06:58 +0000 Received: from gandalf.ozlabs.org ([150.107.74.76]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nllgT-003otg-3W; Tue, 03 May 2022 06:06:55 +0000 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4KsqGv54y2z4ySb; Tue, 3 May 2022 16:06:47 +1000 (AEST) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4KsqGm1blwz4xbw; Tue, 3 May 2022 16:06:39 +1000 (AEST) From: =?utf-8?q?C=C3=A9dric_Le_Goater?= To: linux-spi@vger.kernel.org, linux-mtd@lists.infradead.org Cc: Mark Brown , Tudor Ambarus , Pratyush Yadav , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-aspeed@lists.ozlabs.org, Joel Stanley , Andrew Jeffery , Chin-Ting Kuo , devicetree@vger.kernel.org, Rob Herring , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v6 00/11] spi: spi-mem: Convert Aspeed SMC driver to spi-mem Date: Tue, 3 May 2022 08:06:23 +0200 Message-Id: <20220503060634.122722-1-clg@kaod.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220502_230653_345198_CAB3A05D X-CRM114-Status: GOOD ( 30.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, This series adds a new SPI driver using the spi-mem interface for the Aspeed static memory controllers of the AST2600, AST2500 and AST2400 SoCs. * AST2600 Firmware SPI Memory Controller (FMC) * AST2600 SPI Flash Controller (SPI1 and SPI2) * AST2500 Firmware SPI Memory Controller (FMC) * AST2500 SPI Flash Controller (SPI1 and SPI2) * AST2400 New Static Memory Controller (also referred as FMC) * AST2400 SPI Flash Controller (SPI) It is based on the current OpenBMC kernel driver [1], using directly the MTD SPI-NOR interface and on a patchset [2] previously proposed adding support for the AST2600 only. This driver takes a slightly different approach to cover all 6 controllers. It does not make use of the controller register disabling Address and Data byte lanes because is not available on the AST2400 SoC. We could introduce a specific handler for new features available on recent SoCs if needed. As there is not much difference on performance, the driver chooses the common denominator: "User mode" which has been heavily tested in [1]. "User mode" is also used as a fall back method when flash device mapping window is too small. Problems to address with spi-mem were the configuration of the mapping windows and the calibration of the read timings. The driver handles them in the direct mapping handler when some knowledge on the size of the flash device is know. It is not perfect but not incorrect either. The algorithm is one from [1] because it doesn't require the DMA registers which are not available on all controllers. Direct mapping for writes is not supported (yet). I have seen some corruption with writes and I preferred to use the safer and proven method of the initial driver [1]. We can improve that later. The driver supports Quad SPI RX transfers on the AST2600 SoC but it didn't have the expected results. Therefore it is not activated yet. There are some issues on the pinctrl to investigate first. Tested on: * OpenPOWER Palmetto (AST2400) * Facebook Wedge 100 BMC (AST2400) by Tao Ren * Evaluation board (AST2500) * Inspur FP5280G2 BMC (AST2500) by John Wang * Facebook Backpack CMM BMC (AST2500) by Tao Ren * OpenPOWER Witherspoon (AST2500) * Evaluation board (AST2600 A0 and A3) * Rainier board (AST2600) [1] https://github.com/openbmc/linux/blob/dev-5.15/drivers/mtd/spi-nor/controllers/aspeed-smc.c [2] https://patchwork.ozlabs.org/project/linux-aspeed/list/?series=212394 Thanks, C. Changes in v6: - Removed tabs for aspeed,ast2600-fmc.yaml Changes in v5: - Rebased on 5.18-rc5 - More AST2600 tests from Jae Hyun Yoo - Cleanups of aspeed,ast2600-fmc.yaml - Modified aspeed_spi_send_cmd_addr() routine to return an error - Simplified conditions in exec_op() handler when computing the controller setting - Dropped the use of memcpy_fromio for the SFDP address space Changes in v4: - Rebased on 5.18 - Removal of the SPI-NOR base driver (we had enough tests) - Fix for small size flash devices on AST2600 (Potin) Changes in v3: - Fixed compile warning on aspeed_spi_dirmap_read() prototype reported by kernel test robot - Removed unnecessary entry in ast2600-fmc.yaml - New patch from Tao to set spi-max-frequency on all FMC devices Changes in v2: - Fixed dt_binding_check warnings (Rob) - New entry in MAINTAINERS - Addressed Lukas comments regarding the SPI controller registration and device removal. Checked with driver bind/unbind - Introduced setup and cleanup handlers and removed routine looping on the DT children properties (Pratyush) - Clarified in commit log requirements for training. - Removed defconfig changes of patch 1 since they were reverted in the last patch (Joel) Cédric Le Goater (9): ARM: dts: aspeed: Adjust "reg" property of FMC/SPI controllers dt-bindings: spi: Add Aspeed SMC controllers device tree binding spi: spi-mem: Convert Aspeed SMC driver to spi-mem spi: aspeed: Add support for direct mapping spi: aspeed: Adjust direct mapping to device size spi: aspeed: Workaround AST2500 limitations spi: aspeed: Add support for the AST2400 SPI controller spi: aspeed: Calibrate read timings ARM: dts: aspeed: Enable Dual SPI RX transfers Potin Lai (1): mtd: spi-nor: aspeed: set the decoding size to at least 2MB for AST2600 Tao Ren (1): ARM: dts: aspeed-g4: Set spi-max-frequency for all flashes drivers/mtd/spi-nor/controllers/aspeed-smc.c | 921 ------------- drivers/spi/spi-aspeed-smc.c | 1210 +++++++++++++++++ .../devicetree/bindings/mtd/aspeed-smc.txt | 51 - .../bindings/spi/aspeed,ast2600-fmc.yaml | 82 ++ MAINTAINERS | 10 + arch/arm/boot/dts/aspeed-g4.dtsi | 16 +- arch/arm/boot/dts/aspeed-g5.dtsi | 16 +- arch/arm/boot/dts/aspeed-g6.dtsi | 17 +- drivers/mtd/spi-nor/controllers/Kconfig | 10 - drivers/mtd/spi-nor/controllers/Makefile | 1 - drivers/spi/Kconfig | 11 + drivers/spi/Makefile | 1 + 12 files changed, 1347 insertions(+), 999 deletions(-) delete mode 100644 drivers/mtd/spi-nor/controllers/aspeed-smc.c create mode 100644 drivers/spi/spi-aspeed-smc.c delete mode 100644 Documentation/devicetree/bindings/mtd/aspeed-smc.txt create mode 100644 Documentation/devicetree/bindings/spi/aspeed,ast2600-fmc.yaml