This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] PROCESSOR-SDK-AM62X: How to Enable and Use TPIC2810 on AM62x EVMs

Part Number: PROCESSOR-SDK-AM62X
Other Parts Discussed in Thread: SK-AM62B-P1, SK-AM62B, SK-AM62-SIP, TPIC2810

Tool/software:

TPIC2810 is an 8-bit I2C Based LED driver that is available on a few AM62x EVMs listed below:

This FAQ will show how to enable and use on AM62x EVMs.

  • Schematic

    On AM62x EVMs, the TPIC2810 is connected to WKUP_I2C0 bus. Note that the address of the TPIC2810 is 0x60.

    Links to the schematics are above on the EVM's product page.

    Linux Kernel

    Device Tree Patch

    In the device tree, the PinMuxing needs to be set, reference node to I2C, and finally the LED-GPIOs to change the default state.

    diff --git a/arch/arm64/boot/dts/ti/k3-am625-sk.dts b/arch/arm64/boot/dts/ti/k3-am625-sk.dts
    index b17379781..e6b18e208 100644
    --- a/arch/arm64/boot/dts/ti/k3-am625-sk.dts
    +++ b/arch/arm64/boot/dts/ti/k3-am625-sk.dts
    @@ -120,6 +120,74 @@ wlan_en: regulator-7 {
     		pinctrl-names = "default";
     		pinctrl-0 = <&wlan_en_pins_default>;
     	};
    +
    +	led-controller {
    +		compatible = "gpio-leds";
    +
    +		led-0 {
    +			color = <LED_COLOR_ID_GREEN>;
    +			function = LED_FUNCTION_INDICATOR;
    +			function-enumerator = <1>;
    +			gpios = <&exp2 0 GPIO_ACTIVE_HIGH>;
    +			default-state = "off";
    +		};
    +
    +		led-1 {
    +			color = <LED_COLOR_ID_RED>;
    +			function = LED_FUNCTION_INDICATOR;
    +			function-enumerator = <2>;
    +			gpios = <&exp2 1 GPIO_ACTIVE_HIGH>;
    +			default-state = "off";
    +		};
    +
    +		led-2 {
    +			color = <LED_COLOR_ID_GREEN>;
    +			function = LED_FUNCTION_INDICATOR;
    +			function-enumerator = <3>;
    +			gpios = <&exp2 2 GPIO_ACTIVE_HIGH>;
    +			default-state = "off";
    +		};
    +
    +		led-3 {
    +			color = <LED_COLOR_ID_AMBER>;
    +			function = LED_FUNCTION_INDICATOR;
    +			function-enumerator = <4>;
    +			gpios = <&exp2 3 GPIO_ACTIVE_HIGH>;
    +			default-state = "off";
    +		};
    +
    +		led-4 {
    +			color = <LED_COLOR_ID_GREEN>;
    +			function = LED_FUNCTION_INDICATOR;
    +			function-enumerator = <5>;
    +			gpios = <&exp2 4 GPIO_ACTIVE_HIGH>;
    +			default-state = "off";
    +		};
    +
    +		led-5 {
    +			color = <LED_COLOR_ID_RED>;
    +			function = LED_FUNCTION_INDICATOR;
    +			function-enumerator = <6>;
    +			gpios = <&exp2 5 GPIO_ACTIVE_HIGH>;
    +			default-state = "off";
    +		};
    +
    +		led-6 {
    +			color = <LED_COLOR_ID_GREEN>;
    +			function = LED_FUNCTION_INDICATOR;
    +			function-enumerator = <7>;
    +			gpios = <&exp2 6 GPIO_ACTIVE_HIGH>;
    +			default-state = "off";
    +		};
    +
    +		led-7 {
    +			color = <LED_COLOR_ID_AMBER>;
    +			function = LED_FUNCTION_HEARTBEAT;
    +			function-enumerator = <8>;
    +			linux,default-trigger = "heartbeat";
    +			gpios = <&exp2 7 GPIO_ACTIVE_HIGH>;
    +		};
    +	};
     };
     
     &main_pmx0 {
    @@ -193,6 +261,15 @@ AM62X_IOPAD(0x128, PIN_INPUT, 7) /* (B23) MMC2_SDWP.GPIO0_72 */
     	};
     };
     
    +&mcu_pmx0 {
    +	tpic_pins_default: tpic-default-pins {
    +		pinctrl-single,pins = <
    +			AM62X_MCU_IOPAD(0x004c, PIN_INPUT, 0) /* (B9) WKUP_I2C0_SCL */
    +			AM62X_MCU_IOPAD(0x0050, PIN_INPUT, 0) /* (A9) WKUP_I2C0_SDA */
    +		>;
    +	};
    +};
    +
     &main_i2c1 {
     	exp1: gpio@22 {
     		compatible = "ti,tca6424";
    @@ -285,6 +362,21 @@ mbox_m4_0: mbox-m4-0 {
     	};
     };
     
    +&wkup_i2c0 {
    +	status = "okay";
    +	pinctrl-names = "default";
    +	pinctrl-0 = <&tpic_pins_default>;
    +	clock-frequency = <400000>;
    +
    +	exp2: gpio@60 {
    +		compatible = "ti,tpic2810";
    +		reg = <0x60>;
    +		gpio-controller;
    +		#gpio-cells = <2>;
    +		gpio-line-names = "LED0","LED1","LED2","LED3","LED4","LED5","LED6","LED7";
    +	};
    +};
    +
     &ospi0 {
     	status = "okay";
     	pinctrl-names = "default";
    

    The default state/trigger for the LED can be changed in the device tree.

    Kernel Module

    Follow the SDK documentation for building device trees and kernel modules: https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/10_00_07_04/exports/docs/linux/Foundational_Components_Kernel_Users_Guide.html

    Compile the .dtb and Image & loaded it onto the EVM.

    How to toggle a LED

    root@am62xx-evm:~# cd /sys/class/leds/
    root@am62xx-evm:/sys/class/leds# ls -lt
    total 0
    lrwxrwxrwx 1 root root 0 Apr 28 17:42 amber:heartbeat-8 -> ../../devices/platform/led-controller/leds/amber:heartbeat-8
    lrwxrwxrwx 1 root root 0 Apr 28 17:42 green:indicator-7 -> ../../devices/platform/led-controller/leds/green:indicator-7
    lrwxrwxrwx 1 root root 0 Apr 28 17:42 mmc0:: -> ../../devices/platform/bus@f0000/fa10000.mmc/leds/mmc0::
    lrwxrwxrwx 1 root root 0 Apr 28 17:42 mmc1:: -> ../../devices/platform/bus@f0000/fa00000.mmc/leds/mmc1::
    lrwxrwxrwx 1 root root 0 Apr 28 17:42 am62-sk:green:heartbeat -> ../../devices/platform/leds/leds/am62-sk:green:heartbeat
    lrwxrwxrwx 1 root root 0 Apr 28 17:42 amber:indicator-4 -> ../../devices/platform/led-controller/leds/amber:indicator-4
    lrwxrwxrwx 1 root root 0 Apr 28 17:42 green:indicator-1 -> ../../devices/platform/led-controller/leds/green:indicator-1
    lrwxrwxrwx 1 root root 0 Apr 28 17:42 green:indicator-3 -> ../../devices/platform/led-controller/leds/green:indicator-3
    lrwxrwxrwx 1 root root 0 Apr 28 17:42 green:indicator-5 -> ../../devices/platform/led-controller/leds/green:indicator-5
    lrwxrwxrwx 1 root root 0 Apr 28 17:42 mmc2:: -> ../../devices/platform/bus@f0000/fa20000.mmc/leds/mmc2::
    lrwxrwxrwx 1 root root 0 Apr 28 17:42 red:indicator-2 -> ../../devices/platform/led-controller/leds/red:indicator-2
    lrwxrwxrwx 1 root root 0 Apr 28 17:42 red:indicator-6 -> ../../devices/platform/led-controller/leds/red:indicator-6
    root@am62xx-evm:/sys/class/leds# echo 1 > amber\:indicator-4/brightness 
    

    All the leds are populated in '/sys/class/leds'. For a simple toggle, echo 1/0 to the brightness directory.

    For more information on using SYSFS to interface LEDs, see here for the SYSFS CLASS LED documentation: git.ti.com/.../sysfs-class-led