From patchwork Mon Feb 4 11:53:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 14462 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 8D93A23F96 for ; Mon, 4 Feb 2013 11:56:14 +0000 (UTC) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by fiordland.canonical.com (Postfix) with ESMTP id 3172AA1922C for ; Mon, 4 Feb 2013 11:56:14 +0000 (UTC) Received: by mail-vc0-f180.google.com with SMTP id fo13so3868350vcb.11 for ; Mon, 04 Feb 2013 03:56:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=JqBY6DsFSicXkDU6X2Ro0pedt9NXHNNXCT1ogClRpWo=; b=gCPCQc+T1DVn1tlIhlG+APYlcYUx1TsCOQHrvW2dUTqlvOmtTvLTGtsjBH1FGbsGTF T2jd6aQaNi9JK+FSAuok3K6MU88lz0l6mu3lE4us15i6Zv4y5QEHm86Bb1LHCUnLjP7u RiSrZCJKb3zn97sRYDCXHvhqRfqAIssUAfcza2A9BzaRLheHRombQLRBY9LFMB02uuqv D4SzuxGhuUmNS1Mnah3XUdkCXLAKd2EGvsmRBxoMAYCam1+HArOntj3a0x6LcNXWvHIb CA6YG3WBhrOYuU+wBFFj/OHRqiXQzNLg04Z8x0oCN5Ppg+0r5VKq4F/fXn9ZSM1j6+Ux +GIw== X-Received: by 10.52.21.146 with SMTP id v18mr18928922vde.79.1359978973675; Mon, 04 Feb 2013 03:56:13 -0800 (PST) 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.58.252.8 with SMTP id zo8csp83035vec; Mon, 4 Feb 2013 03:56:13 -0800 (PST) X-Received: by 10.180.92.129 with SMTP id cm1mr9932246wib.10.1359978972691; Mon, 04 Feb 2013 03:56:12 -0800 (PST) Received: from mail-we0-x235.google.com ([2a00:1450:400c:c03::235]) by mx.google.com with ESMTPS id ei1si3460421wib.118.2013.02.04.03.56.12 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Feb 2013 03:56:12 -0800 (PST) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::235 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:400c:c03::235; Authentication-Results: mx.google.com; spf=neutral (google.com: 2a00:1450:400c:c03::235 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-we0-f181.google.com with SMTP id t44so4688020wey.12 for ; Mon, 04 Feb 2013 03:56:12 -0800 (PST) X-Received: by 10.180.94.234 with SMTP id df10mr9927918wib.17.1359978972112; Mon, 04 Feb 2013 03:56:12 -0800 (PST) Received: from localhost.localdomain (cpc34-aztw25-2-0-cust250.18-1.cable.virginmedia.com. [86.16.136.251]) by mx.google.com with ESMTPS id j9sm12937128wia.5.2013.02.04.03.56.10 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Feb 2013 03:56:11 -0800 (PST) From: Lee Jones To: linux-kernel@vger.kernel.org, broonie@opensource.wolfsonmicro.com Cc: Bengt Jonsson , Lee Jones Subject: [PATCH 13/73] regulator: ab8500: Separate regulator and MFD platform data Date: Mon, 4 Feb 2013 11:53:28 +0000 Message-Id: <1359978868-28736-14-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1359978868-28736-1-git-send-email-lee.jones@linaro.org> References: <1359978868-28736-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQk3O5Dy3/r2FLkHUApFu5gB/JgMdgTH3RfUpPlCdZai3vlCcM15gBhbOTC5TsJ0pScNwZ+a From: Bengt Jonsson The ab8500 MFD should not have knowledge about regulator- specific platform data like number of regulators and regulator registers. As the regulator platform data is about to grow with external regulators, this information is moved to a new structure provided by the regulator driver. Signed-off-by: Bengt Jonsson Signed-off-by: Lee Jones Reviewed-by: Yvan FILLION --- arch/arm/mach-ux500/board-mop500-regulators.c | 12 +++++++++--- arch/arm/mach-ux500/board-mop500-regulators.h | 4 +--- drivers/regulator/ab8500.c | 21 +++++++++++++++------ include/linux/regulator/ab8500.h | 7 +++++++ 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/arch/arm/mach-ux500/board-mop500-regulators.c b/arch/arm/mach-ux500/board-mop500-regulators.c index a138587..967e4ac 100644 --- a/arch/arm/mach-ux500/board-mop500-regulators.c +++ b/arch/arm/mach-ux500/board-mop500-regulators.c @@ -122,8 +122,7 @@ static struct regulator_consumer_supply ab8500_vana_consumers[] = { }; /* ab8500 regulator register initialization */ -struct ab8500_regulator_reg_init -ab8500_regulator_reg_init[AB8500_NUM_REGULATOR_REGISTERS] = { +static struct ab8500_regulator_reg_init ab8500_reg_init[] = { /* * VanaRequestCtrl = HP/LP depending on VxRequest * VpllRequestCtrl = HP/LP depending on VxRequest @@ -330,7 +329,7 @@ ab8500_regulator_reg_init[AB8500_NUM_REGULATOR_REGISTERS] = { }; /* AB8500 regulators */ -struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS] = { +static struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS] = { /* supplies to the display/camera */ [AB8500_LDO_AUX1] = { .constraints = { @@ -439,3 +438,10 @@ struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS] = { .consumer_supplies = ab8500_vana_consumers, }, }; + +struct ab8500_regulator_platform_data ab8500_regulator_plat_data = { + .reg_init = ab8500_reg_init, + .num_reg_init = ARRAY_SIZE(ab8500_reg_init), + .regulator = ab8500_regulators, + .num_regulator = ARRAY_SIZE(ab8500_regulators), +}; diff --git a/arch/arm/mach-ux500/board-mop500-regulators.h b/arch/arm/mach-ux500/board-mop500-regulators.h index 78a0642..9ca4869 100644 --- a/arch/arm/mach-ux500/board-mop500-regulators.h +++ b/arch/arm/mach-ux500/board-mop500-regulators.h @@ -14,9 +14,7 @@ #include #include -extern struct ab8500_regulator_reg_init -ab8500_regulator_reg_init[AB8500_NUM_REGULATOR_REGISTERS]; -extern struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS]; +extern struct ab8500_regulator_platform_data ab8500_regulator_plat_data; extern struct regulator_init_data tps61052_regulator; extern struct regulator_init_data gpio_en_3v3_regulator; diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index d88ff3e..3ccb9eb 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -976,8 +976,9 @@ ab8500_regulator_of_probe(struct platform_device *pdev, struct device_node *np) static int ab8500_regulator_probe(struct platform_device *pdev) { struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); - struct ab8500_platform_data *pdata; struct device_node *np = pdev->dev.of_node; + struct ab8500_platform_data *ppdata; + struct ab8500_regulator_platform_data *pdata; int i, err; if (np) { @@ -998,7 +999,14 @@ static int ab8500_regulator_probe(struct platform_device *pdev) dev_err(&pdev->dev, "null mfd parent\n"); return -EINVAL; } - pdata = dev_get_platdata(ab8500->dev); + + ppdata = dev_get_platdata(ab8500->dev); + if (!ppdata) { + dev_err(&pdev->dev, "null parent pdata\n"); + return -EINVAL; + } + + pdata = ppdata->regulator; if (!pdata) { dev_err(&pdev->dev, "null pdata\n"); return -EINVAL; @@ -1011,12 +1019,12 @@ static int ab8500_regulator_probe(struct platform_device *pdev) } /* initialize registers */ - for (i = 0; i < pdata->num_regulator_reg_init; i++) { + for (i = 0; i < pdata->num_reg_init; i++) { int id, mask, value; - id = pdata->regulator_reg_init[i].id; - mask = pdata->regulator_reg_init[i].mask; - value = pdata->regulator_reg_init[i].value; + id = pdata->reg_init[i].id; + mask = pdata->reg_init[i].mask; + value = pdata->reg_init[i].value; /* check for configuration errors */ BUG_ON(id >= AB8500_NUM_REGULATOR_REGISTERS); @@ -1082,5 +1090,6 @@ module_exit(ab8500_regulator_exit); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Sundar Iyer "); +MODULE_AUTHOR("Bengt Jonsson "); MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC"); MODULE_ALIAS("platform:ab8500-regulator"); diff --git a/include/linux/regulator/ab8500.h b/include/linux/regulator/ab8500.h index dd7944f..3a8e026 100644 --- a/include/linux/regulator/ab8500.h +++ b/include/linux/regulator/ab8500.h @@ -152,4 +152,11 @@ enum ab9540_regulator_reg { AB9540_NUM_REGULATOR_REGISTERS, }; +struct ab8500_regulator_platform_data { + int num_reg_init; + struct ab8500_regulator_reg_init *reg_init; + int num_regulator; + struct regulator_init_data *regulator; +}; + #endif