From patchwork Fri Nov 17 20:12:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 166312 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp788311vqn; Fri, 17 Nov 2023 12:16:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGi3/GGPkG4gOM4okzD4NJskLfh8v0rWad88XhRNH1MHygOwz81iC/9k5hgzrlG1B0ORqko X-Received: by 2002:a05:6a21:19a:b0:187:7761:6155 with SMTP id le26-20020a056a21019a00b0018777616155mr229270pzb.55.1700252161992; Fri, 17 Nov 2023 12:16:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700252161; cv=none; d=google.com; s=arc-20160816; b=TnxVdIs9Yd7GixnCOwdltcswd/oNbJtz20zFhvLLq1Imvi+gNP/aQvzug1aKdvnaDT 7gt5hRGGxuM+i58NGR1VZ33cqrzqzrLUTz7EWklCHwVu0GYQm2KB+L4fk0TZueQvDa2A o9om2Z3uT+0Bu3jji+Hru20AAw8F1CS301jhJcxa7eWjbG8WPKhSuYZ/sLR1InuQbatD kZND9Kmy8GPbmBq3rygmGVfHgZEmnHQzEPNzq8iKydHmgSi+wbF994oVKG9SF3HLGwJw hKws7S0PWtrAGHTEoFzF3anZS5qNyfFIDpvr8RhPgy9cKjNRfgeNBEgVo0dittUTduP6 QQMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=m9n1o/iZUaxSEnICaWfmjkoxeuoE9nljoI9vgcv8+Pc=; fh=iMzJmnbboC4LJtlxOKimqPq82YSRfb3zCJyFaxC9c3g=; b=mOLLAoiRDp7F7pObmY8gQ5bJYCt6my+r2zuNrvOcOUNYRn7APGCakgJd64Xj/Ciu6Y 51ZRpVvfWE/idYkULm4p158To9EdMUTr70zB7X4vd3ZvRx4W7LnhYR51mA+Wg9VxqyMf atKW1JWf/HYXEjyzvLUaHgcRjeHRlFf+aiR0tz6AUu4OhggRBNMT/SXU1GD4pN0ayznv G1tIRP47qgYhw4582r+gEZCDL9owyMnza2HEZ0dRYO21q4m+UfUgBxPO8cwuNG/05VkD qN8GiUTM4d7XkDwvBwXkCJkx+o9QObWQiAH4U6AH1WGdMsPAo6/4B3GfTg8kSCDkBFMo 1XeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=ekVvqiLE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id bn13-20020a056a02030d00b005b8ae5cd028si2650464pgb.758.2023.11.17.12.15.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:16:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=ekVvqiLE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 1B18D8324992; Fri, 17 Nov 2023 12:14:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231533AbjKQUOA (ORCPT + 29 others); Fri, 17 Nov 2023 15:14:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232185AbjKQUN5 (ORCPT ); Fri, 17 Nov 2023 15:13:57 -0500 Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38FD9D7E for ; Fri, 17 Nov 2023 12:13:53 -0800 (PST) Received: by mail-oi1-x230.google.com with SMTP id 5614622812f47-3b52360cdf0so1377065b6e.2 for ; Fri, 17 Nov 2023 12:13:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1700252032; x=1700856832; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m9n1o/iZUaxSEnICaWfmjkoxeuoE9nljoI9vgcv8+Pc=; b=ekVvqiLE2X0AyxL40gEGgL8S9/W3gsGfadcgVpEJCyZECyqemP4b6NMfF4Btphzf8l QTRUSjCfVzye+1ry7lGnCcoVXAOhDm+841XSEM+Nq1Tu6oEyh8wUnwzJ2E4fxhqF4dJY G6DlfTtXOszf77/l8q8/mFhcBVx53JNYB2KQm9TX/X8dfvSouFQpiDgxdGQKLvFMYnWo zNIKoyHRhPXqlK0wrCsdRSkZGN2iz/F0m2hKzp44BJEn0gTBMhd9aI4bkk28a4cNpAlF PL6/DYGxqlh3hRdm3R4AOXgdgAshcm2JjospjAhMea+ZcEBAbKyFC//NOhZTv0rTsZTh SRNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700252032; x=1700856832; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m9n1o/iZUaxSEnICaWfmjkoxeuoE9nljoI9vgcv8+Pc=; b=BRl3+opoDSn5g0alYZN2782b45mwo7T/ENY8YMQWY8GCGl40xfOp/HWWMC+J/638F4 pOPnq8YV//EGl5zyKQUuwfb1fAovG94VcVKuIfSFNrq3z6vy5rGOHMYsJJLZpbvIsn1l LfFL26mVbD45ZT3RJQTzOefNqciBtnlVe0TXTkqJOhYifZf9KwgkBh8wbdXJZzo0jTxA f6KVO0HvgimAcuRGVUMgEcWh3I76B5zMFdbj3cAYHjlStPEcGx5pKxD5yLGHtplAwyt8 92yCtzZHUBvd6vepiPWh+Y1hCRuG5uG2lhNkEmpVctyoJk/KwAZglbizNM4tTakXkGmT QjOQ== X-Gm-Message-State: AOJu0YzJyWoDMtY3Cep8eli07c45A0FEAFsCDCUTBs625SCNaqrBdQ3h oQIrOXGCxHDeTIYrAwfkzUGCyfVC3zftZNCr7adjuw== X-Received: by 2002:a05:6808:308a:b0:3a7:4161:44ee with SMTP id bl10-20020a056808308a00b003a7416144eemr509227oib.6.1700252032112; Fri, 17 Nov 2023 12:13:52 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id l21-20020a544515000000b003a8560a9d34sm393814oil.25.2023.11.17.12.13.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:13:51 -0800 (PST) From: David Lechner To: linux-spi@vger.kernel.org, devicetree@vger.kernel.org Cc: David Lechner , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Lars-Peter Clausen , linux-kernel@vger.kernel.org Subject: [PATCH 01/14] dt-bindings: spi: axi-spi-engine: convert to yaml Date: Fri, 17 Nov 2023 14:12:52 -0600 Message-ID: <20231117-axi-spi-engine-series-1-v1-1-cc59db999b87@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> References: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 17 Nov 2023 12:14:49 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782843610979119289 X-GMAIL-MSGID: 1782843610979119289 This converts the axi-spi-engine binding to yaml. There are a few minor fixes in the conversion: * Added maintainers. * Added descriptions for the clocks. * Fixed the double "@" in the example. * Added a comma between the clocks in the example. Signed-off-by: David Lechner Reviewed-by: Rob Herring --- Note: This work is being done by BayLibre on behalf of Analog Devices Inc. This is why the maintainers are @analog.com rather than @baylibre.com. .../devicetree/bindings/spi/adi,axi-spi-engine.txt | 31 ---------- .../bindings/spi/adi,axi-spi-engine.yaml | 66 ++++++++++++++++++++++ 2 files changed, 66 insertions(+), 31 deletions(-) diff --git a/Documentation/devicetree/bindings/spi/adi,axi-spi-engine.txt b/Documentation/devicetree/bindings/spi/adi,axi-spi-engine.txt deleted file mode 100644 index 8a18d71e6879..000000000000 --- a/Documentation/devicetree/bindings/spi/adi,axi-spi-engine.txt +++ /dev/null @@ -1,31 +0,0 @@ -Analog Devices AXI SPI Engine controller Device Tree Bindings - -Required properties: -- compatible : Must be "adi,axi-spi-engine-1.00.a"" -- reg : Physical base address and size of the register map. -- interrupts : Property with a value describing the interrupt - number. -- clock-names : List of input clock names - "s_axi_aclk", "spi_clk" -- clocks : Clock phandles and specifiers (See clock bindings for - details on clock-names and clocks). -- #address-cells : Must be <1> -- #size-cells : Must be <0> - -Optional subnodes: - Subnodes are use to represent the SPI slave devices connected to the SPI - master. They follow the generic SPI bindings as outlined in spi-bus.txt. - -Example: - - spi@@44a00000 { - compatible = "adi,axi-spi-engine-1.00.a"; - reg = <0x44a00000 0x1000>; - interrupts = <0 56 4>; - clocks = <&clkc 15 &clkc 15>; - clock-names = "s_axi_aclk", "spi_clk"; - - #address-cells = <1>; - #size-cells = <0>; - - /* SPI devices */ - }; diff --git a/Documentation/devicetree/bindings/spi/adi,axi-spi-engine.yaml b/Documentation/devicetree/bindings/spi/adi,axi-spi-engine.yaml new file mode 100644 index 000000000000..d48faa42d025 --- /dev/null +++ b/Documentation/devicetree/bindings/spi/adi,axi-spi-engine.yaml @@ -0,0 +1,66 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/spi/adi,axi-spi-engine.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AXI SPI Engine Controller + +description: | + The AXI SPI Engine controller is part of the SPI Engine framework[1] and + allows memory mapped access to the SPI Engine control bus. This allows it + to be used as a general purpose software driven SPI controller as well as + some optional advanced acceleration and offloading capabilities. + + [1] https://wiki.analog.com/resources/fpga/peripherals/spi_engine + +maintainers: + - Michael Hennerich + - Nuno Sá + +allOf: + - $ref: /schemas/spi/spi-controller.yaml# + +properties: + compatible: + const: adi,axi-spi-engine-1.00.a + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + items: + - description: The AXI interconnect clock. + - description: The SPI controller clock. + + clock-names: + items: + - const: s_axi_aclk + - const: spi_clk + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + +unevaluatedProperties: false + +examples: + - | + spi@44a00000 { + compatible = "adi,axi-spi-engine-1.00.a"; + reg = <0x44a00000 0x1000>; + interrupts = <0 56 4>; + clocks = <&clkc 15>, <&clkc 15>; + clock-names = "s_axi_aclk", "spi_clk"; + + #address-cells = <1>; + #size-cells = <0>; + + /* SPI devices */ + }; From patchwork Fri Nov 17 20:12:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 166300 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp787334vqn; Fri, 17 Nov 2023 12:14:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IHeaA3mH5qg/zobBNQ3Yf1Ch9/sgcfQWC3l5qqn4KHNS3lU2tIPx2LchcDsu04Rj138f1vb X-Received: by 2002:a17:902:d2c7:b0:1cc:3825:7ba2 with SMTP id n7-20020a170902d2c700b001cc38257ba2mr809883plc.4.1700252061879; Fri, 17 Nov 2023 12:14:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700252061; cv=none; d=google.com; s=arc-20160816; b=NtEQjO6UNRIC3rbj8P70wZL3rbp0qVKqEV29+KiU01bzZ/N3BL0gUTU6G7RfXHwvc1 6WRPJx8CfOrHovaa1ciwAQTAlXH9SYPnsKAgMYLTuZXonfyuC3Vb7I/LM0qzGbTN+SPj rx2Kv0AtSNrggPqJzRhVWB68sfbC2aGbc3aFtrgK1MrLo3J5RHNuQjw+JM5t4gx4/cLP JFrswLVu+UOaTHdau8jyJ5KOLiRsAiTw6e8MwUmA6MuS6bcSdqJWHSaN6BeLYtne9aWC 2c/trvNZkODgzRLknCYdxFmo+5St6m2YkrTJcEpC/Pras/9vaF+M8QYbwzhYF1i+a2vK q08A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=daUtcUgvD3JlASmZskT09A6jBu8ff2l03YGGYSvkuOo=; fh=iMzJmnbboC4LJtlxOKimqPq82YSRfb3zCJyFaxC9c3g=; b=zTqIVaTnZqNis9v10bLv2doQQWIxJGW6697aFOLIcmfYlggkjoY2n5kkLOvG2PGmfH IXE5jgvrjZVEbYy2QDn9+3s+Zc9YDFCYN/yG8S1z3xG/US1uNRpJ2Myslz3DzUWSKujZ T6uTvz4jvhJPCQNUUyeaYUGWmSESvv3x0GPFSAE/kXkUeDsHxLNzE7bZ8hLZmOFUIB4J CAyEybVebZTmKj6T8Fr93DHhcLloelqxzSimoLMoA5zlxrEpyqfBKbD3ikNtR/h/+tQ+ kDl8TuB3utHUs5AuZDn5GTT2qpXj8UnHcHHQJNogLDP+VE1WValB2xW+Y0ppb0ZnIBrW NAOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=f48DKjAE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id f8-20020a17090274c800b001c9c8e0cbafsi2396635plt.202.2023.11.17.12.14.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:14:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=f48DKjAE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B6D4982AAE81; Fri, 17 Nov 2023 12:14:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346090AbjKQUOD (ORCPT + 29 others); Fri, 17 Nov 2023 15:14:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232195AbjKQUN5 (ORCPT ); Fri, 17 Nov 2023 15:13:57 -0500 Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 963E210D9 for ; Fri, 17 Nov 2023 12:13:53 -0800 (PST) Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-3b2ea7cca04so1480148b6e.2 for ; Fri, 17 Nov 2023 12:13:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1700252033; x=1700856833; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=daUtcUgvD3JlASmZskT09A6jBu8ff2l03YGGYSvkuOo=; b=f48DKjAEIQUdrbqTo8CyXZNyvcYeKbLZzgsbK9bp6xrsHmzxpAXHkNPhWNfRkTSaLa 0S/L9/iwFFvnwYMTjARBSJg3tj8Nb4n9UYVr9cQ0+/A7YKRIr8xhMD34l/INVH9noRdv 9sOMzurGwze+y4Z16rKZnoMzqdj7ZsHnFWAFZsmIJPnZM5Ysl96ymCgwGMcU+1Yo+grr R2BMwrIsnXk1o7hHcd4VHpErxPyU2y242szks8KOljLatQlm48qqF/67x7UV5cEjzZF/ DOtJgqQZNeC9twILU8f8qd/LocFsJI1WtV6R6aSTts6gmTUm+Hj8/l69wZ17ldD5twCc xi0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700252033; x=1700856833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=daUtcUgvD3JlASmZskT09A6jBu8ff2l03YGGYSvkuOo=; b=MGK3wKmilA2V0KlT1LmWTQ1vlMHefTvtlVOZ8sZ+PKOb+281CYcAEIfRzo9JTojhPa Ugw0xr64uTpoTyFK08L6S7uEr1l5e4TvWVXNbSyfJzfvSCtjDonqCK4V+kan5mOZm3Uw wxQewwfj12p52raZ94sfQ82IeSxqkIvf8rcCuhzMzvD7dNiQQREE8z0Lkd5WLM2PYEsL c4HWz/MQpxODtgC0JDaiHLlcewuAUBS+KKV2iysszbLjAPXwlItubDnTdzU0E4yhfUAh j+QO+mdt5nvIJH84z4T2clnzZ8OUE7zBxWx+Iy2RuqEpQM8wnvBTfZgTsvUT4qdpxhaH v5zA== X-Gm-Message-State: AOJu0YwdDGexlus+Y8DffVwKVYUFvWNMaUsPtr+lggDpiI/j/Soxl5qG GiVJSxOM9MNIc5VdhnlghFe2WbtLWJOss0QbHZJeKA== X-Received: by 2002:a05:6808:1704:b0:3b6:d617:a6f7 with SMTP id bc4-20020a056808170400b003b6d617a6f7mr595509oib.3.1700252032911; Fri, 17 Nov 2023 12:13:52 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id l21-20020a544515000000b003a8560a9d34sm393814oil.25.2023.11.17.12.13.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:13:52 -0800 (PST) From: David Lechner To: linux-spi@vger.kernel.org, devicetree@vger.kernel.org Cc: David Lechner , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Lars-Peter Clausen , linux-kernel@vger.kernel.org Subject: [PATCH 02/14] MAINTAINERS: add entry for AXI SPI Engine Date: Fri, 17 Nov 2023 14:12:53 -0600 Message-ID: <20231117-axi-spi-engine-series-1-v1-2-cc59db999b87@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> References: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 12:14:08 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782843506333392967 X-GMAIL-MSGID: 1782843506333392967 The AXI SPI Engine driver has been in the kernel for many years but has lacked a proper maintainers entry. This adds a new entry for the driver and the devicetree bindings. Signed-off-by: David Lechner --- Note: This work is being done by BayLibre on behalf of Analog Devices Inc. This is why the maintainers are @analog.com rather than @baylibre.com. MAINTAINERS | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 97f51d5ec1cf..a40f61ad5843 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3415,6 +3415,16 @@ W: https://ez.analog.com/linux-software-drivers F: Documentation/devicetree/bindings/hwmon/adi,axi-fan-control.yaml F: drivers/hwmon/axi-fan-control.c +AXI SPI ENGINE +M: Michael Hennerich +M: Nuno Sá +R: David Lechner +L: linux-spi@vger.kernel.org +S: Supported +W: https://ez.analog.com/linux-software-drivers +F: Documentation/devicetree/bindings/spi/adi,axi-spi-engine.yaml +F: drivers/spi/spi-axi-spi-engine.c + AXXIA I2C CONTROLLER M: Krzysztof Adamski L: linux-i2c@vger.kernel.org From patchwork Fri Nov 17 20:12:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 166301 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp787343vqn; Fri, 17 Nov 2023 12:14:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IEmXh7ltqKootulI6a3wfr4fT7YcVxzZwx5BOKlY6nE5IDd5i80PMTfAmql4KdLNvtG1iAo X-Received: by 2002:a05:6a20:c1a3:b0:186:7842:ad0f with SMTP id bg35-20020a056a20c1a300b001867842ad0fmr247486pzb.31.1700252062394; Fri, 17 Nov 2023 12:14:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700252062; cv=none; d=google.com; s=arc-20160816; b=YMdNCn6qXA8LMLreqalP/kLkf7QnnHELvsmIIP7rWI6gyZIp/fUTnlkNvfKNjN7F9p Q1UGZK3B2gvZ9zeAMHk2KgUTgAjKL84gzvjPa9Bw6OmIVQHm3nqs6+7HWqd9jgfJNu5Z UT32fIGAU/LrHclaYObbwx1+Cd5+1v2xFS8oW0pE3m10fM+LZxpxvHZJInQ7cxKrSDQa iMOvCjDdBh7YZ2QAi76CtSxdL4nn9oM3RWoZPniNs5ZOP3/fNrjg75ZiUwTOaMRKPUja C9KiZ7O3tJPdV+SlXVeSRFyCQfR8Psvn3aujTBqhg+G6W58svcxcqisBhBaqJWggO34N H16A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6ldjfSGznOnPblU5dGC3l3g5toq9lO7sGMGu6CgtS3M=; fh=iMzJmnbboC4LJtlxOKimqPq82YSRfb3zCJyFaxC9c3g=; b=uFiL9p1sWFiDaAPAqtGesPxlBwBApdVg4vWta+me07F+jc2SVawEWOeGZ7Sc0Z3rgH U1j4VNZEWrLBR8KO1x9M0YhqbaGUDeQscgceJuWYhq8xJVZwXaiNp6ON6VhanpJ9y0oH HSLKU9ccGKevD040dCbo58nKaOActp53RRNuRFta5vsqSvzLr0C052kHI18G5fX3rHGQ JBjhcN/eRKGZGtXeIzbUzWeJ60fokj+g484kRFe20Pt7RfeZ0T3EklQl5Y8WizHYx4+w dOLRiFfD/6IyZhiNfJVHwjKxG+rJuMboXNQiT2xrJ5ARZwlwBKndubQm6GikmY6OUyxW 5+FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=a3T6+vYC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id u4-20020a056a00158400b006b4642308d0si2710361pfk.232.2023.11.17.12.14.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:14:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=a3T6+vYC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 00ACF82A7563; Fri, 17 Nov 2023 12:14:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235608AbjKQUOG (ORCPT + 29 others); Fri, 17 Nov 2023 15:14:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232705AbjKQUN5 (ORCPT ); Fri, 17 Nov 2023 15:13:57 -0500 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55CA210E5 for ; Fri, 17 Nov 2023 12:13:54 -0800 (PST) Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3b40d5ea323so1497219b6e.0 for ; Fri, 17 Nov 2023 12:13:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1700252033; x=1700856833; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6ldjfSGznOnPblU5dGC3l3g5toq9lO7sGMGu6CgtS3M=; b=a3T6+vYCIGb5Q//Z/lesLocw+DyzyxQIQXdyrbzc9cNj/QahPUsj2yjDirdjsw7FV7 1Bm5vbLuiu2/pdkN5ZUyBl2QSygMoYWBTozG4IUYwR8xuGC7Z1sjn37OCM1/SjTZAPMB vxg2HXd3+TRGSAS+OpW5Y1YaX44jGZqmN9Mo+tZcQppikM73mmcIPNfJH22THUSMCiqr mwHQ1SqlyYfs6GTzGW9VdW4f7qdrWr4wKTSfXih/vgf6Fc6SprgzX9wFRvlJr1yb2CVN bKf0jBCcvcz3kJb3H+bGQBBUrv/fahRmCyB9RvY+0umlhAJD+lSDStQRixSGDiDrd8eY fD+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700252033; x=1700856833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6ldjfSGznOnPblU5dGC3l3g5toq9lO7sGMGu6CgtS3M=; b=cP25IULSMNaY8IUSz3mbd0wfSQvqjHOAoV/BX2hIFBiWVAUctEQbsvD5iQbpEjJti5 h/pMnFR9ZjC56mve6sd5owhKje2tWGDMrEHaM4CFczkGM8Ea5cLQj1DD5JT2PWVefJ4T YeVigSllkA+LMzC1E0E4ax4FpKFvLp3o7+zWL1OYiNCUI1lg2oOm0GEVDGHdrDzdgXoX tea5NYNdNk5NQGuCades+IPHqIO/t+DRXESoWJ3anbQR6q1Ax0aWOqCCJQsFyb9zOYgT l+TKAn4+VOUj81t/rjK+SklIpRdxaiffuvrmF4jjGlsjQQNXpgFbUZ3etMxm5Nmce9XA PVsg== X-Gm-Message-State: AOJu0YyNXRImQrlettSQfzgtHhP4wQt/u8BjbqUdjBoE//F3YeRdjOEE QVLUAWN4h78OQGMhozBaLBdwfA== X-Received: by 2002:a05:6808:1718:b0:3b6:da98:437c with SMTP id bc24-20020a056808171800b003b6da98437cmr544507oib.0.1700252033671; Fri, 17 Nov 2023 12:13:53 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id l21-20020a544515000000b003a8560a9d34sm393814oil.25.2023.11.17.12.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:13:53 -0800 (PST) From: David Lechner To: linux-spi@vger.kernel.org, devicetree@vger.kernel.org Cc: David Lechner , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Lars-Peter Clausen , linux-kernel@vger.kernel.org Subject: [PATCH 03/14] spi: axi-spi-engine: simplify driver data allocation Date: Fri, 17 Nov 2023 14:12:54 -0600 Message-ID: <20231117-axi-spi-engine-series-1-v1-3-cc59db999b87@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> References: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 12:14:09 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782843506535920420 X-GMAIL-MSGID: 1782843506535920420 This simplifies the private data allocation in the AXI SPI Engine driver by making use of the feature built into the spi_alloc_host() function instead of doing it manually. Signed-off-by: David Lechner --- drivers/spi/spi-axi-spi-engine.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index b96e55f59d1a..bdf0aa4ceb1d 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -473,15 +473,11 @@ static int spi_engine_probe(struct platform_device *pdev) if (irq < 0) return irq; - spi_engine = devm_kzalloc(&pdev->dev, sizeof(*spi_engine), GFP_KERNEL); - if (!spi_engine) - return -ENOMEM; - - host = spi_alloc_host(&pdev->dev, 0); + host = spi_alloc_host(&pdev->dev, sizeof(*spi_engine)); if (!host) return -ENOMEM; - spi_controller_set_devdata(host, spi_engine); + spi_engine = spi_controller_get_devdata(host); spin_lock_init(&spi_engine->lock); From patchwork Fri Nov 17 20:12:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 166302 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp787350vqn; Fri, 17 Nov 2023 12:14:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IH6bkbQGEBYuik4+FEYZFgRV+lIx1io5InhYh6xvUAidjgl+ait2xwYU0XMu6UTv46LH+xR X-Received: by 2002:a05:6a20:9797:b0:187:c496:898b with SMTP id hx23-20020a056a20979700b00187c496898bmr276276pzc.3.1700252063495; Fri, 17 Nov 2023 12:14:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700252063; cv=none; d=google.com; s=arc-20160816; b=XrgjYmykzJy6vQ+ZVjkjZfgazZwQ3gpWAGUESbk28J3kuWgyyatqDWW9k2ltJBK5Li Ks/cHHHhqYf8Oy0XX+VEW2TnESKtU42NnPEIYMAGYtpy1Lwy739BF5xPQDjwJ/dKuJgw bCDonikhtwhJOrE0QDSGMc3EeHNkmRzqfbyeBbGkBbDpM4HxJwilhqB6k1Qyo55Xs9ah q69ZokmsnT4/Mw5oAqGeIoNFogftdNGG5HLKtSULBp8lHUt8wo7Nw1/W0+qdSHuyFlTA VR7OkqGMdIBlH2RTXTPJT+WHPHh/yXQwFAIIgMW6dDmynSKlc3zgIZlpmn8LgPzGAGTI qRBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kwzXznL4NYavhVUNHzr4kJuVjofxWovc+jaQlF/tetc=; fh=iMzJmnbboC4LJtlxOKimqPq82YSRfb3zCJyFaxC9c3g=; b=VIwejtsVgLHKuRjy971H+pIkEj92YydvW7J6QKkoSoyEgBChSQbe/dUSDXtYNaGk00 5PvYON+8hFQpcDZRNdyMWZYTUnrbDRI22IpvZGBpdtvVwsRGn18Sq+EawDV0F1CyFVqD fEeZ7t3C9yxj7Wgzcl/HdTNh/1Rf0OeKzT/Jz+rIJKtP/5piIl8QkB/cTIb97vqNDXtj fPWo4nJnYS4sZEO6UinIzRhdRIJBqtGYahiaDE0hSedkrtuWrfyojkFVLKYyCdDVccAN ijoXxRq7xtwchboi82mIzTQzbXMncuTILkch60h+DX2rGXFw9B50oemXnmaViWLMblZy AtpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=EUNEI5bF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id z19-20020a63e113000000b005c21722b7d6si783547pgh.863.2023.11.17.12.14.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:14:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=EUNEI5bF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5F21682A7579; Fri, 17 Nov 2023 12:14:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346201AbjKQUOI (ORCPT + 29 others); Fri, 17 Nov 2023 15:14:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235091AbjKQUN6 (ORCPT ); Fri, 17 Nov 2023 15:13:58 -0500 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FC12D7E for ; Fri, 17 Nov 2023 12:13:55 -0800 (PST) Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3b6d88dbaa3so1487346b6e.1 for ; Fri, 17 Nov 2023 12:13:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1700252034; x=1700856834; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kwzXznL4NYavhVUNHzr4kJuVjofxWovc+jaQlF/tetc=; b=EUNEI5bFxbQ+wjUpIFeqryFo8RgL/jszVWX5ykUtkBoQOWq2M/e6FzFsFicDMatiqq cmVlUSsGgNU3HseLs/oWs1599irG5YXdWMAqYadiRsliOHB3GsgJsoNVbNwmNG/k9kPk +vxM2bcGHn3Tk3aYOvBNHLucWF+NGgKTQGxYvl9HElEpy0fd16OxZviC1OOGxmDdQGOM o+sTBaOF6AgqJn+qiBJRBC0kX0qsNV3Dj12lt30uzWQ2e1YYFBYBmxya4hkaGwPEQC7w LlOde6ReuyTrrIRKhc+gCL6y/uqggP0SL7IpTxaZ5z2hsXT6YFT5wYhFxDXrGVdD/sUi zSsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700252034; x=1700856834; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kwzXznL4NYavhVUNHzr4kJuVjofxWovc+jaQlF/tetc=; b=qLPfXiwEp+nV+bN6Yueubd/0rx30NhqeVMBzyPPi8kfuHySvD6AzO3ok9wvbpBkWyi SKLabHjw3LhlP2VzlP3b4eU8LM6ArXJJwX6xdZ4tlKilCPf4NNw29dFoBtGyZHuXTyct oUlMl1BrqBjyIdYgT4o2ePAbcbC9PZndFNLZny0B4FZuutgmCZraoIwkohs0UhUVkzyZ dLDwEr1zMclUqZSO7uLhhRZGDStKz+lwplHgsfVJLNggcuHN4PH5T4rg24c9p2UMHNTV EMQtkTHkHDwP1hXT8cDbqpffYjhyHxk7/FOo/NGwhcYY2oZKt5NevG8rCfTP7i0xFfVE YMjw== X-Gm-Message-State: AOJu0YzIIOWCyUpicWaLzvU9uQQACYOGrhevUN1ulL+WLU21EdJLHZvc lawkn2mXsIYeFXTM5/vbay6P6Q== X-Received: by 2002:a05:6808:1241:b0:3ae:2b43:dd47 with SMTP id o1-20020a056808124100b003ae2b43dd47mr537281oiv.22.1700252034604; Fri, 17 Nov 2023 12:13:54 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id l21-20020a544515000000b003a8560a9d34sm393814oil.25.2023.11.17.12.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:13:54 -0800 (PST) From: David Lechner To: linux-spi@vger.kernel.org, devicetree@vger.kernel.org Cc: David Lechner , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Lars-Peter Clausen , linux-kernel@vger.kernel.org Subject: [PATCH 04/14] spi: axi-spi-engine: use devm_spi_alloc_host() Date: Fri, 17 Nov 2023 14:12:55 -0600 Message-ID: <20231117-axi-spi-engine-series-1-v1-4-cc59db999b87@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> References: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 12:14:10 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782843507866395375 X-GMAIL-MSGID: 1782843507866395375 This modifies the AXI SPI Engine driver to use devm_spi_alloc_host() instead of spi_alloc_host() to simplify the code a bit. In addition to simplifying the error paths in the probe function, we can also remove spi_controller_get/put() calls in the remove function since devm_spi_alloc_host() sets a flag to no longer decrement the controller reference count in the spi_unregister_controller() function. Signed-off-by: David Lechner --- drivers/spi/spi-axi-spi-engine.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index bdf0aa4ceb1d..77c1c115448d 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -473,7 +473,7 @@ static int spi_engine_probe(struct platform_device *pdev) if (irq < 0) return irq; - host = spi_alloc_host(&pdev->dev, sizeof(*spi_engine)); + host = devm_spi_alloc_host(&pdev->dev, sizeof(*spi_engine)); if (!host) return -ENOMEM; @@ -482,22 +482,16 @@ static int spi_engine_probe(struct platform_device *pdev) spin_lock_init(&spi_engine->lock); spi_engine->clk = devm_clk_get_enabled(&pdev->dev, "s_axi_aclk"); - if (IS_ERR(spi_engine->clk)) { - ret = PTR_ERR(spi_engine->clk); - goto err_put_host; - } + if (IS_ERR(spi_engine->clk)) + return PTR_ERR(spi_engine->clk); spi_engine->ref_clk = devm_clk_get_enabled(&pdev->dev, "spi_clk"); - if (IS_ERR(spi_engine->ref_clk)) { - ret = PTR_ERR(spi_engine->ref_clk); - goto err_put_host; - } + if (IS_ERR(spi_engine->ref_clk)) + return PTR_ERR(spi_engine->ref_clk); spi_engine->base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(spi_engine->base)) { - ret = PTR_ERR(spi_engine->base); - goto err_put_host; - } + if (IS_ERR(spi_engine->base)) + return PTR_ERR(spi_engine->base); version = readl(spi_engine->base + SPI_ENGINE_REG_VERSION); if (SPI_ENGINE_VERSION_MAJOR(version) != 1) { @@ -505,8 +499,7 @@ static int spi_engine_probe(struct platform_device *pdev) SPI_ENGINE_VERSION_MAJOR(version), SPI_ENGINE_VERSION_MINOR(version), SPI_ENGINE_VERSION_PATCH(version)); - ret = -ENODEV; - goto err_put_host; + return -ENODEV; } writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_RESET); @@ -515,7 +508,7 @@ static int spi_engine_probe(struct platform_device *pdev) ret = request_irq(irq, spi_engine_irq, 0, pdev->name, host); if (ret) - goto err_put_host; + return ret; host->dev.of_node = pdev->dev.of_node; host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_3WIRE; @@ -533,14 +526,12 @@ static int spi_engine_probe(struct platform_device *pdev) return 0; err_free_irq: free_irq(irq, host); -err_put_host: - spi_controller_put(host); return ret; } static void spi_engine_remove(struct platform_device *pdev) { - struct spi_controller *host = spi_controller_get(platform_get_drvdata(pdev)); + struct spi_controller *host = platform_get_drvdata(pdev); struct spi_engine *spi_engine = spi_controller_get_devdata(host); int irq = platform_get_irq(pdev, 0); @@ -548,8 +539,6 @@ static void spi_engine_remove(struct platform_device *pdev) free_irq(irq, host); - spi_controller_put(host); - writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING); writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE); writel_relaxed(0x01, spi_engine->base + SPI_ENGINE_REG_RESET); From patchwork Fri Nov 17 20:12:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 166303 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp787364vqn; Fri, 17 Nov 2023 12:14:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTlnw9hrVXwWmHoJPGGA/PPVuWhymL++L8WFxhIfo+NpbBlnqPiKdhdXXfD5MNpPY33zDh X-Received: by 2002:a05:6a00:9398:b0:6c6:b15:392 with SMTP id ka24-20020a056a00939800b006c60b150392mr669332pfb.24.1700252065224; Fri, 17 Nov 2023 12:14:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700252065; cv=none; d=google.com; s=arc-20160816; b=1Eeru9BTI1lyXdR+kJatmkE3evBhDumXYdXkUF9B6ME1A3buMB0CQA04iYeS/wPNyV tvvGdQ7AEDVGKih+N/w45J7s48jdhHtKIppj60f+Hap7uVnqkiD4WeuNgEVS/LH3Giep 6y2ASZL6FGTDompyQy6QvGUZFbh9bmCEL7/g5RO+AZEthDMR2Hn1VZCJNO7EROG9b8M+ RJPzNbVFyxbml3x+6mkIlLTKUEESXxbm0PqOOPq9OiDvbHALHlkls4b2m4vzS6t5o1zU oYDAbtgHW1OrlEPW6j7pmcZ6/xnIpeiSNPFNc42lx/mCgJ/9ie8IWsDd0PqVI76RDMqY 7ePQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/Uy/nGn2rChA8c7KicPA5RLHwOBZWkxwdXoqQs+T9FI=; fh=iMzJmnbboC4LJtlxOKimqPq82YSRfb3zCJyFaxC9c3g=; b=bip1uJe1qRGNlK16sGAumNXz/9djbhvNla/1skKWu2eghUk5eKHcbWhCcTLQErwLej TGImyRkLRhQrU03Ej6XKIFdKNaEnw2Sa48TjJrIkdLmN8uZbhIWrmFqTlOHFU/unCjhD bdMH1oACVqABDknuYc+WqacSTGqLFIHSOXeWkDwaH1CvmCDAi0zpkhiD7xGVBnf/F7ur lAyek9ntrwDi+6knKhKAYQV2uAK3jYBHQnJL0S/wWQfPoW8lFKHRa7bRSDO0KJAz661f r1hhkatqwASvB/pgbzdzNUirhKNGmo4gEd68qF4U3DFgmYrcz8cJAsL5RBDXI2H/aCeo Y7PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=2+XdxDiO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id f13-20020aa79d8d000000b006be0e90200dsi2489143pfq.374.2023.11.17.12.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:14:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=2+XdxDiO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D517A82AAE98; Fri, 17 Nov 2023 12:14:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346029AbjKQUOK (ORCPT + 29 others); Fri, 17 Nov 2023 15:14:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232631AbjKQUN7 (ORCPT ); Fri, 17 Nov 2023 15:13:59 -0500 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12D68D57 for ; Fri, 17 Nov 2023 12:13:56 -0800 (PST) Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3b3f55e1bbbso1513212b6e.2 for ; Fri, 17 Nov 2023 12:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1700252035; x=1700856835; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/Uy/nGn2rChA8c7KicPA5RLHwOBZWkxwdXoqQs+T9FI=; b=2+XdxDiOVAUwEHBmlFn/U/iOIbLMEN6BE1ylmm/F72DBfFvWneB9Tkwbs1kV7Iwmxa WKhZLCP1UztnIUpLY4l02FHU/eobad4LFjrmvcLwrBj7/3bfUQrorKrx1vWKdjHRwVlY KsgfhFJKSp2EJMzx56Nbc8GJpZfrV4qEhEcxmvcOl9xsOGWjjt5STQzCRDpT7uH4gBOp 9jZVIJDO2OKaKOSFL0uvUu7e+TVErcRkMLqvdvm7f/r8mmI91rHVgv3Y1P51V8h4+jXP fkUsoamL9iJYFbTS1JhmEOCIgbpvfmrm8U2ht0qXHba0UcZWk84RQ/yoLFA3R37/TO8R 5naw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700252035; x=1700856835; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/Uy/nGn2rChA8c7KicPA5RLHwOBZWkxwdXoqQs+T9FI=; b=WfBAF98ih7L9z3cUCHXTl0hdPs5QST9A/yzTqbhekIxqugNHamwl6EK0xdkG7RFHBk g0ohF4iG5zqur0eS4mzelyXMni3B9i7XqXsPmiCN+/8KleYDcsQWB0bzY2ltmkL2bVlg cTmdR4OQhPtQyG0xhSqlt5qQ1glO2gY69s/UnEhjvkbfBjk5ehcJMpIZzttXMTxC47HB Q+pO8hUA6uvErA1WanC8izm1tfG25XmDDOA30m56Vai/JfFYj1g2Kpvole/rF/8DAIcn WVtk6lf25vi8LB8enCn4z4G56Fs4OGiQv93JYkHs2IxRCazo91hG69Qlztx6Cioho4q9 HiPQ== X-Gm-Message-State: AOJu0Yyjew+Ft7rG0q4yVmAX+mN29SQ6pPoiZcj3huhxFkPdWXYeA4wI ucF8khiT+XMPpInIoxbOfvqTFg== X-Received: by 2002:a05:6808:14cd:b0:3a4:3b56:72b2 with SMTP id f13-20020a05680814cd00b003a43b5672b2mr589101oiw.8.1700252035422; Fri, 17 Nov 2023 12:13:55 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id l21-20020a544515000000b003a8560a9d34sm393814oil.25.2023.11.17.12.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:13:55 -0800 (PST) From: David Lechner To: linux-spi@vger.kernel.org, devicetree@vger.kernel.org Cc: David Lechner , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Lars-Peter Clausen , linux-kernel@vger.kernel.org Subject: [PATCH 05/14] spi: axi-spi-engine: use devm action to reset hw on remove Date: Fri, 17 Nov 2023 14:12:56 -0600 Message-ID: <20231117-axi-spi-engine-series-1-v1-5-cc59db999b87@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> References: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 12:14:11 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782843509532299068 X-GMAIL-MSGID: 1782843509532299068 This moves the reset of the hardware to a devm action in the AXI SPI Engine driver. This will allow us to use devm on later calls in the probe function while preserving the order during cleanup. Signed-off-by: David Lechner --- drivers/spi/spi-axi-spi-engine.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index 77c1c115448d..c18a4b34777e 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -461,6 +461,15 @@ static int spi_engine_transfer_one_message(struct spi_controller *host, return 0; } +static void spi_engine_release_hw(void *p) +{ + struct spi_engine *spi_engine = p; + + writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING); + writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE); + writel_relaxed(0x01, spi_engine->base + SPI_ENGINE_REG_RESET); +} + static int spi_engine_probe(struct platform_device *pdev) { struct spi_engine *spi_engine; @@ -506,6 +515,11 @@ static int spi_engine_probe(struct platform_device *pdev) writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING); writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE); + ret = devm_add_action_or_reset(&pdev->dev, spi_engine_release_hw, + spi_engine); + if (ret) + return ret; + ret = request_irq(irq, spi_engine_irq, 0, pdev->name, host); if (ret) return ret; @@ -532,16 +546,11 @@ static int spi_engine_probe(struct platform_device *pdev) static void spi_engine_remove(struct platform_device *pdev) { struct spi_controller *host = platform_get_drvdata(pdev); - struct spi_engine *spi_engine = spi_controller_get_devdata(host); int irq = platform_get_irq(pdev, 0); spi_unregister_controller(host); free_irq(irq, host); - - writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING); - writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE); - writel_relaxed(0x01, spi_engine->base + SPI_ENGINE_REG_RESET); } static const struct of_device_id spi_engine_match_table[] = { From patchwork Fri Nov 17 20:12:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 166305 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp787461vqn; Fri, 17 Nov 2023 12:14:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMDE6fk5qYuy1sbz9i2PshaoEqIofBYYxGn2HiOBhWXT1mDlDhtoDxHS5fU6RW1qPp3496 X-Received: by 2002:a05:6a20:43a1:b0:187:6fb0:85ba with SMTP id i33-20020a056a2043a100b001876fb085bamr326989pzl.43.1700252076826; Fri, 17 Nov 2023 12:14:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700252076; cv=none; d=google.com; s=arc-20160816; b=FRO5/Qk1YCR+J15htCDzUz0JVlhrN/ONUXZEIVSOkjUi8YAa6I8lAHgFW0A6QTMYTe kFuXKJTmN14yqg4ZCrkUc6thir1z5bemnHuQxXYbk2pHqNu/Obqsa7XFOBDhrAGTTdt9 WGEpFI/9Vz21OKPIx6MoJ+Ky2M+v1EnEd0qexqRZSC6yBKnilz0tOywG9CDTQ4d7WNfj 0lvoHw7XJWxHKKTz9OXlB5zJVS4USEmxZOv8pAq/cJVhQyjP8ypeybE7HFVymRTUP5NR T0aRDdbLw8S5YZUsPyymRuyiF9XBUQKyCg783XJwQOuO2RNh7yEmWqyDkwhE5fNMXg18 JL0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7LNYfVKcT7JMz9dURfBMFGVc3NYglRs5IQioTfjD6HM=; fh=iMzJmnbboC4LJtlxOKimqPq82YSRfb3zCJyFaxC9c3g=; b=pQ8Hb+bLpzx3B08TFPIqzHPVyEpsCGRR17vjRmyfgeM8Ji66Tw1k0QGczXTA2RrKql S7sfhhGC5VHGoDHoX7ZPu1Rn334ho9I7Wm/yoRIfWevKhMqiHNl/K4wGu6JKQz8NDfL1 V0hvvXlF/pAOUslmeeGBn2FkeCcHs02wU5GcounSL/MTODVdFVCfeypP/zInIs+kcQhu yB0+AAAqnTDsCdDrGAIAPmTiauvt+wxuXBmif8Fv2DI31X8wZZC71P4irckvucR7Sfwi qlzqMRw3BKzBGP29pyQ5+ezPMIGX/sREC64xmJRM/8wepLHP0iyEhbZrsOn5Zm3svRbS KHjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=GlzlcKT6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id o188-20020a6341c5000000b005bdfda8e04esi2551708pga.800.2023.11.17.12.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:14:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=GlzlcKT6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C24B582A7560; Fri, 17 Nov 2023 12:14:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235727AbjKQUOM (ORCPT + 29 others); Fri, 17 Nov 2023 15:14:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235724AbjKQUOB (ORCPT ); Fri, 17 Nov 2023 15:14:01 -0500 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E63A3D7A for ; Fri, 17 Nov 2023 12:13:56 -0800 (PST) Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3b3f55e1bbbso1513218b6e.2 for ; Fri, 17 Nov 2023 12:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1700252036; x=1700856836; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7LNYfVKcT7JMz9dURfBMFGVc3NYglRs5IQioTfjD6HM=; b=GlzlcKT63c7jWtIAMe3jmcQOBcMb0qs+2CwppZtzYE+Ko5QS+cljsUj442lH/CKqB8 rKoERKdZTydDrroa3t0J28oaO8BUgPBJYZ5BNkicbImd4zDFF5OX6LjrrpYTOQ/OPadl vWi4jp+F2VN+d+T7nRLMgJFO1EUeujAnR8Kt+YhPLYohMhK3wjzcPySUdT4dWHfBDs9I QxOBr1NbHZy7hyxxPjbY3P6JrU4V5XlFpHwinvsv5NneThCJRjro71Z4AOC2ikHxiiI9 CdflXTfKqFxB/Sc9cf7yzj7qHXGZpJ6kRQa3NX9hyz5AQUDMppbmJAR6KDdf/quTWY5W jJ3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700252036; x=1700856836; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7LNYfVKcT7JMz9dURfBMFGVc3NYglRs5IQioTfjD6HM=; b=hQdCcrNZNXAGrO5b6GASfVQviodzD9WV+yRxCSh5nWJMT2YzZ0PNPouwY29jKt59V4 +iRIrJFGQOUWhgbPNRZMJ0iRe7YP6kjXrmK71y+x3bIaizbAksd95vxM796BS29gQMPD i8wqOZZAmuPM4GIYanLe85gL9v1UVa+8uRw6Txc8FT68IsUX1H57W4ab2UddrBCfD+c6 Clx9euK3XfhCQilDNMLawdFjlwIrWGp36k3QZj9o32ExgF+Qsq/4oLTIMrzsfOQ29Pp0 Q85O8a35dle7hTUZ32xkbSACTWNJlA8KG0N+NJNgL5Ws1dDC5wMNfRfWUUPztxbwiwnB UcHQ== X-Gm-Message-State: AOJu0YxvFRWZQzUu+q5IAT7w8TLeDVgAL+sGuPx9ZSIEofw8KKJCVRDi p95o4bgcvzS4Y+VTDs0MIAlnIg== X-Received: by 2002:a05:6808:1410:b0:3b5:a58c:cca6 with SMTP id w16-20020a056808141000b003b5a58ccca6mr608163oiv.3.1700252036277; Fri, 17 Nov 2023 12:13:56 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id l21-20020a544515000000b003a8560a9d34sm393814oil.25.2023.11.17.12.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:13:55 -0800 (PST) From: David Lechner To: linux-spi@vger.kernel.org, devicetree@vger.kernel.org Cc: David Lechner , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Lars-Peter Clausen , linux-kernel@vger.kernel.org Subject: [PATCH 06/14] spi: axi-spi-engine: use devm_request_irq() Date: Fri, 17 Nov 2023 14:12:57 -0600 Message-ID: <20231117-axi-spi-engine-series-1-v1-6-cc59db999b87@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> References: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 12:14:19 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782843521480575437 X-GMAIL-MSGID: 1782843521480575437 This replaces request_irq() with devm_request_irq() in the AXI SPI Engine driver. This simplifies the error path and removes the need to call free_irq() in the remove function. Signed-off-by: David Lechner --- drivers/spi/spi-axi-spi-engine.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index c18a4b34777e..81d7352d2b8b 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -520,7 +520,8 @@ static int spi_engine_probe(struct platform_device *pdev) if (ret) return ret; - ret = request_irq(irq, spi_engine_irq, 0, pdev->name, host); + ret = devm_request_irq(&pdev->dev, irq, spi_engine_irq, 0, pdev->name, + host); if (ret) return ret; @@ -533,24 +534,18 @@ static int spi_engine_probe(struct platform_device *pdev) ret = spi_register_controller(host); if (ret) - goto err_free_irq; + return ret; platform_set_drvdata(pdev, host); return 0; -err_free_irq: - free_irq(irq, host); - return ret; } static void spi_engine_remove(struct platform_device *pdev) { struct spi_controller *host = platform_get_drvdata(pdev); - int irq = platform_get_irq(pdev, 0); spi_unregister_controller(host); - - free_irq(irq, host); } static const struct of_device_id spi_engine_match_table[] = { From patchwork Fri Nov 17 20:12:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 166304 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp787407vqn; Fri, 17 Nov 2023 12:14:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IEnCELmG410AbfIfu79ALwOY0jO5pcU5Kvpka/9Vt3P/QpKRq1ARX5GcpyGDZdeRV+aY49h X-Received: by 2002:a92:d6c6:0:b0:359:412a:3358 with SMTP id z6-20020a92d6c6000000b00359412a3358mr600232ilp.24.1700252070010; Fri, 17 Nov 2023 12:14:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700252069; cv=none; d=google.com; s=arc-20160816; b=KopVU98E7mXnmYzXzOIcY8jPGW/36PHUCWIVGJSrLBXnPGDtNlnZA7pq80lWP309lR ncXIVRWY8x8JO2m+TUBu++WVFp3LQjAC+XXYeXG8gk42Jax/2MWYsfM8ec6b4PM+9Le5 +/be4DjnkkeVtHd6bE3vzot5UjLsE5XPJt67SWvnJoDaWU1b++Q7np+4tWG+gDw1tZ4N D5EXyA4/HXY++MS5tNyzuV/9HvwRWuQ9bv8GmO14z9kh1KOakzGXONae7UCoZgWb5PB/ UEOHQpl3bHzFGXuJm+/5KL0SY5qTgqIh+mHgvi+8p1SHYcU1UVmI4q0G3DDfXHS6jKOz 6oMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=M1wQ6CLb/dDh5KiZFFpLs1bmPNGn2Z5vlnYTp1713SY=; fh=iMzJmnbboC4LJtlxOKimqPq82YSRfb3zCJyFaxC9c3g=; b=ru/N6+COa9Z1LwXeA1GCXedwthhFNI8TbEbPAAQW2rmHib0TemmVLxqGaw8se7utez 1Dri/82rfw9vK8/ojDOJnwigTOS2KRiqtIcbdZ6Bj5cp5mjBubAbdiAUYl7qTQ4IEoR4 SxkKqCLQ9uFH7msUeePBi25NYfiYl29Nq4AlHuRvPzkSpo5W2cTsUKbr8qw/TLenQmj2 dJ+bXfAeOei/r8CxtL4qJE5RMgWU4Rd+W6z4dCUoeU5t1ssNQ0aW6NCf2BkR8WZ1PGDn 5ks/SE1VDENd2Nh+sJVAC/W9q+6ySbjCucGZyY+E3LgK8V1rze5wRTBbJ7PPeyTC47vW RLIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b="zs/TE/2d"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b17-20020a656691000000b005ab1fd6fbc1si2560632pgw.847.2023.11.17.12.14.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:14:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b="zs/TE/2d"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 341F682AAEA5; Fri, 17 Nov 2023 12:14:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346214AbjKQUOO (ORCPT + 29 others); Fri, 17 Nov 2023 15:14:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235726AbjKQUOB (ORCPT ); Fri, 17 Nov 2023 15:14:01 -0500 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE00410D5 for ; Fri, 17 Nov 2023 12:13:57 -0800 (PST) Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3b2df2fb611so1609902b6e.0 for ; Fri, 17 Nov 2023 12:13:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1700252037; x=1700856837; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M1wQ6CLb/dDh5KiZFFpLs1bmPNGn2Z5vlnYTp1713SY=; b=zs/TE/2dzcTIHUUgBQPW21glYKrUWr6e4lez1HsM2FETRIb0q8ttXaWHDhMMvtxAvz PAhB3Tm0uoj1B5VYSmFBymiCNJ0qscRwXnixBcesVok1F1NthOM3gCQJ55ulb6TnQ81w QoE73k5cJYhWxylpLelYJJ9WOz/68NEgZf77Zx0lX97Ju/Mu1kuYqoQmdP9/AZnwdQKa tTR0PXgA2IwZFFujByP9vR/f06oghFv9yczgJDjOQWmB2ZuW3pJugDhDIl+vje0E7HCk PZ6+/txXyoTmm2d67EzqcMSCnYEhdm1ANSv96YH/3FiQaCQyBA+EZ7MB4QuoamUFPEdh 9RIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700252037; x=1700856837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M1wQ6CLb/dDh5KiZFFpLs1bmPNGn2Z5vlnYTp1713SY=; b=imBIKK6AUSZJTm+5s1peYQnkB0flDt+7qkJnA8PTP95EQkhnvwPRcSFQ9CKnPkMvni zxQLDXH46N3m7hsxQg/17GKQjNeEx34sb9CYFci01SpkH1Aburz3X0JqiImnvYEx+six dHNIVPd1j+btYwPCvKcjhesAeWBJwp1SapxG0pNolYaIP8RfXHu3a+apDqRmvKiAVwEw WNT4/QjnII22jwx7TtefUQFWXg2cfHoE8Nfvt2R/GX0Ct1Jv3JqL5H8QsiwXZI5bsvcc MHW6XssUgMmoprsagLC0aeIjSSrEzvaRRxVPEDwUcUwX2Utf5TsIfkB0nivFVGB99f2l nT1w== X-Gm-Message-State: AOJu0YwBthyXBWePystdeGkR/qHjjTzSFbwRMirbVNA0HZ1CmHGlzP/C XTyghPls7m6bzaaTfm3Y+71Upg== X-Received: by 2002:a05:6808:1922:b0:3b2:e70e:b448 with SMTP id bf34-20020a056808192200b003b2e70eb448mr531624oib.8.1700252037075; Fri, 17 Nov 2023 12:13:57 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id l21-20020a544515000000b003a8560a9d34sm393814oil.25.2023.11.17.12.13.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:13:56 -0800 (PST) From: David Lechner To: linux-spi@vger.kernel.org, devicetree@vger.kernel.org Cc: David Lechner , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Lars-Peter Clausen , linux-kernel@vger.kernel.org Subject: [PATCH 07/14] spi: axi-spi-engine: use devm_spi_register_controller() Date: Fri, 17 Nov 2023 14:12:58 -0600 Message-ID: <20231117-axi-spi-engine-series-1-v1-7-cc59db999b87@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> References: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 12:14:15 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782843514487717653 X-GMAIL-MSGID: 1782843514487717653 This replaces spi_register_controller() with devm_spi_register_controller() in the AXI SPI Engine driver. This saves us from having to call spi_unregister_controller() in the remove function. The remove function is also removed since it is no longer needed. Signed-off-by: David Lechner --- drivers/spi/spi-axi-spi-engine.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index 81d7352d2b8b..819744246952 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -532,7 +532,7 @@ static int spi_engine_probe(struct platform_device *pdev) host->transfer_one_message = spi_engine_transfer_one_message; host->num_chipselect = 8; - ret = spi_register_controller(host); + ret = devm_spi_register_controller(&pdev->dev, host); if (ret) return ret; @@ -541,13 +541,6 @@ static int spi_engine_probe(struct platform_device *pdev) return 0; } -static void spi_engine_remove(struct platform_device *pdev) -{ - struct spi_controller *host = platform_get_drvdata(pdev); - - spi_unregister_controller(host); -} - static const struct of_device_id spi_engine_match_table[] = { { .compatible = "adi,axi-spi-engine-1.00.a" }, { }, @@ -556,7 +549,6 @@ MODULE_DEVICE_TABLE(of, spi_engine_match_table); static struct platform_driver spi_engine_driver = { .probe = spi_engine_probe, - .remove_new = spi_engine_remove, .driver = { .name = "spi-engine", .of_match_table = spi_engine_match_table, From patchwork Fri Nov 17 20:12:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 166311 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp788291vqn; Fri, 17 Nov 2023 12:15:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0z/LmCU1FhdLIBpnwbzHxz+yvFvRvZ/0eZN1nIFhZiNf7gIQQrXcisrcFcgtM7MRyyj5u X-Received: by 2002:a05:6a21:612:b0:187:858b:8c17 with SMTP id ll18-20020a056a21061200b00187858b8c17mr214923pzb.2.1700252159338; Fri, 17 Nov 2023 12:15:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700252159; cv=none; d=google.com; s=arc-20160816; b=TNbOKHU9thuPDBQV8nAh6Rjg+Vnqnsy2KiaDN8JwdI+3w2FpHJ/Wt4zQKw3AkNZVbM 5fMlUVRUcB/mOGUdVvJssfW5MjHzgfVoeVfAOiLdGf8XiPDPXcMq1DHIDe8WQbJwr7Ql Tf7JBoiFeOAwB2vAVyG2AS+yzJqsknVf7uDz90HgDj83KEib/Dv3RCeFOK+JbCE3JPxj 7DZiy6WU2avdQifeS1/NhGMBgNUkM6XEfUIfRSKS9FHdunB/3JU3Tl5ETNMoWirD181i 9Zqpv0lDVsYZ3EaGTb7KX6YHwoKOloxOA/nnrIejg2rhELORBvf083b1iRS/1LiOf8+8 c3bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=npvMQYAJSwyILZ7IKukB/DvG7sNQ93TySYJ1U4gDkl4=; fh=iMzJmnbboC4LJtlxOKimqPq82YSRfb3zCJyFaxC9c3g=; b=LuJMZHONpmw9F/VrbjxdZMHYX6UBRn3eGR34pijbR+c3iMxMHsc9Z3qPyHLME9M5Fi nNb4X22RgiSRCp8RPkndOqMXdK8zgJsKsvVn8xsYzmBbw0rqLzC9FEqyt74qjk6t9cyt SlmKcrw4iKT5byTXCy/IVraGBtVJCv3O6mijTS4UyBC1kIfTPlmoI4LPcxctgZNZxoxH k/U2XDwhhhgTRodO1axHvnKxgQsDH7eF4V2D6/uYdsa2xjVeGVHB292I6Iu6qEIovwrz NdpwxYTrcIiygyYWAgOc8dJ3yXShL+CTOnsXC0XodYJgyImlE5T9LLskFhYg2msJSHiB lvhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=dF4HhDH2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id by29-20020a056a02059d00b0059c0f9ef964si2958840pgb.635.2023.11.17.12.15.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:15:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=dF4HhDH2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 6713E8088A4F; Fri, 17 Nov 2023 12:15:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235752AbjKQUOV (ORCPT + 29 others); Fri, 17 Nov 2023 15:14:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346154AbjKQUOD (ORCPT ); Fri, 17 Nov 2023 15:14:03 -0500 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D96510D9 for ; Fri, 17 Nov 2023 12:13:58 -0800 (PST) Received: by mail-oi1-x232.google.com with SMTP id 5614622812f47-3b566ee5f1dso1446450b6e.0 for ; Fri, 17 Nov 2023 12:13:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1700252038; x=1700856838; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=npvMQYAJSwyILZ7IKukB/DvG7sNQ93TySYJ1U4gDkl4=; b=dF4HhDH2eqiJds+sz20xspLu3qG1xNOdNILpBOPIQlUyyAd/h6KZkNRbNNuCYrZuvG 42zo54xPs/eko/hE5oub++KHHUkCnGYIbv4p+2xIgz/IPQ6e0KsOon+CTZn7MywympNu oYh8XdrJbK3gLKJIzbrlD3wX+DsY5Ll/opwJh9SJKt9JBpjKzhe12AWXCvlcXdkYVpxa GJSl4jWRDwE9c3vUto2rD5w3tFfh/g/c630723YIhpvthgo9nOo2waY3gx/BdmNOexZO 7P2BZAidQZchZ5ouG7SqPpT64+d4u7uthtwRXC5M+KLgpoUxJasnS9SqQnHqWfXIHZw/ Ckvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700252038; x=1700856838; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=npvMQYAJSwyILZ7IKukB/DvG7sNQ93TySYJ1U4gDkl4=; b=arnrjCngIYOWQ/wrnXpvq07rL3xZ9sZ+hT7INJ+3qAgOsVmMcd0fW+Yg9BH4ZB5p/d VYppAg40Zn4Py/fJkx1Q3RMJEeuC00HcSzLnNr6Ak6FYZ21sGl/9mQy/uI2k/lwqSnOn Ud5pEI6cr7XvYYrO1RwaPKEgOJLgEdbSo0Xu3j3LZlJXHHq113sVspL62FWAGx+GcJHX q3RYgZS06ez+knUf60G7ZqP7byhUe2x1nZ+MQ53e/L3+fYNULATglCRxGV3VabkqPK28 qE2tYKuln3/fOZhw1ClcbSV1u0vcMf+KDup78ESPIhVewzLdarbP1giqGezV81Y7wkaS tpEg== X-Gm-Message-State: AOJu0YwtHjSIBAAWwX6Iv9GB0KjOGavnfHjXIN6eqLJgw7vGuiyO16EN Ij6S3HQJGGIEFXTjYAFayC8DVw== X-Received: by 2002:a05:6808:1288:b0:3ab:84f0:b49d with SMTP id a8-20020a056808128800b003ab84f0b49dmr594399oiw.3.1700252037854; Fri, 17 Nov 2023 12:13:57 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id l21-20020a544515000000b003a8560a9d34sm393814oil.25.2023.11.17.12.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:13:57 -0800 (PST) From: David Lechner To: linux-spi@vger.kernel.org, devicetree@vger.kernel.org Cc: David Lechner , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Lars-Peter Clausen , linux-kernel@vger.kernel.org Subject: [PATCH 08/14] spi: axi-spi-engine: check for valid clock rate Date: Fri, 17 Nov 2023 14:12:59 -0600 Message-ID: <20231117-axi-spi-engine-series-1-v1-8-cc59db999b87@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> References: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 17 Nov 2023 12:15:37 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782843608282845417 X-GMAIL-MSGID: 1782843608282845417 This adds a check for a valid SCLK rate in the axi-spi-engine driver during probe. A valid rate is required to get accurate timing for delays and by not allowing 0 we can avoid divide by zero errors later without additional checks. Signed-off-by: David Lechner --- drivers/spi/spi-axi-spi-engine.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index 819744246952..8a6fbb3bb3f1 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -532,6 +532,9 @@ static int spi_engine_probe(struct platform_device *pdev) host->transfer_one_message = spi_engine_transfer_one_message; host->num_chipselect = 8; + if (host->max_speed_hz == 0) + return dev_err_probe(&pdev->dev, -EINVAL, "spi_clk rate is 0"); + ret = devm_spi_register_controller(&pdev->dev, host); if (ret) return ret; From patchwork Fri Nov 17 20:13:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 166313 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp788545vqn; Fri, 17 Nov 2023 12:16:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9Hhw2lOhg7Pjb8IOOpyH1kk9lHOJVmZlNRVsIDgqG5XLtMXPg8yPv/d47lk5ZVBja+f8l X-Received: by 2002:a05:6a21:9997:b0:181:1cfa:4106 with SMTP id ve23-20020a056a21999700b001811cfa4106mr204488pzb.62.1700252186530; Fri, 17 Nov 2023 12:16:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700252186; cv=none; d=google.com; s=arc-20160816; b=Y3koMyVmw0cWlwGSbbVTBUZGHgoeoO2uy+Bo1GTMNW2sbqipFPdt986GajCBCM3o7j HC3ux21gcTDQl0p7RD4dhIizB/Gm+QWVQgz6C+TuaaWu2QitaBjgsoYDwW1KiNWtJxy1 YDlyM4L2oHTQTQIrJLaB+WwePmfR+fJWvLsZ+ciSN7Wo8Pxz7VF9IGovqL88bAKoiENb vvYIG396Hw4XrmAQjzMJ1ddT3NrcAmp2jC7fC5PV4Qux1yBdDiza6nX48cN7CmcHLVG2 3MieRd4WDT6YF80t3O5rTRwCoT8QG9Z1r83ftOEmVSMKWKohQNc2GpgqQMX13weYZkml TxJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1RuICcIcIl3AaiTh6lEHwrcRrEfhi3pyQa5k6SJhLUA=; fh=iMzJmnbboC4LJtlxOKimqPq82YSRfb3zCJyFaxC9c3g=; b=nTKYXMgsUwaveaYinTa7JJtLWu23r32ANfBOppar3WzV0+EQ+LFS7XcWR/l/WsblxC MViUUJkPz0nslLKoHdy+FBni4kS+L6i4Oeyzim+uJyEVQ05UguxpwpHMwHD2dEjktIlQ fCuCOawxqKkaEM8EZs/4tmb+yhU6w6btPo5N7mJOwafhlLm42xy/Hz7UP6SNxAPCXqk5 CFg5/e1VFNtIsZJBfW2WmNZCelhvJuKmZyWJrzPEvI12wfCvOW9UqN65xVGtAoMGb2Qf cvMPmrnIoudfxrh7E5/evAkDCO2ip8FHR3ZQtD42ooS71a/sKN4Ljg5Ij+Lbv/HYF6Av 8J/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b="z3zTquZ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id z10-20020a630a4a000000b005c203ad0e2csi1843206pgk.827.2023.11.17.12.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:16:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b="z3zTquZ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 53844827A773; Fri, 17 Nov 2023 12:16:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235193AbjKQUOY (ORCPT + 29 others); Fri, 17 Nov 2023 15:14:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346189AbjKQUOH (ORCPT ); Fri, 17 Nov 2023 15:14:07 -0500 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C51110EC for ; Fri, 17 Nov 2023 12:13:59 -0800 (PST) Received: by mail-oi1-x232.google.com with SMTP id 5614622812f47-3b2ec9a79bdso1596279b6e.3 for ; Fri, 17 Nov 2023 12:13:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1700252038; x=1700856838; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1RuICcIcIl3AaiTh6lEHwrcRrEfhi3pyQa5k6SJhLUA=; b=z3zTquZ/PPv2BrCckuX+EitkYM/I38XDoZFzCE5W1EYWyPeOUTI1YkuhNWWKqolK82 hTf+jkNQhB/Ys074Zs0o8ZMqISyPVChgSffD7nOBLS3AHrZM9aRz/ebbzYCn1AylZusF MMWn7u6sUqQxS25amZGsnVyt3VCeTit36BoxR1LBjQk8vUD9IrIEaXSXL25p/a5qac2r x9tAde+rnFSdIJA4HzMtxk+gDiZoTmIUrzLZJqU57x4sJ07QMJtN8WVl0Sd/PG1JkC22 jjNbpNQJDxOURyZ+09RaVPGg/DD8WS2b7qzeeTRiHIwY1A3jht6ddO1g2P2CztvvAwP3 sNrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700252038; x=1700856838; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1RuICcIcIl3AaiTh6lEHwrcRrEfhi3pyQa5k6SJhLUA=; b=BlLBkFOBGp0DAjYSXl9FsyR3Fjoz3Ip7ILJS+PSb7VC9h3nut+BsJzd70WlnlsoAY2 WjG1u2GJd7+bxAvQ3Jf0Ugd/NEUPTfHmBVaungMPe3YnkuGQpMRioNmq9Eh0jUSpzdAj aVx1K+zNFdLybRUMbuL7QTosq2qxX7rr8coMNfPeBbFGOabJYCTaDxvbY5RFvkb7auJz uV8KnJSU6LtwH3AE4fRN1aXmDHHQHwoHzvfM2CnkkUgSwSUDAe2tjj+grEY4SSXvBS46 m2I1PvW5i9krRINl5M4dAA0KzB28+fhTTW5kvwnxJ02z2cBPeIcFfIrbXmRWlwH69c2N 9KxA== X-Gm-Message-State: AOJu0YyPwnamvaLZyKeMucIwJmvkEL7ZuhyaSSTINAY0JdCvR2N5tETY +HiCMVO6zIk81bQkrhJovih+hQ== X-Received: by 2002:a05:6808:1a0e:b0:3b2:e624:43a0 with SMTP id bk14-20020a0568081a0e00b003b2e62443a0mr530324oib.15.1700252038650; Fri, 17 Nov 2023 12:13:58 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id l21-20020a544515000000b003a8560a9d34sm393814oil.25.2023.11.17.12.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:13:58 -0800 (PST) From: David Lechner To: linux-spi@vger.kernel.org, devicetree@vger.kernel.org Cc: David Lechner , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Lars-Peter Clausen , linux-kernel@vger.kernel.org Subject: [PATCH 09/14] spi: axi-spi-engine: move msg state to new struct Date: Fri, 17 Nov 2023 14:13:00 -0600 Message-ID: <20231117-axi-spi-engine-series-1-v1-9-cc59db999b87@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> References: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,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 fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 17 Nov 2023 12:16:08 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782843636570972301 X-GMAIL-MSGID: 1782843636570972301 This moves the message state in the AXI SPI Engine driver to a new struct spi_engine_msg_state. Previously, the driver state contained various pointers that pointed to memory owned by a struct spi_message. However, it did not set any of these pointers to NULL when a message was completed. This could lead to use after free bugs. Example of how this could happen: 1. SPI core calls into spi_engine_transfer_one_message() with msg1. 2. Assume something was misconfigured and spi_engine_tx_next() is not called enough times in interrupt callbacks for msg1 such that spi_engine->tx_xfer is never set to NULL before the msg1 completes. 3. SYNC interrupt is received and spi_finalize_current_message() is called for msg1. spi_engine->msg is set to NULL but no other message-specific state is reset. 4. Caller that sent msg1 is notified of the completion and frees msg1 and the associated xfers and tx/rx buffers. 4. SPI core calls into spi_engine_transfer_one_message() with msg2. 5. When spi_engine_tx_next() is called for msg2, spi_engine->tx_xfer is still be pointing to an xfer from msg1, which was already freed. spi_engine_xfer_next() tries to access xfer->transfer_list of one of the freed xfers and we get a segfault or undefined behavior. To avoid issues like this, instead of putting per-message state in the driver state struct, we can make use of the struct spi_message::state field to store a pointer to a new struct spi_engine_msg_state. This way, all of the state that belongs to specific message stays with that message and we don't have to remember to manually reset all aspects of the message state when a message is completed. Rather, a new state is allocated for each message. Most of the changes are just renames where the state is accessed. One place where this wasn't straightforward was the sync_id member. This has been changed to use ida_alloc_range() since we needed to separate the per-message sync_id from the per-controller next available sync_id. Signed-off-by: David Lechner --- drivers/spi/spi-axi-spi-engine.c | 150 +++++++++++++++++++++++++-------------- 1 file changed, 96 insertions(+), 54 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index 8a6fbb3bb3f1..745000a9b2c7 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -78,28 +79,42 @@ struct spi_engine_program { uint16_t instructions[]; }; -struct spi_engine { - struct clk *clk; - struct clk *ref_clk; - - spinlock_t lock; - - void __iomem *base; - - struct spi_message *msg; +/** + * struct spi_engine_message_state - SPI engine per-message state + */ +struct spi_engine_message_state { + /** Instructions for executing this message. */ struct spi_engine_program *p; + /** Number of elements in cmd_buf array. */ unsigned cmd_length; + /** Array of commands not yet written to CMD FIFO. */ const uint16_t *cmd_buf; - + /** Next xfer with tx_buf not yet fully written to TX FIFO. */ struct spi_transfer *tx_xfer; + /** Size of tx_buf in bytes. */ unsigned int tx_length; + /** Bytes not yet written to TX FIFO. */ const uint8_t *tx_buf; - + /** Next xfer with rx_buf not yet fully written to RX FIFO. */ struct spi_transfer *rx_xfer; + /** Size of tx_buf in bytes. */ unsigned int rx_length; + /** Bytes not yet written to the RX FIFO. */ uint8_t *rx_buf; + /** ID to correlate SYNC interrupts with this message. */ + u8 sync_id; +}; + +struct spi_engine { + struct clk *clk; + struct clk *ref_clk; - unsigned int sync_id; + spinlock_t lock; + + void __iomem *base; + + struct spi_message *msg; + struct ida sync_ida; unsigned int completed_id; unsigned int int_enable; @@ -258,100 +273,105 @@ static void spi_engine_xfer_next(struct spi_engine *spi_engine, static void spi_engine_tx_next(struct spi_engine *spi_engine) { - struct spi_transfer *xfer = spi_engine->tx_xfer; + struct spi_engine_message_state *st = spi_engine->msg->state; + struct spi_transfer *xfer = st->tx_xfer; do { spi_engine_xfer_next(spi_engine, &xfer); } while (xfer && !xfer->tx_buf); - spi_engine->tx_xfer = xfer; + st->tx_xfer = xfer; if (xfer) { - spi_engine->tx_length = xfer->len; - spi_engine->tx_buf = xfer->tx_buf; + st->tx_length = xfer->len; + st->tx_buf = xfer->tx_buf; } else { - spi_engine->tx_buf = NULL; + st->tx_buf = NULL; } } static void spi_engine_rx_next(struct spi_engine *spi_engine) { - struct spi_transfer *xfer = spi_engine->rx_xfer; + struct spi_engine_message_state *st = spi_engine->msg->state; + struct spi_transfer *xfer = st->rx_xfer; do { spi_engine_xfer_next(spi_engine, &xfer); } while (xfer && !xfer->rx_buf); - spi_engine->rx_xfer = xfer; + st->rx_xfer = xfer; if (xfer) { - spi_engine->rx_length = xfer->len; - spi_engine->rx_buf = xfer->rx_buf; + st->rx_length = xfer->len; + st->rx_buf = xfer->rx_buf; } else { - spi_engine->rx_buf = NULL; + st->rx_buf = NULL; } } static bool spi_engine_write_cmd_fifo(struct spi_engine *spi_engine) { void __iomem *addr = spi_engine->base + SPI_ENGINE_REG_CMD_FIFO; + struct spi_engine_message_state *st = spi_engine->msg->state; unsigned int n, m, i; const uint16_t *buf; n = readl_relaxed(spi_engine->base + SPI_ENGINE_REG_CMD_FIFO_ROOM); - while (n && spi_engine->cmd_length) { - m = min(n, spi_engine->cmd_length); - buf = spi_engine->cmd_buf; + while (n && st->cmd_length) { + m = min(n, st->cmd_length); + buf = st->cmd_buf; for (i = 0; i < m; i++) writel_relaxed(buf[i], addr); - spi_engine->cmd_buf += m; - spi_engine->cmd_length -= m; + st->cmd_buf += m; + st->cmd_length -= m; n -= m; } - return spi_engine->cmd_length != 0; + return st->cmd_length != 0; } static bool spi_engine_write_tx_fifo(struct spi_engine *spi_engine) { void __iomem *addr = spi_engine->base + SPI_ENGINE_REG_SDO_DATA_FIFO; + struct spi_engine_message_state *st = spi_engine->msg->state; unsigned int n, m, i; const uint8_t *buf; n = readl_relaxed(spi_engine->base + SPI_ENGINE_REG_SDO_FIFO_ROOM); - while (n && spi_engine->tx_length) { - m = min(n, spi_engine->tx_length); - buf = spi_engine->tx_buf; + while (n && st->tx_length) { + m = min(n, st->tx_length); + buf = st->tx_buf; for (i = 0; i < m; i++) writel_relaxed(buf[i], addr); - spi_engine->tx_buf += m; - spi_engine->tx_length -= m; + st->tx_buf += m; + st->tx_length -= m; n -= m; - if (spi_engine->tx_length == 0) + if (st->tx_length == 0) spi_engine_tx_next(spi_engine); } - return spi_engine->tx_length != 0; + return st->tx_length != 0; } static bool spi_engine_read_rx_fifo(struct spi_engine *spi_engine) { void __iomem *addr = spi_engine->base + SPI_ENGINE_REG_SDI_DATA_FIFO; + struct spi_engine_message_state *st = spi_engine->msg->state; unsigned int n, m, i; uint8_t *buf; n = readl_relaxed(spi_engine->base + SPI_ENGINE_REG_SDI_FIFO_LEVEL); - while (n && spi_engine->rx_length) { - m = min(n, spi_engine->rx_length); - buf = spi_engine->rx_buf; + while (n && st->rx_length) { + m = min(n, st->rx_length); + buf = st->rx_buf; for (i = 0; i < m; i++) buf[i] = readl_relaxed(addr); - spi_engine->rx_buf += m; - spi_engine->rx_length -= m; + st->rx_buf += m; + st->rx_length -= m; n -= m; - if (spi_engine->rx_length == 0) + if (st->rx_length == 0) spi_engine_rx_next(spi_engine); } - return spi_engine->rx_length != 0; + return st->rx_length != 0; } static irqreturn_t spi_engine_irq(int irq, void *devid) @@ -387,12 +407,16 @@ static irqreturn_t spi_engine_irq(int irq, void *devid) disable_int |= SPI_ENGINE_INT_SDI_ALMOST_FULL; } - if (pending & SPI_ENGINE_INT_SYNC) { - if (spi_engine->msg && - spi_engine->completed_id == spi_engine->sync_id) { + if (pending & SPI_ENGINE_INT_SYNC && spi_engine->msg) { + struct spi_engine_message_state *st = spi_engine->msg->state; + + if (spi_engine->completed_id == st->sync_id) { struct spi_message *msg = spi_engine->msg; + struct spi_engine_message_state *st = msg->state; - kfree(spi_engine->p); + ida_free(&spi_engine->sync_ida, st->sync_id); + kfree(st->p); + kfree(st); msg->status = 0; msg->actual_length = msg->frame_length; spi_engine->msg = NULL; @@ -417,29 +441,46 @@ static int spi_engine_transfer_one_message(struct spi_controller *host, { struct spi_engine_program p_dry, *p; struct spi_engine *spi_engine = spi_controller_get_devdata(host); + struct spi_engine_message_state *st; unsigned int int_enable = 0; unsigned long flags; size_t size; + int ret; + + st = kzalloc(sizeof(*st), GFP_KERNEL); + if (!st) + return -ENOMEM; p_dry.length = 0; spi_engine_compile_message(spi_engine, msg, true, &p_dry); size = sizeof(*p->instructions) * (p_dry.length + 1); p = kzalloc(sizeof(*p) + size, GFP_KERNEL); - if (!p) + if (!p) { + kfree(st); return -ENOMEM; + } + + ret = ida_alloc_range(&spi_engine->sync_ida, 0, U8_MAX, GFP_KERNEL); + if (ret < 0) { + kfree(p); + kfree(st); + return ret; + } + + st->sync_id = ret; + spi_engine_compile_message(spi_engine, msg, false, p); spin_lock_irqsave(&spi_engine->lock, flags); - spi_engine->sync_id = (spi_engine->sync_id + 1) & 0xff; - spi_engine_program_add_cmd(p, false, - SPI_ENGINE_CMD_SYNC(spi_engine->sync_id)); + spi_engine_program_add_cmd(p, false, SPI_ENGINE_CMD_SYNC(st->sync_id)); + msg->state = st; spi_engine->msg = msg; - spi_engine->p = p; + st->p = p; - spi_engine->cmd_buf = p->instructions; - spi_engine->cmd_length = p->length; + st->cmd_buf = p->instructions; + st->cmd_length = p->length; if (spi_engine_write_cmd_fifo(spi_engine)) int_enable |= SPI_ENGINE_INT_CMD_ALMOST_EMPTY; @@ -448,7 +489,7 @@ static int spi_engine_transfer_one_message(struct spi_controller *host, int_enable |= SPI_ENGINE_INT_SDO_ALMOST_EMPTY; spi_engine_rx_next(spi_engine); - if (spi_engine->rx_length != 0) + if (st->rx_length != 0) int_enable |= SPI_ENGINE_INT_SDI_ALMOST_FULL; int_enable |= SPI_ENGINE_INT_SYNC; @@ -489,6 +530,7 @@ static int spi_engine_probe(struct platform_device *pdev) spi_engine = spi_controller_get_devdata(host); spin_lock_init(&spi_engine->lock); + ida_init(&spi_engine->sync_ida); spi_engine->clk = devm_clk_get_enabled(&pdev->dev, "s_axi_aclk"); if (IS_ERR(spi_engine->clk)) From patchwork Fri Nov 17 20:13:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 166306 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp787541vqn; Fri, 17 Nov 2023 12:14:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEzgpD7/3tDtf9bqljqrl/MHKe/mUtyoTFkORkyHIK5WhXIp5hYTI73ts93WPjPUKI0ZZ90 X-Received: by 2002:a05:6a00:2d89:b0:6bd:ca1d:c51e with SMTP id fb9-20020a056a002d8900b006bdca1dc51emr462194pfb.16.1700252084494; Fri, 17 Nov 2023 12:14:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700252084; cv=none; d=google.com; s=arc-20160816; b=ST4nu0XpcJgLBtrdkium+GZwr08E75S9Fi1crlVVvc+nG749DqRobtaa3pPSfAs3Ww /t1ADfl4Q7sYEgSZrYXDcAP/ULpBERrlfhPVKVkT6mX8XvaPuGLd88lm50f9NNjTw/m+ 2bz69xYZY/WGbpjLCUyou2yWziVLMJgkWKdpgkAjGzQBVy0sUOfZQwaG5v/W+I4ZF2Fo co8b0w5Ge2kEhl0CgKaUHSwK6K0F5rGizz9rC357Zm/Ye2rQ8gP8MZDtNJL8lu5YQuqr cLLjA1qukDc1XwtEqD50jWesPu8PSM81B19znxcGUvOQ5DutDrUsrrQlByaBym24+3VC zGcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3x/o+ZhKJLhCZxPJDvSVJn2SYXdsZyrTC3illb8aSGE=; fh=iMzJmnbboC4LJtlxOKimqPq82YSRfb3zCJyFaxC9c3g=; b=PjFhiXYelyCiOxjOPNeCuZd0uMFtUxIYsmHHgT3t4ZNYv5I8AsPyzTLiLO621WKLSZ GYcP5C/p7FLDP4qB0EsZJQ3ogDyeLJsWsab9oyUQfNdS6EL9t35E8gj9FSZQd9+a8v/F +8rRAwftvjS6zKJ22a7YWaBE6HQ9IoK7EQnyp5Xo7CqzDdcma7TNYJ2fMaAJmg4/wZB5 ysiiX3+0boLyubOimCai0TNmze9ruybmnehBEioEBor83JzsRIaqlbG4VuoV+ub3leE/ Lmz3A5c/0KC28D4RcBiiBerCVzKtUxCgwgosfIpPvkEnCECr40AojpbTkCoxjzCYqVxl f0ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=CwKoOETZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id x2-20020a056a00188200b006b8b194005fsi2648483pfh.256.2023.11.17.12.14.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:14:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=CwKoOETZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7CFF982AB454; Fri, 17 Nov 2023 12:14:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346189AbjKQUO0 (ORCPT + 29 others); Fri, 17 Nov 2023 15:14:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346191AbjKQUOH (ORCPT ); Fri, 17 Nov 2023 15:14:07 -0500 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EF4CD6D for ; Fri, 17 Nov 2023 12:14:00 -0800 (PST) Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3b2df2fb611so1609925b6e.0 for ; Fri, 17 Nov 2023 12:14:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1700252039; x=1700856839; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3x/o+ZhKJLhCZxPJDvSVJn2SYXdsZyrTC3illb8aSGE=; b=CwKoOETZGqRe5UOqmT1L2acNwFT+sCm90z6Wce9bLIOiYNpu/NIa1HtvwKYSaZiosg CUxX+YsEjzHJKPMfFL/itqTlHCgyxQgMoTsEx+2ELphA+EAjxkoo7kUlquYWYRuLxlR8 ST1uNo5tL5iLc9bBnTV6vJSF0Y1HVASK2OkTP3jMKCKupM/YLkIMNzSNrk4ZWT7v/1hz ssMBdM/fDX7YTxgu7Vq199CLU1bF0Y10A07bFl9/SqstvjvtTKwzkPxrJ4Oy+6YbGoci wXmTeMrOk/eI9tuE5MqIqQ1NTp/m2CMe7bRSUPg+F1MbGpxC8coWdqbcsYdg4t96uB/w IxsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700252039; x=1700856839; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3x/o+ZhKJLhCZxPJDvSVJn2SYXdsZyrTC3illb8aSGE=; b=JP17il+EYXhoeJu0VVZ4wg9tmjMusmvcWFAE3s1hlevm0mGRUv313CyMP0345wQ30m vNniMq3R+s4gztVFEc2FIqnTptdBJgem8mFBUFuYbP+QaQcyrZaP+B+7qiiYslpMOSa5 he5zT6ocvFupb/YIbJL8LT2k1xQX4ef2Sm7nNAkUi2ALSZ7uSr+3z1Ihlg6aM4/6pMcG sBU/t3J08566ai49FTgNeXTDFjulhe9l3wtsbC+LfU4a4fMMuhssIirLTfEUOjsr3/GE 8cCWepSmpdCgr82Uk6TwjOnKbp0ROhYSuD5iXVkLnPPw2mdFpAhXUB2V5tv911c1wg/j HSJw== X-Gm-Message-State: AOJu0Yx4BvANI0hxc7G2Cw/HQnXQAteodupnr5o54gg9zxceeInk+ifm Lt05/9bYHSJri8n/ABitdkdgbw== X-Received: by 2002:a05:6808:15a8:b0:3b6:3d44:4d75 with SMTP id t40-20020a05680815a800b003b63d444d75mr576150oiw.22.1700252039458; Fri, 17 Nov 2023 12:13:59 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id l21-20020a544515000000b003a8560a9d34sm393814oil.25.2023.11.17.12.13.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:13:59 -0800 (PST) From: David Lechner To: linux-spi@vger.kernel.org, devicetree@vger.kernel.org Cc: David Lechner , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Lars-Peter Clausen , linux-kernel@vger.kernel.org Subject: [PATCH 10/14] spi: axi-spi-engine: use message_prepare/unprepare Date: Fri, 17 Nov 2023 14:13:01 -0600 Message-ID: <20231117-axi-spi-engine-series-1-v1-10-cc59db999b87@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> References: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 12:14:30 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782843529527595375 X-GMAIL-MSGID: 1782843529527595375 This modifies the AXI SPI Engine driver to make use of the message_prepare and message_unprepare callbacks. This separates the concerns of allocating and freeing the message state from the transfer_one_message callback. The main benfit of this is so that future callers of spi_finalize_current_message() will not have to do manual cleanup of the state. Signed-off-by: David Lechner --- drivers/spi/spi-axi-spi-engine.c | 46 +++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index 745000a9b2c7..210bea23f433 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -412,11 +412,7 @@ static irqreturn_t spi_engine_irq(int irq, void *devid) if (spi_engine->completed_id == st->sync_id) { struct spi_message *msg = spi_engine->msg; - struct spi_engine_message_state *st = msg->state; - ida_free(&spi_engine->sync_ida, st->sync_id); - kfree(st->p); - kfree(st); msg->status = 0; msg->actual_length = msg->frame_length; spi_engine->msg = NULL; @@ -436,14 +432,12 @@ static irqreturn_t spi_engine_irq(int irq, void *devid) return IRQ_HANDLED; } -static int spi_engine_transfer_one_message(struct spi_controller *host, - struct spi_message *msg) +static int spi_engine_prepare_message(struct spi_controller *host, + struct spi_message *msg) { struct spi_engine_program p_dry, *p; struct spi_engine *spi_engine = spi_controller_get_devdata(host); struct spi_engine_message_state *st; - unsigned int int_enable = 0; - unsigned long flags; size_t size; int ret; @@ -472,15 +466,41 @@ static int spi_engine_transfer_one_message(struct spi_controller *host, spi_engine_compile_message(spi_engine, msg, false, p); - spin_lock_irqsave(&spi_engine->lock, flags); spi_engine_program_add_cmd(p, false, SPI_ENGINE_CMD_SYNC(st->sync_id)); - msg->state = st; - spi_engine->msg = msg; st->p = p; - st->cmd_buf = p->instructions; st->cmd_length = p->length; + msg->state = st; + + return 0; +} + +static int spi_engine_unprepare_message(struct spi_controller *host, + struct spi_message *msg) +{ + struct spi_engine *spi_engine = spi_controller_get_devdata(host); + struct spi_engine_message_state *st = msg->state; + + ida_free(&spi_engine->sync_ida, st->sync_id); + kfree(st->p); + kfree(st); + + return 0; +} + +static int spi_engine_transfer_one_message(struct spi_controller *host, + struct spi_message *msg) +{ + struct spi_engine *spi_engine = spi_controller_get_devdata(host); + struct spi_engine_message_state *st = msg->state; + unsigned int int_enable = 0; + unsigned long flags; + + spin_lock_irqsave(&spi_engine->lock, flags); + + spi_engine->msg = msg; + if (spi_engine_write_cmd_fifo(spi_engine)) int_enable |= SPI_ENGINE_INT_CMD_ALMOST_EMPTY; @@ -572,6 +592,8 @@ static int spi_engine_probe(struct platform_device *pdev) host->bits_per_word_mask = SPI_BPW_MASK(8); host->max_speed_hz = clk_get_rate(spi_engine->ref_clk) / 2; host->transfer_one_message = spi_engine_transfer_one_message; + host->prepare_message = spi_engine_prepare_message; + host->unprepare_message = spi_engine_unprepare_message; host->num_chipselect = 8; if (host->max_speed_hz == 0) From patchwork Fri Nov 17 20:13:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 166310 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp787907vqn; Fri, 17 Nov 2023 12:15:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFOnV63+G8vIANIutA34V+PqnqT/D2d4Bv5KzO91VFHpOKKajGlJNgSVIUKHcPiKrhpIOY0 X-Received: by 2002:a05:6a20:da95:b0:187:b7db:8682 with SMTP id iy21-20020a056a20da9500b00187b7db8682mr426701pzb.24.1700252120042; Fri, 17 Nov 2023 12:15:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700252120; cv=none; d=google.com; s=arc-20160816; b=doGNje1oBSJhfKbNWH50+wn68nxg+LDb/umYWaPct9h8ntDvgexFHymsUDw0G6A9JE JErm8vU503bNrE48AXWgtDu22ZUBgPmWmonKRb9c0N0rvTl5cn1/JPBajENZdb82gXzm 3yRwX9cPXpwR4DI+WnhTGoY+WW1serqyBOiaaJmzaBOT/d00OCP8QHcZVBeNaf/BqUQX 2LHIq5EWHxrLhNZdTtlXuVrIKFNqNW1hYHWegoeTDawJPb/mLLhQ8HY39dhIoxp8dG76 HreSeC/+D94eg20gFZ9yElD8beH7NH3iI9pYAKQMymd+nMivuII6S3is8lLEj9XR5751 Pd0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zreOIPUyiZAgHTr9pZpsQXo6OBnZGTBQCaGdmdfM/3Q=; fh=iMzJmnbboC4LJtlxOKimqPq82YSRfb3zCJyFaxC9c3g=; b=zrEEvRiW0ff+77I7CL55UvHVUdR2zf1ifxH39unLcxncvAGpPPhDacddHE5CnexSxE jL/+8RlFyiLsSchZRdmCK74X3d1s8rCgnf55Sb2pQcFMHZmwgMKtG6NVwIGP4OnkFEPW oa6i4HhSsW21HRRXuBTLrkJudgVt12lFFn1zt/Mg45oOPsH3E1ye1TEok+NRczVTHyAv bBs/n4pprQB84d0hFrm3DWzb2lZwLodWk7f389gnDtsuXmLkB/MH+lFa3+ElT+4tLJFT R8A0XRqNS8xhQq+92OHMCHN3lyCtd7EAg+/Ft3HYv+NeNkdU6nKVi1USKrgAbRzYdzSI thSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=zoLAan9f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id y1-20020aa79e01000000b006c040064180si2526360pfq.335.2023.11.17.12.15.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:15:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=zoLAan9f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id B09F58246E35; Fri, 17 Nov 2023 12:14:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346236AbjKQUO2 (ORCPT + 29 others); Fri, 17 Nov 2023 15:14:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346223AbjKQUOT (ORCPT ); Fri, 17 Nov 2023 15:14:19 -0500 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 287741727 for ; Fri, 17 Nov 2023 12:14:01 -0800 (PST) Received: by mail-oi1-x232.google.com with SMTP id 5614622812f47-3b3e13fc1f7so1496423b6e.0 for ; Fri, 17 Nov 2023 12:14:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1700252040; x=1700856840; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zreOIPUyiZAgHTr9pZpsQXo6OBnZGTBQCaGdmdfM/3Q=; b=zoLAan9fa7rF1Edza9nm2jZE0ZBA2io3ee+yQtzpom8/qDZNmf1O2inL7rvBihiqXt uSKPLQcs1pynXpmq7QkhlUa/ts1LLe1MhE5Bq1Tejlu3WRjKEy1rybpUqZHtovTjacwF C+ROjK58rYm5bH32qxjS34t59j539+SG+xgAWf2388nKTANOJ12A21PlkuBP2bAtgi2x c5dl/2ktAwHeJL1RDvKxHGZSn7SPVfBWW4P13t3SRQsZO+W6CxmFJ/jTieWDYBSJIeQo CaGDwtT4JrG724a+zDuKoWV8iV8YjsVVAQEXvu9JAJPfkWV9aT1XPSAl/wcPgYo+wMCb qMNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700252040; x=1700856840; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zreOIPUyiZAgHTr9pZpsQXo6OBnZGTBQCaGdmdfM/3Q=; b=ZcRZauHhZnv0YG7kgj1NmOlxJ8hcYkOkChCqnwmTYLOwWtXqxXyGyRcDEZJJTocvzh 8K13W7qgKVIPjmoEr5xOuIkic9C9uCVymsJFh8BJPeA/E3JLLkjNP0ggwZUL4JjGuFET NVhCapDQ750LzST/rHlA2NI3w7DL7gnmsVShZ5ffCc2G8iCixwmR9A/c8H8KkYjZO+KX U51ByHyG/2tJFrktyX4KoDPMYvHU9/lQ743qsC6ntn6Ma4+rXNZO3iwl0D42yE3D0CL2 FpswF8uhTj4eOnOM5L+d806MJtJ3jbkCtDZN9o19e9KEAO8EXBSnFy46D57NpP2rZJw1 n37Q== X-Gm-Message-State: AOJu0YyMJ6oe7OjcUqwu840bZ4xEcWjjJQDhBoAmkcnomFGZaCvxws2M L01uxjbs1kqvIOE+a/sUu39X4w== X-Received: by 2002:a05:6808:60b:b0:3b2:a9bd:c38f with SMTP id y11-20020a056808060b00b003b2a9bdc38fmr428452oih.37.1700252040479; Fri, 17 Nov 2023 12:14:00 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id l21-20020a544515000000b003a8560a9d34sm393814oil.25.2023.11.17.12.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:13:59 -0800 (PST) From: David Lechner To: linux-spi@vger.kernel.org, devicetree@vger.kernel.org Cc: David Lechner , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Lars-Peter Clausen , linux-kernel@vger.kernel.org Subject: [PATCH 11/14] spi: axi-spi-engine: remove completed_id from driver state Date: Fri, 17 Nov 2023 14:13:02 -0600 Message-ID: <20231117-axi-spi-engine-series-1-v1-11-cc59db999b87@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> References: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 17 Nov 2023 12:14:50 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782843566612591294 X-GMAIL-MSGID: 1782843566612591294 In the AXI SPI Engine driver, the completed_id field in the driver state is only used in one function and the value does not need to persist between function calls. Therefore, it can be removed from the driver state and made a local variable in the function where it is used. Signed-off-by: David Lechner --- drivers/spi/spi-axi-spi-engine.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index 210bea23f433..120001dbc4dc 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -115,7 +115,6 @@ struct spi_engine { struct spi_message *msg; struct ida sync_ida; - unsigned int completed_id; unsigned int int_enable; }; @@ -380,13 +379,14 @@ static irqreturn_t spi_engine_irq(int irq, void *devid) struct spi_engine *spi_engine = spi_controller_get_devdata(host); unsigned int disable_int = 0; unsigned int pending; + int completed_id = -1; pending = readl_relaxed(spi_engine->base + SPI_ENGINE_REG_INT_PENDING); if (pending & SPI_ENGINE_INT_SYNC) { writel_relaxed(SPI_ENGINE_INT_SYNC, spi_engine->base + SPI_ENGINE_REG_INT_PENDING); - spi_engine->completed_id = readl_relaxed( + completed_id = readl_relaxed( spi_engine->base + SPI_ENGINE_REG_SYNC_ID); } @@ -410,7 +410,7 @@ static irqreturn_t spi_engine_irq(int irq, void *devid) if (pending & SPI_ENGINE_INT_SYNC && spi_engine->msg) { struct spi_engine_message_state *st = spi_engine->msg->state; - if (spi_engine->completed_id == st->sync_id) { + if (completed_id == st->sync_id) { struct spi_message *msg = spi_engine->msg; msg->status = 0; From patchwork Fri Nov 17 20:13:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 166307 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp787642vqn; Fri, 17 Nov 2023 12:14:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUgtzuw/hYzaGG85B+gQmDyCMPwyjELE5d8+LDkt+gpFCEOdYmeaI+UbRm4JPZg74GNdtV X-Received: by 2002:a05:6a20:3281:b0:181:ed8b:4823 with SMTP id g1-20020a056a20328100b00181ed8b4823mr187766pzd.43.1700252095057; Fri, 17 Nov 2023 12:14:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700252095; cv=none; d=google.com; s=arc-20160816; b=fL09H4+h6VK1AwksW8ogQGKSIh6vuo2UAmx4XVgyaVuKocN3Dv7ubPEXkuhk6FKNj8 u/vDfKslwW2UV9pSKY98BZYvj9HzivSF7eEBeECXHN9mwcBlCKhVkTkCrX5BpvGTdT0/ C+eRryrkOD4smDidokejvcxRd1CBhhMF90LdPF1A1aA2Wt215SfO2OMPc7/Bcfgw/DSO id0pQB2VXFC6WW/Ib3mmCqHYjjDEnRguSZQ/fVFGYzmz/nzrqJxVgjQxXFeeUFxpunJs +D+twqI7cA7+Jp/uE6Ut3u7g0A6P5nbxTMjcZtDYqsvrUeHkWWpSQQewi/FTLxh06loU esRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ja9GtlZjFcJxKQ+nfaNBwXl6V3JiSfQSXjsqjsMOXR4=; fh=iMzJmnbboC4LJtlxOKimqPq82YSRfb3zCJyFaxC9c3g=; b=sLJLo3mbbVD1e7YoTapyAlj0kvwGF1TW2K7GejXRFGRu81ThLMmDbS5ob2EO1HncyG eitUnMeSJnpg7s3SyCKIMtfT4/RaHJsXQiuyIfprSp64LhrhWmoR/dWJ6iKnTdNG0NLJ PKfUkjj25Qtl1KBi1/dqFxiEDQwsrt6XxmTEsLPzSXl4kjVrZ9l1Ll18fPH/8xYE/Edj VAnwoliy2jC3piO3TNEuOV2Goo0as1EwfxFa4TXhHOgBgdz4txzt990RfwCKIxc2tQx4 FT1dbJxzSVTS/FvajmH+7PDNjKQCj4sENS8XSEXbt9AcHr4rPwMvhvUrUkTczQ5JfUOa 5/OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=qeHkjhHM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id s10-20020a056a00194a00b006c33a1be028si2667316pfk.87.2023.11.17.12.14.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:14:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=qeHkjhHM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 93A6882AAE9B; Fri, 17 Nov 2023 12:14:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346264AbjKQUOa (ORCPT + 29 others); Fri, 17 Nov 2023 15:14:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346235AbjKQUOU (ORCPT ); Fri, 17 Nov 2023 15:14:20 -0500 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E53211732 for ; Fri, 17 Nov 2023 12:14:01 -0800 (PST) Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3b56b618217so1447177b6e.0 for ; Fri, 17 Nov 2023 12:14:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1700252041; x=1700856841; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ja9GtlZjFcJxKQ+nfaNBwXl6V3JiSfQSXjsqjsMOXR4=; b=qeHkjhHMpbe+odDvMjcQssxmn9Jowjsrg73ntJ+RtcqkYbOiVvW5PZhwUrE4EK/xCh 1UDziF6/w3MfjL88xjkyZ3J5yLtUKySnM+qRrvzH759BslAaVqwVrf4bA+fLv1PlLESn ayjRjGQAZpwhXLGHM+OLdddEOL0xDC6gb6mZiGevesvubH2tm1CrFOvGgWefZHL906E2 yFEY1FhhH2QYdyiDUdspgMiwd9dixwAfbcsScBQmh1LBI6lfEC99UC8YHOdDUS1Tdh2A ktVLlKVKV4XQjg8Y17nkCpCHLXEb0NPON6TXTe/ao7zz7kq7TJm/OUnUGzkDtCuKOz6I zmqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700252041; x=1700856841; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ja9GtlZjFcJxKQ+nfaNBwXl6V3JiSfQSXjsqjsMOXR4=; b=JjhX9y79BE83wJtZLBDOJAGQqP1eI8nm262J4Jn0fgdJ6g5IrKIFycFbq0OP8OgVAX OLtS2OVXNRow4vtQI4FqdslYCE+Vk0EBAEP9X7iia7GTSjN/nq+G6OndppYq2PtCBTrV yevJgcfGyMjEcsECDWJ8UG4QF86NXfRzDPgHuy/a59eCLVLP3DyXOVRMBg76Ly3LXm7L vtnurSUChd5+AnTxZ2cBOkjYZooVL2zJ5+Qzq3tS9dcCSUEdM212Cmx65t8Rr6gJ9pCv KY+AqBMi14H5qV1n7CLdnw9vWBDCPI5G3gwl1qEXpMkscQA4Z1BlMk2AXDuJhwxRLmlJ 5mXw== X-Gm-Message-State: AOJu0Yxfntfp6ptOMFdkI+ybLk7oxBMVLquN8+taTseWJ6yjwXoJ45KZ UgcWB04NovuZpnsEyFzm59h5jg== X-Received: by 2002:a05:6808:1315:b0:3b5:6462:3191 with SMTP id y21-20020a056808131500b003b564623191mr555089oiv.48.1700252041296; Fri, 17 Nov 2023 12:14:01 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id l21-20020a544515000000b003a8560a9d34sm393814oil.25.2023.11.17.12.14.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:14:00 -0800 (PST) From: David Lechner To: linux-spi@vger.kernel.org, devicetree@vger.kernel.org Cc: David Lechner , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Lars-Peter Clausen , linux-kernel@vger.kernel.org Subject: [PATCH 12/14] spi: axi-spi-engine: remove struct spi_engine::msg Date: Fri, 17 Nov 2023 14:13:03 -0600 Message-ID: <20231117-axi-spi-engine-series-1-v1-12-cc59db999b87@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> References: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 12:14:36 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782843541067271968 X-GMAIL-MSGID: 1782843541067271968 In the AXI SPI Engine driver, the struct spi_engine::msg member was used to keep track of the current message being processed. The SPI core is already keeping track of this, so we don't need to duplicate the effort. In most cases, we already have a pointer to the current message, so we can pass it directly to the functions that need it. In the one case where we don't have a pointer to the current message, we can get it from struct spi_controller::cur_msg. Signed-off-by: David Lechner --- drivers/spi/spi-axi-spi-engine.c | 60 +++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index 120001dbc4dc..c39f478f34a7 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -112,8 +112,6 @@ struct spi_engine { spinlock_t lock; void __iomem *base; - - struct spi_message *msg; struct ida sync_ida; unsigned int int_enable; @@ -252,10 +250,9 @@ static int spi_engine_compile_message(struct spi_engine *spi_engine, return 0; } -static void spi_engine_xfer_next(struct spi_engine *spi_engine, +static void spi_engine_xfer_next(struct spi_message *msg, struct spi_transfer **_xfer) { - struct spi_message *msg = spi_engine->msg; struct spi_transfer *xfer = *_xfer; if (!xfer) { @@ -270,13 +267,13 @@ static void spi_engine_xfer_next(struct spi_engine *spi_engine, *_xfer = xfer; } -static void spi_engine_tx_next(struct spi_engine *spi_engine) +static void spi_engine_tx_next(struct spi_message *msg) { - struct spi_engine_message_state *st = spi_engine->msg->state; + struct spi_engine_message_state *st = msg->state; struct spi_transfer *xfer = st->tx_xfer; do { - spi_engine_xfer_next(spi_engine, &xfer); + spi_engine_xfer_next(msg, &xfer); } while (xfer && !xfer->tx_buf); st->tx_xfer = xfer; @@ -288,13 +285,13 @@ static void spi_engine_tx_next(struct spi_engine *spi_engine) } } -static void spi_engine_rx_next(struct spi_engine *spi_engine) +static void spi_engine_rx_next(struct spi_message *msg) { - struct spi_engine_message_state *st = spi_engine->msg->state; + struct spi_engine_message_state *st = msg->state; struct spi_transfer *xfer = st->rx_xfer; do { - spi_engine_xfer_next(spi_engine, &xfer); + spi_engine_xfer_next(msg, &xfer); } while (xfer && !xfer->rx_buf); st->rx_xfer = xfer; @@ -306,10 +303,11 @@ static void spi_engine_rx_next(struct spi_engine *spi_engine) } } -static bool spi_engine_write_cmd_fifo(struct spi_engine *spi_engine) +static bool spi_engine_write_cmd_fifo(struct spi_engine *spi_engine, + struct spi_message *msg) { void __iomem *addr = spi_engine->base + SPI_ENGINE_REG_CMD_FIFO; - struct spi_engine_message_state *st = spi_engine->msg->state; + struct spi_engine_message_state *st = msg->state; unsigned int n, m, i; const uint16_t *buf; @@ -327,10 +325,11 @@ static bool spi_engine_write_cmd_fifo(struct spi_engine *spi_engine) return st->cmd_length != 0; } -static bool spi_engine_write_tx_fifo(struct spi_engine *spi_engine) +static bool spi_engine_write_tx_fifo(struct spi_engine *spi_engine, + struct spi_message *msg) { void __iomem *addr = spi_engine->base + SPI_ENGINE_REG_SDO_DATA_FIFO; - struct spi_engine_message_state *st = spi_engine->msg->state; + struct spi_engine_message_state *st = msg->state; unsigned int n, m, i; const uint8_t *buf; @@ -344,16 +343,17 @@ static bool spi_engine_write_tx_fifo(struct spi_engine *spi_engine) st->tx_length -= m; n -= m; if (st->tx_length == 0) - spi_engine_tx_next(spi_engine); + spi_engine_tx_next(msg); } return st->tx_length != 0; } -static bool spi_engine_read_rx_fifo(struct spi_engine *spi_engine) +static bool spi_engine_read_rx_fifo(struct spi_engine *spi_engine, + struct spi_message *msg) { void __iomem *addr = spi_engine->base + SPI_ENGINE_REG_SDI_DATA_FIFO; - struct spi_engine_message_state *st = spi_engine->msg->state; + struct spi_engine_message_state *st = msg->state; unsigned int n, m, i; uint8_t *buf; @@ -367,7 +367,7 @@ static bool spi_engine_read_rx_fifo(struct spi_engine *spi_engine) st->rx_length -= m; n -= m; if (st->rx_length == 0) - spi_engine_rx_next(spi_engine); + spi_engine_rx_next(msg); } return st->rx_length != 0; @@ -376,6 +376,7 @@ static bool spi_engine_read_rx_fifo(struct spi_engine *spi_engine) static irqreturn_t spi_engine_irq(int irq, void *devid) { struct spi_controller *host = devid; + struct spi_message *msg = host->cur_msg; struct spi_engine *spi_engine = spi_controller_get_devdata(host); unsigned int disable_int = 0; unsigned int pending; @@ -393,29 +394,26 @@ static irqreturn_t spi_engine_irq(int irq, void *devid) spin_lock(&spi_engine->lock); if (pending & SPI_ENGINE_INT_CMD_ALMOST_EMPTY) { - if (!spi_engine_write_cmd_fifo(spi_engine)) + if (!spi_engine_write_cmd_fifo(spi_engine, msg)) disable_int |= SPI_ENGINE_INT_CMD_ALMOST_EMPTY; } if (pending & SPI_ENGINE_INT_SDO_ALMOST_EMPTY) { - if (!spi_engine_write_tx_fifo(spi_engine)) + if (!spi_engine_write_tx_fifo(spi_engine, msg)) disable_int |= SPI_ENGINE_INT_SDO_ALMOST_EMPTY; } if (pending & (SPI_ENGINE_INT_SDI_ALMOST_FULL | SPI_ENGINE_INT_SYNC)) { - if (!spi_engine_read_rx_fifo(spi_engine)) + if (!spi_engine_read_rx_fifo(spi_engine, msg)) disable_int |= SPI_ENGINE_INT_SDI_ALMOST_FULL; } - if (pending & SPI_ENGINE_INT_SYNC && spi_engine->msg) { - struct spi_engine_message_state *st = spi_engine->msg->state; + if (pending & SPI_ENGINE_INT_SYNC && msg) { + struct spi_engine_message_state *st = msg->state; if (completed_id == st->sync_id) { - struct spi_message *msg = spi_engine->msg; - msg->status = 0; msg->actual_length = msg->frame_length; - spi_engine->msg = NULL; spi_finalize_current_message(host); disable_int |= SPI_ENGINE_INT_SYNC; } @@ -499,16 +497,14 @@ static int spi_engine_transfer_one_message(struct spi_controller *host, spin_lock_irqsave(&spi_engine->lock, flags); - spi_engine->msg = msg; - - if (spi_engine_write_cmd_fifo(spi_engine)) + if (spi_engine_write_cmd_fifo(spi_engine, msg)) int_enable |= SPI_ENGINE_INT_CMD_ALMOST_EMPTY; - spi_engine_tx_next(spi_engine); - if (spi_engine_write_tx_fifo(spi_engine)) + spi_engine_tx_next(msg); + if (spi_engine_write_tx_fifo(spi_engine, msg)) int_enable |= SPI_ENGINE_INT_SDO_ALMOST_EMPTY; - spi_engine_rx_next(spi_engine); + spi_engine_rx_next(msg); if (st->rx_length != 0) int_enable |= SPI_ENGINE_INT_SDI_ALMOST_FULL; From patchwork Fri Nov 17 20:13:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 166308 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp787706vqn; Fri, 17 Nov 2023 12:15:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IEGvQPoxebFa+Atp2ldZtmUYJc/vIctCTlQ9yWGi4kNjQu7TfoF3m0GIak0kuJdVGSJhRYk X-Received: by 2002:a17:902:eb4b:b0:1ca:362b:166c with SMTP id i11-20020a170902eb4b00b001ca362b166cmr679228pli.61.1700252100699; Fri, 17 Nov 2023 12:15:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700252100; cv=none; d=google.com; s=arc-20160816; b=VQhGuxfz0vU83DioyyToCbYGIDsbnB+WVuE66c985wcc+oT+pFqejhdpvW4K8/WhnK W/rmKzgU8c4SKN9l5ZC8XUM+nSyjByK45kGk1l/wHHTkFzANq2Yg+L4Vbe0J02BgqNGS hBeFn0/8Z15f4XXRkMiOp6wOksc+eQzYWj5bh55p7V3eVJzuG62e4lxglx8p3L4Po36M lxSNeoMSEyvGzXkKCC20Ag6CVXmxn1IN4oigAS24VPDb8Glsz9/QzlBqfMHW4a9XyE9y /ZiBgM2ZMVu45BdzvYywhx7PxCKgAnTAamn5/hiBXGNgqavogZQ+aOvOGFMUbipGz7L4 OFvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6P+/RJb/cpUDSZO9aZmvZcYWX64h3DCpi271jxLHolk=; fh=iMzJmnbboC4LJtlxOKimqPq82YSRfb3zCJyFaxC9c3g=; b=iMqN7YbdBMqXCSDf2p47saB+GoFX1lOx2J3e0dpozFBAdR8FnzUYKjxNY4HK5SQCuD tDa9gf/JmzEX05fTftJqAvOfU2HUSRFK/idLvNqAJZ4yKjvkPOdHBL/d6H2nVwo3FMQ7 bsHVwi5m7jqgxT5HvDdprUudxhDrL4KAYOTXFYfQIUnCzav2loIW9nSxj5E2tFyCgL/z iic6vX/PzTBypj1Kg1hQ3VaC8dECKE+upgOTpzCSI4jQB+88ZYlG2ccbG1kCXwQoudHB vbeThLrrF1W6lp0wFKna2GAzUKTD0kOr4+Jx7io1pB4iomB/UfdXg+iKSKty9hkk+L27 FdzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=mJuBTJQy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id m7-20020a170902db0700b001cc4a373875si2606014plx.459.2023.11.17.12.14.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:15:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=mJuBTJQy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7DFBD82AB469; Fri, 17 Nov 2023 12:14:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346269AbjKQUOd (ORCPT + 29 others); Fri, 17 Nov 2023 15:14:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346184AbjKQUOU (ORCPT ); Fri, 17 Nov 2023 15:14:20 -0500 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B389173B for ; Fri, 17 Nov 2023 12:14:02 -0800 (PST) Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3b2e44c7941so1438968b6e.2 for ; Fri, 17 Nov 2023 12:14:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1700252042; x=1700856842; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6P+/RJb/cpUDSZO9aZmvZcYWX64h3DCpi271jxLHolk=; b=mJuBTJQyYIMZXnaCfua6kd7F4fee5sTKKD/NSeXd0DEH8JMEXpWpvWeYM+UxSvPdhL igr9ZTk3aWYW4EKOr4jJmq74uKxBn/zMM8srLf/HJz3ldK9b2vekNqWIZJgMt+3LbZh7 DkFozzyjukJtnZ0lw9w+YW1yas8rIYPyhPlHRujUhO4Y/o0k5GGMC260bA1fLKq6I+iD dXG9qfwYI5ov35igQhrlHcO7GoiKNV0otvgNcaasvQr7hk26GpRfztiet6KrD1Xm9M7s /emAhjdEVL2TWm0gLBpDsWQwpu3bO7B9kpYAkkIAMbb8cEkPX+Jc2XwiYRqqH5gULECB 2A7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700252042; x=1700856842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6P+/RJb/cpUDSZO9aZmvZcYWX64h3DCpi271jxLHolk=; b=c2cyiDK3FrwU/CxZAUG+ek91o3YE5CogrRsO2T7gijW9zZgyxLLFl7jXhd4QPRjka0 zNzUeBo/kOfjnlZZJTaqI5W7qAVp0cZPak41oO/H797YonqUsDg+iPWCtziqd3CE38iQ hD5TLl+EIlNVc2BanP8Xm9sNK/JARdGdRqWCHAJE8ROQC46P32Bk/4S4mlTP0CK2Sv8X PNOcG+/u6mxJr1M6Xq4qsUF4sL8vjxEjh8c1IHZ6+YQBYnvGMyPjMAiOudeAzTfgaxvA HUNkDQ3PcoqDpM+61p9Ehz5Wymf1+uAGyZUbqJH9sfgNBYqHd0VPDnDQpjtwsgRyRNbv QaXw== X-Gm-Message-State: AOJu0Yz7HldkT96Uw1DOqbF67WnB8CqKVGe87TzB3OYtpAC6IJFUVY5J kn+MCxQrGpSfncMzpP9HumkEvw== X-Received: by 2002:a05:6808:f07:b0:3b2:d8c8:7bfa with SMTP id m7-20020a0568080f0700b003b2d8c87bfamr555396oiw.8.1700252042081; Fri, 17 Nov 2023 12:14:02 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id l21-20020a544515000000b003a8560a9d34sm393814oil.25.2023.11.17.12.14.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:14:01 -0800 (PST) From: David Lechner To: linux-spi@vger.kernel.org, devicetree@vger.kernel.org Cc: David Lechner , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Lars-Peter Clausen , linux-kernel@vger.kernel.org Subject: [PATCH 13/14] spi: axi-spi-engine: add support for cs_off Date: Fri, 17 Nov 2023 14:13:04 -0600 Message-ID: <20231117-axi-spi-engine-series-1-v1-13-cc59db999b87@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> References: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 12:14:42 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782843547124006639 X-GMAIL-MSGID: 1782843547124006639 This adds support for the spi_transfer::cs_off flag to the AXI SPI Engine driver. The logic is copied from the generic spi_transfer_one_message() in spi.c. Signed-off-by: David Lechner --- drivers/spi/spi-axi-spi-engine.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index c39f478f34a7..1c60e6486ee2 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -216,7 +216,7 @@ static int spi_engine_compile_message(struct spi_engine *spi_engine, struct spi_device *spi = msg->spi; struct spi_transfer *xfer; int clk_div, new_clk_div; - bool cs_change = true; + bool keep_cs = false; clk_div = -1; @@ -224,6 +224,9 @@ static int spi_engine_compile_message(struct spi_engine *spi_engine, SPI_ENGINE_CMD_WRITE(SPI_ENGINE_CMD_REG_CONFIG, spi_engine_get_config(spi))); + xfer = list_first_entry(&msg->transfers, struct spi_transfer, transfer_list); + spi_engine_gen_cs(p, dry, spi, !xfer->cs_off); + list_for_each_entry(xfer, &msg->transfers, transfer_list) { new_clk_div = spi_engine_get_clk_div(spi_engine, spi, xfer); if (new_clk_div != clk_div) { @@ -233,20 +236,28 @@ static int spi_engine_compile_message(struct spi_engine *spi_engine, clk_div)); } - if (cs_change) - spi_engine_gen_cs(p, dry, spi, true); - spi_engine_gen_xfer(p, dry, xfer); spi_engine_gen_sleep(p, dry, spi_engine, clk_div, xfer); - cs_change = xfer->cs_change; - if (list_is_last(&xfer->transfer_list, &msg->transfers)) - cs_change = !cs_change; - - if (cs_change) - spi_engine_gen_cs(p, dry, spi, false); + if (xfer->cs_change) { + if (list_is_last(&xfer->transfer_list, &msg->transfers)) { + keep_cs = true; + } else { + if (!xfer->cs_off) + spi_engine_gen_cs(p, dry, spi, false); + + if (!list_next_entry(xfer, transfer_list)->cs_off) + spi_engine_gen_cs(p, dry, spi, true); + } + } else if (!list_is_last(&xfer->transfer_list, &msg->transfers) && + xfer->cs_off != list_next_entry(xfer, transfer_list)->cs_off) { + spi_engine_gen_cs(p, dry, spi, xfer->cs_off); + } } + if (!keep_cs) + spi_engine_gen_cs(p, dry, spi, false); + return 0; } From patchwork Fri Nov 17 20:13:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 166309 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp787727vqn; Fri, 17 Nov 2023 12:15:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IEClvwn0VWzChQEyMV1wgCQi9blzoTIIsWbXDQv/28liDOUDMQuM4nWRl286tHI3ekakzDL X-Received: by 2002:a17:902:f7d6:b0:1ce:5e38:74aa with SMTP id h22-20020a170902f7d600b001ce5e3874aamr149676plw.33.1700252102969; Fri, 17 Nov 2023 12:15:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700252102; cv=none; d=google.com; s=arc-20160816; b=i5VKTEgnu7+o9ILFitWtJfmkx8VijgliWqwFcxAtK8UrGPx82gXlcTUM48AtykTes8 xw9YqyFRgt62KfLtvkbCDiQDIafRbEvGA/lX8aysKnH9xeQ5S056evODjQLynkb7lkx7 eoW1ccg1eDayhHvLruGafLBy08feG3SUfNOlZT2Wf8ShvWEeBEoMqrYMJRspn0oYyM92 q50E+g+as6REkZJbjg6AvZJfhN4kGOWFVQ+c8KV2BE4wlhQnC/1vAJno2hO3LrDkiToE Qu7ZcjpXXXofJhmbWjlhsfRTPSiNeEhBBcoy9YKPtfusCioY/21/owE5doCa48u3HbeQ sY2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PH/rzTgmg6EPZdKGbbueBGhoeiFd6EbUxFAdwFmnGz0=; fh=iMzJmnbboC4LJtlxOKimqPq82YSRfb3zCJyFaxC9c3g=; b=WGqGrkmePjhUK9F2ZxcIwQHDMGbJEvVJkguVfNlZOp+2bcDfAEsQnnaLa+oIRf4Ac0 08z3IsYdUE7gLhJh34EQusOl59M2BXAgO+/P/Y6vnvuquHdJRixCFqmjz9I2ssaAhhn3 HkN5KdEfUXK+9+xsXdUucR6SwI09o7KYww2XnJpqesq66jDo4cabAUHJiYMZKpd4sfJz gpzOP39VwvYySZ0Od6CrqwLbX1jVCzV2hi161Fy3CXMG8RjbHFQ5+SlvqlI+kEKyqLeT evlc+175379g0hmVt9eOPE/6XLJoMpusJR5OYgSlTSgIi32CyNA/DyX3cYCCBsrCMS0N bZSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=QoyamuIG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id t4-20020a17090340c400b001cc3e45ac2esi2527522pld.19.2023.11.17.12.14.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:15:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=QoyamuIG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C28B482AB475; Fri, 17 Nov 2023 12:14:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346273AbjKQUOg (ORCPT + 29 others); Fri, 17 Nov 2023 15:14:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235757AbjKQUOV (ORCPT ); Fri, 17 Nov 2023 15:14:21 -0500 Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A10181987 for ; Fri, 17 Nov 2023 12:14:03 -0800 (PST) Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-3b3f938331fso1145617b6e.1 for ; Fri, 17 Nov 2023 12:14:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1700252043; x=1700856843; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PH/rzTgmg6EPZdKGbbueBGhoeiFd6EbUxFAdwFmnGz0=; b=QoyamuIGyvaCFAItIzBvcz/WC2NNgCFhQq9ulXDGjENTXxp5EDmYMcoJWQGIkKlEVX rIi+lyAMhebdHjrXs41naJGKzHRLuFqrCSVxwPKY4LxYBvz05rdnXO8DmENJam6SByjw JUyoL0BA2WBd0MbI5QhTuAo6/1FUOBpyBpgrz9RO876ycQplhlGj3LOieJyZx9kxvqB8 n8xwsrgNtx2cTSxOLP0BHdDemNIqYXtCQMK9TRPhjbAlirYftngbVrtKwpxtmXdZkx8m UkH7bBck+ypFFj/hITwss8XBLxXwGFJKMMHwDeiHSWhtPG9ou4ZAS25bC1O2IPJUEEaM 8GvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700252043; x=1700856843; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PH/rzTgmg6EPZdKGbbueBGhoeiFd6EbUxFAdwFmnGz0=; b=LGOLfjSmUafwLOwQF9M9cDlPIGQx+Ws85gj9VKDaT4RWb7cnF3q794C4tJ7NkERRMX i93zePGCQKaefjMvAihJi7SPmTBqbaHDT+y48opOYZy/cAzJ54m1UB8BJVRJEFydEGdf hSCVijfhOdCW3BY5gkXxlzi+DwvuOyHdv0ZTs8KQ8EBmMXWMq5QT6/gOS4zLt6FNmga5 GzQpNaVvKiNHUKM8MBvwmiGPEilHh/37LgKceMAJGPFNa5E8x0ZBvzfXYT0aQN1to8vl uzmoF7AqoY5fEn6jUCFYAPTbAQ17nWX7IYe/1qhhrH/GgOrzUA46YgmEjqMV9oXrAs96 Wnsw== X-Gm-Message-State: AOJu0Yw5WhMQgPkkoeU/FZjGQeE7ZOERnf4BzmwIiEarGJnmKR0T2G5x humhiU07KvadHHkZjyvzjo/3sg== X-Received: by 2002:a05:6808:d1:b0:3b2:e4b7:2af2 with SMTP id t17-20020a05680800d100b003b2e4b72af2mr3093122oic.6.1700252042902; Fri, 17 Nov 2023 12:14:02 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id l21-20020a544515000000b003a8560a9d34sm393814oil.25.2023.11.17.12.14.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:14:02 -0800 (PST) From: David Lechner To: linux-spi@vger.kernel.org, devicetree@vger.kernel.org Cc: David Lechner , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Lars-Peter Clausen , linux-kernel@vger.kernel.org Subject: [PATCH 14/14] spi: axi-spi-engine: add support for any word size Date: Fri, 17 Nov 2023 14:13:05 -0600 Message-ID: <20231117-axi-spi-engine-series-1-v1-14-cc59db999b87@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> References: <20231117-axi-spi-engine-series-1-v1-0-cc59db999b87@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 12:14:47 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782843549138541322 X-GMAIL-MSGID: 1782843549138541322 The AXI SPI Engine IP supports any word size from 1 to 32 bits. This adds support for this by setting the bits_per_word_mask and emitting the appropriate instruction to the SPI Engine each time a transfer requires a new word size. The functions that transfer tx/rx buffers from/to the SPI Engine registers (spi_engine_write_{tx,rx}_fifo()) as well as the function that creates the transfer instruction (spi_engine_gen_xfer()) also have to be modified to take into account the word size since xfer->len is the size of the buffers in bytes rather than words. Signed-off-by: David Lechner --- drivers/spi/spi-axi-spi-engine.c | 84 ++++++++++++++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 16 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index 1c60e6486ee2..cbca783830ea 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -53,6 +53,7 @@ #define SPI_ENGINE_CMD_REG_CLK_DIV 0x0 #define SPI_ENGINE_CMD_REG_CONFIG 0x1 +#define SPI_ENGINE_CMD_REG_XFER_BITS 0x2 #define SPI_ENGINE_MISC_SYNC 0x0 #define SPI_ENGINE_MISC_SLEEP 0x1 @@ -157,7 +158,14 @@ static unsigned int spi_engine_get_clk_div(struct spi_engine *spi_engine, static void spi_engine_gen_xfer(struct spi_engine_program *p, bool dry, struct spi_transfer *xfer) { - unsigned int len = xfer->len; + unsigned int len; + + if (xfer->bits_per_word <= 8) + len = xfer->len; + else if (xfer->bits_per_word <= 16) + len = xfer->len / 2; + else + len = xfer->len / 4; while (len) { unsigned int n = min(len, 256U); @@ -217,6 +225,7 @@ static int spi_engine_compile_message(struct spi_engine *spi_engine, struct spi_transfer *xfer; int clk_div, new_clk_div; bool keep_cs = false; + u8 bits_per_word = 0; clk_div = -1; @@ -236,6 +245,13 @@ static int spi_engine_compile_message(struct spi_engine *spi_engine, clk_div)); } + if (bits_per_word != xfer->bits_per_word) { + bits_per_word = xfer->bits_per_word; + spi_engine_program_add_cmd(p, dry, + SPI_ENGINE_CMD_WRITE(SPI_ENGINE_CMD_REG_XFER_BITS, + bits_per_word)); + } + spi_engine_gen_xfer(p, dry, xfer); spi_engine_gen_sleep(p, dry, spi_engine, clk_div, xfer); @@ -342,16 +358,34 @@ static bool spi_engine_write_tx_fifo(struct spi_engine *spi_engine, void __iomem *addr = spi_engine->base + SPI_ENGINE_REG_SDO_DATA_FIFO; struct spi_engine_message_state *st = msg->state; unsigned int n, m, i; - const uint8_t *buf; n = readl_relaxed(spi_engine->base + SPI_ENGINE_REG_SDO_FIFO_ROOM); while (n && st->tx_length) { - m = min(n, st->tx_length); - buf = st->tx_buf; - for (i = 0; i < m; i++) - writel_relaxed(buf[i], addr); - st->tx_buf += m; - st->tx_length -= m; + if (st->tx_xfer->bits_per_word <= 8) { + const u8 *buf = st->tx_buf; + + m = min(n, st->tx_length); + for (i = 0; i < m; i++) + writel_relaxed(buf[i], addr); + st->tx_buf += m; + st->tx_length -= m; + } else if (st->tx_xfer->bits_per_word <= 16) { + const u16 *buf = (const u16 *)st->tx_buf; + + m = min(n, st->tx_length / 2); + for (i = 0; i < m; i++) + writel_relaxed(buf[i], addr); + st->tx_buf += m * 2; + st->tx_length -= m * 2; + } else { + const u32 *buf = (const u32 *)st->tx_buf; + + m = min(n, st->tx_length / 4); + for (i = 0; i < m; i++) + writel_relaxed(buf[i], addr); + st->tx_buf += m * 4; + st->tx_length -= m * 4; + } n -= m; if (st->tx_length == 0) spi_engine_tx_next(msg); @@ -366,16 +400,34 @@ static bool spi_engine_read_rx_fifo(struct spi_engine *spi_engine, void __iomem *addr = spi_engine->base + SPI_ENGINE_REG_SDI_DATA_FIFO; struct spi_engine_message_state *st = msg->state; unsigned int n, m, i; - uint8_t *buf; n = readl_relaxed(spi_engine->base + SPI_ENGINE_REG_SDI_FIFO_LEVEL); while (n && st->rx_length) { - m = min(n, st->rx_length); - buf = st->rx_buf; - for (i = 0; i < m; i++) - buf[i] = readl_relaxed(addr); - st->rx_buf += m; - st->rx_length -= m; + if (st->rx_xfer->bits_per_word <= 8) { + u8 *buf = st->rx_buf; + + m = min(n, st->rx_length); + for (i = 0; i < m; i++) + buf[i] = readl_relaxed(addr); + st->rx_buf += m; + st->rx_length -= m; + } else if (st->rx_xfer->bits_per_word <= 16) { + u16 *buf = (u16 *)st->rx_buf; + + m = min(n, st->rx_length / 2); + for (i = 0; i < m; i++) + buf[i] = readl_relaxed(addr); + st->rx_buf += m * 2; + st->rx_length -= m * 2; + } else { + u32 *buf = (u32 *)st->rx_buf; + + m = min(n, st->rx_length / 4); + for (i = 0; i < m; i++) + buf[i] = readl_relaxed(addr); + st->rx_buf += m * 4; + st->rx_length -= m * 4; + } n -= m; if (st->rx_length == 0) spi_engine_rx_next(msg); @@ -596,7 +648,7 @@ static int spi_engine_probe(struct platform_device *pdev) host->dev.of_node = pdev->dev.of_node; host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_3WIRE; - host->bits_per_word_mask = SPI_BPW_MASK(8); + host->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32); host->max_speed_hz = clk_get_rate(spi_engine->ref_clk) / 2; host->transfer_one_message = spi_engine_transfer_one_message; host->prepare_message = spi_engine_prepare_message;