mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 10:49:33 +00:00
Immutable branch between mach-pxa and power-supply for for 5.12
This immutable branch replaces legacy gpio API in wm97xx_battery and z2_battery with new gpiod API, which involves the drivers in power-supply and some mach-pxa board files. Signed-off-by: Sebastian Reichel <sre@kernel.org> -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAl//Z2YACgkQ2O7X88g7 +pp6Nw//cL6YUsevd1X1GAimdioh4eA4IioU5wzk8KNwr8+8SxFmC4zM2pKVGxpg 00U8hJdsGs7oqf91oGD7sCh1/jvfbcPA+zAoiS6t4Wb2G8gxaKrv+7MkVcPPqp6K WADhEoVl6e37bP6d1CiuMl+ahJAgC9x7SiTZcO7EhowkS2xf0o3RewEGq/b2o0Lz FkfzjwJProhLNpSH6lJL1WjyoCVWMImX236K0F3c9T1yaqU9zprFy6gJh18+ASqH ZGBEW7Gpe0TScfpC5BrujEIkC0LkHcANlQFG268QZyD1aQaBdjeFz+uxqfMOiduf M/oW+J9k1KZbxnHVCrLTEjCf7zwDsujNFETG0tspyht4nvR1IFzn6PYhQFQ0XmRl KeApqznfZyeafhwFH4etKn5PfY8Zsk2aQxQGhE4v9hFiKLuPjXwfm3ou3KaP25+j y3c708PwkhKpE7aZ2WbG0GhWvfy7jGymSXW3f/jHnaGlMZ5whrE7qihUGeF0z3bm Xp6sX8y8vdK3KJ2EhK53begvEI+KRaIQsb/qhvg56N771vXuru1P/MKJf6HMq+tZ 9qfK+mvs0ZvV9zk+bYYy7V5G3wjmyj4tgBvipSEg5LRAjIfPqkUs30pWIO923pTv 3U+96P1zqBDEvwE+Rw9nikMyeym89cxqw5BfTuyZKtRp3LJZO/w= =c7Ln -----END PGP SIGNATURE----- Merge tag 'ib-psy-pxa-for-5.12-signed' into psy-next Immutable branch between mach-pxa and power-supply for for 5.12 This immutable branch replaces legacy gpio API in wm97xx_battery and z2_battery with new gpiod API, which involves the drivers in power-supply and some mach-pxa board files. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
commit
b059b48500
8 changed files with 51 additions and 57 deletions
|
@ -577,7 +577,6 @@ static struct platform_device power_dev = {
|
|||
static struct wm97xx_batt_pdata mioa701_battery_data = {
|
||||
.batt_aux = WM97XX_AUX_ID1,
|
||||
.temp_aux = -1,
|
||||
.charge_gpio = -1,
|
||||
.min_voltage = 0xc00,
|
||||
.max_voltage = 0xfc0,
|
||||
.batt_tech = POWER_SUPPLY_TECHNOLOGY_LION,
|
||||
|
|
|
@ -212,7 +212,6 @@ void __init palm27x_irda_init(int pwdn)
|
|||
static struct wm97xx_batt_pdata palm27x_batt_pdata = {
|
||||
.batt_aux = WM97XX_AUX_ID3,
|
||||
.temp_aux = WM97XX_AUX_ID2,
|
||||
.charge_gpio = -1,
|
||||
.batt_mult = 1000,
|
||||
.batt_div = 414,
|
||||
.temp_mult = 1,
|
||||
|
|
|
@ -273,7 +273,6 @@ static struct platform_device power_supply = {
|
|||
static struct wm97xx_batt_pdata palmte2_batt_pdata = {
|
||||
.batt_aux = WM97XX_AUX_ID3,
|
||||
.temp_aux = WM97XX_AUX_ID2,
|
||||
.charge_gpio = -1,
|
||||
.max_voltage = PALMTE2_BAT_MAX_VOLTAGE,
|
||||
.min_voltage = PALMTE2_BAT_MIN_VOLTAGE,
|
||||
.batt_mult = 1000,
|
||||
|
|
|
@ -488,7 +488,6 @@ static struct z2_battery_info batt_chip_info = {
|
|||
.batt_I2C_bus = 0,
|
||||
.batt_I2C_addr = 0x55,
|
||||
.batt_I2C_reg = 2,
|
||||
.charge_gpio = GPIO0_ZIPITZ2_AC_DETECT,
|
||||
.min_voltage = 3475000,
|
||||
.max_voltage = 4190000,
|
||||
.batt_div = 59,
|
||||
|
@ -497,9 +496,19 @@ static struct z2_battery_info batt_chip_info = {
|
|||
.batt_name = "Z2",
|
||||
};
|
||||
|
||||
static struct gpiod_lookup_table z2_battery_gpio_table = {
|
||||
.dev_id = "aer915",
|
||||
.table = {
|
||||
GPIO_LOOKUP("gpio-pxa", GPIO0_ZIPITZ2_AC_DETECT,
|
||||
NULL, GPIO_ACTIVE_HIGH),
|
||||
{ },
|
||||
},
|
||||
};
|
||||
|
||||
static struct i2c_board_info __initdata z2_i2c_board_info[] = {
|
||||
{
|
||||
I2C_BOARD_INFO("aer915", 0x55),
|
||||
.dev_name = "aer915",
|
||||
.platform_data = &batt_chip_info,
|
||||
}, {
|
||||
I2C_BOARD_INFO("wm8750", 0x1b),
|
||||
|
@ -510,6 +519,7 @@ static struct i2c_board_info __initdata z2_i2c_board_info[] = {
|
|||
static void __init z2_i2c_init(void)
|
||||
{
|
||||
pxa_set_i2c_info(NULL);
|
||||
gpiod_add_lookup_table(&z2_battery_gpio_table);
|
||||
i2c_register_board_info(0, ARRAY_AND_SIZE(z2_i2c_board_info));
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -15,11 +15,12 @@
|
|||
#include <linux/wm97xx.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
static struct work_struct bat_work;
|
||||
static struct gpio_desc *charge_gpiod;
|
||||
static DEFINE_MUTEX(work_lock);
|
||||
static int bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
|
||||
static enum power_supply_property *prop;
|
||||
|
@ -96,12 +97,11 @@ static void wm97xx_bat_external_power_changed(struct power_supply *bat_ps)
|
|||
static void wm97xx_bat_update(struct power_supply *bat_ps)
|
||||
{
|
||||
int old_status = bat_status;
|
||||
struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps);
|
||||
|
||||
mutex_lock(&work_lock);
|
||||
|
||||
bat_status = (pdata->charge_gpio >= 0) ?
|
||||
(gpio_get_value(pdata->charge_gpio) ?
|
||||
bat_status = (charge_gpiod) ?
|
||||
(gpiod_get_value(charge_gpiod) ?
|
||||
POWER_SUPPLY_STATUS_DISCHARGING :
|
||||
POWER_SUPPLY_STATUS_CHARGING) :
|
||||
POWER_SUPPLY_STATUS_UNKNOWN;
|
||||
|
@ -171,18 +171,19 @@ static int wm97xx_bat_probe(struct platform_device *dev)
|
|||
if (dev->id != -1)
|
||||
return -EINVAL;
|
||||
|
||||
if (gpio_is_valid(pdata->charge_gpio)) {
|
||||
ret = gpio_request(pdata->charge_gpio, "BATT CHRG");
|
||||
if (ret)
|
||||
goto err;
|
||||
ret = gpio_direction_input(pdata->charge_gpio);
|
||||
if (ret)
|
||||
goto err2;
|
||||
ret = request_irq(gpio_to_irq(pdata->charge_gpio),
|
||||
charge_gpiod = devm_gpiod_get_optional(&dev->dev, NULL, GPIOD_IN);
|
||||
if (IS_ERR(charge_gpiod))
|
||||
return dev_err_probe(&dev->dev,
|
||||
PTR_ERR(charge_gpiod),
|
||||
"failed to get charge GPIO\n");
|
||||
if (charge_gpiod) {
|
||||
gpiod_set_consumer_name(charge_gpiod, "BATT CHRG");
|
||||
ret = request_irq(gpiod_to_irq(charge_gpiod),
|
||||
wm97xx_chrg_irq, 0,
|
||||
"AC Detect", dev);
|
||||
if (ret)
|
||||
goto err2;
|
||||
return dev_err_probe(&dev->dev, ret,
|
||||
"failed to request GPIO irq\n");
|
||||
props++; /* POWER_SUPPLY_PROP_STATUS */
|
||||
}
|
||||
|
||||
|
@ -204,7 +205,7 @@ static int wm97xx_bat_probe(struct platform_device *dev)
|
|||
}
|
||||
|
||||
prop[i++] = POWER_SUPPLY_PROP_PRESENT;
|
||||
if (pdata->charge_gpio >= 0)
|
||||
if (charge_gpiod)
|
||||
prop[i++] = POWER_SUPPLY_PROP_STATUS;
|
||||
if (pdata->batt_tech >= 0)
|
||||
prop[i++] = POWER_SUPPLY_PROP_TECHNOLOGY;
|
||||
|
@ -242,23 +243,15 @@ static int wm97xx_bat_probe(struct platform_device *dev)
|
|||
err4:
|
||||
kfree(prop);
|
||||
err3:
|
||||
if (gpio_is_valid(pdata->charge_gpio))
|
||||
free_irq(gpio_to_irq(pdata->charge_gpio), dev);
|
||||
err2:
|
||||
if (gpio_is_valid(pdata->charge_gpio))
|
||||
gpio_free(pdata->charge_gpio);
|
||||
err:
|
||||
if (charge_gpiod)
|
||||
free_irq(gpiod_to_irq(charge_gpiod), dev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int wm97xx_bat_remove(struct platform_device *dev)
|
||||
{
|
||||
struct wm97xx_batt_pdata *pdata = dev->dev.platform_data;
|
||||
|
||||
if (pdata && gpio_is_valid(pdata->charge_gpio)) {
|
||||
free_irq(gpio_to_irq(pdata->charge_gpio), dev);
|
||||
gpio_free(pdata->charge_gpio);
|
||||
}
|
||||
if (charge_gpiod)
|
||||
free_irq(gpiod_to_irq(charge_gpiod), dev);
|
||||
cancel_work_sync(&bat_work);
|
||||
power_supply_unregister(bat_psy);
|
||||
kfree(prop);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/irq.h>
|
||||
|
@ -18,6 +18,7 @@
|
|||
|
||||
struct z2_charger {
|
||||
struct z2_battery_info *info;
|
||||
struct gpio_desc *charge_gpiod;
|
||||
int bat_status;
|
||||
struct i2c_client *client;
|
||||
struct power_supply *batt_ps;
|
||||
|
@ -95,8 +96,8 @@ static void z2_batt_update(struct z2_charger *charger)
|
|||
|
||||
mutex_lock(&charger->work_lock);
|
||||
|
||||
charger->bat_status = (info->charge_gpio >= 0) ?
|
||||
(gpio_get_value(info->charge_gpio) ?
|
||||
charger->bat_status = charger->charge_gpiod ?
|
||||
(gpiod_get_value(charger->charge_gpiod) ?
|
||||
POWER_SUPPLY_STATUS_CHARGING :
|
||||
POWER_SUPPLY_STATUS_DISCHARGING) :
|
||||
POWER_SUPPLY_STATUS_UNKNOWN;
|
||||
|
@ -131,7 +132,7 @@ static int z2_batt_ps_init(struct z2_charger *charger, int props)
|
|||
enum power_supply_property *prop;
|
||||
struct z2_battery_info *info = charger->info;
|
||||
|
||||
if (info->charge_gpio >= 0)
|
||||
if (charger->charge_gpiod)
|
||||
props++; /* POWER_SUPPLY_PROP_STATUS */
|
||||
if (info->batt_tech >= 0)
|
||||
props++; /* POWER_SUPPLY_PROP_TECHNOLOGY */
|
||||
|
@ -147,7 +148,7 @@ static int z2_batt_ps_init(struct z2_charger *charger, int props)
|
|||
return -ENOMEM;
|
||||
|
||||
prop[i++] = POWER_SUPPLY_PROP_PRESENT;
|
||||
if (info->charge_gpio >= 0)
|
||||
if (charger->charge_gpiod)
|
||||
prop[i++] = POWER_SUPPLY_PROP_STATUS;
|
||||
if (info->batt_tech >= 0)
|
||||
prop[i++] = POWER_SUPPLY_PROP_TECHNOLOGY;
|
||||
|
@ -206,22 +207,23 @@ static int z2_batt_probe(struct i2c_client *client,
|
|||
|
||||
mutex_init(&charger->work_lock);
|
||||
|
||||
if (info->charge_gpio >= 0 && gpio_is_valid(info->charge_gpio)) {
|
||||
ret = gpio_request(info->charge_gpio, "BATT CHRG");
|
||||
if (ret)
|
||||
goto err;
|
||||
charger->charge_gpiod = devm_gpiod_get_optional(&client->dev,
|
||||
NULL, GPIOD_IN);
|
||||
if (IS_ERR(charger->charge_gpiod))
|
||||
return dev_err_probe(&client->dev,
|
||||
PTR_ERR(charger->charge_gpiod),
|
||||
"failed to get charge GPIO\n");
|
||||
|
||||
ret = gpio_direction_input(info->charge_gpio);
|
||||
if (ret)
|
||||
goto err2;
|
||||
if (charger->charge_gpiod) {
|
||||
gpiod_set_consumer_name(charger->charge_gpiod, "BATT CHRG");
|
||||
|
||||
irq_set_irq_type(gpio_to_irq(info->charge_gpio),
|
||||
irq_set_irq_type(gpiod_to_irq(charger->charge_gpiod),
|
||||
IRQ_TYPE_EDGE_BOTH);
|
||||
ret = request_irq(gpio_to_irq(info->charge_gpio),
|
||||
ret = request_irq(gpiod_to_irq(charger->charge_gpiod),
|
||||
z2_charge_switch_irq, 0,
|
||||
"AC Detect", charger);
|
||||
if (ret)
|
||||
goto err3;
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = z2_batt_ps_init(charger, props);
|
||||
|
@ -245,11 +247,8 @@ static int z2_batt_probe(struct i2c_client *client,
|
|||
err4:
|
||||
kfree(charger->batt_ps_desc.properties);
|
||||
err3:
|
||||
if (info->charge_gpio >= 0 && gpio_is_valid(info->charge_gpio))
|
||||
free_irq(gpio_to_irq(info->charge_gpio), charger);
|
||||
err2:
|
||||
if (info->charge_gpio >= 0 && gpio_is_valid(info->charge_gpio))
|
||||
gpio_free(info->charge_gpio);
|
||||
if (charger->charge_gpiod)
|
||||
free_irq(gpiod_to_irq(charger->charge_gpiod), charger);
|
||||
err:
|
||||
kfree(charger);
|
||||
return ret;
|
||||
|
@ -258,16 +257,13 @@ static int z2_batt_probe(struct i2c_client *client,
|
|||
static int z2_batt_remove(struct i2c_client *client)
|
||||
{
|
||||
struct z2_charger *charger = i2c_get_clientdata(client);
|
||||
struct z2_battery_info *info = charger->info;
|
||||
|
||||
cancel_work_sync(&charger->bat_work);
|
||||
power_supply_unregister(charger->batt_ps);
|
||||
|
||||
kfree(charger->batt_ps_desc.properties);
|
||||
if (info->charge_gpio >= 0 && gpio_is_valid(info->charge_gpio)) {
|
||||
free_irq(gpio_to_irq(info->charge_gpio), charger);
|
||||
gpio_free(info->charge_gpio);
|
||||
}
|
||||
if (charger->charge_gpiod)
|
||||
free_irq(gpiod_to_irq(charger->charge_gpiod), charger);
|
||||
|
||||
kfree(charger);
|
||||
|
||||
|
|
|
@ -294,7 +294,6 @@ struct wm97xx {
|
|||
struct wm97xx_batt_pdata {
|
||||
int batt_aux;
|
||||
int temp_aux;
|
||||
int charge_gpio;
|
||||
int min_voltage;
|
||||
int max_voltage;
|
||||
int batt_div;
|
||||
|
|
|
@ -6,7 +6,6 @@ struct z2_battery_info {
|
|||
int batt_I2C_bus;
|
||||
int batt_I2C_addr;
|
||||
int batt_I2C_reg;
|
||||
int charge_gpio;
|
||||
int min_voltage;
|
||||
int max_voltage;
|
||||
int batt_div;
|
||||
|
|
Loading…
Reference in a new issue