Commit 417c0fc2 authored by Linus Walleij's avatar Linus Walleij Committed by Lee Jones

mfd/power: ab8500: Push data to power supply code

The global definition of platform data for the battery
management code has no utility after the OF conversion,
move the <linux/mfd/abx500/ab8500-bm.h> to be a local
file in drivers/power/supply and stop defining the
platform data in drivers/power/supply/ab8500_bmdata.c
and broadcast to the kernel only to have it assigned
as platform data to the MFD cells and then picked back
into the same subsystem that defined it in the first
place. This kills off a layer of indirection.
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Acked-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent 53207aa1
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <linux/mfd/core.h> #include <linux/mfd/core.h>
#include <linux/mfd/abx500.h> #include <linux/mfd/abx500.h>
#include <linux/mfd/abx500/ab8500.h> #include <linux/mfd/abx500/ab8500.h>
#include <linux/mfd/abx500/ab8500-bm.h>
#include <linux/mfd/dbx500-prcmu.h> #include <linux/mfd/dbx500-prcmu.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
...@@ -609,14 +608,14 @@ int ab8500_suspend(struct ab8500 *ab8500) ...@@ -609,14 +608,14 @@ int ab8500_suspend(struct ab8500 *ab8500)
} }
static const struct mfd_cell ab8500_bm_devs[] = { static const struct mfd_cell ab8500_bm_devs[] = {
MFD_CELL_OF("ab8500-charger", NULL, &ab8500_bm_data, MFD_CELL_OF("ab8500-charger", NULL, NULL, 0, 0,
sizeof(ab8500_bm_data), 0, "stericsson,ab8500-charger"), "stericsson,ab8500-charger"),
MFD_CELL_OF("ab8500-btemp", NULL, &ab8500_bm_data, MFD_CELL_OF("ab8500-btemp", NULL, NULL, 0, 0,
sizeof(ab8500_bm_data), 0, "stericsson,ab8500-btemp"), "stericsson,ab8500-btemp"),
MFD_CELL_OF("ab8500-fg", NULL, &ab8500_bm_data, MFD_CELL_OF("ab8500-fg", NULL, NULL, 0, 0,
sizeof(ab8500_bm_data), 0, "stericsson,ab8500-fg"), "stericsson,ab8500-fg"),
MFD_CELL_OF("ab8500-chargalg", NULL, &ab8500_bm_data, MFD_CELL_OF("ab8500-chargalg", NULL, NULL, 0, 0,
sizeof(ab8500_bm_data), 0, "stericsson,ab8500-chargalg"), "stericsson,ab8500-chargalg"),
}; };
static const struct mfd_cell ab8500_devs[] = { static const struct mfd_cell ab8500_devs[] = {
......
/* SPDX-License-Identifier: GPL-2.0-only */ /* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright ST-Ericsson 2012.
*
* Author: Arun Murthy <arun.murthy@stericsson.com>
*/
#ifndef _AB8500_BM_H #ifndef _AB8500_CHARGER_H_
#define _AB8500_BM_H #define _AB8500_CHARGER_H_
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/mfd/abx500.h> #include <linux/mfd/abx500.h>
...@@ -453,16 +448,11 @@ struct ab8500_bm_data { ...@@ -453,16 +448,11 @@ struct ab8500_bm_data {
}; };
struct ab8500_btemp; struct ab8500_btemp;
struct ab8500_gpadc;
struct ab8500_fg; struct ab8500_fg;
#ifdef CONFIG_AB8500_BM
extern struct abx500_bm_data ab8500_bm_data; extern struct abx500_bm_data ab8500_bm_data;
void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA); void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA);
struct ab8500_btemp *ab8500_btemp_get(void);
int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp);
int ab8500_btemp_get_temp(struct ab8500_btemp *btemp);
struct ab8500_fg *ab8500_fg_get(void); struct ab8500_fg *ab8500_fg_get(void);
int ab8500_fg_inst_curr_blocking(struct ab8500_fg *dev); int ab8500_fg_inst_curr_blocking(struct ab8500_fg *dev);
int ab8500_fg_inst_curr_start(struct ab8500_fg *di); int ab8500_fg_inst_curr_start(struct ab8500_fg *di);
...@@ -470,7 +460,4 @@ int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res); ...@@ -470,7 +460,4 @@ int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res);
int ab8500_fg_inst_curr_started(struct ab8500_fg *di); int ab8500_fg_inst_curr_started(struct ab8500_fg *di);
int ab8500_fg_inst_curr_done(struct ab8500_fg *di); int ab8500_fg_inst_curr_done(struct ab8500_fg *di);
#else #endif /* _AB8500_CHARGER_H_ */
static struct abx500_bm_data ab8500_bm_data;
#endif
#endif /* _AB8500_BM_H */
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/mfd/abx500.h> #include <linux/mfd/abx500.h>
#include <linux/mfd/abx500/ab8500.h> #include <linux/mfd/abx500/ab8500.h>
#include <linux/mfd/abx500/ab8500-bm.h>
#include "ab8500-bm.h"
/* /*
* These are the defined batteries that uses a NTC and ID resistor placed * These are the defined batteries that uses a NTC and ID resistor placed
......
...@@ -25,9 +25,10 @@ ...@@ -25,9 +25,10 @@
#include <linux/mfd/core.h> #include <linux/mfd/core.h>
#include <linux/mfd/abx500.h> #include <linux/mfd/abx500.h>
#include <linux/mfd/abx500/ab8500.h> #include <linux/mfd/abx500/ab8500.h>
#include <linux/mfd/abx500/ab8500-bm.h>
#include <linux/iio/consumer.h> #include <linux/iio/consumer.h>
#include "ab8500-bm.h"
#define VTVOUT_V 1800 #define VTVOUT_V 1800
#define BTEMP_THERMAL_LOW_LIMIT -10 #define BTEMP_THERMAL_LOW_LIMIT -10
...@@ -119,16 +120,6 @@ static enum power_supply_property ab8500_btemp_props[] = { ...@@ -119,16 +120,6 @@ static enum power_supply_property ab8500_btemp_props[] = {
static LIST_HEAD(ab8500_btemp_list); static LIST_HEAD(ab8500_btemp_list);
/**
* ab8500_btemp_get() - returns a reference to the primary AB8500 BTEMP
* (i.e. the first BTEMP in the instance list)
*/
struct ab8500_btemp *ab8500_btemp_get(void)
{
return list_first_entry(&ab8500_btemp_list, struct ab8500_btemp, node);
}
EXPORT_SYMBOL(ab8500_btemp_get);
/** /**
* ab8500_btemp_batctrl_volt_to_res() - convert batctrl voltage to resistance * ab8500_btemp_batctrl_volt_to_res() - convert batctrl voltage to resistance
* @di: pointer to the ab8500_btemp structure * @di: pointer to the ab8500_btemp structure
...@@ -754,7 +745,7 @@ static void ab8500_btemp_periodic(struct ab8500_btemp *di, ...@@ -754,7 +745,7 @@ static void ab8500_btemp_periodic(struct ab8500_btemp *di,
* *
* Returns battery temperature * Returns battery temperature
*/ */
int ab8500_btemp_get_temp(struct ab8500_btemp *di) static int ab8500_btemp_get_temp(struct ab8500_btemp *di)
{ {
int temp = 0; int temp = 0;
...@@ -790,19 +781,6 @@ int ab8500_btemp_get_temp(struct ab8500_btemp *di) ...@@ -790,19 +781,6 @@ int ab8500_btemp_get_temp(struct ab8500_btemp *di)
} }
return temp; return temp;
} }
EXPORT_SYMBOL(ab8500_btemp_get_temp);
/**
* ab8500_btemp_get_batctrl_temp() - get the temperature
* @btemp: pointer to the btemp structure
*
* Returns the batctrl temperature in millidegrees
*/
int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp)
{
return btemp->bat_temp * 1000;
}
EXPORT_SYMBOL(ab8500_btemp_get_batctrl_temp);
/** /**
* ab8500_btemp_get_property() - get the btemp properties * ab8500_btemp_get_property() - get the btemp properties
...@@ -991,7 +969,6 @@ static const struct power_supply_desc ab8500_btemp_desc = { ...@@ -991,7 +969,6 @@ static const struct power_supply_desc ab8500_btemp_desc = {
static int ab8500_btemp_probe(struct platform_device *pdev) static int ab8500_btemp_probe(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct abx500_bm_data *plat = pdev->dev.platform_data;
struct power_supply_config psy_cfg = {}; struct power_supply_config psy_cfg = {};
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct ab8500_btemp *di; struct ab8500_btemp *di;
...@@ -1002,11 +979,7 @@ static int ab8500_btemp_probe(struct platform_device *pdev) ...@@ -1002,11 +979,7 @@ static int ab8500_btemp_probe(struct platform_device *pdev)
if (!di) if (!di)
return -ENOMEM; return -ENOMEM;
if (!plat) { di->bm = &ab8500_bm_data;
dev_err(dev, "no battery management data supplied\n");
return -EINVAL;
}
di->bm = plat;
ret = ab8500_bm_of_probe(dev, np, di->bm); ret = ab8500_bm_of_probe(dev, np, di->bm);
if (ret) { if (ret) {
......
...@@ -28,12 +28,13 @@ ...@@ -28,12 +28,13 @@
#include <linux/mfd/core.h> #include <linux/mfd/core.h>
#include <linux/mfd/abx500/ab8500.h> #include <linux/mfd/abx500/ab8500.h>
#include <linux/mfd/abx500.h> #include <linux/mfd/abx500.h>
#include <linux/mfd/abx500/ab8500-bm.h>
#include <linux/mfd/abx500/ux500_chargalg.h> #include <linux/mfd/abx500/ux500_chargalg.h>
#include <linux/usb/otg.h> #include <linux/usb/otg.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/iio/consumer.h> #include <linux/iio/consumer.h>
#include "ab8500-bm.h"
/* Charger constants */ /* Charger constants */
#define NO_PW_CONN 0 #define NO_PW_CONN 0
#define AC_PW_CONN 1 #define AC_PW_CONN 1
...@@ -3344,7 +3345,6 @@ static const struct power_supply_desc ab8500_usb_chg_desc = { ...@@ -3344,7 +3345,6 @@ static const struct power_supply_desc ab8500_usb_chg_desc = {
static int ab8500_charger_probe(struct platform_device *pdev) static int ab8500_charger_probe(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct abx500_bm_data *plat = pdev->dev.platform_data;
struct power_supply_config ac_psy_cfg = {}, usb_psy_cfg = {}; struct power_supply_config ac_psy_cfg = {}, usb_psy_cfg = {};
struct ab8500_charger *di; struct ab8500_charger *di;
int irq, i, charger_status, ret = 0, ch_stat; int irq, i, charger_status, ret = 0, ch_stat;
...@@ -3354,11 +3354,7 @@ static int ab8500_charger_probe(struct platform_device *pdev) ...@@ -3354,11 +3354,7 @@ static int ab8500_charger_probe(struct platform_device *pdev)
if (!di) if (!di)
return -ENOMEM; return -ENOMEM;
if (!plat) { di->bm = &ab8500_bm_data;
dev_err(dev, "no battery management data supplied\n");
return -EINVAL;
}
di->bm = plat;
ret = ab8500_bm_of_probe(dev, np, di->bm); ret = ab8500_bm_of_probe(dev, np, di->bm);
if (ret) { if (ret) {
......
...@@ -31,10 +31,11 @@ ...@@ -31,10 +31,11 @@
#include <linux/mfd/core.h> #include <linux/mfd/core.h>
#include <linux/mfd/abx500.h> #include <linux/mfd/abx500.h>
#include <linux/mfd/abx500/ab8500.h> #include <linux/mfd/abx500/ab8500.h>
#include <linux/mfd/abx500/ab8500-bm.h>
#include <linux/iio/consumer.h> #include <linux/iio/consumer.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include "ab8500-bm.h"
#define MILLI_TO_MICRO 1000 #define MILLI_TO_MICRO 1000
#define FG_LSB_IN_MA 1627 #define FG_LSB_IN_MA 1627
#define QLSB_NANO_AMP_HOURS_X10 1071 #define QLSB_NANO_AMP_HOURS_X10 1071
...@@ -3026,7 +3027,6 @@ static const struct power_supply_desc ab8500_fg_desc = { ...@@ -3026,7 +3027,6 @@ static const struct power_supply_desc ab8500_fg_desc = {
static int ab8500_fg_probe(struct platform_device *pdev) static int ab8500_fg_probe(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct abx500_bm_data *plat = pdev->dev.platform_data;
struct power_supply_config psy_cfg = {}; struct power_supply_config psy_cfg = {};
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct ab8500_fg *di; struct ab8500_fg *di;
...@@ -3037,11 +3037,7 @@ static int ab8500_fg_probe(struct platform_device *pdev) ...@@ -3037,11 +3037,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)
if (!di) if (!di)
return -ENOMEM; return -ENOMEM;
if (!plat) { di->bm = &ab8500_bm_data;
dev_err(dev, "no battery management data supplied\n");
return -EINVAL;
}
di->bm = plat;
ret = ab8500_bm_of_probe(dev, np, di->bm); ret = ab8500_bm_of_probe(dev, np, di->bm);
if (ret) { if (ret) {
......
...@@ -29,9 +29,10 @@ ...@@ -29,9 +29,10 @@
#include <linux/mfd/abx500.h> #include <linux/mfd/abx500.h>
#include <linux/mfd/abx500/ab8500.h> #include <linux/mfd/abx500/ab8500.h>
#include <linux/mfd/abx500/ux500_chargalg.h> #include <linux/mfd/abx500/ux500_chargalg.h>
#include <linux/mfd/abx500/ab8500-bm.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include "ab8500-bm.h"
/* Watchdog kick interval */ /* Watchdog kick interval */
#define CHG_WD_INTERVAL (6 * HZ) #define CHG_WD_INTERVAL (6 * HZ)
...@@ -1980,7 +1981,6 @@ static const struct power_supply_desc abx500_chargalg_desc = { ...@@ -1980,7 +1981,6 @@ static const struct power_supply_desc abx500_chargalg_desc = {
static int abx500_chargalg_probe(struct platform_device *pdev) static int abx500_chargalg_probe(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct abx500_bm_data *plat = pdev->dev.platform_data;
struct power_supply_config psy_cfg = {}; struct power_supply_config psy_cfg = {};
struct abx500_chargalg *di; struct abx500_chargalg *di;
int ret = 0; int ret = 0;
...@@ -1991,11 +1991,7 @@ static int abx500_chargalg_probe(struct platform_device *pdev) ...@@ -1991,11 +1991,7 @@ static int abx500_chargalg_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
} }
if (!plat) { di->bm = &ab8500_bm_data;
dev_err(&pdev->dev, "no battery management data supplied\n");
return -EINVAL;
}
di->bm = plat;
ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm); ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm);
if (ret) { if (ret) {
......
...@@ -18,13 +18,13 @@ ...@@ -18,13 +18,13 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/mfd/abx500/ab8500.h> #include <linux/mfd/abx500/ab8500.h>
#include <linux/mfd/abx500/ab8500-bm.h>
#include <linux/mfd/abx500/ux500_chargalg.h> #include <linux/mfd/abx500/ux500_chargalg.h>
#include <linux/pm2301_charger.h> #include <linux/pm2301_charger.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/pm.h> #include <linux/pm.h>
#include "ab8500-bm.h"
#include "pm2301_charger.h" #include "pm2301_charger.h"
#define to_pm2xxx_charger_ac_device_info(x) container_of((x), \ #define to_pm2xxx_charger_ac_device_info(x) container_of((x), \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment