Page MenuHomeFreeBSD

Add Rockchip RK3399 eMMC PHY driver
ClosedPublic

Authored by ganbold on Jul 3 2019, 6:27 AM.
Tags
None
Referenced Files
F105783547: D20840.diff
Fri, Dec 20, 3:43 PM
Unknown Object (File)
Sun, Dec 15, 7:43 AM
Unknown Object (File)
Sun, Dec 15, 2:53 AM
Unknown Object (File)
Sat, Dec 14, 3:14 AM
Unknown Object (File)
Thu, Dec 5, 12:08 AM
Unknown Object (File)
Wed, Dec 4, 3:45 PM
Unknown Object (File)
Wed, Dec 4, 12:21 PM
Unknown Object (File)
Wed, Dec 4, 12:21 PM

Details

Summary

Add driver for Rockchip RK3399 eMMC PHY.
Tested on NanoPC-T4 board.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 25365

Event Timeline

Updated, once clock is enabled in sdhci_fdt, rk_emmcphy_init(void) can be called again to get the clock, etc.

sys/arm64/rockchip/rk3399_emmcphy.c
215

This should be the phy_init method, then sdhci can just call phy_init(sc->phy);

Disable phy when enable var is false.

sys/arm64/rockchip/rk3399_emmcphy.c
120

This doesn't need to be a global variable now.

144

You should validate that the phy id is correct by using phynode_get_id

146

This is not correct, this function is suppose to disable the phy by writing to the registers.
This will just call the same function by doing that.

236

Can you do a smaller delay value and use a loop for the timeout ?
Is there any info in the user manual on how long the DLL init is ?

Global variable is removed.
Phy id is validated after getting id by phynode_get_id().
When enable var is false it will disable the phy.
Looked both NetBSD and linux sources for delay value:

https://github.com/NetBSD/src/blob/trunk/sys/arch/arm/rockchip/rk_emmcphy.c#L207
https://elixir.bootlin.com/linux/v5.2-rc7/source/drivers/phy/rockchip/phy-rockchip-emmc.c#L204

Rockchip RK3399 TRM V1.3 Part2.pdf says in page 698:

After the DLL control loop reaches steady state a DLL ready signal is generated by the DLL circuits ‘phyctrl_dllrdy’. The time from ‘phyctrl_endll’ to DLL ready signal ‘phyctrl_dllrdy’ varies with the clock frequency. At 200MHz clock frequency the DLL ready delay is 2.56us, at 100MHz clock frequency the DLL ready delay is 5.112us and at 50 MHz clock frequency the DLL ready delay is 10.231us.

Correct the class name when creating phynode, otherwise rk_emmcphy_enable() is never called.

sys/arm64/rockchip/rk3399_emmcphy.c
236

Why not waiting the correct amount of time based on the frequency ?

Tried with smaller wait values per frequency respectively.
However it is not working. So added more comments in the code
describing why more safer value would work in any case.

Tried with smaller wait values per frequency respectively.
However it is not working. So added more comments in the code
describing why more safer value would work in any case.

Ok, fine with me, we can change that later if we need to,

This revision is now accepted and ready to land.Jul 19 2019, 5:59 PM
This revision was automatically updated to reflect the committed changes.