[BPI-R4] CPU fan setup

i bought the same fan and its not spinning. did you resolve the issue?

PWM is not reported as working in mainline…on a quick look the dts exists with compatible “mediatek,mt7988-pwm”, but driver is not prepared for it (in my 6.8-dango and i guess openwrt too),

but i see in daniels latest wip-branch, pwm support seems to be added (at least compatible in driver).

but the dtsi node is disabled and not enabled in board dts…i try to enable it and report back…i at least need pinctrl node and one in board dts setting pinctrl and status

Seems there is only 1 possible pinctrl per pwm (0-6), so adding pinctrl should be easy…

@dangowrt your current wip tree is broken (“Label or path slot0 not found”) for a mt7622 dts (mt7622-adtran-smartrg-841-t6), disabled this for now. Have you tried pwm yet?

on first try i get error that pin is busy (don’t i need the pinctrl here - already in right state?)

root@bpi-r4-v11:~# dmesg | grep -i pwm
[    5.136100] mt7988-pinctrl 1001f000.pinctrl: pin PWMD1 already requested by 10048000.pwm; cannot claim for pinctrl_moore:533

seems not working yet…based on shematics fan-socket is pwm0…i can set export and pwm settings

root@bpi-r4-v11:~# echo 0 > /sys/class/pwm/pwmchip0/export
root@bpi-r4-v11:~# echo 200000 >/sys/class/pwm/pwmchip0/pwm0/period
root@bpi-r4-v11:~# echo 100000 >/sys/class/pwm/pwmchip0/pwm0/duty_cycle
root@bpi-r4-v11:~# echo 1 >/sys/class/pwm/pwmchip0/pwm0/enable

and i do not measure any voltage on the right 2 pins of fan socket (left one is 5V, and middle is gnd)

clocks look same when comparing with sdk/bpi repo…but not yet found the infra_divs but they are all 1,1 so maybe not needed

I have the same issue with the fan, the one in the photo, it never starts up, not even when the Banana Pi has been on for an hour and is already hot… Any solutions? Thank you!

@dangowrt I have same issue that the PWM fan never spins, any eta this will support by openwrt snapshot?

openwrt and daniels wip tree i use does not yet have pwm working…in my tests the controller itself is available in sysfs, but does not give pwm signal to fan socket

based on the other thread i compared the register offsets and settings for the compatible, they are same, only a bit different structure with the reg_offset_v2

static const unsigned int mtk_pwm_reg_offset_v2[] = {
	0x0080, 0x00c0, 0x0100, 0x0140, 0x0180, 0x01c0, 0x0200, 0x0240
};

static const struct pwm_mediatek_of_data mt7988_pwm_data = {
	.num_pwms = 8,
	.pwm45_fixup = false,
	.has_ck_26m_sel = false,
	.reg_offset = mtk_pwm_reg_offset_v2,
};

@dangowrt does pwm work for you? just to confirm i do not miss anything (but as controller comes up i guess there is another rootcause here).

maybe @sam33 can help here?

Mine starts the fan automatically when the temp is 42 or higher and stops it, if it is 41 or lower.

upstream openwrt with your patch?

Yes, upstream with my patch

mhm, clk and pinctrl driver is nearly same as my (daniels wip) tree, also dts seems to be same (also no pinctrl defined in openwrt source)…very strange…in pwm driver it looks there is no functional difference.

Can you please share the config you use when you compile daniels wip, so I can see if I get the same result as you? Also are daniels wip the same as dangowrt?

defconfig: BPI-Router-Linux/arch/arm64/configs/mt7988a_bpi-r4_defconfig at 6.8-dango_2 · frank-w/BPI-Router-Linux · GitHub

dangowrt is daniels username here and in github

you can compile my kernel using my build.sh with param importconfig and then without (board is already set to bpi-r4 in build.conf)

Can we put some connector to gpio? With adapter to normal fan?

I have compiled the kernel, but I can’t manage to install it to the SD-Card.

Image-filename: 6.8.0-rc7-dango_2 Name: 6.8.0-rc7-dango_2 Press [enter] to copy data to SD-Card… SD-Card not found!

I have tried to mount it with:

./build.sh mount Error looking up object for device /dev/disk/by-label/BPI-BOOT Error looking up object for device /dev/disk/by-label/BPI-ROOT

But as you see, that don’t work.

lsblk:

sdc 8:32 1 29.8G 0 disk ├─sdc1 8:33 1 4M 0 part ├─sdc2 8:34 1 512K 0 part ├─sdc3 8:35 1 2M 0 part ├─sdc4 8:36 1 4M 0 part ├─sdc5 8:37 1 32M 0 part ├─sdc6 8:38 1 20M 0 part └─sdc7 8:39 1 28G 0 part

Install option is only for my debian/ubuntu images which have a bpi-boot partition…openwrt uses different approach,but you can load kernel fit image (itb) in uboot from usb/tftp,but afaik openwrt uses differnt config options to apply the overlays (e.g. sdcard).

OK, then I’ll build your debian image and try that. :slight_smile:

you can also use the built image from here: automatic-images - Google Drive

make sure your filename is put in uEnv.txt (fit=filename.itb) on bpi-boot-partition (like written after install)

The image on Google Drive did not give out any PWM, but I got it working by editing the dts and compiling it myself.

mt7988a-bananapi-bpi-r4.dts (7.0 KB)

Can you test it too ? :slight_smile:

Looks like you only added fan node,right? I have no fan yet,i measured pwm signal on pin of fan socket and there was none

Yeah, I added

&fan { pwms = <&pwm 0 50000 0>; status = “okay”; };

It works great here though.

I did also edit a bit on the i2c, so rtc can work properly - as long as a 3.3 - 3.7v battery is plugged in.

I have added your patches, and the changes have been made but I can’t seem to get openwrt to include them into the new build. What am I doing wrong?