diff options
author | Jonghwa Lee <jonghwa3.lee@samsung.com> | 2013-06-10 16:01:24 +0900 |
---|---|---|
committer | Marek Szyprowski <m.szyprowski@samsung.com> | 2014-05-15 07:20:13 +0200 |
commit | b53e1627ee52061cf462bc4e6ef748baedc77bea (patch) | |
tree | efe82b4ed4550ba903d9d184b8569ed0074ac9a0 /drivers/power | |
parent | 747dfd7d8fde3b2ed5cf3bfa1d48d410d8114e26 (diff) | |
download | linux-3.10-b53e1627ee52061cf462bc4e6ef748baedc77bea.tar.gz linux-3.10-b53e1627ee52061cf462bc4e6ef748baedc77bea.tar.bz2 linux-3.10-b53e1627ee52061cf462bc4e6ef748baedc77bea.zip |
charger_manager: Workaround for supporting platform data without DT parsing.
All data will be move into DT later.
Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/charger-manager.c | 115 |
1 files changed, 114 insertions, 1 deletions
diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c index 98de1ddce45..3264fd83781 100644 --- a/drivers/power/charger-manager.c +++ b/drivers/power/charger-manager.c @@ -23,6 +23,7 @@ #include <linux/power/charger-manager.h> #include <linux/regulator/consumer.h> #include <linux/sysfs.h> +#include <linux/of.h> static const char * const default_event_names[] = { [CM_EVENT_UNKNOWN] = "Unknown", @@ -1451,9 +1452,118 @@ err: return ret; } +/* + * Charger driver platform data + * To do : Should be transferred to DT. + */ + +static int thermistor_ck(int *mC) +{ + return 0; +} + +static char *charger_stats[] = { +#if defined(CONFIG_CHARGER_MAX77693) + "max77693-charger", +#endif + NULL, +}; + +#define BATT_CHARGING_SOURCE_TA 2 +#define BATT_CHARGING_SOURCE_USB 3 +#define BATT_CHARGING_SOURCE_SLOW_TA 4 +#define BATT_CHARGING_SOURCE_FAST_TA 5 +#define BATT_CHARGING_SOURCE_MHL_TA 6 + +struct charger_cable charger_cable_vinchg1[] = { + { + .extcon_name = "max77693-muic", + .name = "USB", + .min_uA = 475000, + .max_uA = 475000 + 25000, + }, { + .extcon_name = "max77693-muic", + .name = "TA", + .min_uA = 650000, + .max_uA = 650000 + 25000, + }, { + .extcon_name = "max77693-muic", + .name = "Slow-charger", + .min_uA = 650000, + .max_uA = 650000 + 25000, + }, { + .extcon_name = "max77693-muic", + .name = "Fast-charger", + .min_uA = 650000, + .max_uA = 650000 + 25000, + }, { + .extcon_name = "max77693-muic", + .name = "MHL", + .min_uA = 475000, + .max_uA = 475000 + 25000, + }, +}; +static struct charger_regulator regulators[] = { + { + .regulator_name = "vinchg1", + .cables = charger_cable_vinchg1, + .num_cables = ARRAY_SIZE(charger_cable_vinchg1), + }, +}; + +static struct charger_desc cm_drv_data = { + .psy_name = "battery", + .polling_mode = CM_POLL_EXTERNAL_POWER_ONLY, + .polling_interval_ms = 30000, + .fullbatt_vchkdrop_ms = 30000, + .fullbatt_vchkdrop_uV = 150000, + .fullbatt_uV = 4200000, + .fullbatt_soc = 100, + .fullbatt_full_capacity = 0, + + .battery_present = CM_CHARGER_STAT, + .psy_charger_stat = charger_stats, + .num_charger_regulators = 1, + .psy_fuel_gauge = "max170xx_battery", + .charger_regulators = regulators, + .num_charger_regulators = ARRAY_SIZE(regulators), + + .temperature_out_of_range = thermistor_ck, + .measure_battery_temp = true, + + .charging_max_duration_ms = (6 * 60 * 60 * 1000), /* 6hr */ + .discharging_max_duration_ms = (1.5 * 60 * 60 * 1000),/* 1.5hr */ +}; + +#ifdef CONFIG_OF +static struct of_device_id charger_manager_match[] = { + { + .compatible = "charger-manager", + .data = (void *)&cm_drv_data, + }, + {}, +}; +#endif + +static inline struct charger_desc *cm_get_drv_data( + struct platform_device *pdev) +{ +#ifdef CONFIG_OF + if (pdev->dev.of_node) { + const struct of_device_id *match; + match = of_match_node(charger_manager_match, + pdev->dev.of_node); + if (!match) + return NULL; + return (struct charger_desc *)match->data; + } +#endif + return (struct charger_desc *)dev_get_platdata(&pdev->dev); +} + static int charger_manager_probe(struct platform_device *pdev) { - struct charger_desc *desc = dev_get_platdata(&pdev->dev); + struct charger_desc *desc; struct charger_manager *cm; int ret = 0, i = 0; int j = 0; @@ -1470,6 +1580,8 @@ static int charger_manager_probe(struct platform_device *pdev) } } + desc = cm_get_drv_data(pdev); + if (!desc) { dev_err(&pdev->dev, "No platform data (desc) found.\n"); ret = -ENODEV; @@ -1861,6 +1973,7 @@ static struct platform_driver charger_manager_driver = { .name = "charger-manager", .owner = THIS_MODULE, .pm = &charger_manager_pm, + .of_match_table = charger_manager_match, }, .probe = charger_manager_probe, .remove = charger_manager_remove, |