Message ID | 20230505074701.1030980-1-bigunclemax@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp232407vqo; Fri, 5 May 2023 01:16:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Dve8Vh3ourssUR3mtwGT9RCIBy1irCfuqHF13sgMxWu2jIIYQ/yOrTGUvxR0MEqaKZp4x X-Received: by 2002:a05:6a00:13a4:b0:643:90ae:2068 with SMTP id t36-20020a056a0013a400b0064390ae2068mr1651201pfg.6.1683274559931; Fri, 05 May 2023 01:15:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683274559; cv=none; d=google.com; s=arc-20160816; b=kC0SM6k1vV72q7tD06jeiBO4p+UTrhNQuTWIqOY5mMCg0Nu+Q+yjhA3PoFYkipK6YX cbFaJ+7b7MZvBtGxXDaI7H5OG59vc2uFClmVqUwJKTmAlQdVt19J6AX79D8inZpmlYvJ 1su8wGs9cuKGccO8zzXV4O4pokuLUhWc5Mv4kCVo1lqs8hXfvPVm4SXPugtvmzHsKjxR lNoGR3/SRlJJAUM4s2tsXNyc6pmuT5ucGqeU9UYECQ7Pvstw1RiustWzniJ87Hcosp3c 65SwWTDeKhi4a9eD/mKZ/DZ8Jtdcz2DE6xlnLDHAQTxCn3AQtyB6AC5Yx6I2G/ggff0G 3aTQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=GNV1oA5bifbHrVzVGDwGABZ92MbgAi9sOiOOiEw4RrY=; b=pcv4QmoluR3qzorwqUgpK+l1y+4GXPebbcKjZlNNYnTY/Ofhx6J6I4+UVpc+J/6rdi WBdXdKKMxAekbXXpQHtTsdhCbf2ue1wudQgWJJ+DzvBr5kphYT8eLt8hnfLpPGCNFdbI 0+aWid2D3d7m9Ruoeuc1+vlP4IUXRALCUbFb4wKneBg7hKTI1/7SgkmGkfC0EeKg8Viu Aq8/EcczZKENZlp3NjjFQJAcvHQnbFyjFY00lg6R1FBkXPPiAi1/tWNx3QOTEBYwVCV2 iRs7GYx/fqgQLKq6NsMvWDZJLK/QJRCH69zGFc46A0AGoGtqUgm01qtgX5vCtfaQPRU2 QKww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=lkg+LH04; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m29-20020a63711d000000b0052c88812440si1414726pgc.508.2023.05.05.01.15.44; Fri, 05 May 2023 01:15:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=lkg+LH04; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231379AbjEEHrY (ORCPT <rfc822;b08248@gmail.com> + 99 others); Fri, 5 May 2023 03:47:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229807AbjEEHrW (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 5 May 2023 03:47:22 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3121F150E8; Fri, 5 May 2023 00:47:21 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f1958d3a53so14525795e9.0; Fri, 05 May 2023 00:47:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683272839; x=1685864839; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=GNV1oA5bifbHrVzVGDwGABZ92MbgAi9sOiOOiEw4RrY=; b=lkg+LH04TwCQLhmLbRKDg/dBJWQ7XdfptJmigPx/HjYBXY0JRepARb5d/8OAgeih30 3s4tXEUw9Eyzzf6rPHJisFmt66eFJtGTRs0+k7bGdujqpSbJM4E5IQ7BCKaxvynwbRGA mJV3MzMugU0NIXgPwW4Ydux0lvBTjIwHjJw13UBxeyldqBJyTDc8XMZydN5t31/e1Ql/ Gz32EkDcx+AeFOVED0YbBJ8E0NpUnnrwX5MhiJJ1kkFyR7H4D8l+1EL8ZOeYFjy5m2zh rJr/4WDj4rDXo6MBKHzKd+T57LDftmdNnEZgDlp6IQW/vY/Ec/nq7wWhUtLHN9iY7Ppq 7HEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683272839; x=1685864839; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GNV1oA5bifbHrVzVGDwGABZ92MbgAi9sOiOOiEw4RrY=; b=fs0RjwE2Uro00xD/fuSxsHN3z7qiJOlMXC7xIZYEp/Vkq8k8lQHbegNYQg+lYPR3qC V7G0iUyNLmomqUaavWy8tBs0i6yqQOuX4BZqY6VYKzR2ejRcxOXaOUfTAhslUTSQlyFr J4cIcA8AlnofjiEXd1PtAPSaRG4AQNW2gZd8jZeyZGx1fpAR3fo66qvWBzmORTrKLLK7 HR0LSuu+7MY66TzDm2LisSsxDZZW8eAp+pVEn3cFLppJOTX1+HJc3kFQufghYEj8OdPO XBoKIZlrgXQHNfvYIz2RqZ/YVMkd7SHKiMQ6LTpWAXdbWxCUnmHzSa2lnEpZGcd1O51n Hekg== X-Gm-Message-State: AC+VfDx3N/faWZsTH24Z7sbz2skzYK87wjmgfaAQalf/Z5XbyOLSfqME KQCMTjjJUgDtw+hU2vcN4ks= X-Received: by 2002:a1c:4b0a:0:b0:3ee:96f0:ea31 with SMTP id y10-20020a1c4b0a000000b003ee96f0ea31mr375663wma.18.1683272839493; Fri, 05 May 2023 00:47:19 -0700 (PDT) Received: from localhost.localdomain ([176.221.215.212]) by smtp.gmail.com with ESMTPSA id j8-20020a5d5648000000b003062cdc6ac5sm1482198wrw.89.2023.05.05.00.47.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 00:47:19 -0700 (PDT) From: Maksim Kiselev <bigunclemax@gmail.com> To: robh+dt@kernel.org Cc: Maksim Kiselev <bigunclemax@gmail.com>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor@kernel.org>, Chen-Yu Tsai <wens@csie.org>, Jernej Skrabec <jernej.skrabec@gmail.com>, Samuel Holland <samuel@sholland.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Cristian Ciocaltea <cristian.ciocaltea@collabora.com>, Andre Przywara <andre.przywara@arm.com>, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] riscv: dts: allwinner: d1: Add SPI0 controller node Date: Fri, 5 May 2023 10:46:51 +0300 Message-Id: <20230505074701.1030980-1-bigunclemax@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765041304867331258?= X-GMAIL-MSGID: =?utf-8?q?1765041304867331258?= |
Series |
riscv: dts: allwinner: d1: Add SPI0 controller node
|
|
Commit Message
Maxim Kiselev
May 5, 2023, 7:46 a.m. UTC
Some boards form the MangoPi family (MQ\MQ-Dual\MQ-R) may have
an optional SPI flash that connects to the SPI0 controller.
This controller is already supported by sun8i-h3-spi driver.
So let's add its DT node.
Signed-off-by: Maksim Kiselev <bigunclemax@gmail.com>
---
.../boot/dts/allwinner/sunxi-d1s-t113.dtsi | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
Comments
On Fri, 5 May 2023 10:46:51 +0300 Maksim Kiselev <bigunclemax@gmail.com> wrote: Hi Maksim, thanks for sending a patch! > Some boards form the MangoPi family (MQ\MQ-Dual\MQ-R) may have > an optional SPI flash that connects to the SPI0 controller. > This controller is already supported by sun8i-h3-spi driver. > So let's add its DT node. Interesting, I see SPI mentioned in the D1 platform support cover letter, but indeed there is no DT node. From a quick glance at the manuals, it looks like there are not quite the same, though: the D1/R528/T113s mentions a SPI_SAMP_DL register @0x28, whereas the older IP has a SPI_CCR register @0x24 - which is not mentioned in the newer manuals. The driver relies on that clock control register, so it wouldn't really work reliably, if that register is not there. It *might* work by pure chance because of a particular setup or clock rate, though. Samuel, did you investigate SPI support on the D1/T113s? I see it marked as "WIP" in the Wiki status page, so where there any patches floating around? Regardless of that, one comment that would apply anyway: > Signed-off-by: Maksim Kiselev <bigunclemax@gmail.com> > --- > .../boot/dts/allwinner/sunxi-d1s-t113.dtsi | 20 +++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi b/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi > index 922e8e0e2c09..d2de211d67d7 100644 > --- a/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi > +++ b/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi > @@ -108,6 +108,12 @@ rmii_pe_pins: rmii-pe-pins { > function = "emac"; > }; > > + /omit-if-no-ref/ > + spi0_pins: spi0-pins { > + pins = "PC2", "PC3", "PC4", "PC5"; > + function = "spi0"; > + }; > + > /omit-if-no-ref/ > uart1_pg6_pins: uart1-pg6-pins { > pins = "PG6", "PG7"; > @@ -447,6 +453,20 @@ mmc2: mmc@4022000 { > #size-cells = <0>; > }; > > + spi0: spi@4025000 { > + compatible = "allwinner,sun8i-h3-spi"; Even if it would be compatible, we need to use a more specific compatible first, with the H3 one as a fallback: compatible = "allwinner,sun20i-d1-spi", "allwinner,sun8i-h3-spi"; But that would require that the H3 is a strict subset of the D1 SPI IP. Cheers, Andre > + reg = <0x04025000 0x300>; > + interrupts = <SOC_PERIPHERAL_IRQ(15) IRQ_TYPE_LEVEL_HIGH>; > + clocks = <&ccu CLK_BUS_SPI0>, <&ccu CLK_SPI0>; > + clock-names = "ahb", "mod"; > + dmas = <&dma 22>, <&dma 22>; > + dma-names = "rx", "tx"; > + resets = <&ccu RST_BUS_SPI0>; > + status = "disabled"; > + #address-cells = <1>; > + #size-cells = <0>; > + }; > + > usb_otg: usb@4100000 { > compatible = "allwinner,sun20i-d1-musb", > "allwinner,sun8i-a33-musb";
Hi Andre, > From a quick glance at the manuals, it > looks like there are not quite the same, though: the D1/R528/T113s > mentions a SPI_SAMP_DL register @0x28, whereas the older IP has a SPI_CCR > register @0x24 - which is not mentioned in the newer manuals. The driver > relies on that clock control register, so it wouldn't really work > reliably, if that register is not there. Thank you for pointing this out. I missed this difference. I actually have a board with T113 SoC, and it looks like writing to SPI_CCR@0x24 does nothing. And it doesn't affect access to connected SPI NOR flash (read\write operations are fine). But I completely agree with you that this difference should be handled by the spi driver.
On Fri, 5 May 2023 17:27:07 +0400 Maxim Kiselev <bigunclemax@gmail.com> wrote: Hi Maxim, > > From a quick glance at the manuals, it > > looks like there are not quite the same, though: the D1/R528/T113s > > mentions a SPI_SAMP_DL register @0x28, whereas the older IP has a SPI_CCR > > register @0x24 - which is not mentioned in the newer manuals. The driver > > relies on that clock control register, so it wouldn't really work > > reliably, if that register is not there. > > Thank you for pointing this out. I missed this difference. > I actually have a board with T113 SoC, and it looks like writing to > SPI_CCR@0x24 does nothing. According to the manual, the register doesn't exist, so this would support this theory. Most Allwinner IP just implements non-existing registers as RAZ/WI. > And it doesn't affect access to connected SPI NOR flash (read\write > operations are fine). I guess it just works with *some* (default?) clock settings then. Might be faster than configured, but the SPI flash chip might be fine with that. > But I completely agree with you that this difference should be handled > by the spi driver. As Samuel pointed out on IRC, there are patches, for the R329, using the same IP: https://lore.kernel.org/lkml/BYAPR20MB2472E8B10BFEF75E7950BBC0BCF79@BYAPR20MB2472.namprd20.prod.outlook.com/ And he also seemed to have issues, at least with SPI-NAND on one board: https://lore.kernel.org/lkml/0b5b586a-3bc7-384e-103c-e40d0b2fac23@sholland.org/ Can you please try these patches, and use: compatible = "allwinner,sun20i-d1-spi", "allwinner,sun50i-r329-spi"; for the compatible string? If possible, you could revive this series, and add the D1/T113s support on top: just add the compatible string combo to the binding document. Cheers, Andre
> Can you please try these patches, and use: > compatible = "allwinner,sun20i-d1-spi", "allwinner,sun50i-r329-spi"; > for the compatible string? I tested my patch (with compatible prop changed to allwinner,sun50i-r329-spi) on top of these patches and it works fine for me. > If possible, you could revive this series, and add the D1/T113s support on > top: just add the compatible string combo to the binding document. Just one question. Should I do it now, or is it better to wait while Icenowy Zheng finishes work on the next revision of this series?
On Sat, 6 May 2023 01:25:02 +0400 Maxim Kiselev <bigunclemax@gmail.com> wrote: Hi Maxim, > > Can you please try these patches, and use: > > compatible = "allwinner,sun20i-d1-spi", "allwinner,sun50i-r329-spi"; > > for the compatible string? > > I tested my patch (with compatible prop changed to > allwinner,sun50i-r329-spi) on top of these patches and it works fine > for me. > > > If possible, you could revive this series, and add the D1/T113s support on > > top: just add the compatible string combo to the binding document. > > Just one question. Should I do it now, or is it better to wait while > Icenowy Zheng finishes work on the next revision of this series? This series is over a year old, I doubt she will jump on this again any time soon. So it would be great if you could rebase the patches, keeping her authorship and Signed-off-by:, adding your Signed-off-by: and posting them. I might take a deep breath and try to solder some NOR SPI on my MQ-R to test it later on.... Many thanks! Andre
diff --git a/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi b/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi index 922e8e0e2c09..d2de211d67d7 100644 --- a/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi +++ b/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi @@ -108,6 +108,12 @@ rmii_pe_pins: rmii-pe-pins { function = "emac"; }; + /omit-if-no-ref/ + spi0_pins: spi0-pins { + pins = "PC2", "PC3", "PC4", "PC5"; + function = "spi0"; + }; + /omit-if-no-ref/ uart1_pg6_pins: uart1-pg6-pins { pins = "PG6", "PG7"; @@ -447,6 +453,20 @@ mmc2: mmc@4022000 { #size-cells = <0>; }; + spi0: spi@4025000 { + compatible = "allwinner,sun8i-h3-spi"; + reg = <0x04025000 0x300>; + interrupts = <SOC_PERIPHERAL_IRQ(15) IRQ_TYPE_LEVEL_HIGH>; + clocks = <&ccu CLK_BUS_SPI0>, <&ccu CLK_SPI0>; + clock-names = "ahb", "mod"; + dmas = <&dma 22>, <&dma 22>; + dma-names = "rx", "tx"; + resets = <&ccu RST_BUS_SPI0>; + status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; + }; + usb_otg: usb@4100000 { compatible = "allwinner,sun20i-d1-musb", "allwinner,sun8i-a33-musb";