drivers: sensor: vl53l0x: fix XSHUT pin as active low

Also utilises gpio_pin_configure_dt() API to configure and set pin
state at the same time.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
diff --git a/boards/arm/b_l4s5i_iot01a/b_l4s5i_iot01a.dts b/boards/arm/b_l4s5i_iot01a/b_l4s5i_iot01a.dts
index 1a010e7..210b5a2 100644
--- a/boards/arm/b_l4s5i_iot01a/b_l4s5i_iot01a.dts
+++ b/boards/arm/b_l4s5i_iot01a/b_l4s5i_iot01a.dts
@@ -130,7 +130,7 @@
 	vl53l0x@29 {
 		compatible = "st,vl53l0x";
 		reg = <0x29>;
-		xshut-gpios = <&gpioc 6 GPIO_ACTIVE_HIGH>;
+		xshut-gpios = <&gpioc 6 GPIO_ACTIVE_LOW>;
 	};
 };
 
diff --git a/boards/arm/disco_l475_iot1/disco_l475_iot1.dts b/boards/arm/disco_l475_iot1/disco_l475_iot1.dts
index 13bceeb..c4f9273 100644
--- a/boards/arm/disco_l475_iot1/disco_l475_iot1.dts
+++ b/boards/arm/disco_l475_iot1/disco_l475_iot1.dts
@@ -163,7 +163,7 @@
 	vl53l0x@29 {
 		compatible = "st,vl53l0x";
 		reg = <0x29>;
-		xshut-gpios = <&gpioc 6 GPIO_ACTIVE_HIGH>;
+		xshut-gpios = <&gpioc 6 GPIO_ACTIVE_LOW>;
 	};
 };
 
diff --git a/boards/shields/x_nucleo_53l0a1/x_nucleo_53l0a1.overlay b/boards/shields/x_nucleo_53l0a1/x_nucleo_53l0a1.overlay
index 781e921..9af8031 100644
--- a/boards/shields/x_nucleo_53l0a1/x_nucleo_53l0a1.overlay
+++ b/boards/shields/x_nucleo_53l0a1/x_nucleo_53l0a1.overlay
@@ -23,18 +23,18 @@
 	vl53l0x_c_x_nucleo_53l0a1: vl53l0x@30 {
 		compatible = "st,vl53l0x";
 		reg = <0x30>;
-		xshut-gpios = <&expander1_x_nucleo_53l0a1 15 0>;
+		xshut-gpios = <&expander1_x_nucleo_53l0a1 15 GPIO_ACTIVE_LOW>;
 	};
 
 	/* Satellites optional sensors */
 	vl53l0x_l_x_nucleo_53l0a1: vl53l0x@31 {
 		compatible = "st,vl53l0x";
 		reg = <0x31>;
-		xshut-gpios = <&expander2_x_nucleo_53l0a1 14 0>;
+		xshut-gpios = <&expander2_x_nucleo_53l0a1 14 GPIO_ACTIVE_LOW>;
 	};
 	vl53l0x_r_x_nucleo_53l0a1: vl53l0x@32 {
 		compatible = "st,vl53l0x";
 		reg = <0x32>;
-		xshut-gpios = <&expander2_x_nucleo_53l0a1 15 0>;
+		xshut-gpios = <&expander2_x_nucleo_53l0a1 15 GPIO_ACTIVE_LOW>;
 	};
 };
diff --git a/drivers/sensor/vl53l0x/vl53l0x.c b/drivers/sensor/vl53l0x/vl53l0x.c
index ff368df..71a6c85 100644
--- a/drivers/sensor/vl53l0x/vl53l0x.c
+++ b/drivers/sensor/vl53l0x/vl53l0x.c
@@ -171,11 +171,10 @@
 
 	LOG_DBG("[%s] Starting", dev->name);
 
-	/* Pull XSHUT high to start the sensor */
 	if (config->xshut.port) {
-		r = gpio_pin_set_dt(&config->xshut, 1);
+		r = gpio_pin_configure_dt(&config->xshut, GPIO_OUTPUT_INACTIVE);
 		if (r < 0) {
-			LOG_ERR("[%s] Unable to set XSHUT gpio (error %d)",
+			LOG_ERR("[%s] Unable to inactivate XSHUT: %d",
 				dev->name, r);
 			return -EIO;
 		}
@@ -326,17 +325,12 @@
 	}
 #endif
 
-	if (config->xshut.port) {
-		r = gpio_pin_configure_dt(&config->xshut, GPIO_OUTPUT);
-		if (r < 0) {
-			LOG_ERR("[%s] Unable to configure GPIO as output",
-				dev->name);
-		}
-	}
-
 #ifdef CONFIG_VL53L0X_RECONFIGURE_ADDRESS
-	/* Pull XSHUT low to shut down the sensor for now */
-	r = gpio_pin_set_dt(&config->xshut, 0);
+	/*
+	 * Shutdown all vl53l0x sensors so at each sensor's 1st fetch call
+	 * they can be enabled one at a time and programmed with their address.
+	 */
+	r = gpio_pin_configure_dt(&config->xshut, GPIO_OUTPUT_ACTIVE);
 	if (r < 0) {
 		LOG_ERR("[%s] Unable to shutdown sensor", dev->name);
 		return -EIO;
diff --git a/dts/bindings/sensor/st,vl53l0x.yaml b/dts/bindings/sensor/st,vl53l0x.yaml
index 68184e8..6797eac 100644
--- a/dts/bindings/sensor/st,vl53l0x.yaml
+++ b/dts/bindings/sensor/st,vl53l0x.yaml
@@ -10,3 +10,5 @@
 properties:
   xshut-gpios:
     type: phandle-array
+    description: |
+      Xshutdown pin, Active LOW.