Modification pins on the Device Tree

Dear Support,

I hope all goes well for you.

We intend to use QSPI_1_CLK for simple GPIO output, so I was wondering how to change the feature of this pin to GPIO. Is it listed in the device tree, and do I need to change it there? Is there a tutorial you can recommend? I found this page, but it is quite difficult for me.
When I look for ls /boot/overlays noting in this folder, [ls: cannot access ‘/boot/overlays’: No such file or directory]

QSPI_1_CLK info is below:
gpiochip2 - 32 lines:
line 0: “SODIMM_52” unused input active-high

Thank you so much for your help.

Best regards,
Mehrdad

Hello @Mehrdad ,

When I look for ls /boot/overlays noting in this folder, [ls: cannot access ‘/boot/overlays’: No such file or directory]

Most probably you are using Torizon, and not a BSP image. In that case you have to follow the specific instructions for Torizon.

Best regards,
Josep

Hi @josep.tx ,
Thank you for your response.
The page that you send is related to unpacking the image, building the image, and checking out the image. Modifying and changing one-pin behavior is not a straightforward process.
Best regards,
Mehrdad

Hi @Mehrdad !

We have the Device Tree Customization | Toradex Developer Center article which gives an overview of the device tree.

Also, we have the Device Tree Customization Examples | Toradex Developer Center article with some examples.

This is one good PDF from NXP about device trees: https://www.nxp.com/docs/en/application-note/AN5125.pdf

And one interesting NXP Community thread about pin mux and pad: Solved: Can anybody explain me the contains of linux file ... - NXP Community

Do those help you?

Best regards,

Hi @josep.tx and @henrique.tx ,

Thank you so much for the document.

Using a non-wifi Verdin board imx8mini, I want to use the QSPI_1_CLK for simple GPIO for BLINKING LED.

image

I did these:

First, disable the QSPI_1 in the imx8mm-verdin-dahlia.dtsi

/* Verdin QSPI_1 */
&flexspi {
	status = "disabled";
};

Second, add a node like this below and I named pinctrl_gpio11 and called gpio11grp

	pinctrl_gpio11: gpio11grp {
		fsl,pins = <
			MX8MM_IOMUXC_NAND_ALE_QSPI_A_SCLK		0x106	/* SODIMM 52 */
		>;
	};

Third, add the pinctrl_gpio11 to the iomuxc

&iomuxc {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_gpio1>, <&pinctrl_gpio2>,
		    <&pinctrl_gpio3>, <&pinctrl_gpio4>,
		    <&pinctrl_gpio7>, <&pinctrl_gpio8>,<&pinctrl_gpio11>,
		    <&pinctrl_gpio_hog1>, <&pinctrl_gpio_hog2>, <&pinctrl_gpio_hog3>,
		    <&pinctrl_pmic_tpm_ena>;

I did this but after testing it did not work and I could not blink the LED :frowning:

Best regards,
Mehrdad

Hi @Mehrdad!

Changing the name of the node to gpio11grp actually doesn’t have any effect on the hardware functionality. The name of the node (gpio11grp) and its label (pinctrl_gpio11) are there mainly for organization purposes in this case.

The pin muxing is actually defined in the line below by the MX8MM_IOMUXC_NAND_ALE_QSPI_A_SCLK macro.

Please check this other Pin Multiplexing - Changing Pin Functionalities in the Linux Device Tree | Toradex Developer Center article

Best regards,

Hi @henrique.tx ,

Thank you so much for your help,

I removed the pinctrl_gpio11 and it works.:slight_smile:

As far as I understand in the imx8mm-verdin-dahlia.dtsi file if the status changes to “disabled” no need to create pin control for the new gpio and by default, it changes to GPIO.

Thank you so much for your support. Also, I modified the UART_2 to SPI_2 with the function of ecspi1 and was wondering if is it correct?

in the imx8mm-verdin-dahlia.dtsi file:

  /* Verdin SPI_2_ TODO_MS */

&ecspi1 {
	status = "okay";

	spidev10: spidev@0 {
		compatible = "toradex,evalspi";
		reg = <0>;
		spi-max-frequency = <10000000>;
		status = "okay";
	};
};

and

/* Verdin UART_2 */
&uart3 {
	status = "disabled";
};

in the imx8mm-verdin.dtsi:
add lines below and set the pinctrl-0 to pinctrl_uart3 .

/* Verdin SPI_2 TODO_MS */
&ecspi1 {
	#address-cells = <1>;
	#size-cells = <0>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_uart3 >;
	cs-gpios = <&gpio5 9 GPIO_ACTIVE_LOW>;
};

and in the ssh panel, I have

  torizon@verdin-imx8mm-07022050:~$ ls /dev/sp*
  /dev/spidev0.0  /dev/spidev1.0

before modification was:

torizon@verdin-imx8mm-07022050:~$ ls /dev/sp*
/dev/spidev1.0

For SPI_1 in VS code added: static const char *device = “/dev/verdin-spi-cs0”;

if the process is correct for the device what should I add for SPI_2 in the VS code?

Thank you for taking the time.

Best regards,
Mehrdad

1 Like

Dear Toradex Support,

I think I found my question below
if the process is correct for the device what should I add for SPI_2 in the VS code?
I should create a Create Symbolic Links and I did make a spisample with full permission

image

and added the /dev/spisample to the device on the torizon configuration
but when I run the code I have an error

can’t open device: No such file or directory
image

Could you please let me know if there is something should I consider in the device tree?

Thanks for taking your time.

Best regards,
Mehrdad