Configuring TPM to Control RGB LED on IMX8ULP EVK with Android Kernel

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Configuring TPM to Control RGB LED on IMX8ULP EVK with Android Kernel

2,500 Views
rahul_ms__
Contributor I

Hi NXP,

I am currently working on the IMX8ULP EVK Board with the Android Kernel running on the A35 core. My goal is to configure the TPM module to control the RGB LED on the baseboard.

Steps Taken:

  1. Device Tree Configuration:

    • The device tree already included a node for backlight control of the display on the daughter card.
    • I added a new node for PWM control (referencing the Config Tools) to manage the RGB LED.
  2. Issues Faced:

    • The new PWM node appears under /sys/firmware/devicetree/base/ but not under /sys/class/.
    • The entries under /sys/firmware/devicetree/base/pwmbacklight are read-only. Attempts to change permissions (using chmod -R 777) or write to these entries (even with superuser privileges) result in a "Permission denied" error.
  3. Driver Selection:

    • The backlight driver uses pwm-rpmsg, and I added the same driver for the RGB LED as a reference. However, I suspect this is causing the issue because:
      • The backlight PWM on PTA03 is controlled by RTD peripherals.
      • The RGB LEDs on Ports E and F are controlled by APD peripherals.
    • The driver I need (pwm-imx27.c) is present in the SDK but is missing in the current image.

Questions:

  1. How can I build and include the pwm-imx27.c driver in the image to control the PWM for the RGB LED?
  2. Could you provide guidance on resolving the read-only issue for the new PWM node?

Relevant Device Tree Changes:

Device Tree Node for PWM RGB LED:

/ {
    pwm_rgbLed: pwmbacklight {
        compatible = "pwm-backlight";
        pinctrl-0 = <&pinctrl_pwm>;
        pwms = <&tpm7 2 50000 0>;
        #pwm-cells = <3>;
        brightness-levels = <0 1 2 3 4 ... 100>;
        default-brightness-level = <100>;
    };
};

Pin Configuration:

&iomuxc1 {
    pinctrl_pwm: pinctrlpwm {
        fsl,pins = <
            MX8ULP_PAD_PTF29__TPM7_CH2 0x00000002
        >;
    };
};

TPM Node in imx8ulp.dtsi:

tpm7: tpm@29830000 {
    #pwm-cells = <3>;
    compatible = "fsl,imx8ulp-tpm", "fsl,imx7ulp-tpm";
    fsl,pwm-channel-number = <6>;
    reg = <0x29830000 0x1000>;
    interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>;
    clocks = <&sosc>, <&sosc>;
    clock-names = "ipg", "per";
    status = "okay";
};

Observations:

  • The /sys/class/ directory contains the following entries but not pwmbacklight:
    android_usb    gpu_class  misc            pwm          spidev
    arvo           graphics   mmc_host        pxp_device   thermal
    backlight      hidraw     mtd             pyra         trusty_ipc
    bdi            hwmon      mux             rc           tty
    block          i2c-dev    nd              regulator    typec
    bsg            ieee80211  net             remoteproc   typec_mux
    devcoredump    input      nvme            retimer      ublk-char
    devfreq        iommu      nvme-generic    rfkill       udc
    devfreq-event  isku       nvme-subsystem  rpmsg        uio
    devlink        kone       pci_bus         rtc          usb_power_delivery
    dma            koneplus   pci_epc         ryos         usb_role
    dma_heap       konepure   phy             savu         video4linux
    dmabuf_imx     kovaplus   pmsg            scsi_device  wakeup
    drm            leds       power_supply    scsi_disk    watchdog
    extcon         lirc       powercap        scsi_host    xt_idletimer
    firmware       mdio_bus   pps             sound        zram-control
    gnss           mem        ptp             spi_master
  • The PWM node for RGB LED (pwmbacklight) is visible under /sys/firmware/devicetree/base/ with the following structure:
    /sys/firmware/devicetree/base/pwmbacklight/  
    ├── #pwm-cells  
    ├── brightness-levels  
    ├── compatible  
    ├── default-brightness-level  
    ├── name  
    ├── pinctrl-0  
    ├── pwms  
  • Attempting to modify values results in:
    echo 50 > default-brightness-level  
    /system/bin/sh: can't create default-brightness-level: Permission denied  

Could you please provide guidance on how to properly configure and include the pwm-imx27 driver or resolve the above issues?

Thanks in advance!

0 Kudos
Reply
3 Replies

2,412 Views
pengyong_zhang
NXP Employee
NXP Employee

Hi @rahul_ms__ 

1, Which version of Android did you use?

2, Why did you need pwm-imx27.c on 8ulp? I think it's used for soc like 8mp.

3, I'm not sure if pwm-backlight is used like customer did. pwm-backlight is used for display backlight. RGB LED is controlled by 3 PWMs. Did you need to control these 3. not only TPM7_CH2?

pengyong_zhang_0-1737426861699.png

B.R

0 Kudos
Reply

2,406 Views
rahul_ms__
Contributor I

1, Which version of Android did you use? I'm Using Android 14.

2, Why did you need pwm-imx27.c on 8ulp? I think it's used for soc like 8mp. Which driver should I use to control PWM pin for 8ULP?

3, I'm not sure if pwm-backlight is used like customer did. pwm-backlight is used for display backlight. RGB LED is controlled by 3 PWMs. Did you need to control these 3. not only TPM7_CH2? I’ve adjusted the approach for configuring the PWM pins to match the backlight setup. Currently, I need to configure three pins for RGB, but for testing purposes, I’m only setting up TPM2_CH2.

 

I’ve added the PWM node, but I’m unable to turn on the LED using it. Could you help me identify what might be causing the issue?

 

 

 

0 Kudos
Reply

2,404 Views
rahul_ms__
Contributor I

Hi @pengyong_zhang ,

We have made some progress after this. We tried using the configuration compatible = "fsl,imx8ulp-tpm", "fsl,imx7ulp-tpm";.

However, since no corresponding driver exists in the SDK, this change did not make any difference.
On a positive note, We successfully accessed the tpm under sysfs. We are able to set the period and duty cycle, and the written values are reflected when read back. However, writing "high" to the enable property does not take effect (cat enable always returns 0). Consequently, We are unable to enable the RGB LED.

To debug further, We used cat /sys/kernel/debug/pinctrl/*/pinmux-pins to verify if the pins were assigned to other activities. The output confirmed that pin 93 (PTF29) is correctly configured as pinctrl_pwm, matching the device tree configuration.
Could you advise on the next steps to resolve this issue?

0 Kudos
Reply