From patchwork Mon Oct 1 04:08:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\"Rajanikanth H.V" X-Patchwork-Id: 11876 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 75E7723EFB for ; Mon, 1 Oct 2012 04:09:40 +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 F283AA186CF for ; Mon, 1 Oct 2012 04:09:39 +0000 (UTC) Received: by ieje10 with SMTP id e10so10760847iej.11 for ; Sun, 30 Sep 2012 21:09:39 -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:cc :subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:x-gm-message-state; bh=R9Hlbdxlzmx/AeNMa5gQ8DlCxNu/KXOebaswMy412u0=; b=BIPe8+cFwojQ4kAL6dUUE6vNccuCW3+ZsDJY7WVuOPbTPiNDVuWmLL0vjicjafX/DL bLqZNGsQxmetH/dofCHx6IJYpwQ7nGPWDuPSxlORhKeqI+HlXjhyyXHKMUh2K5qpBb+f spHie8YwpFk94izDiFXF2EEIKrnBBu8qMhYCbRKTBe8NmbB/ovKGZTSJB6/ata3Sxz1I /uvQ0/3LZoPpT4CmL95DePb+Wy5NTA0sZXFKFgUR3YAl9A2nnie1dj+SPT35VirPUFNk 13CXZlBdVVk0DUS0RUbDvZVupiDUBfp7FiNo1Xd2XHBrgiowxBDWvBxgemBqks1Tgjvx 4b+w== Received: by 10.42.110.130 with SMTP id q2mr10336657icp.53.1349064579419; Sun, 30 Sep 2012 21:09:39 -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 ex8csp6796igc; Sun, 30 Sep 2012 21:09:38 -0700 (PDT) Received: by 10.14.203.69 with SMTP id e45mr761073eeo.38.1349064577752; Sun, 30 Sep 2012 21:09:37 -0700 (PDT) Received: from eu1sys200aog104.obsmtp.com (eu1sys200aog104.obsmtp.com [207.126.144.117]) by mx.google.com with SMTP id h45si169099eem.29.2012.09.30.21.09.33 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 30 Sep 2012 21:09:37 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.117 is neither permitted nor denied by best guess record for domain of rajanikanth.hv@stericsson.com) client-ip=207.126.144.117; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.117 is neither permitted nor denied by best guess record for domain of rajanikanth.hv@stericsson.com) smtp.mail=rajanikanth.hv@stericsson.com Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob104.postini.com ([207.126.147.11]) with SMTP ID DSNKUGkXfIFUt9WPyhfxmToRdJFeqIrS66Yj@postini.com; Mon, 01 Oct 2012 04:09:37 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id DD2737F; Mon, 1 Oct 2012 04:08:53 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BE4AB185B; Mon, 1 Oct 2012 04:08:52 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 9F7F024C07C; Mon, 1 Oct 2012 06:08:49 +0200 (CEST) Received: from ubuntu12.bnr.st.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.83.0; Mon, 1 Oct 2012 06:08:51 +0200 From: Rajanikanth H.V To: , , , , Cc: , , , , , Subject: [PATCH 4/4] mfd: ab8500: add devicetree support for charging algorithm Date: Mon, 1 Oct 2012 09:38:33 +0530 Message-ID: <1349064513-31301-5-git-send-email-rajanikanth.hv@stericsson.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1349064513-31301-1-git-send-email-rajanikanth.hv@stericsson.com> References: <1349064513-31301-1-git-send-email-rajanikanth.hv@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQlEm5F9AsFWdLxRGk1gOaZMNxUpmVP4xxD9aV0qOZU/hu4R5nBf20sjJEKenaBffEPOKMIT 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 | 36 ++++++++++++ drivers/mfd/ab8500-core.c | 1 + drivers/power/abx500_chargalg.c | 58 ++++++++++++++++---- 3 files changed, 83 insertions(+), 12 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..73b7ccc --- /dev/null +++ b/Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt @@ -0,0 +1,36 @@ +=== AB8500 Charging Algorithm Driver === + +Charging algorithm is logical part of energy-management-module +which implements the state machine to handle charing status w.r.t +VBUS and main charger, battery-state, over-voltage protection, +'battery-temperature' status. +Charging algorithm also implements subset of power-supply properties. +Ref: enum power_supply_property, include/linux/power_supply.h + +This module does not directly interact with h/w, it primarily depends +on fuel-gauge and runtime battery status information. + +The properties below describes the node for Charging Algorithm +module: + +Required Properties: +- compatible = "stericsson,ab8500-chargalg" +- interface-name: + Name of the controller/driver which is part of energy-management-module +- supplied-to: + This property shall have dependent nodes which represent other + energy-management-module. + example: + ab8500-btemp { + /* dependent energy management module */ + supplied-to = <&ab8500_fuel_gauge>; + }; + +Other dependent node is: + ab8500_battery_info: ab8500_bat_type { + }; + This node will provide information on 'thermistor interface' and + 'battery technology type' used. + +ref: further details. + Documentation/devicetree/bindings/power_supply/ab8500/fg.txt diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index 0c81138..0ab3506 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c @@ -1059,6 +1059,7 @@ 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, }, diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/abx500_chargalg.c index ba548e4..8d83580 100644 --- a/drivers/power/abx500_chargalg.c +++ b/drivers/power/abx500_chargalg.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -1795,27 +1796,56 @@ 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 int __devinit abx500_chargalg_probe(struct platform_device *pdev) { - struct abx500_bm_plat_data *plat_data; int ret = 0; + struct abx500_chargalg *di; + struct device_node *np = pdev->dev.of_node; + struct abx500_bm_plat_data *plat_data = pdev->dev.platform_data; - 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; + } + if (np) { + if (!plat_data) { + plat_data = + devm_kzalloc(&pdev->dev, sizeof(*plat_data), + GFP_KERNEL); + if (!plat_data) { + dev_err(&pdev->dev, + "%s no mem for plat_data\n", __func__); + return -ENOMEM; + } + plat_data->bmdev_pdata = devm_kzalloc(&pdev->dev, + sizeof(*plat_data->bmdev_pdata), GFP_KERNEL); + if (!plat_data->bmdev_pdata) { + dev_err(&pdev->dev, + "%s no mem for pdata->chargalg\n", + __func__); + return -ENOMEM; + } + } + ret = bmdevs_of_probe(&pdev->dev, np, plat_data); + if (ret < 0) { + dev_err(&pdev->dev, "failed to get platform data\n"); + return ret; + } + } + if (!plat_data) { + dev_err(&pdev->dev, "No platform data\n"); + return -EINVAL; + } /* get device struct */ - di->dev = &pdev->dev; - - plat_data = pdev->dev.platform_data; + di->dev = &pdev->dev; di->pdata = plat_data->bmdev_pdata; - di->bat = plat_data->battery; + di->bat = plat_data->battery; /* chargalg supply */ di->chargalg_psy.name = "abx500_chargalg"; @@ -1844,7 +1874,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 */ @@ -1885,12 +1915,15 @@ 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), @@ -1899,6 +1932,7 @@ static struct platform_driver abx500_chargalg_driver = { .driver = { .name = "abx500-chargalg", .owner = THIS_MODULE, + .of_match_table = ab8500_chargalg_match, }, };