NanoPC T4: how to make DisplayPort & Type-C working in 5.* kernels


Oleksii
 Share

1 1

Recommended Posts

Hello, nanopc t4 folks,

 

Some, not so long time ago, I worked on fusb302.ko driver and device tree improvements in order to make USB Type-C port working properly in the mainline 5.* kernel. I managed to get DisplayPort over type-C + some general type-c handling improved before my board simply died. Unfortunately, I was not able to finish all the planned work and cannot continue further :( However, I guess, working DP is already fairly good achievement that might be interesting for many of us. Hereby, I want to publish some patches to the mainline!!! driver and device tree that add missing functionality, so one can get DP+type-C working on NanoPC T4 (and all RK3399 based boards with Fairchild FUSB302 chip for PD with relatively small DT adjustments). I would be very happy if results of my work can be helpful to others and extremely happy if there any volunteers, who are willing to continue work on this subject. My primary goal was to contribute to Armbian, first of all, with a potential mainline repo contribution. What was added:

  • Extcon notifications support (type-c related cables) in the stock fusb302 driver (developed by Google folks, but also used by Intel :) if I understand correctly)
  • DisplayPort altmode is registered automatically, if device tree has proper modelling for that
  • DisplayPort altmode is entered as soon as DP cable connection is detected (both DP+USB3.0 and DP only pin assignments are supported) 
  • DisplayPort altmode is handled by the unified DP altmode driver rather than custom out-of-tree PD chip driver
  • "connector" node modelling in the device tree according to the mainline kernel docs and modern requirements
  • fusb node phandle is still specified as extcon source for Rockchip's proprietary drivers, however, last can be easily adjusted to resolve extcon directly from connector node link (as soon as extcon property is declared as deprecated for all new development).
  • fusb302 driver is now correctly linked to dwc3 driver which provides role_switch functionality (+1 step to correct "Dual Role" mode handling based on the cable detection). This also eliminates annoying error message in the boot log: "OF: graph: no port node found in /i2c@ff3d0000/typec-portc@22"

 

Please, also notice that type-c mode is forced to Host as in the most of rk3399 based SBC dtbs presently. This is rather a workaround for such boards, than a permanent solution, until all necessary bits are developed for correct role switching in the drivers. I kindly ask some NanoPC T4 owners to build mainline kernel with my patches and test whether expected functionality also works for you. Those patches apply to linux kernel since 5.6 when I started to work, but should also apply to way earlier versions according to my brief analysis of kernel commits history.

 

fusb302-add-extcon.patch rk3399-nanopc-t4-type-c-modeling.patch

Link to post
Share on other sites

Armbian is a community driven open source project. Do you like to contribute your code?

I downloaded and compiled current. There was a couple errors

I will try again using "dev" since that is post 5.6


arch/arm64/boot/dts/rockchip/rk3399-nanopc-t4.dts:167.35-169.5: ERROR (phandle_references): /usb@fe800000/usb@fe800000/port/endpoint: Reference to non-existent node or label "fusb0_role_sw"

arch/arm64/boot/dts/rockchip/rk3399-nanopc-t4.dts:146.29-148.5: ERROR (phandle_references): /syscon@ff770000/usb2-phy@e450/otg-port/port/endpoint: Reference to non-existent node or label "usbc_hs"

arch/arm64/boot/dts/rockchip/rk3399-nanopc-t4.dts:124.29-126.5: ERROR (phandle_references): /phy@ff7c0000/dp-port/port/endpoint: Reference to non-existent node or label "usbc_dp"

arch/arm64/boot/dts/rockchip/rk3399-nanopc-t4.dts:136.29-138.5: ERROR (phandle_references): /phy@ff7c0000/usb3-port/port/endpoint: Reference to non-existent node or label "usbc_ss"

ERROR: Input tree has errors, aborting (use -f to force output)
make[2]: *** [scripts/Makefile.lib:291: arch/arm64/boot/dts/rockchip/rk3399-nanopc-t4.dtb] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [scripts/Makefile.build:500: arch/arm64/boot/dts/rockchip] Error 2
make: *** [Makefile:1246: dtbs] Error 2

 

 

Thanks. I am interested in learning this. The changes are a bit extreme. But I learn tons as I go.

