From patchwork Thu Oct 25 06:30:54 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: 12490 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 39B7123F9B for ; Thu, 25 Oct 2012 06:31:39 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 9E429A18E8C for ; Thu, 25 Oct 2012 06:31:38 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id f6so1020314iag.11 for ; Wed, 24 Oct 2012 23:31:37 -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=8IfAQwyQ0E4ZhygYvS59DIpya/LuyBITp/3olv3UXlA=; b=UQ6kR8v4EYoNAyyMc0CS+06XRowqd4GB2jaztHd2mcTvPWj+x4DKuiV3YC9g+ubyRE 7hJTPWPYWT9OAESvU1DcJR/AHFXxVlY/ajB8Bxw8zj8L4jraRBgrERtxw9Nq2faqqXwT BLy8cNh1JLwIOXRNh6N+1vCEM7sUgvng6D7Jefzmfn6HOJuyY/ujXEDMGOyHs4WAGZ6c Y1LFvNgUPpUCOcv526NY0oRcqB11QyqcZiWpTN40f9VvFVmoS0YOV1qNwR+7hOqbWIXa EbCJZ1TQVMCWcvbPS9gIOO8hehoumP4Xi7bc9YFZx4nRSkGqIZ/ZLkin006/u02g5z8N 7yxQ== Received: by 10.50.194.169 with SMTP id hx9mr4879235igc.70.1351146697790; Wed, 24 Oct 2012 23:31:37 -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.67.148 with SMTP id n20csp745212igt; Wed, 24 Oct 2012 23:31:36 -0700 (PDT) Received: by 10.14.200.194 with SMTP id z42mr16725420een.13.1351146695890; Wed, 24 Oct 2012 23:31:35 -0700 (PDT) Received: from eu1sys200aog102.obsmtp.com (eu1sys200aog102.obsmtp.com [207.126.144.113]) by mx.google.com with SMTP id j5si1233925eeo.26.2012.10.24.23.31.17 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 24 Oct 2012 23:31:35 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.113 is neither permitted nor denied by best guess record for domain of rajanikanth.hv@stericsson.com) client-ip=207.126.144.113; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.113 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-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob102.postini.com ([207.126.147.11]) with SMTP ID DSNKUIjcs/8O8bmPfqHPVMCCWtbfMMF8rct4@postini.com; Thu, 25 Oct 2012 06:31:35 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id C3F17FE; Thu, 25 Oct 2012 06:22:59 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id E42B1FC5; Thu, 25 Oct 2012 06:31:11 +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 relay2.stm.gmessaging.net (Postfix) with ESMTPS id 34529A8074; Thu, 25 Oct 2012 08:31:08 +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; Thu, 25 Oct 2012 08:31:10 +0200 From: Rajanikanth H.V To: , , , , Cc: , , , , , Subject: [PATCH 4/4] mfd: ab8500: add devicetree support for chargalg Date: Thu, 25 Oct 2012 12:00:54 +0530 Message-ID: <1351146654-9110-5-git-send-email-rajanikanth.hv@stericsson.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1351146654-9110-1-git-send-email-rajanikanth.hv@stericsson.com> References: <1351146654-9110-1-git-send-email-rajanikanth.hv@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmpJnKce4teQq+iCXU7lr4+sqtca1NB7FvElNLcUyP4DNfEr/Xl+Iq3N7Jd/Q34Ti3N8w7u 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 | 54 ++++++++++++++------ include/linux/mfd/abx500.h | 6 --- 5 files changed, 65 insertions(+), 21 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 b1ecb5d..a678afa 100644 --- a/arch/arm/boot/dts/dbx5x0.dtsi +++ b/arch/arm/boot/dts/dbx5x0.dtsi @@ -373,6 +373,11 @@ vddadc-supply = <&ab8500_ldo_tvout_reg>; }; + ab8500_chargalg { + compatible = "stericsson,ab8500-chargalg"; + battery = <&ab8500_battery>; + }; + ab8500_usb { compatible = "stericsson,ab8500-usb"; interrupts = < 90 0x4 diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index c7a120b..afe835b 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_USE_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 88b5cc1..829fcfd 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 @@ -231,7 +233,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,25 +1796,45 @@ 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"); + printk("%s falling back to legacy platform data\n", __func__); + } /* 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"; @@ -1821,8 +1842,8 @@ static int __devinit abx500_chargalg_probe(struct platform_device *pdev) 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; @@ -1842,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 */ @@ -1883,20 +1904,23 @@ 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 bbf3ad6..a14c1a6 100644 --- a/include/linux/mfd/abx500.h +++ b/include/linux/mfd/abx500.h @@ -389,12 +389,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,