mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
BACKPORT: power: supply: gpio-charger: Convert to GPIO descriptors
This converts the GPIO charger to use exclusively GPIO
descriptors, moving the two remaining platforms passing
global GPIO numbers over to using a GPIO descriptor table.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Conflicts:
arch/arm/mach-pxa/tosa.c
arch/arm/mach-sa1100/collie.c
drivers/power/supply/gpio-charger.c
(cherry picked from commit 17529bcf0a)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
Change-Id: I22fb3dc7d42163d7a715d219665a14474cdd7422
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/gpio.h> /* For legacy platform data */
|
||||
#include <linux/init.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/kernel.h>
|
||||
@@ -140,7 +139,6 @@ static int gpio_charger_probe(struct platform_device *pdev)
|
||||
struct power_supply_desc *charger_desc;
|
||||
struct gpio_desc *charge_status;
|
||||
int charge_status_irq;
|
||||
unsigned long flags;
|
||||
int ret;
|
||||
int num_props = 0;
|
||||
|
||||
@@ -158,29 +156,7 @@ static int gpio_charger_probe(struct platform_device *pdev)
|
||||
* boardfile descriptor tables. It's good to try this first.
|
||||
*/
|
||||
gpio_charger->gpiod = devm_gpiod_get_optional(dev, NULL, GPIOD_IN);
|
||||
|
||||
/*
|
||||
* Fallback to legacy platform data method, if no GPIO is specified
|
||||
* using boardfile descriptor tables.
|
||||
*/
|
||||
if (!gpio_charger->gpiod && pdata) {
|
||||
/* Non-DT: use legacy GPIO numbers */
|
||||
if (!gpio_is_valid(pdata->gpio)) {
|
||||
dev_err(dev, "Invalid gpio pin in pdata\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
flags = GPIOF_IN;
|
||||
if (pdata->gpio_active_low)
|
||||
flags |= GPIOF_ACTIVE_LOW;
|
||||
ret = devm_gpio_request_one(dev, pdata->gpio, flags,
|
||||
dev_name(dev));
|
||||
if (ret) {
|
||||
dev_err(dev, "Failed to request gpio pin: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
/* Then convert this to gpiod for now */
|
||||
gpio_charger->gpiod = gpio_to_desc(pdata->gpio);
|
||||
} else if (IS_ERR(gpio_charger->gpiod)) {
|
||||
if (IS_ERR(gpio_charger->gpiod)) {
|
||||
/* Just try again if this happens */
|
||||
if (PTR_ERR(gpio_charger->gpiod) == -EPROBE_DEFER)
|
||||
return -EPROBE_DEFER;
|
||||
|
||||
@@ -22,18 +22,12 @@
|
||||
* struct gpio_charger_platform_data - platform_data for gpio_charger devices
|
||||
* @name: Name for the chargers power_supply device
|
||||
* @type: Type of the charger
|
||||
* @gpio: GPIO which is used to indicate the chargers status
|
||||
* @gpio_active_low: Should be set to 1 if the GPIO is active low otherwise 0
|
||||
* @supplied_to: Array of battery names to which this chargers supplies power
|
||||
* @num_supplicants: Number of entries in the supplied_to array
|
||||
*/
|
||||
struct gpio_charger_platform_data {
|
||||
const char *name;
|
||||
enum power_supply_type type;
|
||||
|
||||
int gpio;
|
||||
int gpio_active_low;
|
||||
|
||||
char **supplied_to;
|
||||
size_t num_supplicants;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user