Hi @leonardo.costa.tx
Thanks for the guidance!
Based on your suggestion, we have repurposed the SD/MMC1 pins as GPIOs by updating the device tree overlay accordingly. Below is a summary of the changes we made:
Disabled Unused Interfaces
We disabled the unused peripherals like CAN, UARTs, USB, SD, and I2C as per our hardware requirements.
Pinmux Configuration Added
In the &main_pmx0 node, we added new pinmux groups to switch the SD/MMC1, QSPI1_DQS, and I2C4 (CSI) pins to GPIO mode using mode 7.
GPIO Hogs Added
We used the gpio-hog mechanism to initialize and configure these GPIOs as inputs with custom line-name labels for easy identification via sysfs or gpiod.
After these changes my overlay looks like this
to create overlay i followed this link
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
* Copyright 2023 Toradex
*/
/dts-v1/;
/plugin/;
#include <dt-bindings/leds/common.h>
#include <dt-bindings/gpio/gpio.h>
#include "k3-pinctrl.h"
/ {
compatible = "toradex,verdin-am62";
};
/* Disable Verdin CAN_1 */
&main_mcan0 {
status = "disabled";
};
/* Disable Verdin CAN_2 */
&mcu_mcan0 {
status = "disabled";
};
/* Verdin PWM_3 DSI */
&epwm1 {
status = "disabled";
};
/* Verdin I2C_2 DSI */
&main_i2c2 {
status = "disabled";
};
/* Verdin UART_1 */
&main_uart1 {
status = "disabled";
};
/* Verdin UART_2 */
&wkup_uart0 {
status = "disabled";
};
/* Verdin UART_4 */
&mcu_uart0 {
status = "disabled";
};
/* Verdin USB_1 */
&usbss0 {
status = "disabled";
};
&usb0 {
status = "disabled";
};
/* Verdin SD_1 */
&sdhci1 {
status = "disabled";
};
/* Verdin CTRL_WAKE1_MICO# */
&verdin_gpio_keys {
status = "disabled";
};
/* Verdin PCIE_1_RESET# */
&verdin_pcie_1_reset_hog {
status = "disabled";
};
/* Verdin I2C_4 CSI */
&main_i2c3 {
status = "disabled";
};
/* Pinmux for repurposing MMC1 pins to GPIO */
&main_pmx0 {
pinctrl_gpio_sd_repurpose: sd-gpio-pins {
pinctrl-single,pins = <
AM62X_IOPAD(0x23c, PIN_INPUT, 7) /* MMC1_CMD --> GPIO1_15 (47) */
AM62X_IOPAD(0x234, PIN_INPUT, 7) /* MMC1_CLK --> GPIO1_14 (46) */
AM62X_IOPAD(0x230, PIN_INPUT, 7) /* MMC1_DAT0 --> GPIO1_13 (45) */
AM62X_IOPAD(0x22c, PIN_INPUT, 7) /* MMC1_DAT1 --> GPIO1_12 (44) */
AM62X_IOPAD(0x228, PIN_INPUT, 7) /* MMC1_DAT2 --> GPIO1_11 (43) */
AM62X_IOPAD(0x224, PIN_INPUT, 7) /* MMC1_DAT3 --> GPIO1_10 (42) */
>;
};
/* Repurpose QSPI1_DQS pin */
pinctrl_qspi1_dqs_gpio: qspi1-dqs-gpio {
pinctrl-single,pins = <
AM62X_IOPAD(0x01c0, PIN_INPUT, 7) /* GPIO1_18, SODIMM 66 */
>;
};
/* Repurpose I2C4 (CSI) pins */
pinctrl_i2c3_gpio: i2c3-gpio-pins {
pinctrl-single,pins = <
AM62X_IOPAD(0x01d4, PIN_INPUT, 7) /* GPIO1_23, SODIMM 93 */
>;
};
};
/* GPIO1 hog for repurposed MMC1 as input */
&main_gpio1 {
gpio-line-names =
"SD1_CMD", "SD1_CLK", "SD1_DAT0", "SD1_DAT1",
"SD1_DAT2", "SD1_DAT3", "SODIMM_66", "SODIMM_93";
gpio-hog@0 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpio_sd_repurpose>;
gpios = <47 GPIO_ACTIVE_HIGH>, <46 GPIO_ACTIVE_HIGH>,
<45 GPIO_ACTIVE_HIGH>, <44 GPIO_ACTIVE_HIGH>,
<43 GPIO_ACTIVE_HIGH>, <42 GPIO_ACTIVE_HIGH>;
input;
line-name = "repurposed-sd1-gpios";
};
gpio-hog@1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_qspi1_dqs_gpio>;
gpios = <18 GPIO_ACTIVE_HIGH>;
input;
line-name = "repurposed-QSPI1-gpios";
};
gpio-hog@2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c3_gpio>;
gpios = <23 GPIO_ACTIVE_HIGH>;
input;
line-name = "repurposed-I2C4-gpios";
};
};
After deploying the overlay and rebooting, the GPIOs show up correctly under /sys/class/gpio/ and in gpioinfo but its in gpiochip3 i menrioned it somwhere
gpiochip3 - 52 lines:
line 0: "SD1_CMD" input
line 1: "SD1_CLK" input
line 2: "SD1_DAT0" input
line 3: "SD1_DAT1" input
line 4: "SD1_DAT2" input
line 5: "SD1_DAT3" input
line 6: "SODIMM_66" input
line 7: "SODIMM_93" input
line 8: unnamed input
line 9: unnamed input
line 10: unnamed input
line 11: unnamed input
line 12: unnamed input
Also, I want to configure some GPIOs as outputs. Even though I’ve specified them as outputs in the device tree, some of the pins are still being treated as inputs. For the ones that are recognized as outputs, they are automatically claimed by consumers like output consumer="red:debug-2". When I try to access those GPIOs via /sys/class/gpio, I get a “resource busy” error.
Kindly help me with this issue like where exactly i am making mistake
now i want to configure these node as GPIO output
/* Repurpose MCASP1 (I2S2) pins */
pinctrl_mcasp1_gpio: mcasp1-gpio-pins {
pinctrl-single,pins = <
// AM62X_IOPAD(0x0090, PIN_OUTPUT, 7) /* MCASP1_ACLKX --> GPIO0_9, SODIMM 42 (commented out) */
AM62X_IOPAD(0x0098, PIN_OUTPUT, 7) /* MCASP1_AFSX --> GPIO0_11, SODIMM 44 */
AM62X_IOPAD(0x008c, PIN_OUTPUT, 7) /* MCASP1_AXR0 --> GPIO0_8, SODIMM 46 */
AM62X_IOPAD(0x0088, PIN_OUTPUT, 7) /* MCASP1_AXR1 --> GPIO0_7, SODIMM 48 */
>;
};
/* Repurpose OSPI0 pins */
pinctrl_ospi0_gpio: ospi0-gpio-pins {
pinctrl-single,pins = <
AM62X_IOPAD(0x0000, PIN_OUTPUT, 7) /* OSPI0_CLK --> GPIO0_0, SODIMM 52 */
AM62X_IOPAD(0x002c, PIN_OUTPUT, 7) /* OSPI0_CSn0 --> GPIO0_11, SODIMM 54 */
AM62X_IOPAD(0x0030, PIN_OUTPUT, 7) /* OSPI0_CSn1 --> GPIO0_12, SODIMM 64 */
AM62X_IOPAD(0x000c, PIN_INPUT, 7) /* OSPI0_D0 --> GPIO0_3, SODIMM 56 */
AM62X_IOPAD(0x0010, PIN_INPUT, 7) /* OSPI0_D1 --> GPIO0_4, SODIMM 58 */
AM62X_IOPAD(0x0014, PIN_INPUT, 7) /* OSPI0_D2 --> GPIO0_5, SODIMM 60 */
AM62X_IOPAD(0x0018, PIN_INPUT, 7) /* OSPI0_D3 --> GPIO0_6, SODIMM 62 */
>;
};
Best regards,
Uday