VIM4 PWM Issue

Subject: VIM4 Android 14 - PWM_F (Pin 35 / GPIO18) appears non-functional and missing from PWM debug interface

Hello,

I am trying to use PWM_F on Pin 35 (GPIO18) of the VIM4 running Android 14, but it appears that the PWM controller is not functioning correctly.

According to the documentation:

* Simple PWM mode:
https://docs.khadas.com/products/sbc/vim4/applications/gpio/pwm#tab__vim41

I tested :

1. Using the official patch to disable the backlight and expose a pure PWM signal on Pin 35.
2. Using the Android backlight driver configured to use PWM_F.

In both cases, no PWM signal is generated on Pin 35.

### What I observe

The backlight driver loads successfully and reports that it is using PWM_F:

```text
~$ adb shell
VIM4:/ # clear
VIM4:/ # dmesg | grep -E "pwm|aml_bl|backlight"
[ 0.621712] [pwm_regulator_init_state] Get return < i-1:3
[ 0.622724] [pwm_regulator_init_state] Get return < i-1:3
[ 0.624190] [pwm_regulator_init_state] Get return == i: 6
[ 1.802356] bl: [0]: load: backlight_0
[ 1.803680] bl: [0]: bl pwm_port: PWM_F(0x5)
[ 1.804350] bl: [0]: name = backlight_pwm, method = pwm(1)
[ 1.806895] bl: [0]: aml_bl_config_probe_work: ok
VIM4:/ #
VIM4:/ # cat /sys/class/aml_bl/bl0/pwm_info
read backlight pwm info:
pwm_bypass: 0
pwm_duty_free: 0
pwm_index: 0
pwm_port: PWM_F(0x5)
pwm_method: 1
pwm_freq: 180
pwm_phase: 0
pwm_duty_max: 100
pwm_duty_min: 25
pwm_level_max: 255
pwm_level_min: 10
pwm_cnt: 5555555
pwm_max: 5555555
pwm_min: 1388888
pwm_level: 2953513
pwm_mapping: 10_71_132_193_255 255_255_0
pwm_switch_port: PWM_A(0x0)
pwm_switch_freq: 0
pwm_duty: 53%
pwm invalid
VIM4:/ # cat /sys/class/aml_bl/bl0/status
read backlight status:
key_valid: 0
config_load: 0
index: 0
name: backlight_pwm
state: 0x2
level: 102
level_brightness: 102
level_gd: 0
level_uboot: 102
level_default: 102
step_on_flag 0
brightness_bypass: 0

debug_force: 0

level_max: 255
level_min: 10
level_mid: 128
level_mid_mapping: 128

method: pwm
en_gpio: GPIOT_18(0)
en_gpio_on: 1
en_gpio_off: 0
power_on_delay: 200
power_off_delay: 200

pwm_method: 1
pwm_port: PWM_F(0x5)
pwm_freq: 180
pwm_phase: 0
pwm_duty_max: 100
pwm_duty_min: 25
pwm_on_delay: 10
pwm_off_delay: 10
en_sequence_reverse: 0

```

More importantly, PWM_F never appears in /sys/kernel/debug/pwm.

Current PWM debug output only shows:

```text
platform/fe030000.pwm
platform/fe060000.pwm
platform/fe05e000.pwm
platform/fe058000.pwm
```

There is no entry corresponding to PWM_EF / PWM_F.

Even after disabling the backlight node, the situation is unchanged.
```text
VIM4:/ # cat /proc/device-tree/backlight/status
disabledVIM4:/ #
VIM4:/ # dmesg | grep aml_bl
1|VIM4:/ # dmesg | grep pwm
[ 0.622129] [pwm_regulator_init_state] Get return < i-1:3
[ 0.623132] [pwm_regulator_init_state] Get return < i-1:3
[ 0.624629] [pwm_regulator_init_state] Get return == i: 6
VIM4:/ # cat /sys/kernel/debug/pwm
platform/fe030000.pwm, 4 PWM devices
pwm-0 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-1 (pwmao_f-regulator ): requested enabled period: 840 ns duty: 0 ns polarity: normal
pwm-2 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-3 ((null) ): period: 0 ns duty: 0 ns polarity: normal

platform/fe060000.pwm, 4 PWM devices
pwm-0 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-1 (pwmao_d-regulator ): requested enabled period: 1500 ns duty: 930 ns polarity: normal
pwm-2 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-3 ((null) ): period: 0 ns duty: 0 ns polarity: normal

platform/fe05e000.pwm, 4 PWM devices
pwm-0 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-1 (pwmao_b-regulator ): requested enabled period: 1500 ns duty: 1215 ns polarity: normal
pwm-2 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-3 ((null) ): period: 0 ns duty: 0 ns polarity: normal

platform/fe058000.pwm, 4 PWM devices
pwm-0 (pwm_channel1_conf ): requested enabled period: 30550 ns duty: 15270 ns polarity: normal
pwm-1 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-2 (pwm_channel2_conf ): requested enabled period: 30500 ns duty: 15250 ns polarity: normal
pwm-3 ((null) ): period: 0 ns duty: 0 ns polarity: normal
```

### Questions

1. Is pwm@5c000 (PWM_EF) expected to be enabled on the VIM4 Android 14 BSP?
2. Does Backlight on PWM_F output pwm signal on PIN35 or it directly output it to DSI/MIPI lcd panel ?
2. Why does PWM_F never appear in /sys/kernel/debug/pwm?
3. Is there a known issue with PWM_F / Pin 35 on Android 14?
4. Has anyone successfully generated a PWM waveform on Pin 35 (GPIO18) using the current Android 14 BSP?

Any guidance would be appreciated.

Thank you.

@Support_Account_1 Please post your modified code. Also, what compilation commands did you execute after making the modifications?

Hi @goenjoy For enabling backlight on pwm_f we have removed backlight dts node which works on pwm_e and replace it with backlight1 node wich works on pwm_f
For using pwm_f without backlight we just apply their patch to dts
We just recompile dts and update vendor_boot_a partition on target directly

Hi Devs, I have not heard back from you. Could you please advise on this ?