@@ -2878,8 +2878,11 @@ static int __devexit ab8500_charger_remove(struct platform_device *pdev)
destroy_workqueue(di->charger_wq);
flush_scheduled_work();
- power_supply_unregister(&di->usb_chg.psy);
- power_supply_unregister(&di->ac_chg.psy);
+ if (di->usb_chg.enabled)
+ power_supply_unregister(&di->usb_chg.psy);
+ if (di->ac_chg.enabled)
+ power_supply_unregister(&di->ac_chg.psy);
+
platform_set_drvdata(pdev, NULL);
kfree(di);
@@ -2942,6 +2945,7 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
ARRAY_SIZE(ab8500_charger_voltage_map) - 1];
di->ac_chg.max_out_curr = ab8500_charger_current_map[
ARRAY_SIZE(ab8500_charger_current_map) - 1];
+ di->ac_chg.enabled = di->pdata->ac_enabled;
/* USB supply */
/* power_supply base class */
@@ -2960,7 +2964,7 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
ARRAY_SIZE(ab8500_charger_voltage_map) - 1];
di->usb_chg.max_out_curr = ab8500_charger_current_map[
ARRAY_SIZE(ab8500_charger_current_map) - 1];
-
+ di->usb_chg.enabled = di->pdata->usb_enabled;
/* Create a work queue for the charger */
di->charger_wq =
@@ -3036,17 +3040,21 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
}
/* Register AC charger class */
- ret = power_supply_register(di->dev, &di->ac_chg.psy);
- if (ret) {
- dev_err(di->dev, "failed to register AC charger\n");
- goto free_regulator;
+ if (di->ac_chg.enabled) {
+ ret = power_supply_register(di->dev, &di->ac_chg.psy);
+ if (ret) {
+ dev_err(di->dev, "failed to register AC charger\n");
+ goto free_regulator;
+ }
}
/* Register USB charger class */
- ret = power_supply_register(di->dev, &di->usb_chg.psy);
- if (ret) {
- dev_err(di->dev, "failed to register USB charger\n");
- goto free_ac;
+ if (di->usb_chg.enabled) {
+ ret = power_supply_register(di->dev, &di->usb_chg.psy);
+ if (ret) {
+ dev_err(di->dev, "failed to register USB charger\n");
+ goto free_ac;
+ }
}
di->usb_phy = usb_get_phy(USB_PHY_TYPE_USB2);
@@ -3122,9 +3130,11 @@ free_irq:
put_usb_phy:
usb_put_phy(di->usb_phy);
free_usb:
- power_supply_unregister(&di->usb_chg.psy);
+ if (di->usb_chg.enabled)
+ power_supply_unregister(&di->usb_chg.psy);
free_ac:
- power_supply_unregister(&di->ac_chg.psy);
+ if (di->ac_chg.enabled)
+ power_supply_unregister(&di->ac_chg.psy);
free_regulator:
regulator_put(di->regu);
free_charger_wq:
@@ -398,6 +398,8 @@ struct abx500_charger_platform_data {
char **supplied_to;
size_t num_supplicants;
bool autopower_cfg;
+ bool ac_enabled;
+ bool usb_enabled;
};
struct abx500_btemp_platform_data {
@@ -27,12 +27,14 @@ struct ux500_charger_ops {
* @ops ux500 charger operations
* @max_out_volt maximum output charger voltage in mV
* @max_out_curr maximum output charger current in mA
+ * @enabled indicates if this charger is used or not
*/
struct ux500_charger {
struct power_supply psy;
struct ux500_charger_ops ops;
int max_out_volt;
int max_out_curr;
+ bool enabled;
};
#endif