Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * omap_pmic_of_setup_gpios() - Setup GPIO array if needed.
- * @dev: device to pick up the gpios from
- */
- static int omap_pmic_of_setup_gpios(struct device *dev)
- {
- struct device_node *node = dev->of_node;
- int num_gpios, i, ret;
- num_gpios = of_gpio_count(node);
- if (num_gpios < 0)
- return 0;
- for (i = 0; i < num_gpios; i++) {
- int gpio;
- enum of_gpio_flags flags;
- gpio = of_get_gpio_flags(node, i, &flags);
- if (!gpio_is_valid(gpio)) {
- dev_err(dev, "Invalid GPIO[%d]: %d\n", i, gpio);
- return -EINVAL;
- }
- ret = devm_gpio_request(dev, gpio, dev_name(dev));
- if (ret) {
- dev_err(dev, "Unable to get GPIO %d (%d)\n", gpio, ret);
- return ret;
- }
- ret = gpio_direction_output(gpio,
- !!(flags & OF_GPIO_ACTIVE_LOW));
- if (ret) {
- dev_err(dev, "Failed to set GPIO %d (%d)\n", gpio, ret);
- return ret;
- }
- dev_dbg(dev, "GPIO=%d set_to=%d\n", gpio,
- !!(flags & OF_GPIO_ACTIVE_LOW));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement