Skip to content

Commit 52ba320

Browse files
AngeloGioacchino Del Regnosmb49
authored andcommitted
pwm: mtk-disp: Configure double buffering before reading in .get_state()
BugLink: https://bugs.launchpad.net/bugs/2025095 [ Upstream commit b16c310 ] The DISP_PWM controller's default behavior is to always use register double buffering: all reads/writes are then performed on shadow registers instead of working registers and this becomes an issue in case our chosen configuration in Linux is different from the default (or from the one that was pre-applied by the bootloader). An example of broken behavior is when the controller is configured to use shadow registers, but this driver wants to configure it otherwise: what happens is that the .get_state() callback is called right after registering the pwmchip and checks whether the PWM is enabled by reading the DISP_PWM_EN register; At this point, if shadow registers are enabled but their content was not committed before booting Linux, we are *not* reading the current PWM enablement status, leading to the kernel knowing that the hardware is actually enabled when, in reality, it's not. The aforementioned issue emerged since this driver was fixed with commit 0b5ef34 ("pwm: mtk-disp: Fix the parameters calculated by the enabled flag of disp_pwm") making it to read the enablement status from the right register. Configure the controller in the .get_state() callback to avoid this desync issue and get the backlight properly working again. Fixes: 3f2b167 ("pwm: mtk-disp: Implement atomic API .get_state()") Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Tested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Tested-by: Alexandre Mergnat <amergnat@baylibre.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
1 parent b7e289c commit 52ba320

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/pwm/pwm-mtk-disp.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,16 @@ static void mtk_disp_pwm_get_state(struct pwm_chip *chip,
196196
return;
197197
}
198198

199+
/*
200+
* Apply DISP_PWM_DEBUG settings to choose whether to enable or disable
201+
* registers double buffer and manual commit to working register before
202+
* performing any read/write operation
203+
*/
204+
if (mdp->data->bls_debug)
205+
mtk_disp_pwm_update_bits(mdp, mdp->data->bls_debug,
206+
mdp->data->bls_debug_mask,
207+
mdp->data->bls_debug_mask);
208+
199209
rate = clk_get_rate(mdp->clk_main);
200210
con0 = readl(mdp->base + mdp->data->con0);
201211
con1 = readl(mdp->base + mdp->data->con1);

0 commit comments

Comments
 (0)