From patchwork Wed Apr 23 23:21:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Porter X-Patchwork-Id: 28942 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 80B9B20534 for ; Wed, 23 Apr 2014 23:22:26 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id lh14sf6104038vcb.2 for ; Wed, 23 Apr 2014 16:22:26 -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=QAZdf8BWgkF0lCuDG0kPM3AJwk0+fP2a3fF8CXytAVY=; b=KMJxJEGOBfK0j9izuj37QP5Mycx09vieMXlC5YrbtwFZPFLP0ZS/kDnIGtSGd53Evl XRx8noiIqDkxI8Ld7a27n51pmPK+8R0eT33IMr0Rw29TBZLN7gS6d8U3wJqc8sT9bd7S ct1g/7JuY1Kixu8tun7k3o5xtGlKPquF4AuVQv9blGAa4h49rrXRqBTYZ4ka1ySSdOSS uZKFIetMI2fAd02vu7O6XzaYhQRTKEPYLO0IYyb9FWaOXUQwqUyB2Q4GIa1h65BxVU8E V/MZh59b0Nqj/lQ2iBeYn8T0gDstFuM4909o/Rr5+uyMJpe2n8nH3MV1EGlvQmx+mOWm 2JQQ== X-Gm-Message-State: ALoCoQl7icj8JktDfgq9nIIfg0Q71nZzPhNyPfqd4MUeSkvTDtCzMwIJ3+mFWn48JX1hLPHa3hw/ X-Received: by 10.236.118.38 with SMTP id k26mr27299840yhh.35.1398295346151; Wed, 23 Apr 2014 16:22:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.72 with SMTP id s66ls905577qgs.85.gmail; Wed, 23 Apr 2014 16:22:26 -0700 (PDT) X-Received: by 10.52.164.237 with SMTP id yt13mr37158204vdb.18.1398295345974; Wed, 23 Apr 2014 16:22:25 -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 fn10si519264vdc.9.2014.04.23.16.22.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Apr 2014 16:22:25 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id la4so2038184vcb.17 for ; Wed, 23 Apr 2014 16:22:25 -0700 (PDT) X-Received: by 10.52.144.42 with SMTP id sj10mr36074019vdb.19.1398295345866; Wed, 23 Apr 2014 16:22:25 -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 ib8csp139901vcb; Wed, 23 Apr 2014 16:22:25 -0700 (PDT) X-Received: by 10.68.245.162 with SMTP id xp2mr59877529pbc.69.1398295345057; Wed, 23 Apr 2014 16:22:25 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id as3si1448700pbc.479.2014.04.23.16.22.24; Wed, 23 Apr 2014 16:22:24 -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 S1752410AbaDWXVw (ORCPT + 27 others); Wed, 23 Apr 2014 19:21:52 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:43726 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752151AbaDWXVs (ORCPT ); Wed, 23 Apr 2014 19:21:48 -0400 Received: by mail-ie0-f174.google.com with SMTP id rp18so1665318iec.19 for ; Wed, 23 Apr 2014 16:21:48 -0700 (PDT) X-Received: by 10.42.136.130 with SMTP id u2mr43750140ict.51.1398295308085; Wed, 23 Apr 2014 16:21:48 -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.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Apr 2014 16:21:47 -0700 (PDT) From: Matt Porter To: Devicetree List , Lee Jones , Samuel Ortiz , Liam Girdwood , Mark Brown Cc: Tim Kryger , Markus Mayer , Linux Kernel Mailing List , Linux ARM Kernel List Subject: [PATCH v2 2/4] mfd: bcm590xx: add support for secondary I2C slave address Date: Wed, 23 Apr 2014 19:21:31 -0400 Message-Id: <1398295293-11033-3-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> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.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: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , BCM590xx utilizes a secondary I2C slave address to access additional register space. Add support for the secondary address space by instantiating a dummy I2C device with the appropriate secondary I2C slave address. Also expose a secondary 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..43cba1a 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_pri = { .reg_bits = 8, .val_bits = 8, - .max_register = BCM590XX_MAX_REGISTER, + .max_register = BCM590XX_MAX_REGISTER_PRI, .cache_type = REGCACHE_RBTREE, }; -static int bcm590xx_i2c_probe(struct i2c_client *i2c, +static const struct regmap_config bcm590xx_regmap_config_sec = { + .reg_bits = 8, + .val_bits = 8, + .max_register = BCM590XX_MAX_REGISTER_SEC, + .cache_type = REGCACHE_RBTREE, +}; + +static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri, const struct i2c_device_id *id) { struct bcm590xx *bcm590xx; int ret; - bcm590xx = devm_kzalloc(&i2c->dev, sizeof(*bcm590xx), GFP_KERNEL); + bcm590xx = devm_kzalloc(&i2c_pri->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(i2c_pri, bcm590xx); + bcm590xx->dev = &i2c_pri->dev; + bcm590xx->i2c_pri = i2c_pri; - 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->regmap_pri = devm_regmap_init_i2c(i2c_pri, + &bcm590xx_regmap_config_pri); + if (IS_ERR(bcm590xx->regmap_pri)) { + ret = PTR_ERR(bcm590xx->regmap_pri); + dev_err(&i2c_pri->dev, "primary regmap init failed: %d\n", ret); return ret; } - ret = mfd_add_devices(&i2c->dev, -1, bcm590xx_devs, + /* Secondary I2C slave address is the base address with A(2) asserted */ + bcm590xx->i2c_sec = i2c_new_dummy(i2c_pri->adapter, + i2c_pri->addr | BIT(2)); + if (IS_ERR_OR_NULL(bcm590xx->i2c_sec)) { + dev_err(&i2c_pri->dev, "failed to add secondary I2C device\n"); + return -ENODEV; + } + i2c_set_clientdata(bcm590xx->i2c_sec, bcm590xx); + + bcm590xx->regmap_sec = devm_regmap_init_i2c(bcm590xx->i2c_sec, + &bcm590xx_regmap_config_sec); + if (IS_ERR(bcm590xx->regmap_sec)) { + ret = PTR_ERR(bcm590xx->regmap_sec); + dev_err(&bcm590xx->i2c_sec->dev, + "secondary regmap init failed: %d\n", ret); + goto err; + } + + ret = mfd_add_devices(&i2c_pri->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(&i2c_pri->dev, "failed to add sub-devices: %d\n", ret); + goto err; + } + + return 0; +err: + i2c_unregister_device(bcm590xx->i2c_sec); return ret; } diff --git a/include/linux/mfd/bcm590xx.h b/include/linux/mfd/bcm590xx.h index 434df2d..267aede 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_PRI 0xe7 +#define BCM590XX_MAX_REGISTER_SEC 0xf0 struct bcm590xx { struct device *dev; - struct i2c_client *i2c_client; - struct regmap *regmap; + struct i2c_client *i2c_pri; + struct i2c_client *i2c_sec; + struct regmap *regmap_pri; + struct regmap *regmap_sec; unsigned int id; };