drivers: regulator: fixed: refactor initialization code.

In some cases, the enable pin may be already enabled by a previous
stage, e.g. bootloader. Therefore, it is not desirable to disable
the pin, as it could cause malfunctioning of the device. Refactor init
procedure so that we pick the right GPIO flags during the first
configuration stage.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
diff --git a/drivers/regulator/regulator_fixed.c b/drivers/regulator/regulator_fixed.c
index 3e12ee4..2811712 100644
--- a/drivers/regulator/regulator_fixed.c
+++ b/drivers/regulator/regulator_fixed.c
@@ -58,6 +58,7 @@
 static int regulator_fixed_init(const struct device *dev)
 {
 	const struct regulator_fixed_config *cfg = dev->config;
+	bool init_enabled;
 	int ret;
 
 	regulator_common_data_init(dev);
@@ -67,21 +68,23 @@
 		return -ENODEV;
 	}
 
-	ret = gpio_pin_configure_dt(&cfg->enable, GPIO_OUTPUT_INACTIVE);
-	if (ret < 0) {
-		return ret;
-	}
+	init_enabled = regulator_common_is_init_enabled(dev);
 
-	ret = regulator_common_init(dev, false);
-	if (ret < 0) {
-		return ret;
-	}
+	if (init_enabled) {
+		ret = gpio_pin_configure_dt(&cfg->enable, GPIO_OUTPUT_ACTIVE);
+		if (ret < 0) {
+			return ret;
+		}
 
-	if (regulator_is_enabled(dev)) {
 		k_busy_wait(cfg->startup_delay_us);
+	} else {
+		ret = gpio_pin_configure_dt(&cfg->enable, GPIO_OUTPUT_INACTIVE);
+		if (ret < 0) {
+			return ret;
+		}
 	}
 
-	return 0;
+	return regulator_common_init(dev, init_enabled);
 }
 
 #define REGULATOR_FIXED_DEFINE(inst)                                           \