Mainline Linux Khadas MCU driver

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

big tnx!!! for good news !

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.

@numbqq Wes should be have a solution for reference, right?

numbqq will assist you on this.

We change the dts dynamicly before booting linux.

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 ?

Hello Neil,

We will test this driver, thank you!

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

The MCU driver has been accepted for upstream: https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git/log/?h=for-mfd-next

9 Likes

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.

Please check here

Does the password feature allow you to protect the boot mode setying?

There is no protection for boot mode.

What is the password used to protect, then, @numbqq?