Skip to content

Commit ca76ceb

Browse files
committed
mfd: arizona: Read the device identification information after boot
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>
1 parent f722406 commit ca76ceb

File tree

1 file changed

+49
-31
lines changed

1 file changed

+49
-31
lines changed

drivers/mfd/arizona-core.c

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -536,51 +536,22 @@ int arizona_dev_init(struct arizona *arizona)
536536

537537
regcache_cache_only(arizona->regmap, false);
538538

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

545-
ret = regmap_read(arizona->regmap, ARIZONA_DEVICE_REVISION,
546-
&arizona->rev);
547-
if (ret != 0) {
548-
dev_err(dev, "Failed to read revision register: %d\n", ret);
549-
goto err_reset;
550-
}
551-
arizona->rev &= ARIZONA_DEVICE_REVISION_MASK;
552-
553546
switch (reg) {
554-
#ifdef CONFIG_MFD_WM5102
555547
case 0x5102:
556-
type_name = "WM5102";
557-
if (arizona->type != WM5102) {
558-
dev_err(arizona->dev, "WM5102 registered as %d\n",
559-
arizona->type);
560-
arizona->type = WM5102;
561-
}
562-
apply_patch = wm5102_patch;
563-
arizona->rev &= 0x7;
564-
break;
565-
#endif
566-
#ifdef CONFIG_MFD_WM5110
567548
case 0x5110:
568-
type_name = "WM5110";
569-
if (arizona->type != WM5110) {
570-
dev_err(arizona->dev, "WM5110 registered as %d\n",
571-
arizona->type);
572-
arizona->type = WM5110;
573-
}
574-
apply_patch = wm5110_patch;
575549
break;
576-
#endif
577550
default:
578-
dev_err(arizona->dev, "Unknown device ID %x\n", reg);
551+
dev_err(arizona->dev, "Unknown device ID: %x\n", reg);
579552
goto err_reset;
580553
}
581554

582-
dev_info(dev, "%s revision %c\n", type_name, arizona->rev + 'A');
583-
584555
/* If we have a /RESET GPIO we'll already be reset */
585556
if (!arizona->pdata.reset) {
586557
regcache_mark_dirty(arizona->regmap);
@@ -600,6 +571,7 @@ int arizona_dev_init(struct arizona *arizona)
600571
}
601572
}
602573

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

595+
/* Read the device ID information & do device specific stuff */
596+
ret = regmap_read(arizona->regmap, ARIZONA_SOFTWARE_RESET, &reg);
597+
if (ret != 0) {
598+
dev_err(dev, "Failed to read ID register: %d\n", ret);
599+
goto err_reset;
600+
}
601+
602+
ret = regmap_read(arizona->regmap, ARIZONA_DEVICE_REVISION,
603+
&arizona->rev);
604+
if (ret != 0) {
605+
dev_err(dev, "Failed to read revision register: %d\n", ret);
606+
goto err_reset;
607+
}
608+
arizona->rev &= ARIZONA_DEVICE_REVISION_MASK;
609+
610+
switch (reg) {
611+
#ifdef CONFIG_MFD_WM5102
612+
case 0x5102:
613+
type_name = "WM5102";
614+
if (arizona->type != WM5102) {
615+
dev_err(arizona->dev, "WM5102 registered as %d\n",
616+
arizona->type);
617+
arizona->type = WM5102;
618+
}
619+
apply_patch = wm5102_patch;
620+
arizona->rev &= 0x7;
621+
break;
622+
#endif
623+
#ifdef CONFIG_MFD_WM5110
624+
case 0x5110:
625+
type_name = "WM5110";
626+
if (arizona->type != WM5110) {
627+
dev_err(arizona->dev, "WM5110 registered as %d\n",
628+
arizona->type);
629+
arizona->type = WM5110;
630+
}
631+
apply_patch = wm5110_patch;
632+
break;
633+
#endif
634+
default:
635+
dev_err(arizona->dev, "Unknown device ID %x\n", reg);
636+
goto err_reset;
637+
}
638+
639+
dev_info(dev, "%s revision %c\n", type_name, arizona->rev + 'A');
640+
623641
if (apply_patch) {
624642
ret = apply_patch(arizona);
625643
if (ret != 0) {

0 commit comments

Comments
 (0)