Re: Rockchip RK3328 Rock64 HDMI

From: Dmitry Salychev <dsl_at_FreeBSD.org>
Date: Fri, 20 Sep 2024 20:32:50 UTC
Christoph Pfaller <pfaller@protonmail.com> writes:

> Hello!
>
> I recently switched to FreeBSD on my Rock64 due to appearing kernel panics when running the board with Linux. So far I
> enjoy the operating system. However; there is one little annoyance - the integrated HDMI output does not work. So I want to
> change that.
>
> As we are on ARM my first intention was looking into the device tree for the rk3328. I compared it to Linux device tree and also
> found some missing parts. My next step was looking into the drivers itself and as the Linux drivers sources are available here
> https://github.com/torvalds/linux/tree/master/drivers/gpu/drm/rockchip I got some idea how the corresponding driver should
> look like.
>
> However, I am unsure how I should proceed getting HDMI to work. Accodring to https://wiki.freebsd.org/arm/RockChip HDMI
> works for the rockchip rk3399 but I could not find any drivers  neither in the freebsd-src or drm-kmod (I am new to FreeBSD so
> i don't know if this is even the right place to look for). I hope someone with more technical knowledge about FreeBSD or HDMI
> can provide me with some guidance on where I have to look and work on.
>
> Greetings
> pf0

Hey!

I'd start digging into:

sys/contrib/device-tree/src/arm64/rockchip/rk3399-rockpro64.dts
sys/contrib/device-tree/src/arm64/rockchip/rk3399-rockpro64.dtsi
sys/contrib/device-tree/src/arm64/rockchip/rk3399-rockpro64-v2.dts

Btw, "hdmi" node is enabled in rk3399-rockpro64.dtsi:

#include "rk3399.dtsi"
#include "rk3399-opp.dtsi"
...
&hdmi {
	ddc-i2c-bus = <&i2c3>;
	pinctrl-names = "default";
	pinctrl-0 = <&hdmi_cec>;
	status = "okay";
};

If you take a look at rk3399.dtsi, you'll see:

	hdmi: hdmi@ff940000 {
		compatible = "rockchip,rk3399-dw-hdmi";
		reg = <0x0 0xff940000 0x0 0x20000>;
		interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH 0>;
		clocks = <&cru PCLK_HDMI_CTRL>,
			 <&cru SCLK_HDMI_SFR>,
			 <&cru SCLK_HDMI_CEC>,
			 <&cru PCLK_VIO_GRF>,
			 <&cru PLL_VPLL>;
		clock-names = "iahb", "isfr", "cec", "grf", "ref";
		power-domains = <&power RK3399_PD_HDCP>;
		reg-io-width = <4>;
		rockchip,grf = <&grf>;
		#sound-dai-cells = <0>;
		status = "disabled";

Try to grep sys/dev, but I don't see any driver on the latest CURRENT
which declares compatibility with "rockchip,rk3399-dw-hdmi".

drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c from the Linux source tree is
only ~600 LoC. You'd try to port it to FreeBSD using LinuxKPI[1], I
guess. I'd love to try running it on my PinePhone Pro.

Regards,
Dmitry

[1] https://wiki.freebsd.org/LinuxKPI

-- 
https://wiki.freebsd.org/DmitrySalychev