Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18a22c43 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "leds-gpio : Enable ldo at leds-gpio.c when booting"

parents 2b0df1cd 7ecf3128
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -172,6 +172,8 @@
				&wifi_led_green_default
				&wifi_led_red_default>;
		status = "okay";
		vdd_ldo_1-supply = <&pm660_l15>;
		vdd_ldo_2-supply = <&pm660_l17>;

		led@1 {
			label = "PWR_LED:red:106";
+71 −4
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/slab.h>
#include <linux/regulator/consumer.h>

struct gpio_led_data {
	struct led_classdev cdev;
@@ -144,6 +145,7 @@ static int create_gpio_led(const struct gpio_led *template,

struct gpio_leds_priv {
	int num_leds;
	struct regulator *vdd_ldo_1, *vdd_ldo_2;
	struct gpio_led_data leds[];
};

@@ -158,8 +160,7 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
	struct device *dev = &pdev->dev;
	struct fwnode_handle *child;
	struct gpio_leds_priv *priv;
	int count, ret;

	int count, ret, error;
	count = device_get_child_node_count(dev);
	if (!count)
		return ERR_PTR(-ENODEV);
@@ -214,7 +215,28 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
		led_dat->cdev.dev->of_node = np;
		priv->num_leds++;
	}

	priv->vdd_ldo_1 = regulator_get(&pdev->dev, "vdd_ldo_1");
	if (IS_ERR(priv->vdd_ldo_1)) {
		error = PTR_ERR(priv->vdd_ldo_1);
		pr_err("%s: regulator get failed vdd_ldo_1 rc=%d\n",
			__func__, error);
	}
	ret = regulator_enable(priv->vdd_ldo_1);
	if (ret) {
		pr_err("%s: Regulator vdd_ldo_1 enable failed rc=%d\n",
			__func__, ret);
	}
	priv->vdd_ldo_2 = regulator_get(&pdev->dev, "vdd_ldo_2");
	if (IS_ERR(priv->vdd_ldo_2)) {
		error = PTR_ERR(priv->vdd_ldo_2);
		pr_err("%s: regulator get failed vdd_ldo_2 rc=%d\n",
			__func__, error);
	}
	ret = regulator_enable(priv->vdd_ldo_2);
	if (ret) {
		pr_err("%s: Regulator vdd_ldo_2 enable failed rc=%d\n",
			__func__, ret);
	}
	return priv;
}

@@ -230,7 +252,6 @@ static int gpio_led_probe(struct platform_device *pdev)
	struct gpio_led_platform_data *pdata = dev_get_platdata(&pdev->dev);
	struct gpio_leds_priv *priv;
	int i, ret = 0;

	if (pdata && pdata->num_leds) {
		priv = devm_kzalloc(&pdev->dev,
				sizeof_gpio_leds_priv(pdata->num_leds),
@@ -269,6 +290,50 @@ static void gpio_led_shutdown(struct platform_device *pdev)
	}
}

static int gpio_led_suspend(struct platform_device *pdev, pm_message_t message)
{
	int ret;
	struct gpio_leds_priv *priv = platform_get_drvdata(pdev);

	if (priv->vdd_ldo_1) {
		ret = regulator_disable(priv->vdd_ldo_1);
		if (ret) {
			pr_err("%s: Regulator vdd_ldo_1 disable failed rc=%d\n",
				__func__, ret);
			return ret;
		}
	}
	if (priv->vdd_ldo_2) {
		ret = regulator_disable(priv->vdd_ldo_2);
		if (ret) {
			pr_err("%s: Regulator vdd_ldo_2 disable failed rc=%d\n",
				__func__, ret);
			return ret;
		}
	}
	return 0;
}

static int gpio_led_resume(struct platform_device *pdev)
{
	int ret;
	struct gpio_leds_priv *priv = platform_get_drvdata(pdev);

	ret = regulator_enable(priv->vdd_ldo_1);
	if (ret) {
		pr_err("%s: Regulator vdd_ldo_1 enable failed rc=%d\n",
			__func__, ret);
		return ret;
	}
	ret = regulator_enable(priv->vdd_ldo_2);
	if (ret) {
		pr_err("%s: Regulator vdd_ldo_2 enable failed rc=%d\n",
			__func__, ret);
		return ret;
	}
	return 0;
}

static struct platform_driver gpio_led_driver = {
	.probe		= gpio_led_probe,
	.shutdown	= gpio_led_shutdown,
@@ -276,6 +341,8 @@ static struct platform_driver gpio_led_driver = {
		.name	= "leds-gpio",
		.of_match_table = of_gpio_leds_match,
	},
	.suspend = gpio_led_suspend,
	.resume = gpio_led_resume,
};

module_platform_driver(gpio_led_driver);