Linux-RISC-V Archive mirror
 help / color / mirror / Atom feed
From: Yangyu Chen <cyy@cyyself.name>
To: linux-riscv@lists.infradead.org
Cc: Conor Dooley <conor@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Rob Herring <robh@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	linux-usb@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, Yangyu Chen <cyy@cyyself.name>
Subject: [PATCH v1 0/2] riscv: dts: add USB nodes for Canaan Kendryte K230 SoCs
Date: Sun, 21 Apr 2024 20:52:50 +0800	[thread overview]
Message-ID: <tencent_E9B853316D217B8D1E7CDF8288DA5E8ED908@qq.com> (raw)

As K230 SoCs have two USB controllers, add USB nodes for it. I have tested
the new dts file on both CanMV-K230 and K230 EVB. 

I confirm it can work well in USB Host Mode with high speed. I use
CanMV-K230 to connect an RTL8152 USB Ethernet adaptor to an OTG Port
(USB0), which works well with this log [1]. The on-board ethernet is
connected to the USB1 port, which works. On K230 EVB, the RTL8152 USB
Ethernet adaptor works well on a USB0 port with high speed [2]. I have no
health device to test the USB1 port on K230 EVB. My K230 EVB USB1 port has
no +5V power output even on factory-patched u-boot + opensbi+ kernel. 

I also confirmed the dt-binding can work well with NFS as rootfs over USB
Ethernet. It's good news for those who want to use K230 SoCs to boot a
mainline kernel with distro rootfs for daily RVV1.0 software performance
evaluation since we haven't submitted MMC drivers to the mainline for
SD Card support.

There is a thing to do: add the USB PHY drivers. Although I can let
High-Speed USB work on both of my boards, the pulling on D+ and D- pins are
not right in gadget mode for another host to detect the speed. We can see
from the factory-patched USB driver, which adds an item pointer to the USB
PHY controller [3] and sets the pulling mode for D+ and D- pins for
different modes [4]. However, the factory-patched USB driver is not the
right way for the mainline kernel to go. We should add the USB PHY drivers
to do the right thing. We can infer these things from the factory code:

- USB PHY Control MMIOs are at base 0x91585000 with size 0x1000. [3]
- usb_ctl3 register controls the ID_PULLUP, DMPULLDOWN(D-), DPPULLDOWN(D+).
- ID_PULLUP is at bit 4, DMPULLDOWN is at bit 8, DPPULLDOWN is at bit 9.
- The usb_ctl3 register is 4Bytes wide.
- For USB0 port, usb_ctl3 is at offset 0x7c.
- For USB1 port, usb_ctl3 is at offset 0x9c. [4]

But I'm too busy these days to add a PHY driver. I would be happy to help
if someone volunteered to do that.

base-branch: [5]

This patch is available to test on that tree [6].

[1] https://gist.github.com/cyyself/f7f2849e6a262b6281687b906e1512cc
[2] https://gist.github.com/cyyself/ea8895012d1035ca5bd3375b798f5786
[3] https://github.com/kendryte/k230_sdk/blob/v1.5/src/little/linux/drivers/usb/dwc2/platform.c#L526
[4] https://github.com/kendryte/k230_sdk/blob/v1.5/src/little/linux/drivers/usb/dwc2/params.c#L195
[5] https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/log/?h=riscv-dt-for-next
[6] https://github.com/cyyself/linux/tree/k230-usb-v1

Yangyu Chen (2):
  dt-bindings: dwc2: Add bindings for new Canaan Kendryte K230 SoC
  riscv: dts: add usb nodes for Canaan Kendryte K230 SoCs

 .../devicetree/bindings/usb/dwc2.yaml         |  3 ++
 arch/riscv/boot/dts/canaan/k230.dtsi          | 29 +++++++++++++++++++
 2 files changed, 32 insertions(+)

base-commit: 5db2c4dc413e27720b8f567522cd5ebb0bb7ef70
-- 
2.43.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

             reply	other threads:[~2024-04-21 12:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-21 12:52 Yangyu Chen [this message]
2024-04-21 12:53 ` [PATCH v1 1/2] dt-bindings: dwc2: Add bindings for new Canaan Kendryte K230 SoC Yangyu Chen
2024-04-22  4:33   ` Krzysztof Kozlowski
2024-04-21 12:53 ` [PATCH v1 2/2] riscv: dts: add usb nodes for Canaan Kendryte K230 SoCs Yangyu Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_E9B853316D217B8D1E7CDF8288DA5E8ED908@qq.com \
    --to=cyy@cyyself.name \
    --cc=conor@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).