linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qiao Zhou <zhouqiao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
To: arnd-r2nGTMty4D4@public.gmane.org,
	broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org,
	rpurdie-Fm38FmjxZ/leoWH0uzbU5w@public.gmane.org,
	sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
	haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	chao.xie-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org,
	yu.tang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org,
	wilbur.wang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Qiao Zhou <zhouqiao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
Subject: [PATCH 2/4] mfd: workaround: add companion chip in 88pm80x
Date: Wed,  4 Jul 2012 16:55:13 +0800	[thread overview]
Message-ID: <1341392115-9425-3-git-send-email-zhouqiao@marvell.com> (raw)
In-Reply-To: <1341392115-9425-1-git-send-email-zhouqiao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.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 <zhouqiao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
---
 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 <linux/uaccess.h>
 #include <linux/err.h>
 
+/*
+ * 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;
-- 
1.7.0.4

  parent reply	other threads:[~2012-07-04  8:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-04  8:55 [PATCH 0/4 V2] add 88pm80x mfd driver Qiao Zhou
     [not found] ` <1341392115-9425-1-git-send-email-zhouqiao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-07-04  8:55   ` [PATCH 1/4] mfd: support 88pm80x in 80x driver Qiao Zhou
     [not found]     ` <1341392115-9425-2-git-send-email-zhouqiao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-07-04 11:37       ` Arnd Bergmann
     [not found]         ` <201207041137.49020.arnd-r2nGTMty4D4@public.gmane.org>
2012-07-04 15:14           ` Qiao Zhou
     [not found]             ` <B2A7C617B3AB7F44B7B44C7D374B431E13A09E8DEE-PBXNphkCnnUA/4UcAFAujRL4W9x8LtSr@public.gmane.org>
2012-07-04 15:27               ` Arnd Bergmann
     [not found]                 ` <201207041527.13954.arnd-r2nGTMty4D4@public.gmane.org>
2012-07-04 15:33                   ` Mark Brown
     [not found]                     ` <20120704153307.GE4111-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-07-04 15:47                       ` Qiao Zhou
2012-07-04 15:44                   ` Qiao Zhou
2012-07-04  8:55   ` Qiao Zhou [this message]
2012-07-04  8:55   ` [PATCH 3/4] rtc: add rtc support to 88PM80X PMIC Qiao Zhou
2012-07-04  8:55   ` [PATCH 4/4] input: add onkey " Qiao Zhou
  -- strict thread matches above, loose matches on Subject: below --
2012-07-05 11:07 [PATCH 0/4 V3] add 88pm80x mfd driver Qiao Zhou
     [not found] ` <1341486425-697-1-git-send-email-zhouqiao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-07-05 11:07   ` [PATCH 2/4] mfd: workaround: add companion chip in 88pm80x Qiao Zhou
2012-07-06  6:48 [PATCH 0/4 V4] add 88pm80x mfd driver Qiao Zhou
     [not found] ` <1341557330-24413-1-git-send-email-zhouqiao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-07-06  6:48   ` [PATCH 2/4] mfd: workaround: add companion chip in 88pm80x Qiao Zhou
2012-07-09  6:13 [PATCH 0/4 V4] add 88pm80x mfd driver Qiao Zhou
     [not found] ` <1341814418-13300-1-git-send-email-zhouqiao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-07-09  6:13   ` [PATCH 2/4] mfd: workaround: add companion chip in 88pm80x Qiao Zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1341392115-9425-3-git-send-email-zhouqiao@marvell.com \
    --to=zhouqiao-eyqppykdwxrbdgjk7y7tuq@public.gmane.org \
    --cc=arnd-r2nGTMty4D4@public.gmane.org \
    --cc=broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
    --cc=chao.xie-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
    --cc=haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rpurdie-Fm38FmjxZ/leoWH0uzbU5w@public.gmane.org \
    --cc=sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=wilbur.wang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
    --cc=yu.tang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).