@machangbao
I think your tool is totally wrong.

You cannot assume that the base value of GPIO1 on the chip is 0, or that the base value of GPIO2 is 32. This is assigned by the Linux driver, not determined by the chip itself. You can test that the base value of GPIO1 on iMX8MM and iMX93 is not 0. Your tool will fail.
On iMX6 GPIO1, the base is 0, but this is a coincidence. And it should be done this way on 32-bit ARM Linux, but not on 64-bit ARM Linux such as i.MX8MM.
The calculation formula in the Linux documentation provided by @meketok @ is correct. It is based on the base value.
(N to N + ngpio - 1), in other words, you can not assume here base is 0 for GPIO1, base is 32 for GPIO2.
/sys/class/gpio/gpiochipN/
"base" ...
same as N, the first GPIO managed by this chip
"label" ...
provided for diagnostics (not always unique)
"ngpio" ...
how many GPIOs this manages (N to N + ngpio - 1)
I have replied to @Harvey021 . you are wrong.