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: 28372 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f70.google.com (mail-pb0-f70.google.com [209.85.160.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5392720534 for ; Mon, 14 Apr 2014 18:52:46 +0000 (UTC) Received: by mail-pb0-f70.google.com with SMTP id rp16sf32886446pbb.9 for ; Mon, 14 Apr 2014 11:52:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=UGoYAsgKXt9joIhoVHhfgTsuKTjaEVgvsYXTVvXZ+xE=; b=HmjU+o2R4tGdoZmOydegm5l5u20uG70MCwbNI5WlRO9dmISm68nTP2eTs/PVegf58C reCP3z+7/KreFw/Hjn+j2nSjdKfCVei/Gabxphma3reUftKYHXvIYyikrM3PaL7cNiGt ksutSio5i22Kj9h6fqekQWUVo64rLsAa6lKWrlpD6DxFZG8J2+tIamg+thgvCtMkufDS zatyUD+EHvf6W2gRO2wGAv83++8YULUm+AGJC18gahRAvrcUsxEMSXStpD+vDt8+A9AW X7TbH7q3+/2Hf/HEMkSnjxH6qjUAiV4E7FjqHR+1oYd6gcAm+kbgOk9Kp3MBRtphWwYJ JSaw== X-Gm-Message-State: ALoCoQk6uC7cGl5orB4NrXUgYG5Q9hmbrwvC0CVqikTGPojUARWgo97R7j43dJ71aWcRSYOgTkDA X-Received: by 10.66.173.75 with SMTP id bi11mr21886402pac.4.1397501565518; Mon, 14 Apr 2014 11:52:45 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.103 with SMTP id k94ls865762qgd.30.gmail; Mon, 14 Apr 2014 11:52:45 -0700 (PDT) X-Received: by 10.221.27.8 with SMTP id ro8mr1822057vcb.30.1397501565324; Mon, 14 Apr 2014 11:52:45 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id h11si2904826veh.158.2014.04.14.11.52.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 14 Apr 2014 11:52:45 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id la4so8147885vcb.3 for ; Mon, 14 Apr 2014 11:52:45 -0700 (PDT) X-Received: by 10.52.108.164 with SMTP id hl4mr3751082vdb.25.1397501565241; Mon, 14 Apr 2014 11:52:45 -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.220.221.72 with SMTP id ib8csp172282vcb; Mon, 14 Apr 2014 11:52:44 -0700 (PDT) X-Received: by 10.140.40.229 with SMTP id x92mr50005808qgx.13.1397501564873; Mon, 14 Apr 2014 11:52:44 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id d10si7107838qaf.101.2014.04.14.11.52.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Apr 2014 11:52:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; 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-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 (/) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.223.172 listed in list.dnswl.org] 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+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mporter@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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; };