From patchwork Thu Nov 22 18:43:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajanikanth HV X-Patchwork-Id: 1785101 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 75327DF24C for ; Thu, 22 Nov 2012 18:50:01 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tbbnx-0005DL-DE; Thu, 22 Nov 2012 18:47:17 +0000 Received: from mail-pb0-f49.google.com ([209.85.160.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TbbnC-00053A-0w for linux-arm-kernel@lists.infradead.org; Thu, 22 Nov 2012 18:46:31 +0000 Received: by mail-pb0-f49.google.com with SMTP id un15so5552575pbc.36 for ; Thu, 22 Nov 2012 10:46:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=wWpdO8ZDg4g92e0TIwvNAWDCV0O+07JCC+xZqUWX2Cg=; b=WmyYP1XeVFzvJ/z39+/iRjcl/nMNYxSOydBWh5lUzuQ1uXeTh76WzvMjJcywLSsqYV KKjTYN+5MPQ5QnbX3FIuDnTXtIobXor1rsTff9LvmyRU8Ecw7y6GIbscnrPlSf1vRXnW /KSPyOCyJgtJoGndrPdRaWbnX01/VvXAiLd88yLyEYeOBzbzjZj1jmeV4ljn12k8xD6H CJNCWM445mvoZ6bDninpj6A6q/UZ0p7/4dWd1J34zZBPhb+UhcfzZVzo76/gGhqAuTxE EQdhjr153L8ExYxys/d7wNH3mHBGUEJmaiLHj1om4CIuLceSlVc1HyyOxzGqxI52NNph FyYA== Received: by 10.68.225.232 with SMTP id rn8mr7295004pbc.34.1353609989734; Thu, 22 Nov 2012 10:46:29 -0800 (PST) Received: from localhost.localdomain ([117.231.140.125]) by mx.google.com with ESMTPS id n11sm2428353pby.67.2012.11.22.10.46.23 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Nov 2012 10:46:29 -0800 (PST) From: "Rajanikanth H.V" To: rob.herring@calxeda.com, robherring2@gmail.com, francescolavra.fl@gmail.com, anton.vorontsov@linaro.org Subject: [PATCH 4/4] mfd: ab8500: add devicetree support for chargalg Date: Fri, 23 Nov 2012 00:13:47 +0530 Message-Id: <1353609827-8218-5-git-send-email-rajanikanth.hv@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1353609827-8218-1-git-send-email-rajanikanth.hv@linaro.org> References: <1353609827-8218-1-git-send-email-rajanikanth.hv@linaro.org> X-Gm-Message-State: ALoCoQmw6sGEq1qNVIXGDZAH6JqEq35YQpZzGINpYi29Kaz78mIpDlCXiklwQIPzcivHgUiSgdXG X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121122_134630_242049_A8BDA6D0 X-CRM114-Status: GOOD ( 20.85 ) X-Spam-Score: 0.4 (/) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.49 listed in list.dnswl.org] 3.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: "Rajanikanth H.V" , linaro-dev@lists.linaro.org, linus.walleij@stericsson.com, arnd@arndb.de, patches@linaro.org, linux-kernel@vger.kernel.org, rajanikanth.hv@stericsson.com, STEricsson_nomadik_linux@list.st.com, lee.jones@linaro.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: "Rajanikanth H.V" This patch adds device tree support for charging algorithm driver Signed-off-by: Rajanikanth H.V --- .../bindings/power_supply/ab8500/chargalg.txt | 16 ++++++ arch/arm/boot/dts/dbx5x0.dtsi | 5 ++ drivers/mfd/ab8500-core.c | 5 ++ drivers/power/abx500_chargalg.c | 56 ++++++++++++++------ include/linux/mfd/abx500.h | 6 --- 5 files changed, 66 insertions(+), 22 deletions(-) create mode 100644 Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt diff --git a/Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt b/Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt new file mode 100644 index 0000000..ef53283 --- /dev/null +++ b/Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt @@ -0,0 +1,16 @@ +=== AB8500 Charging Algorithm Driver === + +The properties below describes the node for chargalg driver. + +Required Properties: +- compatible = Shall be: "stericsson,ab8500-chargalg" +- battery = Shall be battery specific information + +Example: +ab8500_chargalg { + compatible = "stericsson,ab8500-chargalg"; + battery = <&ab8500_battery>; +}; + +For information on battery specific node, Ref: +Documentation/devicetree/bindings/power_supply/ab8500/fg.txt diff --git a/arch/arm/boot/dts/dbx5x0.dtsi b/arch/arm/boot/dts/dbx5x0.dtsi index 7e9c01a..f1661b3 100644 --- a/arch/arm/boot/dts/dbx5x0.dtsi +++ b/arch/arm/boot/dts/dbx5x0.dtsi @@ -357,6 +357,11 @@ thermistor-on-batctrl; }; + ab8500-chargalg { + compatible = "stericsson,ab8500-chargalg"; + battery = <&ab8500_battery>; + }; + ab8500-charger { compatible = "stericsson,ab8500-charger"; battery = <&ab8500_battery>; diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index c7a120b..5ec70f2 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c @@ -1071,8 +1071,13 @@ static struct mfd_cell __devinitdata ab8500_bm_devs[] = { }, { .name = "ab8500-chargalg", + .of_compatible = "stericsson,ab8500-chargalg", .num_resources = ARRAY_SIZE(ab8500_chargalg_resources), .resources = ab8500_chargalg_resources, +#ifndef CONFIG_OF + .platform_data = &ab8500_bm_data, + .pdata_size = sizeof(ab8500_bm_data), +#endif }, }; diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/abx500_chargalg.c index 94bf69b..96eb2c5 100644 --- a/drivers/power/abx500_chargalg.c +++ b/drivers/power/abx500_chargalg.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include #include #include @@ -205,7 +207,6 @@ enum maxim_ret { * @chg_info: information about connected charger types * @batt_data: data of the battery * @susp_status: current charger suspension status - * @pdata: pointer to the abx500_chargalg platform data * @bat: pointer to the abx500_bm platform data * @chargalg_psy: structure that holds the battery properties exposed by * the charging algorithm @@ -231,7 +232,6 @@ struct abx500_chargalg { struct abx500_chargalg_charger_info chg_info; struct abx500_chargalg_battery_data batt_data; struct abx500_chargalg_suspension_status susp_status; - struct abx500_bmdevs_plat_data *pdata; struct abx500_bm_data *bat; struct power_supply chargalg_psy; struct ux500_charger *ac_chg; @@ -1795,35 +1795,55 @@ static int __devexit abx500_chargalg_remove(struct platform_device *pdev) flush_scheduled_work(); power_supply_unregister(&di->chargalg_psy); platform_set_drvdata(pdev, NULL); - kfree(di); return 0; } +static char *supply_interface[] = { + "ab8500_fg", +}; + static int __devinit abx500_chargalg_probe(struct platform_device *pdev) { - struct abx500_bmdevs_plat_data *plat_data; + struct device_node *np = pdev->dev.of_node; + struct abx500_chargalg *di; int ret = 0; - struct abx500_chargalg *di = - kzalloc(sizeof(struct abx500_chargalg), GFP_KERNEL); - if (!di) + di = devm_kzalloc(&pdev->dev, sizeof(*di), GFP_KERNEL); + if (!di) { + dev_err(&pdev->dev, "%s no mem for ab8500_chargalg\n", + __func__); return -ENOMEM; + } + + di->bat = pdev->mfd_cell->platform_data; + if (!di->bat) { + if (np) { + ret = bmdevs_of_probe(&pdev->dev, np, &di->bat); + if (ret) { + dev_err(&pdev->dev, + "failed to get battery information\n"); + return ret; + } + } else { + dev_err(&pdev->dev, "missing dt node for ab8500_chargalg\n"); + return -EINVAL; + } + } else { + dev_info(&pdev->dev, "falling back to legacy platform data\n"); + } /* get device struct */ di->dev = &pdev->dev; - plat_data = pdev->dev.platform_data; - di->pdata = plat_data; - /* chargalg supply */ di->chargalg_psy.name = "abx500_chargalg"; di->chargalg_psy.type = POWER_SUPPLY_TYPE_BATTERY; di->chargalg_psy.properties = abx500_chargalg_props; di->chargalg_psy.num_properties = ARRAY_SIZE(abx500_chargalg_props); di->chargalg_psy.get_property = abx500_chargalg_get_property; - di->chargalg_psy.supplied_to = di->pdata->supplied_to; - di->chargalg_psy.num_supplicants = di->pdata->num_supplicants; + di->chargalg_psy.supplied_to = supply_interface; + di->chargalg_psy.num_supplicants = ARRAY_SIZE(supply_interface), di->chargalg_psy.external_power_changed = abx500_chargalg_external_power_changed; @@ -1843,7 +1863,7 @@ static int __devinit abx500_chargalg_probe(struct platform_device *pdev) create_singlethread_workqueue("abx500_chargalg_wq"); if (di->chargalg_wq == NULL) { dev_err(di->dev, "failed to create work queue\n"); - goto free_device_info; + return -ENOMEM; } /* Init work for chargalg */ @@ -1884,20 +1904,24 @@ free_psy: power_supply_unregister(&di->chargalg_psy); free_chargalg_wq: destroy_workqueue(di->chargalg_wq); -free_device_info: - kfree(di); return ret; } +static const struct of_device_id ab8500_chargalg_match[] = { + { .compatible = "stericsson,ab8500-chargalg", }, + { }, +}; + static struct platform_driver abx500_chargalg_driver = { .probe = abx500_chargalg_probe, .remove = __devexit_p(abx500_chargalg_remove), .suspend = abx500_chargalg_suspend, .resume = abx500_chargalg_resume, .driver = { - .name = "abx500-chargalg", + .name = "ab8500-chargalg", .owner = THIS_MODULE, + .of_match_table = ab8500_chargalg_match, }, }; diff --git a/include/linux/mfd/abx500.h b/include/linux/mfd/abx500.h index 33f2c58..2138bd3 100644 --- a/include/linux/mfd/abx500.h +++ b/include/linux/mfd/abx500.h @@ -274,12 +274,6 @@ struct abx500_bm_data { extern struct abx500_bm_data ab8500_bm_data; -struct abx500_bmdevs_plat_data { - char **supplied_to; - size_t num_supplicants; - bool autopower_cfg; -}; - enum { NTC_EXTERNAL = 0, NTC_INTERNAL,