From patchwork Wed Apr 23 23:21:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Porter X-Patchwork-Id: 4045121 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6D4409F387 for ; Wed, 23 Apr 2014 23:25:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 71E05202E6 for ; Wed, 23 Apr 2014 23:25:30 +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 7B2EF202DD for ; Wed, 23 Apr 2014 23:25:29 +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 1Wd6Ul-0007M5-PG; Wed, 23 Apr 2014 23:22:27 +0000 Received: from mail-ie0-f180.google.com ([209.85.223.180]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wd6UV-0007HZ-GV for linux-arm-kernel@lists.infradead.org; Wed, 23 Apr 2014 23:22:12 +0000 Received: by mail-ie0-f180.google.com with SMTP id as1so1650029iec.39 for ; Wed, 23 Apr 2014 16:21:50 -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=DYztiI0EOBx3OZnVvg3fA3eexStbrGNIP2OAKPW7yVs=; b=fidor79QWZe1YNx+qt67sQxZoRJEjMFhlSONAPSF6NuGG3Qv/hXk2ltGHRT7o1aLnx vksK0CysYYQo8l1HzGMX90I6n+5yH8yotB0RWLSk4oql9v5UZNqg/1A1KflW+BWFXtPe uXYyRKWRVEvscRfYUqBFZ4FQgDgdaoFEcnVt0FbNehsnpIeOoRvfbRvaABjX5Byq4zDD YHk/IXY9A9P+9mE3avvtMUMGYazFbUecJ+2AfWNTENZlJyv6B1bUoF5renw43SwQ+Xep MeLlEv95r8LFig2ixdiOQaV2PwKuy0CjRuKzEk2S3GZWHQmQU/Pzo4Zsqk+cjQoTcBwd cmsg== X-Gm-Message-State: ALoCoQlYClOPAahFC74a9UzbbMTYKD9nqOmA/87f9Z/5gy7p7HjXhi2+nONc2k5M3DrVgDX/PA/5 X-Received: by 10.50.50.66 with SMTP id a2mr5953336igo.8.1398295310536; Wed, 23 Apr 2014 16:21:50 -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 kr5sm40107350igb.9.2014.04.23.16.21.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Apr 2014 16:21:49 -0700 (PDT) From: Matt Porter To: Devicetree List , Lee Jones , Samuel Ortiz , Liam Girdwood , Mark Brown Subject: [PATCH v2 3/4] regulator: bcm590xx: add support for regulators on secondary I2C slave Date: Wed, 23 Apr 2014 19:21:32 -0400 Message-Id: <1398295293-11033-4-git-send-email-mporter@linaro.org> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1398295293-11033-1-git-send-email-mporter@linaro.org> References: <1398295293-11033-1-git-send-email-mporter@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140423_162211_633020_6C896D1E X-CRM114-Status: GOOD ( 16.97 ) 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.5 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 secondary 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..57544e2 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->regmap_sec; + else + config.regmap = bcm590xx->regmap_pri; if (bcm590xx_reg_matches) config.of_node = bcm590xx_reg_matches[i].of_node;