From patchwork Thu Sep 27 20:08:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11796 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id A6BD924140 for ; Thu, 27 Sep 2012 20:09:50 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 54F53A18B18 for ; Thu, 27 Sep 2012 20:09:50 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so5234855iej.11 for ; Thu, 27 Sep 2012 13:09:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=lKLODSl4YVwSttNq8e1PvcOnw8qqw3jz6mtWV3VPL7Q=; b=jDakh2Nv/rXZ1c8JhuZCoeiic/P1IgkXdoAjAmlun+2e+Bhfif86CDZzGJjR/rYNBY o3EVh5JP+GH7tvVLVQRtFg+w2G84LG2gUmIp1rqWq++VFjY3B1fZ3OZwOtWN6S0aJCPR EaR2bv4ov04MUerJsy8I40IfvRZroysZoy8hTdjVqimq3pbO4WPE3qaRoRpc1xCwBjbu EC7a8fcP0qyFVDC2FeCIwHHaJTfZPFSIqipuWtWY+Umrko5+Y6b72U16eoEvi8VrCwws woxFvKzE/8m5o4j+9Erx1UpJPhSzQBGe1vl0SgdX80UiouiHZYp5ES7bvlEEUiN87Cex lZbw== Received: by 10.42.109.194 with SMTP id m2mr3831297icp.48.1348776590075; Thu, 27 Sep 2012 13:09:50 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp436313igc; Thu, 27 Sep 2012 13:09:49 -0700 (PDT) Received: by 10.68.195.195 with SMTP id ig3mr14662019pbc.108.1348776589424; Thu, 27 Sep 2012 13:09:49 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id pi9si5467641pbb.12.2012.09.27.13.09.49 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 13:09:49 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of mathieu.poirier@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of mathieu.poirier@linaro.org) smtp.mail=mathieu.poirier@linaro.org Received: by mail-pb0-f50.google.com with SMTP id md4so1686045pbc.37 for ; Thu, 27 Sep 2012 13:09:49 -0700 (PDT) Received: by 10.68.191.168 with SMTP id gz8mr10230516pbc.128.1348776589133; Thu, 27 Sep 2012 13:09:49 -0700 (PDT) Received: from localhost.localdomain (S0106002369de4dac.cg.shawcable.net. [70.73.24.112]) by mx.google.com with ESMTPS id sa2sm1587890pbc.4.2012.09.27.13.09.48 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 13:09:48 -0700 (PDT) From: mathieu.poirier@linaro.org To: patches@linaro.org Subject: [PATCH 23/57] power: Add plaform data charger configurables Date: Thu, 27 Sep 2012 14:08:40 -0600 Message-Id: <1348776554-10019-24-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1348776554-10019-1-git-send-email-mathieu.poirier@linaro.org> References: <1348776554-10019-1-git-send-email-mathieu.poirier@linaro.org> X-Gm-Message-State: ALoCoQl3kVoOgDfnM2gYgmt3xUeV0JtetHfayPTPQ9xpzoQf8SJGqIh8STIc3NauSxs164wLx2rv From: Loic Pallardy Allow to indicate wheter AC and USB charge capabilities are supported from platform data. Signed-off-by: Loic Pallardy Signed-off-by: Mathieu Poirier Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/58093 Reviewed-by: Marcus COOPER Reviewed-by: Olivier CLERGEAUD --- drivers/power/ab8500_charger.c | 36 ++++++++++++++++++---------- include/linux/mfd/abx500.h | 2 + include/linux/mfd/abx500/ux500_chargalg.h | 2 + 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index cbc9fd7..3100f11 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c @@ -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: diff --git a/include/linux/mfd/abx500.h b/include/linux/mfd/abx500.h index 4d44a10..eef1ddc 100644 --- a/include/linux/mfd/abx500.h +++ b/include/linux/mfd/abx500.h @@ -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 { diff --git a/include/linux/mfd/abx500/ux500_chargalg.h b/include/linux/mfd/abx500/ux500_chargalg.h index 9b07725..5b77a61 100644 --- a/include/linux/mfd/abx500/ux500_chargalg.h +++ b/include/linux/mfd/abx500/ux500_chargalg.h @@ -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