Lines Matching +full:gpio +full:- +full:config
9 * Roger Quadros <ext-roger.quadros@nokia.com>
17 * non-controllable regulators, as well as for allowing testing on
27 #include <linux/gpio.h>
41 * of_get_fixed_voltage_config - extract fixed_voltage_config structure info
53 struct fixed_voltage_config *config; in of_get_fixed_voltage_config() local
54 struct device_node *np = dev->of_node; in of_get_fixed_voltage_config()
57 config = devm_kzalloc(dev, sizeof(struct fixed_voltage_config), in of_get_fixed_voltage_config()
59 if (!config) in of_get_fixed_voltage_config()
60 return ERR_PTR(-ENOMEM); in of_get_fixed_voltage_config()
62 config->init_data = of_get_regulator_init_data(dev, dev->of_node, desc); in of_get_fixed_voltage_config()
63 if (!config->init_data) in of_get_fixed_voltage_config()
64 return ERR_PTR(-EINVAL); in of_get_fixed_voltage_config()
66 init_data = config->init_data; in of_get_fixed_voltage_config()
67 init_data->constraints.apply_uV = 0; in of_get_fixed_voltage_config()
69 config->supply_name = init_data->constraints.name; in of_get_fixed_voltage_config()
70 if (init_data->constraints.min_uV == init_data->constraints.max_uV) { in of_get_fixed_voltage_config()
71 config->microvolts = init_data->constraints.min_uV; in of_get_fixed_voltage_config()
75 return ERR_PTR(-EINVAL); in of_get_fixed_voltage_config()
78 if (init_data->constraints.boot_on) in of_get_fixed_voltage_config()
79 config->enabled_at_boot = true; in of_get_fixed_voltage_config()
81 config->gpio = of_get_named_gpio(np, "gpio", 0); in of_get_fixed_voltage_config()
82 if ((config->gpio < 0) && (config->gpio != -ENOENT)) in of_get_fixed_voltage_config()
83 return ERR_PTR(config->gpio); in of_get_fixed_voltage_config()
85 of_property_read_u32(np, "startup-delay-us", &config->startup_delay); in of_get_fixed_voltage_config()
87 config->enable_high = of_property_read_bool(np, "enable-active-high"); in of_get_fixed_voltage_config()
88 config->gpio_is_open_drain = of_property_read_bool(np, in of_get_fixed_voltage_config()
89 "gpio-open-drain"); in of_get_fixed_voltage_config()
91 if (of_find_property(np, "vin-supply", NULL)) in of_get_fixed_voltage_config()
92 config->input_supply = "vin"; in of_get_fixed_voltage_config()
94 return config; in of_get_fixed_voltage_config()
102 struct fixed_voltage_config *config; in reg_fixed_voltage_probe() local
107 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), in reg_fixed_voltage_probe()
110 return -ENOMEM; in reg_fixed_voltage_probe()
112 if (pdev->dev.of_node) { in reg_fixed_voltage_probe()
113 config = of_get_fixed_voltage_config(&pdev->dev, in reg_fixed_voltage_probe()
114 &drvdata->desc); in reg_fixed_voltage_probe()
115 if (IS_ERR(config)) in reg_fixed_voltage_probe()
116 return PTR_ERR(config); in reg_fixed_voltage_probe()
118 config = dev_get_platdata(&pdev->dev); in reg_fixed_voltage_probe()
121 if (!config) in reg_fixed_voltage_probe()
122 return -ENOMEM; in reg_fixed_voltage_probe()
124 drvdata->desc.name = devm_kstrdup(&pdev->dev, in reg_fixed_voltage_probe()
125 config->supply_name, in reg_fixed_voltage_probe()
127 if (drvdata->desc.name == NULL) { in reg_fixed_voltage_probe()
128 dev_err(&pdev->dev, "Failed to allocate supply name\n"); in reg_fixed_voltage_probe()
129 return -ENOMEM; in reg_fixed_voltage_probe()
131 drvdata->desc.type = REGULATOR_VOLTAGE; in reg_fixed_voltage_probe()
132 drvdata->desc.owner = THIS_MODULE; in reg_fixed_voltage_probe()
133 drvdata->desc.ops = &fixed_voltage_ops; in reg_fixed_voltage_probe()
135 drvdata->desc.enable_time = config->startup_delay; in reg_fixed_voltage_probe()
137 if (config->input_supply) { in reg_fixed_voltage_probe()
138 drvdata->desc.supply_name = devm_kstrdup(&pdev->dev, in reg_fixed_voltage_probe()
139 config->input_supply, in reg_fixed_voltage_probe()
141 if (!drvdata->desc.supply_name) { in reg_fixed_voltage_probe()
142 dev_err(&pdev->dev, in reg_fixed_voltage_probe()
144 return -ENOMEM; in reg_fixed_voltage_probe()
148 if (config->microvolts) in reg_fixed_voltage_probe()
149 drvdata->desc.n_voltages = 1; in reg_fixed_voltage_probe()
151 drvdata->desc.fixed_uV = config->microvolts; in reg_fixed_voltage_probe()
153 if (gpio_is_valid(config->gpio)) { in reg_fixed_voltage_probe()
154 cfg.ena_gpio = config->gpio; in reg_fixed_voltage_probe()
155 if (pdev->dev.of_node) in reg_fixed_voltage_probe()
158 cfg.ena_gpio_invert = !config->enable_high; in reg_fixed_voltage_probe()
159 if (config->enabled_at_boot) { in reg_fixed_voltage_probe()
160 if (config->enable_high) in reg_fixed_voltage_probe()
165 if (config->enable_high) in reg_fixed_voltage_probe()
170 if (config->gpio_is_open_drain) in reg_fixed_voltage_probe()
173 cfg.dev = &pdev->dev; in reg_fixed_voltage_probe()
174 cfg.init_data = config->init_data; in reg_fixed_voltage_probe()
176 cfg.of_node = pdev->dev.of_node; in reg_fixed_voltage_probe()
178 drvdata->dev = devm_regulator_register(&pdev->dev, &drvdata->desc, in reg_fixed_voltage_probe()
180 if (IS_ERR(drvdata->dev)) { in reg_fixed_voltage_probe()
181 ret = PTR_ERR(drvdata->dev); in reg_fixed_voltage_probe()
182 dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret); in reg_fixed_voltage_probe()
188 dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name, in reg_fixed_voltage_probe()
189 drvdata->desc.fixed_uV); in reg_fixed_voltage_probe()
196 { .compatible = "regulator-fixed", },
205 .name = "reg-fixed-voltage",
225 MODULE_ALIAS("platform:reg-fixed-voltage");