Skip to content

Commit

Permalink
mfd: arizona: Read the device identification information after boot
Browse files Browse the repository at this point in the history
Future devices may not fully report the device identification information
until their boot sequence is complete so defer acting on these until that
has finished.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
(cherry picked from commit ca76ceb8b9ca1466be9b6de5e4c0fb19b37417ee)

Change-Id: Ia0ea345d928db469f76e8f0b987868fe19a8d2e6
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
(cherry picked from commit 30b4a3cc38bd5cf71f1fc8a66e3b336e51ffdbaf)
  • Loading branch information
broonie authored and Yinjun Chen committed Mar 25, 2015
1 parent 605793f commit 6d205a0
Showing 1 changed file with 49 additions and 31 deletions.
80 changes: 49 additions & 31 deletions drivers/mfd/arizona-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,51 +536,22 @@ int arizona_dev_init(struct arizona *arizona)

regcache_cache_only(arizona->regmap, false);

/* Verify that this is a chip we know about */
ret = regmap_read(arizona->regmap, ARIZONA_SOFTWARE_RESET, &reg);
if (ret != 0) {
dev_err(dev, "Failed to read ID register: %d\n", ret);
goto err_reset;
}

ret = regmap_read(arizona->regmap, ARIZONA_DEVICE_REVISION,
&arizona->rev);
if (ret != 0) {
dev_err(dev, "Failed to read revision register: %d\n", ret);
goto err_reset;
}
arizona->rev &= ARIZONA_DEVICE_REVISION_MASK;

switch (reg) {
#ifdef CONFIG_MFD_WM5102
case 0x5102:
type_name = "WM5102";
if (arizona->type != WM5102) {
dev_err(arizona->dev, "WM5102 registered as %d\n",
arizona->type);
arizona->type = WM5102;
}
apply_patch = wm5102_patch;
arizona->rev &= 0x7;
break;
#endif
#ifdef CONFIG_MFD_WM5110
case 0x5110:
type_name = "WM5110";
if (arizona->type != WM5110) {
dev_err(arizona->dev, "WM5110 registered as %d\n",
arizona->type);
arizona->type = WM5110;
}
apply_patch = wm5110_patch;
break;
#endif
default:
dev_err(arizona->dev, "Unknown device ID %x\n", reg);
dev_err(arizona->dev, "Unknown device ID: %x\n", reg);
goto err_reset;
}

dev_info(dev, "%s revision %c\n", type_name, arizona->rev + 'A');

/* If we have a /RESET GPIO we'll already be reset */
if (!arizona->pdata.reset) {
regcache_mark_dirty(arizona->regmap);
Expand All @@ -600,6 +571,7 @@ int arizona_dev_init(struct arizona *arizona)
}
}

/* Ensure device startup is complete */
switch (arizona->type) {
case WM5102:
ret = regmap_read(arizona->regmap, 0x19, &val);
Expand All @@ -620,6 +592,52 @@ int arizona_dev_init(struct arizona *arizona)
break;
}

/* Read the device ID information & do device specific stuff */
ret = regmap_read(arizona->regmap, ARIZONA_SOFTWARE_RESET, &reg);
if (ret != 0) {
dev_err(dev, "Failed to read ID register: %d\n", ret);
goto err_reset;
}

ret = regmap_read(arizona->regmap, ARIZONA_DEVICE_REVISION,
&arizona->rev);
if (ret != 0) {
dev_err(dev, "Failed to read revision register: %d\n", ret);
goto err_reset;
}
arizona->rev &= ARIZONA_DEVICE_REVISION_MASK;

switch (reg) {
#ifdef CONFIG_MFD_WM5102
case 0x5102:
type_name = "WM5102";
if (arizona->type != WM5102) {
dev_err(arizona->dev, "WM5102 registered as %d\n",
arizona->type);
arizona->type = WM5102;
}
apply_patch = wm5102_patch;
arizona->rev &= 0x7;
break;
#endif
#ifdef CONFIG_MFD_WM5110
case 0x5110:
type_name = "WM5110";
if (arizona->type != WM5110) {
dev_err(arizona->dev, "WM5110 registered as %d\n",
arizona->type);
arizona->type = WM5110;
}
apply_patch = wm5110_patch;
break;
#endif
default:
dev_err(arizona->dev, "Unknown device ID %x\n", reg);
goto err_reset;
}

dev_info(dev, "%s revision %c\n", type_name, arizona->rev + 'A');

if (apply_patch) {
ret = apply_patch(arizona);
if (ret != 0) {
Expand Down

0 comments on commit 6d205a0

Please sign in to comment.