Define new GPIO Pin for SIM Selection

Hi,

I have 1 USIM at SLOT1 and (1 ESIM + 1 Phy SIM) at SLOT2.

I am using '‘AT+QUIMSLOT’ to select the SIM SLOT and a GPIO 421 line to select the eSIM or Physical SIM in that slot. However, the GPIO line is not defined in DTS yet, I must create it manually every time I want to set the value (like the code below).

I want to have that GPIO permamently defined in DTS, so where and how do I add the devicetree’s section for that GPIO in file sdxbaagha.dtsi for this purpose?

if [ ! -d "/sys/class/gpio/gpio421" ]; then
    echo 421 > /sys/class/gpio/export
    echo out > /sys/class/gpio/gpio421/direction
fi

atcmd 'AT+QUIMSLOT=2'
echo 0 > /sys/class/gpio/gpio421/value

BR
MEQ

I have a suggestion, you can write a chardev device driver yourself, create a /dev/gpio421.

Normally even for Android, we would add such

echo 421 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio421/direction

in the init.rc. It is better to add it in the init script.

Thanks Bean.Wang-Q.

I know that init script is one of many ways to do it.

Can you share me the reason why don’t we make the changes on the device tree for this purpose?

MEQ

If you only change the device tree it won’t work as you expected.

There must be some drivers that use the settings in the DTS,

Yes, I know that we must use the GPIO in another script/driver. The main purpose of that change is to persist the GPIO in the FW.

It means the DTS change is possible, right? Do you have any guide for DTS change?

BR
MEQ