I managed to get pwm working on an HLK7628N, maybe it will help others as well, there are some unanswered mt7628 + pwm questions
enable /dev/mem
# disable eth0-eth4 (eth0 has to be disabled as well, doesn't work otherwise)
devmem 0x1000003C 32 0x00FE01FF
# PWM1 PWM0: PWM mode
devmem 0x10000060 32 0x04054404
# pwm clock enable
VAL_CTRL=$(devmem 0x10000030)
NEW_CTRL=$((VAL_CTRL | 0x80000000))
printf "GPIO out: %0x\n" $NEW_CTRL
devmem 0x10000030 32 $NEW_CTRL
# PWM stop
devmem 0x10005000 32 0
# Bit 15 (OLD MODE) + 40MHz
# 20kHz 1/4 duty
PWM_CON_VAL=$((0x800B))
devmem 0x10005010 32 $PWM_CON_VAL
# PWM0 Data width
devmem 0x1000503c 32 256
# PWM0 Thresh
devmem 0x10005040 32 64
# start PWM0
devmem 0x10005000 32 1
changes in the dts:
# do not add PWM pins in &state_default { ...
# do not add PwM pins in &pinctrl { ...
# disable ethernet
ðernet {
status = "disabled";
};
# config for the kernel module, doesn't work yet
&pwm {
status = "okay";
pinctrl-names = "default";
};
actually the pwm_mediatek_ramips.ko seems to be broken for kernel 6.12
mtk-pwm 10005000.pwm: probe with driver mtk-pwm failed with error -22
it looks as if
pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL);
has to be replaced by
chip = devm_pwmchip_alloc(&pdev->dev, NUM_PWM, sizeof(*pc));