From patchwork Tue Jul 8 12:27:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Daniel Kachhap X-Patchwork-Id: 33197 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f198.google.com (mail-ig0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A7F7A2070A for ; Tue, 8 Jul 2014 12:28:41 +0000 (UTC) Received: by mail-ig0-f198.google.com with SMTP id h3sf2162017igd.5 for ; Tue, 08 Jul 2014 05:28:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=lVSvDq/spZRLT9RU23BTlL+9HuhNJ/hzEFBYvnZH1Ts=; b=fgHMdv+w9HXdy3G/q1tbCIw97F6/jebAD9rc6c9nU8WLmPQH2KHmLhxgiidR3NnF6B CMNW4P1oPFWdr4Vq89xG6coVe7eK54gWccM8ZkhF9fZjQ0w2UU5qvbteV/jn9Y1a3618 kKia+YaD25laozmDatrd8/ZVevpSU+LfQlAC4YCzkEDHZOVBCQIVnP7bZz8Yc68aRKWg wfKMhelfS12HKH7S7GuFUNyMYVYSxPL2m9F6CLutd5AnJe+hJf3Ay/+tQP18dY9k7zau Zoh73ng9WrynZDUHhkjrTQUQFnlK+fSAUNaOnSsioswZA7+DOhaNiNIpeg6vcjgM1toh 9sCg== X-Gm-Message-State: ALoCoQnk0JB843kjw8Rzg6fEgH85KvhUgDc9QtZG/LiwmQjuWhg4X+DCG42w+qrctpckSE/zXjsr X-Received: by 10.43.103.136 with SMTP id di8mr16607740icc.14.1404822521207; Tue, 08 Jul 2014 05:28:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.106.33 with SMTP id d30ls1844315qgf.47.gmail; Tue, 08 Jul 2014 05:28:41 -0700 (PDT) X-Received: by 10.58.112.65 with SMTP id io1mr77846veb.61.1404822521076; Tue, 08 Jul 2014 05:28:41 -0700 (PDT) Received: from mail-vc0-x22d.google.com (mail-vc0-x22d.google.com [2607:f8b0:400c:c03::22d]) by mx.google.com with ESMTPS id sk10si20071979vec.81.2014.07.08.05.28.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 08 Jul 2014 05:28:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::22d as permitted sender) client-ip=2607:f8b0:400c:c03::22d; Received: by mail-vc0-f173.google.com with SMTP id lf12so5333359vcb.18 for ; Tue, 08 Jul 2014 05:28:41 -0700 (PDT) X-Received: by 10.220.2.18 with SMTP id 18mr92328vch.49.1404822521002; Tue, 08 Jul 2014 05:28:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp765858vcb; Tue, 8 Jul 2014 05:28:40 -0700 (PDT) X-Received: by 10.70.54.162 with SMTP id k2mr2933278pdp.138.1404822520142; Tue, 08 Jul 2014 05:28:40 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ih9si3819175pbc.11.2014.07.08.05.28.39; Tue, 08 Jul 2014 05:28:39 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754640AbaGHM2S (ORCPT + 27 others); Tue, 8 Jul 2014 08:28:18 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:43370 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754583AbaGHM2Q (ORCPT ); Tue, 8 Jul 2014 08:28:16 -0400 Received: by mail-pa0-f50.google.com with SMTP id bj1so7349309pad.9 for ; Tue, 08 Jul 2014 05:28:16 -0700 (PDT) X-Received: by 10.68.103.228 with SMTP id fz4mr35595260pbb.46.1404822496114; Tue, 08 Jul 2014 05:28:16 -0700 (PDT) Received: from localhost.localdomain ([14.140.216.146]) by mx.google.com with ESMTPSA id pu5sm55707055pbb.4.2014.07.08.05.28.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Jul 2014 05:28:15 -0700 (PDT) From: Amit Daniel Kachhap To: Sangbeom Kim , Liam Girdwood , Mark Brown Cc: linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] regulator: s2mpa01: Optimize the regulator description macro Date: Tue, 8 Jul 2014 17:57:59 +0530 Message-Id: <1404822480-31525-2-git-send-email-amit.daniel@samsung.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1404822480-31525-1-git-send-email-amit.daniel@samsung.com> References: <1404822480-31525-1-git-send-email-amit.daniel@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: amit.daniel@samsung.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::22d as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@ Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch makes the regulator description macro take minimum and steps voltage as parameter. In this way many repeated macros can be removed. Now these macros are repeated only if the the LDO/BUCK ctrl registers have non-linear positions. The good thing is these ctrl registers are mostly linear so they are not passed as parameters. This patch reduces the code size and also allow easy addition of more s2mpxxx PMIC drivers which differs a lot in minimum/step voltages. Signed-off-by: Amit Daniel Kachhap --- drivers/regulator/s2mpa01.c | 136 ++++++++++++-------------------------------- 1 file changed, 37 insertions(+), 99 deletions(-) diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c index 962c5f1..8073466 100644 --- a/drivers/regulator/s2mpa01.c +++ b/drivers/regulator/s2mpa01.c @@ -235,28 +235,14 @@ static struct regulator_ops s2mpa01_buck_ops = { .set_ramp_delay = s2mpa01_set_ramp_delay, }; -#define regulator_desc_ldo1(num) { \ +#define regulator_desc_ldo(num, min, step) { \ .name = "LDO"#num, \ .id = S2MPA01_LDO##num, \ .ops = &s2mpa01_ldo_ops, \ .type = REGULATOR_VOLTAGE, \ .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step = STEP_50_MV, \ - .n_voltages = S2MPA01_LDO_N_VOLTAGES, \ - .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \ - .vsel_mask = S2MPA01_LDO_VSEL_MASK, \ - .enable_reg = S2MPA01_REG_L1CTRL + num - 1, \ - .enable_mask = S2MPA01_ENABLE_MASK \ -} -#define regulator_desc_ldo2(num) { \ - .name = "LDO"#num, \ - .id = S2MPA01_LDO##num, \ - .ops = &s2mpa01_ldo_ops, \ - .type = REGULATOR_VOLTAGE, \ - .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step = STEP_25_MV, \ + .min_uV = min, \ + .uV_step = step, \ .n_voltages = S2MPA01_LDO_N_VOLTAGES, \ .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \ .vsel_mask = S2MPA01_LDO_VSEL_MASK, \ @@ -296,14 +282,14 @@ static struct regulator_ops s2mpa01_buck_ops = { .enable_mask = S2MPA01_ENABLE_MASK \ } -#define regulator_desc_buck6_7(num) { \ +#define regulator_desc_buck6_10(num, min, step) { \ .name = "BUCK"#num, \ .id = S2MPA01_BUCK##num, \ .ops = &s2mpa01_buck_ops, \ .type = REGULATOR_VOLTAGE, \ .owner = THIS_MODULE, \ - .min_uV = MIN_600_MV, \ - .uV_step = STEP_6_25_MV, \ + .min_uV = min, \ + .uV_step = step, \ .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ .ramp_delay = S2MPA01_RAMP_DELAY, \ .vsel_reg = S2MPA01_REG_B6CTRL2 + (num - 6) * 2, \ @@ -312,91 +298,43 @@ static struct regulator_ops s2mpa01_buck_ops = { .enable_mask = S2MPA01_ENABLE_MASK \ } -#define regulator_desc_buck8 { \ - .name = "BUCK8", \ - .id = S2MPA01_BUCK8, \ - .ops = &s2mpa01_buck_ops, \ - .type = REGULATOR_VOLTAGE, \ - .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step = STEP_12_5_MV, \ - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ - .ramp_delay = S2MPA01_RAMP_DELAY, \ - .vsel_reg = S2MPA01_REG_B8CTRL2, \ - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \ - .enable_reg = S2MPA01_REG_B8CTRL1, \ - .enable_mask = S2MPA01_ENABLE_MASK \ -} - -#define regulator_desc_buck9 { \ - .name = "BUCK9", \ - .id = S2MPA01_BUCK9, \ - .ops = &s2mpa01_buck_ops, \ - .type = REGULATOR_VOLTAGE, \ - .owner = THIS_MODULE, \ - .min_uV = MIN_1500_MV, \ - .uV_step = STEP_12_5_MV, \ - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ - .ramp_delay = S2MPA01_RAMP_DELAY, \ - .vsel_reg = S2MPA01_REG_B9CTRL2, \ - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \ - .enable_reg = S2MPA01_REG_B9CTRL1, \ - .enable_mask = S2MPA01_ENABLE_MASK \ -} - -#define regulator_desc_buck10 { \ - .name = "BUCK10", \ - .id = S2MPA01_BUCK10, \ - .ops = &s2mpa01_buck_ops, \ - .type = REGULATOR_VOLTAGE, \ - .owner = THIS_MODULE, \ - .min_uV = MIN_1000_MV, \ - .uV_step = STEP_12_5_MV, \ - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ - .ramp_delay = S2MPA01_RAMP_DELAY, \ - .vsel_reg = S2MPA01_REG_B10CTRL2, \ - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \ - .enable_reg = S2MPA01_REG_B10CTRL1, \ - .enable_mask = S2MPA01_ENABLE_MASK \ -} - static struct regulator_desc regulators[] = { - regulator_desc_ldo2(1), - regulator_desc_ldo1(2), - regulator_desc_ldo1(3), - regulator_desc_ldo1(4), - regulator_desc_ldo1(5), - regulator_desc_ldo2(6), - regulator_desc_ldo1(7), - regulator_desc_ldo1(8), - regulator_desc_ldo1(9), - regulator_desc_ldo1(10), - regulator_desc_ldo2(11), - regulator_desc_ldo1(12), - regulator_desc_ldo1(13), - regulator_desc_ldo1(14), - regulator_desc_ldo1(15), - regulator_desc_ldo1(16), - regulator_desc_ldo1(17), - regulator_desc_ldo1(18), - regulator_desc_ldo1(19), - regulator_desc_ldo1(20), - regulator_desc_ldo1(21), - regulator_desc_ldo2(22), - regulator_desc_ldo2(23), - regulator_desc_ldo1(24), - regulator_desc_ldo1(25), - regulator_desc_ldo1(26), + regulator_desc_ldo(1, MIN_800_MV, STEP_25_MV), + regulator_desc_ldo(2, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(3, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(4, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(5, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(6, MIN_800_MV, STEP_25_MV), + regulator_desc_ldo(7, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(8, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(9, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(10, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(11, MIN_800_MV, STEP_25_MV), + regulator_desc_ldo(12, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(13, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(14, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(15, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(16, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(17, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(18, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(19, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(20, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(21, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(22, MIN_800_MV, STEP_25_MV), + regulator_desc_ldo(23, MIN_800_MV, STEP_25_MV), + regulator_desc_ldo(24, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(25, MIN_800_MV, STEP_50_MV), + regulator_desc_ldo(26, MIN_800_MV, STEP_50_MV), regulator_desc_buck1_4(1), regulator_desc_buck1_4(2), regulator_desc_buck1_4(3), regulator_desc_buck1_4(4), regulator_desc_buck5, - regulator_desc_buck6_7(6), - regulator_desc_buck6_7(7), - regulator_desc_buck8, - regulator_desc_buck9, - regulator_desc_buck10, + regulator_desc_buck6_10(6, MIN_600_MV, STEP_6_25_MV), + regulator_desc_buck6_10(7, MIN_600_MV, STEP_6_25_MV), + regulator_desc_buck6_10(8, MIN_800_MV, STEP_12_5_MV), + regulator_desc_buck6_10(9, MIN_1500_MV, STEP_12_5_MV), + regulator_desc_buck6_10(10, MIN_1000_MV, STEP_12_5_MV), }; static int s2mpa01_pmic_probe(struct platform_device *pdev)