Other Parts Discussed in Thread: SK-AM62B-P1, SYSCONFIG
Tool/software:
I want to use MCU GPIO from A53/Linux or Main Domain GPIO from M4/MCU. How can I allocate these GPIOs and use them?
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.
Tool/software:
I want to use MCU GPIO from A53/Linux or Main Domain GPIO from M4/MCU. How can I allocate these GPIOs and use them?
Background Information
The Connectivity Table provides an understanding of which peripherals/modules are accessible from which cores/domains. In the AM62x TRM, see Section 3.1.8 Connectivity Table/Table 3-8. Connectivity Table among Initiators and Targets for the complete table.
The A53SS is the Main Domain & MCU M4FSS is the MCU Domain. The table indicates that MCU Domain GPIOs are accessible from the A53 Core & the Main Domain GPIOs are accessible from the M4 Core.
Accessing MCU Domain GPIOs from Main Domain
Software and Hardware Used:
Steps Required:
The Linux Device tree will describe hardware and its properties to the Linux Kernel. By adding a node to the device tree about a peripheral, Linux will claim it.
For this example, two GPIOs can be accessed via the MCU Header of the device. This example uses SK-AM62B-P1 and schematics can be found here: https://www.ti.com/tool/SK-AM62B-P1#design-files
Online Sysconfig can be used to generate pinmux code for the device tree:
Apply the contents of the generated .dtsi file and compile.
The contents should be copied into to the board level file, k3-am625-sk.dts. Also, removed the reserved node from k3-am62x-sk-common.dtsi.
diff --git a/arch/arm64/boot/dts/ti/k3-am625-sk.dts b/arch/arm64/boot/dts/ti/k3-am625-sk.dts index f9b7fa2e8..321ac26d4 100644 --- a/arch/arm64/boot/dts/ti/k3-am625-sk.dts +++ b/arch/arm64/boot/dts/ti/k3-am625-sk.dts @@ -203,6 +203,21 @@ AM62X_IOPAD(0x128, PIN_INPUT, 7) /* (B23) MMC2_SDWP.GPIO0_72 */ }; }; +&mcu_pmx0 { + mcugpio0_pins_default: mcugpio0-default-pins { + pinctrl-single,pins = < + AM62X_MCU_IOPAD(0x003c, PIN_INPUT, 7) /* (E5) MCU_MCAN1_TX.MCU_GPIO0_15 */ + AM62X_MCU_IOPAD(0x0040, PIN_INPUT, 7) /* (D4) MCU_MCAN1_RX.MCU_GPIO0_16 */ + >; + }; +}; + +&mcu_gpio0 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&mcugpio0_pins_default>; +}; + &main_i2c1 { exp1: gpio@22 { compatible = "ti,tca6424"; diff --git a/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi b/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi index b1980b85c..8272322bd 100644 --- a/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi +++ b/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi @@ -580,9 +580,9 @@ dpi1_out: endpoint { /* mcu_gpio0 and mcu_gpio_intr are reserved for mcu firmware usage */ &mcu_gpio0 { - status = "reserved"; + status = "okay"; }; &mcu_gpio_intr { - status = "reserved"; + status = "okay"; };
By default, the MCU GPIOs are set to reserved because its intended use is for the MCU Domain and applications. By setting the status to okay, Linux will claim any MCU Domain GPIOs that are defined in the MCU Pinmux node.
Compile these changes and copy the new DTB file on to the root partition. Follow the instructions to compile the device tree binary in the SDK Documentation: https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/09_02_01_10/exports/docs/linux/Foundational_Components_Kernel_Users_Guide.html
Boot the AM62x device with these new changes and Use the GPIO Linux commands:
root@am62xx-evm:~# gpiodetect
gpiochip0 [4201000.gpio] (24 lines)
gpiochip1 [600000.gpio] (92 lines)
gpiochip2 [601000.gpio] (52 lines)
gpiochip3 [1-0022] (24 lines)
The address for MCU GPIOs is 0x4201000 so gpiochip0 is assigned to the MCU Domain GPIOs. If the [4201000.gpio] does not populate, review the changes made to the device tree.
To toggle the output:
root@am62xx-evm:~# gpioset gpiochip0 15=1 root@am62xx-evm:~# gpioset gpiochip0 16=1 root@am62xx-evm:~# root@am62xx-evm:~# gpioset gpiochip0 15=0 root@am62xx-evm:~# gpioset gpiochip0 16=0
To read the input:
root@am62xx-evm:~# gpioget gpiochip0 15 1 root@am62xx-evm:~# gpioget gpiochip0 16 1
Accessing Main Domain GPIOs from MCU Domain
Software and Hardware Used:
Steps Required:
For the simplest test, we can use the existing GPIO_BLINKING_LED example that comes with the MCU+ SDK. This example can be found <MCU+ SDK Installation Directory>/examples/drivers/gpio/gpio_led_blink/<device>/m4ss0-<freertos/nortos>.
For this demonstration, Main domain's GPIO0_42 will be used since its connected to the User Expansion Header:
Modify the example.sysconfig file
First, review the datasheet to check which pad is needed. GPIO0_42 will be used, so sysconfig will needed to be updated with this information.
Open the example.sysconfig file & change which GPIO is being used. Uncheck 'Use MCU Domain Peripherals.' Then select which Main Domain GPIO Module and the pad that the GPIO comes from.
Build and Load the project
From there, build the project following these instruction: https://software-dl.ti.com/mcu-plus-sdk/esd/AM62X/09_02_01_06/exports/docs/api_guide_am62x/GETTING_STARTED_BUILD.html
Launch target configuration & load the .out file onto the BLAZAR_Cortex_M4F_1. Follow the loading instructions here: https://software-dl.ti.com/mcu-plus-sdk/esd/AM62X/09_02_01_06/exports/docs/api_guide_am62x/CCS_LAUNCH_PAGE.html
When clicking resume on the program, the Main Domain GPIO will toggle for 10 seconds as seen below:
Limitation
When Linux claims a peripheral via the device tree, it will not allow any access to it from another domain. This means two domains are not able to access the same peripheral at the same time and only one application can access a peripheral at one time.
Additional Information
For more information about accessing non-MCU Domain peripherals, see the SDK documentation: https://software-dl.ti.com/mcu-plus-sdk/esd/AM62X/09_02_01_06/exports/docs/api_guide_am62x/MAIN_DOMAIN_PERIPHERAL_FROM_MCU.html
AM62x Multicore Academy, Section about Peripherals: https://dev.ti.com/tirex/explore/node?node=A__AZAVEddCL5eFK1WrnKz45Q__AM62-ACADEMY__uiYMDcq__LATEST
Getting Started with MCU+ SDK: https://software-dl.ti.com/mcu-plus-sdk/esd/AM62X/09_02_01_06/exports/docs/api_guide_am62x/GETTING_STARTED.html
Getting Started with Linux SDK: https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/09_02_01_10/exports/docs/devices/AM62X/linux/Overview_Getting_Started_Guide.html
Data Verification Error Workaround: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1346760/sk-am62-data-verification-error-while-loading-the-program
Example of enabling MCU's MCAN: https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/arch/arm64/boot/dts/ti/k3-am62x-sk-mcan.dtso?h=ti-linux-6.1.y