How to match io-expander(tca9539) gpio pins?

Hi everybody:

I use a tca9539 io-expander as regulators and gpios.The driver file is ./drivers/gpio/gpio-pca953x.c. When I coding the devece tree,I don’t know how to name the gpio pins.
There are 16 gpio pins in tca9539.P00,P01,P02 … P07,P10,P11,P12 … P17
For example:

surround_cam1_en: regulator@14 {
			compatible = "regulator-fixed-sync";
			reg = <14>;
			regulator-name = "surround_cam1_en";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			enable-active-high;		
		
			gpio = <&tca9539_calmcar_74 ? 1>;
		};

My question:The ? how to match tca9539’s gpio pins?

Best Regards

@CalmCar
The ? is from 0 to 15 to match the pin0 to pin15

Hi CalmCar & ShaneCCC,

Could you control this group of gpio successfully?
We also went to use such gpio for development, but some gpio seems couldn’t use such like gpio1 ~ gpio3(we modify the device tree to aliases the gpio start from gpio400, so in our system the gpio mapping are gpio400 ~ gpio415)
When I control directly from command line as below, it shows message that “Device or resource busy”
Did it means that TX1 also use some of the gpio?(I just know the HDMI power is control by this group of gpio)

echo 401 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio401/direction

Thanks

@Ray0420
Yes,I can control the pins.But I control it in kernel drivers.not user zone.

“Device or resource busy” means some other driver acquire this pin and not release.

Hi CalmCar & ShaneCCC,

Thanks for your information.
Currently, we are still checking which device or function causes the busy condition.

Thanks

Hi CalmCar & ShaneCCC,

I found the reason why the “Device or resource busy” issue happen.
When I check the device tree file “tegra210-jetson-cv-power-tree-p2597-2180-a00.dtsi”.
Some gpio such as #1/#2/#3/#4/#7/#9/#12/#13 are used as fan or other regulator function.
I didn’t find the circuit design on my carrier board.
What functions are needed from such regulator for TX1 module?
Actually, we need such gpio generating from this gpio expander.
If TX1 module didn’t use such gpio for any function, could I modify the device tree for our design?
Below are some of the coding.

.....................
vdd_fan: regulator@13 {
			gpio = <&tca9539_74 4 0>;
		};

		en_vdd_ts_1v8: regulator@201 {
			compatible = "regulator-fixed-sync";
			reg = <201>;
			regulator-name = "en-vdd-ts-1v8";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			gpio = <&tca9539_74 1 1>;
			enable-active-high;
		};

		en_vdd_ts_hv_3v3: regulator@202 {
			compatible = "regulator-fixed-sync";
			reg = <202>;
			regulator-name = "en-vdd-ts-hv-3v3";
			regulator-min-microvolt = <3300000>;
			regulator-max-microvolt = <3300000>;
			gpio = <&tca9539_74 2 1>;
			enable-active-high;
		};

		en_avdd_disp_3v3: regulator@203 {
			compatible = "regulator-fixed-sync";
			reg = <203>;
			regulator-name = "en-vdd-disp-3v3";
			regulator-min-microvolt = <3300000>;
			regulator-max-microvolt = <3300000>;
			regulator-boot-on;
			gpio = <&tca9539_74 3 1>;
			enable-active-high;
		};


		en_mdm_pwr_3v7: regulator@204 {
			compatible = "regulator-fixed-sync";
			reg = <204>;
			regulator-name = "en-mdm-pwr-3v7";
			regulator-min-microvol = <3700000>;
			regulator-max-microvol = <3700000>;
			gpio = <&tca9539_74 7 1>;
			enable-active-high;
		};
......................

Thanks

@Ray
If your carrier didn’t design as reference carrier board you need figure out the different and modify it to correct.