On Tue, 26 Apr 2016, Lars-Peter Clausen wrote:
On 04/21/2016 04:01 PM, Ricard Wanderlof wrote:
... The problem I have is that the driver assumes that the CODEC has been initialized with the default register settings when the system boots. However, if the system has not been power cycled but just rebooted, this is not necessarily the case, as the CODEC has no external reset pin but derives its reset signal internally from the power level. ...
Sorry I haven't been able to respond earlier.
I've been thinking about this for the last few days trying to come up with a good solution, but it is really difficult.
The issue you are describing is simply an oversight from my side.
One solution would be do drop the register default values and let regmap fill the register cache on demand when a read is done the first time for a register. The problem with this approach is that we leave the device in an unknown state when we probe the driver, but we really want to have it in a known state of lowest power.
The alternative is to write out the register defaults when the device is probed, sort of a poor mans software reset, this brings us into a known state. This approach has the downside that there is the overhead of having to write all registers.
I don't like either, but given the limitations of the hardware we'll have to choose one and in that case I'd slightly lean towards the later solution has it gives us consistent and predictable behavior and the overhead of writing the registers should be manageable.
Either way, there will be a fair amount of communication with the codec, either as a result of setting the default values, or as a result of reading the existing ones in order to determine what would be necessary to write.
I would think that having the codec in a controlled known (low power) state would tip the balance in favor of the second solution.
One question is though should one write out _all_ registers, including those not actually used by the driver? I'm thinking of an upgrade/downgrade situation, where a previously running kernel version has set up a register which the currently running version doesn't need to touch.
/Ricard