Hi Guys,
I started writing a proper driver for the Khadas MCU present on the VIM2 rev 13, VIM3, VIM3L and Edge boards :
The main feature is to have FAN control, this adds it as hwmon device and cooling-devices added the the cpu thermal zone as active cooling devices in addition to the CPUs DVFS in passive & hot.
It also adds a power-off driver, and an nvmem driver for the USER memory.
I plan to send it to the upstream mailing-lists this week, but I’d like to have some tests and feedbacks !
I haven’t added it to the VIM2 DT since I don’t know how to handle the second revision of the board upstream, but it should work just fine.
Cc: @hyphop @Gouwa
Neil
10 Likes
hyphop
April 6, 2020, 10:24am
#2
big tnx!!! for good news !
Gouwa
April 6, 2020, 12:10pm
#3
The HW ID is different between V12 and V13/14:
V12:
V13/14:
3 Likes
Thanks @Gouwa , it will help for U-Boot, but for Linux side, should I add a separate upstream khadas-vim2-v14.dts selected by U-Boot with this HW_ID ?
Concerning the MCU, I was unable to change the USER bytes, is there a specific sequence to change them ? I only exposed the USER bytes in the nvmem driver, but I could expose more fields like the MAC, and USID.
Gouwa
April 7, 2020, 10:04am
#5
@numbqq Wes should be have a solution for reference, right?
narmstrong:
Concerning the MCU, I was unable to change the USER bytes, is there a specific sequence to change them ? I only exposed the USER bytes in the nvmem driver, but I could expose more fields like the MAC, and USID.
numbqq will assist you on this.
numbqq
April 7, 2020, 11:37am
#6
Gouwa:
should I add a separate upstream khadas-vim2-v14.dts selected by U-Boot with this HW_ID ?
We change the dts dynamicly before booting linux.
if test -e ${dev} ${dev_num}:${distro_bootpart} ${mark_prefix}.next; then
echo "Booting mainline kernel...";
setenv condev "console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0";
# Setup dtb for different HW version
fdt addr ${dtb_loadaddr};
fdt resize 65536;
if test "X${hwver}" = "XVIM1.V14"; then
fdt set /soc/bus@c1100000/i2c@87c0/khadas-mcu@18 hwver "VIM1.V14";
else if test "X${hwver}" = "XVIM2.V14"; then
fdt set /soc/bus@c1100000/i2c@87c0/khadas-mcu@18 hwver "VIM2.V14";
fdt set /gpio-fan status "disabled";
fdt set /fan status "disabled";
else if test "X${hwver}" = "XVIM3.V11" || test "X${hwver}" = "XVIM3.V12"; then
fdt set /soc/bus@ff800000/i2c@5000/khadas-mcu@18 hwver ${hwver};
kbi init;
kbi portmode r;
fdt get value usb2_phy0 /soc/bus@ff600000/phy@36000 phandle;
fdt get value usb2_phy1 /soc/bus@ff600000/phy@3a000 phandle;
But for mainline kernel, maybe a separate dts is needed.
OK, I will add a separate DT file to be selected by the bootloader.
@hyphop did you have time to test the driver ?
numbqq
April 8, 2020, 2:57am
#8
Hello Neil,
We will test this driver, thank you!
Gouwa:
Concerning the MCU, I was unable to change the USER bytes, is there a specific sequence to change them ? I only exposed the USER bytes in the nvmem driver, but I could expose more fields like the MAC, and USID.
In order to access the USER data registers, you need to check the user password, default is khadas
.
i2cset -f -y 2 0x18 0x81 0x1 // check password start
i2cset -f -y 2 0x18 0x83 0x4B // password[0] = 'k'
i2cset -f -y 2 0x18 0x83 0x68 // password[1] = 'h'
i2cset -f -y 2 0x18 0x83 0x61 // password[2] = 'a'
i2cset -f -y 2 0x18 0x83 0x64 // password[3] = 'd'
i2cset -f -y 2 0x18 0x83 0x61 // password[4] = 'a'
i2cset -f -y 2 0x18 0x83 0x73 // password[5] = 's'
i2cset -f -y 2 0x18 0x81 0x0 // check password done
After this you can write/read the USER registers.
Note: If you change the default user password, you need to remenber the new one you set.
3 Likes
Right I missed this, I’ll add a way to check the password in the nvmem driver.
1 Like
Thanks for the awesome work!
Any doc on how to set the fan speed using upstream kernel?
I checked the hwmon0 device but can’t see the fan speed nodes, while khadas_mcu_fan module is properly loaded.