diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-06-29 12:55:54 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-06-30 06:00:07 -0400 |
commit | 778b28b4348af9c72bb5ac0dc129363a706325ef (patch) | |
tree | b051af5e54639c7467092485d865e0aaabb35df0 /drivers/regulator | |
parent | 7171511eaec5bf23fb06078f59784a3a0626b38f (diff) |
regulator: core: convert to use gpio_desc internally
Convert the regulator GPIO handling to use a gpio descriptor rather than
numbers. This allows us to revise the interfaces to permit all GPIOs
to be used with the regulator core.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 4c1f999041dd..03ce33387a5d 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/suspend.h> | 24 | #include <linux/suspend.h> |
25 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
26 | #include <linux/gpio.h> | 26 | #include <linux/gpio.h> |
27 | #include <linux/gpio/consumer.h> | ||
27 | #include <linux/of.h> | 28 | #include <linux/of.h> |
28 | #include <linux/regmap.h> | 29 | #include <linux/regmap.h> |
29 | #include <linux/regulator/of_regulator.h> | 30 | #include <linux/regulator/of_regulator.h> |
@@ -77,7 +78,7 @@ struct regulator_map { | |||
77 | */ | 78 | */ |
78 | struct regulator_enable_gpio { | 79 | struct regulator_enable_gpio { |
79 | struct list_head list; | 80 | struct list_head list; |
80 | int gpio; | 81 | struct gpio_desc *gpiod; |
81 | u32 enable_count; /* a number of enabled shared GPIO */ | 82 | u32 enable_count; /* a number of enabled shared GPIO */ |
82 | u32 request_count; /* a number of requested shared GPIO */ | 83 | u32 request_count; /* a number of requested shared GPIO */ |
83 | unsigned int ena_gpio_invert:1; | 84 | unsigned int ena_gpio_invert:1; |
@@ -1660,10 +1661,13 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev, | |||
1660 | const struct regulator_config *config) | 1661 | const struct regulator_config *config) |
1661 | { | 1662 | { |
1662 | struct regulator_enable_gpio *pin; | 1663 | struct regulator_enable_gpio *pin; |
1664 | struct gpio_desc *gpiod; | ||
1663 | int ret; | 1665 | int ret; |
1664 | 1666 | ||
1667 | gpiod = gpio_to_desc(config->ena_gpio); | ||
1668 | |||
1665 | list_for_each_entry(pin, ®ulator_ena_gpio_list, list) { | 1669 | list_for_each_entry(pin, ®ulator_ena_gpio_list, list) { |
1666 | if (pin->gpio == config->ena_gpio) { | 1670 | if (pin->gpiod == gpiod) { |
1667 | rdev_dbg(rdev, "GPIO %d is already used\n", | 1671 | rdev_dbg(rdev, "GPIO %d is already used\n", |
1668 | config->ena_gpio); | 1672 | config->ena_gpio); |
1669 | goto update_ena_gpio_to_rdev; | 1673 | goto update_ena_gpio_to_rdev; |
@@ -1682,7 +1686,7 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev, | |||
1682 | return -ENOMEM; | 1686 | return -ENOMEM; |
1683 | } | 1687 | } |
1684 | 1688 | ||
1685 | pin->gpio = config->ena_gpio; | 1689 | pin->gpiod = gpiod; |
1686 | pin->ena_gpio_invert = config->ena_gpio_invert; | 1690 | pin->ena_gpio_invert = config->ena_gpio_invert; |
1687 | list_add(&pin->list, ®ulator_ena_gpio_list); | 1691 | list_add(&pin->list, ®ulator_ena_gpio_list); |
1688 | 1692 | ||
@@ -1701,10 +1705,10 @@ static void regulator_ena_gpio_free(struct regulator_dev *rdev) | |||
1701 | 1705 | ||
1702 | /* Free the GPIO only in case of no use */ | 1706 | /* Free the GPIO only in case of no use */ |
1703 | list_for_each_entry_safe(pin, n, ®ulator_ena_gpio_list, list) { | 1707 | list_for_each_entry_safe(pin, n, ®ulator_ena_gpio_list, list) { |
1704 | if (pin->gpio == rdev->ena_pin->gpio) { | 1708 | if (pin->gpiod == rdev->ena_pin->gpiod) { |
1705 | if (pin->request_count <= 1) { | 1709 | if (pin->request_count <= 1) { |
1706 | pin->request_count = 0; | 1710 | pin->request_count = 0; |
1707 | gpio_free(pin->gpio); | 1711 | gpiod_put(pin->gpiod); |
1708 | list_del(&pin->list); | 1712 | list_del(&pin->list); |
1709 | kfree(pin); | 1713 | kfree(pin); |
1710 | } else { | 1714 | } else { |
@@ -1732,8 +1736,8 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable) | |||
1732 | if (enable) { | 1736 | if (enable) { |
1733 | /* Enable GPIO at initial use */ | 1737 | /* Enable GPIO at initial use */ |
1734 | if (pin->enable_count == 0) | 1738 | if (pin->enable_count == 0) |
1735 | gpio_set_value_cansleep(pin->gpio, | 1739 | gpiod_set_value_cansleep(pin->gpiod, |
1736 | !pin->ena_gpio_invert); | 1740 | !pin->ena_gpio_invert); |
1737 | 1741 | ||
1738 | pin->enable_count++; | 1742 | pin->enable_count++; |
1739 | } else { | 1743 | } else { |
@@ -1744,8 +1748,8 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable) | |||
1744 | 1748 | ||
1745 | /* Disable GPIO if not used */ | 1749 | /* Disable GPIO if not used */ |
1746 | if (pin->enable_count <= 1) { | 1750 | if (pin->enable_count <= 1) { |
1747 | gpio_set_value_cansleep(pin->gpio, | 1751 | gpiod_set_value_cansleep(pin->gpiod, |
1748 | pin->ena_gpio_invert); | 1752 | pin->ena_gpio_invert); |
1749 | pin->enable_count = 0; | 1753 | pin->enable_count = 0; |
1750 | } | 1754 | } |
1751 | } | 1755 | } |