Skip to content

Commit 5500e39

Browse files
Qiao ZhouSamuel Ortiz
authored andcommitted
mfd: Add companion chip in 88pm80x
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@marvell.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent 70c6cce commit 5500e39

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎drivers/mfd/88pm80x.c‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
#include <linux/uaccess.h>
1919
#include <linux/err.h>
2020

21+
/*
22+
* workaround: some registers needed by pm805 are defined in pm800, so
23+
* need to use this global variable to maintain the relation between
24+
* pm800 and pm805. would remove it after HW chip fixes the issue.
25+
*/
26+
static struct pm80x_chip *g_pm80x_chip;
2127

2228
const struct regmap_config pm80x_regmap_config = {
2329
.reg_bits = 8,
@@ -61,6 +67,19 @@ int __devinit pm80x_init(struct i2c_client *client,
6167

6268
device_init_wakeup(&client->dev, 1);
6369

70+
/*
71+
* workaround: set g_pm80x_chip to the first probed chip. if the
72+
* second chip is probed, just point to the companion to each
73+
* other so that pm805 can access those specific register. would
74+
* remove it after HW chip fixes the issue.
75+
*/
76+
if (!g_pm80x_chip)
77+
g_pm80x_chip = chip;
78+
else {
79+
chip->companion = g_pm80x_chip->client;
80+
g_pm80x_chip->companion = chip->client;
81+
}
82+
6483
return 0;
6584

6685
err_chip_id:
@@ -75,6 +94,15 @@ int __devexit pm80x_deinit(struct i2c_client *client)
7594
{
7695
struct pm80x_chip *chip = i2c_get_clientdata(client);
7796

97+
/*
98+
* workaround: clear the dependency between pm800 and pm805.
99+
* would remove it after HW chip fixes the issue.
100+
*/
101+
if (g_pm80x_chip->companion)
102+
g_pm80x_chip->companion = NULL;
103+
else
104+
g_pm80x_chip = NULL;
105+
78106
regmap_exit(chip->regmap);
79107
devm_kfree(&client->dev, chip);
80108

‎include/linux/mfd/88pm80x.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ struct pm80x_chip {
295295
struct pm80x_subchip *subchip;
296296
struct device *dev;
297297
struct i2c_client *client;
298+
struct i2c_client *companion;
298299
struct regmap *regmap;
299300
struct regmap_irq_chip *regmap_irq_chip;
300301
struct regmap_irq_chip_data *irq_data;

0 commit comments

Comments
 (0)