소스 검색

regulator: fixed: dt: support for input supply

Add support for input supply in DT parsing of node.
The input supply will be provided by the property
"vin-supply" in the regulator node.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Laxman Dewangan 13 년 전
부모
커밋
6be5bfc3bf
3개의 변경된 파일22개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 0
      Documentation/devicetree/bindings/regulator/fixed-regulator.txt
  2. 18 1
      drivers/regulator/fixed.c
  3. 2 0
      include/linux/regulator/fixed.h

+ 2 - 0
Documentation/devicetree/bindings/regulator/fixed-regulator.txt

@@ -10,6 +10,7 @@ Optional properties:
 If this property is missing, the default assumed is Active low.
 If this property is missing, the default assumed is Active low.
 - gpio-open-drain: GPIO is open drain type.
 - gpio-open-drain: GPIO is open drain type.
   If this property is missing then default assumption is false.
   If this property is missing then default assumption is false.
+-vin-supply: Input supply name.
 
 
 Any property defined as part of the core regulator
 Any property defined as part of the core regulator
 binding, defined in regulator.txt, can also be used.
 binding, defined in regulator.txt, can also be used.
@@ -29,4 +30,5 @@ Example:
 		enable-active-high;
 		enable-active-high;
 		regulator-boot-on;
 		regulator-boot-on;
 		gpio-open-drain;
 		gpio-open-drain;
+		vin-supply = <&parent_reg>;
 	};
 	};

+ 18 - 1
drivers/regulator/fixed.c

@@ -102,6 +102,9 @@ of_get_fixed_voltage_config(struct device *dev)
 	if (of_find_property(np, "gpio-open-drain", NULL))
 	if (of_find_property(np, "gpio-open-drain", NULL))
 		config->gpio_is_open_drain = true;
 		config->gpio_is_open_drain = true;
 
 
+	if (of_find_property(np, "vin-supply", NULL))
+		config->input_supply = "vin";
+
 	return config;
 	return config;
 }
 }
 
 
@@ -169,6 +172,17 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
 
 
 	drvdata->desc.enable_time = config->startup_delay;
 	drvdata->desc.enable_time = config->startup_delay;
 
 
+	if (config->input_supply) {
+		drvdata->desc.supply_name = kstrdup(config->input_supply,
+							GFP_KERNEL);
+		if (!drvdata->desc.supply_name) {
+			dev_err(&pdev->dev,
+				"Failed to allocate input supply\n");
+			ret = -ENOMEM;
+			goto err_name;
+		}
+	}
+
 	if (config->microvolts)
 	if (config->microvolts)
 		drvdata->desc.n_voltages = 1;
 		drvdata->desc.n_voltages = 1;
 
 
@@ -202,7 +216,7 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
 	if (IS_ERR(drvdata->dev)) {
 	if (IS_ERR(drvdata->dev)) {
 		ret = PTR_ERR(drvdata->dev);
 		ret = PTR_ERR(drvdata->dev);
 		dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
 		dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
-		goto err_name;
+		goto err_input;
 	}
 	}
 
 
 	platform_set_drvdata(pdev, drvdata);
 	platform_set_drvdata(pdev, drvdata);
@@ -212,6 +226,8 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
 
 
 	return 0;
 	return 0;
 
 
+err_input:
+	kfree(drvdata->desc.supply_name);
 err_name:
 err_name:
 	kfree(drvdata->desc.name);
 	kfree(drvdata->desc.name);
 err:
 err:
@@ -223,6 +239,7 @@ static int __devexit reg_fixed_voltage_remove(struct platform_device *pdev)
 	struct fixed_voltage_data *drvdata = platform_get_drvdata(pdev);
 	struct fixed_voltage_data *drvdata = platform_get_drvdata(pdev);
 
 
 	regulator_unregister(drvdata->dev);
 	regulator_unregister(drvdata->dev);
+	kfree(drvdata->desc.supply_name);
 	kfree(drvdata->desc.name);
 	kfree(drvdata->desc.name);
 
 
 	return 0;
 	return 0;

+ 2 - 0
include/linux/regulator/fixed.h

@@ -22,6 +22,7 @@ struct regulator_init_data;
 /**
 /**
  * struct fixed_voltage_config - fixed_voltage_config structure
  * struct fixed_voltage_config - fixed_voltage_config structure
  * @supply_name:	Name of the regulator supply
  * @supply_name:	Name of the regulator supply
+ * @input_supply:	Name of the input regulator supply
  * @microvolts:		Output voltage of regulator
  * @microvolts:		Output voltage of regulator
  * @gpio:		GPIO to use for enable control
  * @gpio:		GPIO to use for enable control
  * 			set to -EINVAL if not used
  * 			set to -EINVAL if not used
@@ -46,6 +47,7 @@ struct regulator_init_data;
  */
  */
 struct fixed_voltage_config {
 struct fixed_voltage_config {
 	const char *supply_name;
 	const char *supply_name;
+	const char *input_supply;
 	int microvolts;
 	int microvolts;
 	int gpio;
 	int gpio;
 	unsigned startup_delay;
 	unsigned startup_delay;