From patchwork Wed Jul 4 08:55:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiao Zhou X-Patchwork-Id: 1155171 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 418023FE4F for ; Wed, 4 Jul 2012 08:59:57 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SmLNY-0005Kj-5g; Wed, 04 Jul 2012 08:56:08 +0000 Received: from na3sys009aog104.obsmtp.com ([74.125.149.73]) by merlin.infradead.org with smtp (Exim 4.76 #1 (Red Hat Linux)) id 1SmLNF-0005IE-Br for linux-arm-kernel@lists.infradead.org; Wed, 04 Jul 2012 08:55:50 +0000 Received: from MSI-MTA.marvell.com ([65.219.4.132]) by na3sys009aob104.postini.com ([74.125.148.12]) with SMTP ID DSNKT/QFCY1q7uX93UzXGy3d5znCiv2Ls5Nv@postini.com; Wed, 04 Jul 2012 01:55:49 PDT Received: from maili.marvell.com ([10.68.76.210]) by MSI-MTA.marvell.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 4 Jul 2012 01:55:18 -0700 Received: from localhost (unknown [10.38.36.111]) by maili.marvell.com (Postfix) with ESMTP id EEC6F4E50D; Wed, 4 Jul 2012 01:55:18 -0700 (PDT) From: Qiao Zhou To: arnd@arndb.de, broonie@opensource.wolfsonmicro.com, rpurdie@rpsys.net, sameo@linux.intel.com, haojian.zhuang@gmail.com, chao.xie@marvell.com, yu.tang@marvell.com, wilbur.wang@marvell.com, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org Subject: [PATCH 2/4] mfd: workaround: add companion chip in 88pm80x Date: Wed, 4 Jul 2012 16:55:13 +0800 Message-Id: <1341392115-9425-3-git-send-email-zhouqiao@marvell.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1341392115-9425-1-git-send-email-zhouqiao@marvell.com> References: <1341392115-9425-1-git-send-email-zhouqiao@marvell.com> X-OriginalArrivalTime: 04 Jul 2012 08:55:18.0549 (UTC) FILETIME=[BC8CE450:01CD59C2] X-Spam-Note: CRM114 invocation failed X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [74.125.149.73 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Qiao Zhou X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org in hw design, 800 is mainly for pmic control, while 805 for audio. but there are 3 registers which controls class D speaker property, and they are defined in 800 i2c client domain. so 805 codec driver needs to use 800 i2c client to access class D speaker reg for audio path management. so add this workaround for the purpose to let 805 access 800 i2c in some scenario. Signed-off-by: Qiao Zhou --- drivers/mfd/88pm80x-i2c.c | 28 ++++++++++++++++++++++++++++ include/linux/mfd/88pm80x.h | 1 + 2 files changed, 29 insertions(+), 0 deletions(-) diff --git a/drivers/mfd/88pm80x-i2c.c b/drivers/mfd/88pm80x-i2c.c index fe37900..81e7aab 100644 --- a/drivers/mfd/88pm80x-i2c.c +++ b/drivers/mfd/88pm80x-i2c.c @@ -21,6 +21,12 @@ #include #include +/* + * workaround: some registers needed by pm805 are defined in pm800, so + * need to use this global variable to maintain the relation between + * pm800 and pm805. would remove it after HW chip fixes the issue. + */ +static struct pm80x_chip *g_pm80x_chip; const struct regmap_config pm80x_regmap_config = { .reg_bits = 8, @@ -151,6 +157,19 @@ int __devinit pm80x_init(struct i2c_client *client, device_init_wakeup(&client->dev, 1); + /* + * workaround: set g_pm80x_chip to the first probed chip. if the + * second chip is probed, just point to the companion to each + * other so that pm805 can access those specific register. would + * remove it after HW chip fixes the issue. + */ + if (!g_pm80x_chip) + g_pm80x_chip = chip; + else { + chip->companion = g_pm80x_chip->client; + g_pm80x_chip->companion = chip->client; + } + return 0; err_chip_id: @@ -164,6 +183,15 @@ int __devexit pm80x_deinit(struct i2c_client *client) { struct pm80x_chip *chip = i2c_get_clientdata(client); + /* + * workaround: clear the dependency between pm800 and pm805. + * would remove it after HW chip fixes the issue. + */ + if (g_pm80x_chip->companion) + g_pm80x_chip->companion = NULL; + else + g_pm80x_chip = NULL; + regmap_exit(chip->regmap); devm_kfree(&client->dev, chip); diff --git a/include/linux/mfd/88pm80x.h b/include/linux/mfd/88pm80x.h index 115348a..217a55c 100644 --- a/include/linux/mfd/88pm80x.h +++ b/include/linux/mfd/88pm80x.h @@ -479,6 +479,7 @@ struct pm80x_chip { struct pm80x_subchip *subchip; struct device *dev; struct i2c_client *client; + struct i2c_client *companion; struct regmap *regmap; struct regmap_irq_chip *regmap_irq_chip; struct regmap_irq_chip_data *irq_data;