Apart from differential signals like USB, MIPI or LVDS, almost all signals of the CPU are multiplexed. So they can serve different purposes. And one of these purposes is GPIO. Other functions depend on the pin. In most cases we use a dedicated function as default. But if you do not need this function, you can use these pins as GPIOs. So for example if you do not need the third or fourth UART port, then you can use these pins as GPIOs instead. Or if you do not need SPI or I2C, then these pins can suit as GPIOs. So the number of GPIOs depends on what other functions you actually need.
Some pins are already defined as GPIOs by us. For example we always provide one or two additional signals in addition to the basic I2C or SPI signals to serve as reset or interrupt. These pins can of course be used as GPIOs, too. Pins 44, 46, 52, 54 are examples for such pins. They are probably the best candidates for your own GPIOs to start with.
Configuration is basically done in the Device Tree. The device tree tells Linux, what devices there are and which pins to use for them. Our default device tree defines all the interfaces that you can see in the hardware documentation. If you do not need some interface or device, then the basic idea is to simply remove those entries from the device tree and configure those pins for GPIOs. For most devices we have already prepared a CONFIG macro that does exactly this. All these macros are defined at the beginning of the device tree. If you don't need a device, simply add two slashes in front of the #define to comment it out. This will disable the device and in most cases, the pins will then automatically fall back to the GPIO setting, which is the default at reset time of the CPU.
Let's do a specific example.
I2C_C provides two signals on pins 40 and 42 of the PicoCore-Connector. You do not need I2C_C and want to use these pins as GPIOs instead. So you edit the device tree file, which is
arch/arm64/boot/dts/F+S/picocoremx8mp.dts
You'll find the following macros near the beginning of the file
- /* I2C */
- /* default CAN_B */
- #define CONFIG_PICOCOREMX8MP_I2C_A
- #define CONFIG_PICOCOREMX8MP_I2C_B
- #define CONFIG_PICOCOREMX8MP_I2C_C
- #define CONFIG_PICOCOREMX8MP_I2C_D
- #define CONFIG_PICOCOREMX8MP_I2C_E
- //#define CONFIG_PICOCOREMX8MP_I2C_D_A71CH
Change the line for I2C_C to:
- //#define CONFIG_PICOCOREMX8MP_I2C_C
Then save the file, rebuild the device tree and store the new device tree on the board. How this is done is shown in the document "Linux on F&S Boards". Now you can use these two pins as GPIOs. The GPIO Reference Card shows, that they are GPIOs number 136 and 137.
Your F&S Support Team