From patchwork Mon Apr 14 18:50:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Porter X-Patchwork-Id: 3985341 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 97DE8BFF02 for ; Mon, 14 Apr 2014 18:53:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFF5B201FA for ; Mon, 14 Apr 2014 18:53:36 +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 BBA1620170 for ; Mon, 14 Apr 2014 18:53:35 +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 1WZlyR-000079-JK; Mon, 14 Apr 2014 18:51:19 +0000 Received: from mail-ie0-f172.google.com ([209.85.223.172]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WZlyA-0008IJ-2f for linux-arm-kernel@lists.infradead.org; Mon, 14 Apr 2014 18:51:02 +0000 Received: by mail-ie0-f172.google.com with SMTP id as1so8570431iec.17 for ; Mon, 14 Apr 2014 11:50:39 -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=dH6jOqlOwDMBO4iIcwkfH8j6Lwpmn+kzGmRBKznOU7g=; b=iEnUAITrNPtGng0MnJ7h6tZJiMN2u4SwxYuLXLhZcDE3boXRdnd4+M8Sw+eNNM7K+U nW/MxHQYfdmReffEHxsVXvMi/jZ3n88f4Py2Ey4DEDdcs/bokWxiSwRWToBLIxmK4Qo+ 4TLmknuitmnLlkmPFWVwVjtmcLMs5QtmaENb7SiXn7/hAPZlcYLGjXSdzgAT/xearsQG Xppgb6U0cgtQioeYI8keljJgFLyzusCSLT9k8nc/Ovwrtw6KsrhGtxNcmTIBn1ToCngR See/SFiKdt7h0hHd18UHVGfTY4WqAzAUxJHXProH0TXud2RydeYaWK4RSUce/7ejnI6t WWnA== X-Gm-Message-State: ALoCoQkyABiwS8vcWp4ctHY3aug8JxTI2VjKLUP0NMa8pLMdaakNTdQ/nLAcIdyh21Fz9RsYl7hn X-Received: by 10.50.4.74 with SMTP id i10mr18320748igi.43.1397501438992; Mon, 14 Apr 2014 11:50:38 -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.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Apr 2014 11:50:38 -0700 (PDT) From: Matt Porter To: Devicetree List , Lee Jones , Samuel Ortiz , Liam Girdwood , Mark Brown Subject: [PATCH 2/4] mfd: bcm590xx: add support for second i2c slave address space Date: Mon, 14 Apr 2014 14:50:26 -0400 Message-Id: <1397501428-8857-3-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_115102_173649_8086022B X-CRM114-Status: GOOD ( 17.22 ) 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 BCM590xx utilizes a second i2c slave address to access additional register space. Add support for the second address space by instantiated a dummy i2c device with the appropriate secondary i2c slave address. Expose a second regmap register space so that mfd drivers can access this secondary i2c slave address space. Signed-off-by: Matt Porter --- drivers/mfd/bcm590xx.c | 60 +++++++++++++++++++++++++++++++++----------- include/linux/mfd/bcm590xx.h | 9 ++++--- 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/drivers/mfd/bcm590xx.c b/drivers/mfd/bcm590xx.c index e9a33c7..b710ffa 100644 --- a/drivers/mfd/bcm590xx.c +++ b/drivers/mfd/bcm590xx.c @@ -28,39 +28,71 @@ static const struct mfd_cell bcm590xx_devs[] = { }, }; -static const struct regmap_config bcm590xx_regmap_config = { +static const struct regmap_config bcm590xx_regmap_config_0 = { .reg_bits = 8, .val_bits = 8, - .max_register = BCM590XX_MAX_REGISTER, + .max_register = BCM590XX_MAX_REGISTER_0, .cache_type = REGCACHE_RBTREE, }; -static int bcm590xx_i2c_probe(struct i2c_client *i2c, +static const struct regmap_config bcm590xx_regmap_config_1 = { + .reg_bits = 8, + .val_bits = 8, + .max_register = BCM590XX_MAX_REGISTER_1, + .cache_type = REGCACHE_RBTREE, +}; + +static int bcm590xx_i2c_probe(struct i2c_client *addmap0, const struct i2c_device_id *id) { struct bcm590xx *bcm590xx; int ret; - bcm590xx = devm_kzalloc(&i2c->dev, sizeof(*bcm590xx), GFP_KERNEL); + bcm590xx = devm_kzalloc(&addmap0->dev, sizeof(*bcm590xx), GFP_KERNEL); if (!bcm590xx) return -ENOMEM; - i2c_set_clientdata(i2c, bcm590xx); - bcm590xx->dev = &i2c->dev; - bcm590xx->i2c_client = i2c; + i2c_set_clientdata(addmap0, bcm590xx); + bcm590xx->dev = &addmap0->dev; + bcm590xx->addmap0 = addmap0; - bcm590xx->regmap = devm_regmap_init_i2c(i2c, &bcm590xx_regmap_config); - if (IS_ERR(bcm590xx->regmap)) { - ret = PTR_ERR(bcm590xx->regmap); - dev_err(&i2c->dev, "regmap initialization failed: %d\n", ret); + bcm590xx->regmap0 = devm_regmap_init_i2c(addmap0, + &bcm590xx_regmap_config_0); + if (IS_ERR(bcm590xx->regmap0)) { + ret = PTR_ERR(bcm590xx->regmap0); + dev_err(&addmap0->dev, "regmap 0 init failed: %d\n", ret); return ret; } - ret = mfd_add_devices(&i2c->dev, -1, bcm590xx_devs, + /* Second I2C slave address is the base address with A(2) asserted */ + bcm590xx->addmap1 = i2c_new_dummy(addmap0->adapter, + addmap0->addr | BIT(2)); + if (IS_ERR_OR_NULL(bcm590xx->addmap1)) { + dev_err(&addmap0->dev, "failed to add address map 1 device\n"); + return -ENODEV; + } + i2c_set_clientdata(bcm590xx->addmap1, bcm590xx); + + bcm590xx->regmap1 = devm_regmap_init_i2c(bcm590xx->addmap1, + &bcm590xx_regmap_config_1); + if (IS_ERR(bcm590xx->regmap1)) { + ret = PTR_ERR(bcm590xx->regmap1); + dev_err(&bcm590xx->addmap1->dev, + "regmap 1 init failed: %d\n", ret); + goto err; + } + + ret = mfd_add_devices(&addmap0->dev, -1, bcm590xx_devs, ARRAY_SIZE(bcm590xx_devs), NULL, 0, NULL); - if (ret < 0) - dev_err(&i2c->dev, "failed to add sub-devices: %d\n", ret); + if (ret < 0) { + dev_err(&addmap0->dev, "failed to add sub-devices: %d\n", ret); + goto err; + } + + return 0; +err: + i2c_unregister_device(bcm590xx->addmap1); return ret; } diff --git a/include/linux/mfd/bcm590xx.h b/include/linux/mfd/bcm590xx.h index 434df2d..a2723f2 100644 --- a/include/linux/mfd/bcm590xx.h +++ b/include/linux/mfd/bcm590xx.h @@ -19,12 +19,15 @@ #include /* max register address */ -#define BCM590XX_MAX_REGISTER 0xe7 +#define BCM590XX_MAX_REGISTER_0 0xe7 +#define BCM590XX_MAX_REGISTER_1 0xf0 struct bcm590xx { struct device *dev; - struct i2c_client *i2c_client; - struct regmap *regmap; + struct i2c_client *addmap0; + struct i2c_client *addmap1; + struct regmap *regmap0; + struct regmap *regmap1; unsigned int id; };