From patchwork Mon Apr 14 18:50:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Porter X-Patchwork-Id: 3985361 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 033C5BFF02 for ; Mon, 14 Apr 2014 18:53:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 06C13201FB for ; Mon, 14 Apr 2014 18:53:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 005FC20170 for ; Mon, 14 Apr 2014 18:53:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WZlyX-00009S-Mf; Mon, 14 Apr 2014 18:51:25 +0000 Received: from mail-ie0-f170.google.com ([209.85.223.170]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WZlyB-0008IX-1r for linux-arm-kernel@lists.infradead.org; Mon, 14 Apr 2014 18:51:03 +0000 Received: by mail-ie0-f170.google.com with SMTP id rd18so8585871iec.1 for ; Mon, 14 Apr 2014 11:50:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MJBpijOoC0BwBYnWSoYY3VfQWGvitrBnHmc9CewF+dk=; b=k6Xm4uueTU3201qGSuzkB1JstT3o5xKoccsO/wZBrzBcHtYxhPAc+kEMyrbPmHBqGd EtJTYoAA9nzu9ePD789U1+aJYEORjc2aIKcyobi1HgAJCVZXaZ1/vh98AAnDgIUw0HTK +/2q7JUV70VeuPq18EMxtfQ9McCxJWquptkL3beyW9hFCf7yl2pNgj8aM8EwyBqx7lee DMgcPZjewgfTqVWS9WjY1GZBddx5HfiIP2yiQN9fmzpp66chCT7yUvzBMhKaT/PtYzcY SdIq7u2FaHXMYsnwqqBi2LPmz9JuWmYPQ9iqhq+iU1fzt3LWqjfDMrMj+qfFBWu7StUT zzzA== X-Gm-Message-State: ALoCoQmB8aPB8afeiJ+dCoT8mX09l5+1CYfZKG9p1ZY4PJas+kmv61D0rwM/buNVI9XNRDxzAcaK X-Received: by 10.50.56.109 with SMTP id z13mr17817406igp.6.1397501440886; Mon, 14 Apr 2014 11:50:40 -0700 (PDT) Received: from beef.ohporter.com (cpe-98-27-254-98.neo.res.rr.com. [98.27.254.98]) by mx.google.com with ESMTPSA id vf14sm15871924igb.8.2014.04.14.11.50.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Apr 2014 11:50:39 -0700 (PDT) From: Matt Porter To: Devicetree List , Lee Jones , Samuel Ortiz , Liam Girdwood , Mark Brown Subject: [PATCH 3/4] regulator: bcm590xx: add support for regulators on secondary i2c slave Date: Mon, 14 Apr 2014 14:50:27 -0400 Message-Id: <1397501428-8857-4-git-send-email-mporter@linaro.org> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1397501428-8857-1-git-send-email-mporter@linaro.org> References: <1397501428-8857-1-git-send-email-mporter@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140414_115103_261200_59BD1A61 X-CRM114-Status: GOOD ( 16.98 ) X-Spam-Score: -0.7 (/) Cc: Tim Kryger , Markus Mayer , Linux Kernel Mailing List , Linux ARM Kernel List X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The bcm590xx mfd driver now exposes a second regmap descriptor making the registers for regulators on the secondary i2c slave address available. Add support for GPLDO1-6 and VBUS regulators found within this register range. Signed-off-by: Matt Porter Acked-by: Mark Brown --- drivers/regulator/bcm590xx-regulator.c | 92 ++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 10 deletions(-) diff --git a/drivers/regulator/bcm590xx-regulator.c b/drivers/regulator/bcm590xx-regulator.c index c3750c5..4f0b5d9 100644 --- a/drivers/regulator/bcm590xx-regulator.c +++ b/drivers/regulator/bcm590xx-regulator.c @@ -22,7 +22,7 @@ #include #include -/* Register defs */ +/* I2C slave 0 registers */ #define BCM590XX_RFLDOPMCTRL1 0x60 #define BCM590XX_IOSR1PMCTRL1 0x7a #define BCM590XX_IOSR2PMCTRL1 0x7c @@ -31,13 +31,34 @@ #define BCM590XX_SDSR2PMCTRL1 0x86 #define BCM590XX_MSRPMCTRL1 0x8a #define BCM590XX_VSRPMCTRL1 0x8e -#define BCM590XX_REG_ENABLE BIT(7) - #define BCM590XX_RFLDOCTRL 0x96 #define BCM590XX_CSRVOUT1 0xc0 + +/* I2C slave 1 registers */ +#define BCM590XX_GPLDO5PMCTRL1 0x16 +#define BCM590XX_GPLDO6PMCTRL1 0x18 +#define BCM590XX_GPLDO1CTRL 0x1a +#define BCM590XX_GPLDO2CTRL 0x1b +#define BCM590XX_GPLDO3CTRL 0x1c +#define BCM590XX_GPLDO4CTRL 0x1d +#define BCM590XX_GPLDO5CTRL 0x1e +#define BCM590XX_GPLDO6CTRL 0x1f +#define BCM590XX_OTG_CTRL 0x40 +#define BCM590XX_GPLDO1PMCTRL1 0x57 +#define BCM590XX_GPLDO2PMCTRL1 0x59 +#define BCM590XX_GPLDO3PMCTRL1 0x5b +#define BCM590XX_GPLDO4PMCTRL1 0x5d + +#define BCM590XX_REG_ENABLE BIT(7) +#define BCM590XX_VBUS_ENABLE BIT(2) #define BCM590XX_LDO_VSEL_MASK GENMASK(5, 3) #define BCM590XX_SR_VSEL_MASK GENMASK(5, 0) +/* + * RFLDO to VSR regulators are + * accessed via I2C slave 0 + */ + /* LDO regulator IDs */ #define BCM590XX_REG_RFLDO 0 #define BCM590XX_REG_CAMLDO1 1 @@ -62,9 +83,25 @@ #define BCM590XX_REG_SDSR2 18 #define BCM590XX_REG_VSR 19 -#define BCM590XX_NUM_REGS 20 +/* + * GPLDO1 to VBUS regulators are + * accessed via I2C slave 1 + */ + +#define BCM590XX_REG_GPLDO1 20 +#define BCM590XX_REG_GPLDO2 21 +#define BCM590XX_REG_GPLDO3 22 +#define BCM590XX_REG_GPLDO4 23 +#define BCM590XX_REG_GPLDO5 24 +#define BCM590XX_REG_GPLDO6 25 +#define BCM590XX_REG_VBUS 26 + +#define BCM590XX_NUM_REGS 27 #define BCM590XX_REG_IS_LDO(n) (n < BCM590XX_REG_CSR) +#define BCM590XX_REG_IS_GPLDO(n) \ + ((n > BCM590XX_REG_VSR) && (n < BCM590XX_REG_VBUS)) +#define BCM590XX_REG_IS_VBUS(n) (n == BCM590XX_REG_VBUS) struct bcm590xx_board { struct regulator_init_data *bcm590xx_pmu_init_data[BCM590XX_NUM_REGS]; @@ -149,6 +186,12 @@ static struct bcm590xx_info bcm590xx_regs[] = { BCM590XX_REG_RANGES(sdsr1, dcdc_sdsr1_ranges), BCM590XX_REG_RANGES(sdsr2, dcdc_iosr1_ranges), BCM590XX_REG_RANGES(vsr, dcdc_iosr1_ranges), + BCM590XX_REG_TABLE(gpldo1, ldo_a_table), + BCM590XX_REG_TABLE(gpldo2, ldo_a_table), + BCM590XX_REG_TABLE(gpldo3, ldo_a_table), + BCM590XX_REG_TABLE(gpldo4, ldo_a_table), + BCM590XX_REG_TABLE(gpldo5, ldo_a_table), + BCM590XX_REG_TABLE(gpldo6, ldo_a_table), }; struct bcm590xx_reg { @@ -161,6 +204,8 @@ static int bcm590xx_get_vsel_register(int id) { if (BCM590XX_REG_IS_LDO(id)) return BCM590XX_RFLDOCTRL + id; + else if (BCM590XX_REG_IS_GPLDO(id)) + return BCM590XX_GPLDO1CTRL + id; else return BCM590XX_CSRVOUT1 + (id - BCM590XX_REG_CSR) * 3; } @@ -171,6 +216,8 @@ static int bcm590xx_get_enable_register(int id) if (BCM590XX_REG_IS_LDO(id)) reg = BCM590XX_RFLDOPMCTRL1 + id * 2; + else if (BCM590XX_REG_IS_GPLDO(id)) + reg = BCM590XX_GPLDO1PMCTRL1 + id * 2; else switch (id) { case BCM590XX_REG_CSR: @@ -191,8 +238,11 @@ static int bcm590xx_get_enable_register(int id) case BCM590XX_REG_SDSR2: reg = BCM590XX_SDSR2PMCTRL1; break; + case BCM590XX_REG_VBUS: + reg = BCM590XX_OTG_CTRL; }; + return reg; } @@ -216,6 +266,12 @@ static struct regulator_ops bcm590xx_ops_dcdc = { .map_voltage = regulator_map_voltage_linear_range, }; +static struct regulator_ops bcm590xx_ops_vbus = { + .is_enabled = regulator_is_enabled_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, +}; + #define BCM590XX_MATCH(_name, _id) \ { \ .name = #_name, \ @@ -243,6 +299,13 @@ static struct of_regulator_match bcm590xx_matches[] = { BCM590XX_MATCH(sdsr1, SDSR1), BCM590XX_MATCH(sdsr2, SDSR2), BCM590XX_MATCH(vsr, VSR), + BCM590XX_MATCH(gpldo1, GPLDO1), + BCM590XX_MATCH(gpldo2, GPLDO2), + BCM590XX_MATCH(gpldo3, GPLDO3), + BCM590XX_MATCH(gpldo4, GPLDO4), + BCM590XX_MATCH(gpldo5, GPLDO5), + BCM590XX_MATCH(gpldo6, GPLDO6), + BCM590XX_MATCH(vbus, VBUS), }; static struct bcm590xx_board *bcm590xx_parse_dt_reg_data( @@ -353,17 +416,23 @@ static int bcm590xx_probe(struct platform_device *pdev) pmu->desc[i].linear_ranges = info->linear_ranges; pmu->desc[i].n_linear_ranges = info->n_linear_ranges; - if (BCM590XX_REG_IS_LDO(i)) { + if ((BCM590XX_REG_IS_LDO(i)) || (BCM590XX_REG_IS_GPLDO(i))) { pmu->desc[i].ops = &bcm590xx_ops_ldo; pmu->desc[i].vsel_mask = BCM590XX_LDO_VSEL_MASK; - } else { + } else if (BCM590XX_REG_IS_VBUS(i)) + pmu->desc[i].ops = &bcm590xx_ops_vbus; + else { pmu->desc[i].ops = &bcm590xx_ops_dcdc; pmu->desc[i].vsel_mask = BCM590XX_SR_VSEL_MASK; } - pmu->desc[i].vsel_reg = bcm590xx_get_vsel_register(i); - pmu->desc[i].enable_is_inverted = true; - pmu->desc[i].enable_mask = BCM590XX_REG_ENABLE; + if (BCM590XX_REG_IS_VBUS(i)) + pmu->desc[i].enable_mask = BCM590XX_VBUS_ENABLE; + else { + pmu->desc[i].vsel_reg = bcm590xx_get_vsel_register(i); + pmu->desc[i].enable_is_inverted = true; + pmu->desc[i].enable_mask = BCM590XX_REG_ENABLE; + } pmu->desc[i].enable_reg = bcm590xx_get_enable_register(i); pmu->desc[i].type = REGULATOR_VOLTAGE; pmu->desc[i].owner = THIS_MODULE; @@ -371,7 +440,10 @@ static int bcm590xx_probe(struct platform_device *pdev) config.dev = bcm590xx->dev; config.init_data = reg_data; config.driver_data = pmu; - config.regmap = bcm590xx->regmap; + if (BCM590XX_REG_IS_GPLDO(i) || BCM590XX_REG_IS_VBUS(i)) + config.regmap = bcm590xx->regmap1; + else + config.regmap = bcm590xx->regmap0; if (bcm590xx_reg_matches) config.of_node = bcm590xx_reg_matches[i].of_node;