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

**URL:** <https://forums.developer.nvidia.com/t/how-to-match-io-expander-tca9539-gpio-pins/54199>\
**Category:** Jetson TX1\
**Created:** [October 14, 2017, 7:26am UTC](https://forums.developer.nvidia.com/t/how-to-match-io-expander-tca9539-gpio-pins/54199 "2017-10-14T07:26:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![CalmCar](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/calmcar/32/11119_2.png) [@CalmCar](https://forums.developer.nvidia.com/u/CalmCar)\
**Post date:** [October 14, 2017, 7:26am UTC](https://forums.developer.nvidia.com/t/how-to-match-io-expander-tca9539-gpio-pins/54199/1 "2017-10-14T07:26:46Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

**Author:** ![ShaneCCC](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/shaneccc/32/14043_2.png) [@ShaneCCC](https://forums.developer.nvidia.com/u/ShaneCCC)\
**Post date:** [October 16, 2017, 10:13am UTC](https://forums.developer.nvidia.com/t/how-to-match-io-expander-tca9539-gpio-pins/54199/2 "2017-10-16T10:13:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ray0420](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Ray0420](https://forums.developer.nvidia.com/u/Ray0420)\
**Post date:** [November 16, 2017, 10:18am UTC](https://forums.developer.nvidia.com/t/how-to-match-io-expander-tca9539-gpio-pins/54199/3 "2017-11-16T10:18:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![CalmCar](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/calmcar/32/11119_2.png) [@CalmCar](https://forums.developer.nvidia.com/u/CalmCar)\
**Post date:** [November 16, 2017, 11:26am UTC](https://forums.developer.nvidia.com/t/how-to-match-io-expander-tca9539-gpio-pins/54199/4 "2017-11-16T11:26:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ShaneCCC](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/shaneccc/32/14043_2.png) [@ShaneCCC](https://forums.developer.nvidia.com/u/ShaneCCC)\
**Post date:** [November 17, 2017, 3:11am UTC](https://forums.developer.nvidia.com/t/how-to-match-io-expander-tca9539-gpio-pins/54199/5 "2017-11-17T03:11:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ray0420](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Ray0420](https://forums.developer.nvidia.com/u/Ray0420)\
**Post date:** [November 17, 2017, 10:14am UTC](https://forums.developer.nvidia.com/t/how-to-match-io-expander-tca9539-gpio-pins/54199/6 "2017-11-17T10:14:09Z")

</div>

Hi CalmCar & ShaneCCC,

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

Thanks

---

<div class="post-metadata">

**Author:** ![Ray0420](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Ray0420](https://forums.developer.nvidia.com/u/Ray0420)\
**Post date:** [December 6, 2017, 6:50am UTC](https://forums.developer.nvidia.com/t/how-to-match-io-expander-tca9539-gpio-pins/54199/7 "2017-12-06T06:50:32Z")

</div>

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.

```auto
.....................
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

---

<div class="post-metadata">

**Author:** ![ShaneCCC](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/shaneccc/32/14043_2.png) [@ShaneCCC](https://forums.developer.nvidia.com/u/ShaneCCC)\
**Post date:** [December 6, 2017, 7:08am UTC](https://forums.developer.nvidia.com/t/how-to-match-io-expander-tca9539-gpio-pins/54199/8 "2017-12-06T07:08:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![TomNVIDIA](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/tomnvidia/32/14181_2.png) [@TomNVIDIA](https://forums.developer.nvidia.com/u/TomNVIDIA)\
**Post date:** [October 18, 2021, 6:58pm UTC](https://forums.developer.nvidia.com/t/how-to-match-io-expander-tca9539-gpio-pins/54199/9 "2021-10-18T18:58:32Z")

</div>


