mfd: arizona: Move chip reset to before register patch
Subsystems (2)
PATCH 1/1 mfd: arizona: Move chip reset to before register patch
In the absence of a physical reset line the chip is reset by writing the first register, this was done after the register patch was applied which negates the settings applied in the register patch.
This patch moves the reset to take place before the register patch is applied.
--- drivers/mfd/arizona-core.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
drivers/mfd/arizona-core.c +9 -9
@@ -366,6 +366,15 @@ int __devinit arizona_dev_init(struct arizona *arizona)regcache_cache_only (arizona->regmap, false); +/* If we have a /RESET GPIO we'll already be reset */ +if (!arizona->pdata.reset) { + ret =regmap_write (arizona->regmap,ARIZONA_SOFTWARE_RESET ,0 ); +if (ret !=0 ) { +dev_err (dev,"Failed to reset device: %d\n" , ret); + goto err_reset; + } + } + ret =regmap_read (arizona->regmap,ARIZONA_SOFTWARE_RESET , ®);if (ret !=0 ) {dev_err (dev,"Failed to read ID register: %d\n" , ret);
@@ -413,15 +422,6 @@ int __devinit arizona_dev_init(struct arizona *arizona)if (ret !=0 )dev_err (arizona->dev,"Failed to apply patch: %d\n" , ret); -/* If we have a /RESET GPIO we'll already be reset */ -if (!arizona->pdata.reset) { - ret =regmap_write (arizona->regmap,ARIZONA_SOFTWARE_RESET ,0 ); -if (ret !=0 ) { -dev_err (dev,"Failed to reset device: %d\n" , ret); - goto err_reset; - } - } - ret =arizona_wait_for_boot (arizona);if (ret !=0 ) {dev_err (arizona->dev,"Device failed initial boot: %d\n" , ret);
Signature · 1 line
1.7.2.5
Quoted 6 lines · Charles Keepax
In the absence of a physical reset line the chip is reset by writing the first register, this was done after the register patch was applied which negates the settings applied in the register patch.
This patch moves the reset to take place before the register patch is applied.
No, we should never write to the chip until we have successfully identified it. Do a sync or similar instead (we should be triggering this very soon afterwards via runtime PM anyway).
Quoted 11 lines · Mark Brown
Quoted 6 lines · Charles Keepax
In the absence of a physical reset line the chip is reset by writing the first register, this was done after the register patch was applied which negates the settings applied in the register patch.
This patch moves the reset to take place before the register patch is applied.
No, we should never write to the chip until we have successfully identified it. Do a sync or similar instead (we should be triggering this very soon afterwards via runtime PM anyway).
In that case I would be inclined to seperate out the chip identification and the register patch doing the reset in between. Is this something that would sound reasonable or would you rather just add a sync after the reset?
Quoted 10 lines · Charles Keepax
Quoted 3 lines · Mark Brown
No, we should never write to the chip until we have successfully identified it. Do a sync or similar instead (we should be triggering this very soon afterwards via runtime PM anyway).
In that case I would be inclined to seperate out the chip identification and the register patch doing the reset in between. Is this something that would sound reasonable or would you rather just add a sync after the reset?
Just do a sync, make sure that we mark the map as dirty when we do the reset via register write and it'll not have any effect anyway. We should also check if we've got the LDO and use that for reset too actually...
Quoted 12 lines · Mark Brown
Quoted 10 lines · Charles Keepax
Quoted 3 lines · Mark Brown
No, we should never write to the chip until we have successfully identified it. Do a sync or similar instead (we should be triggering this very soon afterwards via runtime PM anyway).
In that case I would be inclined to seperate out the chip identification and the register patch doing the reset in between. Is this something that would sound reasonable or would you rather just add a sync after the reset?
Quoted 4 lines
Just do a sync, make sure that we mark the map as dirty when we do the reset via register write and it'll not have any effect anyway. We should also check if we've got the LDO and use that for reset too actually...
The way the code is layed out at the moment if we don't successfully get the LDO we won't get as far as the register write reset. Meaning that if we can do the reset by cycling the power on the LDO is there any point in having the option to do the reset via a register write later?
Quoted 7 lines · Charles Keepax
Quoted 4 lines · Mark Brown
Just do a sync, make sure that we mark the map as dirty when we do the reset via register write and it'll not have any effect anyway. We should also check if we've got the LDO and use that for reset too actually...
Quoted 5 lines
The way the code is layed out at the moment if we don't successfully get the LDO we won't get as far as the register write reset. Meaning that if we can do the reset by cycling the power on the LDO is there any point in having the option to do the reset via a register write later?
No, we can't rely on having control over the LDO - it might be always on. But we should ideally try to use it as a fallback, using a notifier to find out if that worked or not.
Re: [PATCH v2] mfd: arizona: Sync regcache after reset
In the absence of a physical reset line the chip is reset by writing the first register, which is done after the register patch has been applied. This patch synchronises the register cache after the reset to preserve any register changes that had been applied.
---
I will look at the LDO reset and submit it as a seperate patch at a later date.
drivers/mfd/arizona-core.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
drivers/mfd/arizona-core.c +8 -0
@@ -415,11 +415,19 @@ int __devinit arizona_dev_init(struct arizona *arizona)/* If we have a /RESET GPIO we'll already be reset */ if (!arizona->pdata.reset) { +regcache_mark_dirty (arizona->regmap); + ret =regmap_write (arizona->regmap,ARIZONA_SOFTWARE_RESET ,0 );if (ret !=0 ) {dev_err (dev,"Failed to reset device: %d\n" , ret); goto err_reset; } + + ret =regcache_sync (arizona->regmap); +if (ret !=0 ) { +dev_err (dev,"Failed to sync device: %d\n" , ret); + goto err_ldoena; + } } ret =arizona_wait_for_boot (arizona);
Signature · 1 line
1.7.2.5
Re: [PATCH v2] mfd: arizona: Sync regcache after reset
Quoted 6 lines · Charles Keepax
In the absence of a physical reset line the chip is reset by writing the first register, which is done after the register patch has been applied. This patch synchronises the register cache after the reset to preserve any register changes that had been applied.
Signed-off-by Charles Keepax <[email protected]>
Please submit patches as covered in SubmittingPatches, you've added a random "Re" to the subject line...
PATCH v2 1/1 mfd: arizona: Sync regcache after reset
In the absence of a physical reset line the chip is reset by writing the first register, which is done after the register patch has been applied. This patch synchronises the register cache after the reset to preserve any register changes that had been applied.
--- drivers/mfd/arizona-core.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
drivers/mfd/arizona-core.c +8 -0
@@ -415,11 +415,19 @@ int __devinit arizona_dev_init(struct arizona *arizona)/* If we have a /RESET GPIO we'll already be reset */ if (!arizona->pdata.reset) { +regcache_mark_dirty (arizona->regmap); + ret =regmap_write (arizona->regmap,ARIZONA_SOFTWARE_RESET ,0 );if (ret !=0 ) {dev_err (dev,"Failed to reset device: %d\n" , ret); goto err_reset; } + + ret =regcache_sync (arizona->regmap); +if (ret !=0 ) { +dev_err (dev,"Failed to sync device: %d\n" , ret); + goto err_ldoena; + } } ret =arizona_wait_for_boot (arizona);
Signature · 1 line
1.7.2.5
PATCH v3 1/1 mfd: arizona: Sync regcache after reset
In the absence of a physical reset line the chip is reset by writing the first register, which is done after the register patch has been applied. This patch synchronises the register cache after the reset to preserve any register changes that had been applied.
---
Apologies but it seems I accidentally generated yesterdays patch against a local development branch rather than the upstream branch. Sorry for the inconvience here is a fixed version.
drivers/mfd/arizona-core.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
drivers/mfd/arizona-core.c +8 -0
@@ -415,11 +415,19 @@ int __devinit arizona_dev_init(struct arizona *arizona)/* If we have a /RESET GPIO we'll already be reset */ if (!arizona->pdata.reset) { +regcache_mark_dirty (arizona->regmap); + ret =regmap_write (arizona->regmap,ARIZONA_SOFTWARE_RESET ,0 );if (ret !=0 ) {dev_err (dev,"Failed to reset device: %d\n" , ret); goto err_reset; } + + ret =regcache_sync (arizona->regmap); +if (ret !=0 ) { +dev_err (dev,"Failed to sync device: %d\n" , ret); + goto err_reset; + } } ret =arizona_wait_for_boot (arizona);
Signature · 1 line
1.7.2.5