I dont have a DisplayPort but I have a few Anker Type-C hubs and power strips.

To be frank, I bought the Metal Case and Heat-sink Fan. This has improved things.

I run 4.4.213 and Ubuntu Focal Desktop. I am pretty happy now and I have

decided on new programming directions. I run VSCode on my NanoPC-T4.

I am excited by the Gnome3 and moving to TypeScript and Node.

I mostly run Sage Math and Python Science software. This box compiles and runs some advanced

software. Nonetheless I am learning ARM architecture and will keep at the RK3399 and Synopsis

SoC architecture.  I am going to see if the new 5.x kernel can just connect my Anker Type-C hub.

 

I do want to thank everyone for their work on the NanoPC.

 

NOTE: the Ubuntu NetworkManager Setting has a bug and crashes when updating.

I just dont use the GUI. I am not saying running Ubuntu Gnome3 Desktop is ready to go.

It is actually amazingly good though. anyhow...but it will be better under new Panfrost and friends.

Link to post
Share on other sites

Hi Oleksii

At first I downloaed your patches and put it in armbian's build tool, it report errors with fusb302 patch

Then I downloaded your rk3399-nanopc-t4-type-c-modeling.patch only and add two lines

extcon-cables = <1 2 5 6 9 10 12 44>;
typec-altmodes = <0xff01 1 0x001c0000 1>;

based on Helios64 commit on armbian's git (ea5bf1afd56423c069dd3267e9effc2c62d6706c), then I connect type-c monitor to my nanopct4 board and get these dmesg info:

root@nanopct4:~# dmesg |grep dp
[    5.720996] systemd[1]: Created slice system-modprobe.slice.
[    5.813967] systemd[1]: Starting Coldplug All udev Devices...
[    6.497528] systemd[1]: Finished Coldplug All udev Devices.
[    6.915278] rockchip-drm display-subsystem: bound fec00000.dp (ops cdn_dp_component_ops [rockchipdrm])
[    6.919926] cdn-dp fec00000.dp: [drm:cdn_dp_pd_event_work [rockchipdrm]] Not connected. Disabling cdn
[    7.222288] cdn-dp fec00000.dp: [drm:cdn_dp_pd_event_work [rockchipdrm]] Not connected. Disabling cdn
root@nanopct4:~# dmesg |grep typec
[    1.413642] vbus_typec: supplied by vcc5v0_sys
[    7.797465] typec_displayport port0-partner.0: No compatible pin configuration found:0000 -> 0014, 001c <- 0000

Do you have any ideas on how to fix it?

Thanks a lot!

Link to post
Share on other sites

4 hours ago, charliealex73 said:

Hi Oleksii

At first I downloaed your patches and put it in armbian's build tool, it report errors with fusb302 patch

Then I downloaded your rk3399-nanopc-t4-type-c-modeling.patch only and add two lines


extcon-cables = <1 2 5 6 9 10 12 44>;
typec-altmodes = <0xff01 1 0x001c0000 1>;

based on Helios64 commit on armbian's git (ea5bf1afd56423c069dd3267e9effc2c62d6706c), then I connect type-c monitor to my nanopct4 board and get these dmesg info:

 

1. My work is based on mainline fusb302 driver sources, Armbian replaces it with some proprietary one. Patches shouldn't apply on top of armbian's version.

2. DTB patch makes absolutely no sense unless driver has proper support for altmode negotiation and extcon notifications. There is no magic in DTB itself, it is just a configuration parameters "provider"!

3.  extcon-cables and typec-altmodes -  where did you get those from? I can only guess, however, those "unofficial" bindings have no relation to the current driver in mainline.

Link to post
Share on other sites

My Orange Pi 4B has got FUSB302B too.

USB Type-C gives power but my keyboard or mouse can't work...

 

Other 2 USB type A works ok.

 

I try Armbian_21.05.1_Orangepi4_focal_current, Armbian_20.05.3_Orangepi4_bionic_current. Thay doesn't work.

 

But USB Type-C works on https://github.com/orangepi-xunlong/orangepi-build Looks like USB Type-C wants old kernel...

 

How I use can @Oleksiipath with Orange Pi 4B ?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

1 1