Skip to content

Commit b57b4b4

Browse files
tmlinddlezcano
authored andcommitted
thermal: ti-soc-thermal: Skip pointless register access for dra7
On dra7, there is no Start of Conversion (SOC) register bit and we have an empty bgap_soc_mask in the configuration for the thermal driver. Let's not do pointless reads and writes with the empty mask. There's also no point waiting for End of Conversion bit (EOCZ) to go high on dra7. We only care about it going down, and are now mostly timing out waiting for EOCZ high while it has already gone down. When we add checking for the timeout errors in a later patch, waiting for EOCZ high would cause bogus time out errors. Cc: Adam Ford <aford173@gmail.com> Cc: Carl Philipp Klemm <philipp@uvos.xyz> Cc: Eduardo Valentin <edubezval@gmail.com> Cc: H. Nikolaus Schaller <hns@goldelico.com> Cc: Merlijn Wajer <merlijn@wizzup.org> Cc: Pavel Machek <pavel@ucw.cz> Cc: Peter Ujfalusi <peter.ujfalusi@gmail.com> Cc: Sebastian Reichel <sre@kernel.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Tested-by: Adam Ford <aford173@gmail.com> #logicpd-torpedo-37xx-devkit Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20210205134534.49200-2-tony@atomide.com
1 parent 73da3f0 commit b57b4b4

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

drivers/thermal/ti-soc-thermal/ti-bandgap.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -602,29 +602,30 @@ void *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id)
602602
static int
603603
ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id)
604604
{
605-
u32 counter = 1000;
606-
struct temp_sensor_registers *tsr;
605+
struct temp_sensor_registers *tsr = bgp->conf->sensors[id].registers;
606+
u32 counter;
607607

608608
/* Select single conversion mode */
609609
if (TI_BANDGAP_HAS(bgp, MODE_CONFIG))
610610
RMW_BITS(bgp, id, bgap_mode_ctrl, mode_ctrl_mask, 0);
611611

612-
/* Start of Conversion = 1 */
613-
RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 1);
612+
/* Set Start of Conversion if available */
613+
if (tsr->bgap_soc_mask) {
614+
RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 1);
614615

615-
/* Wait for EOCZ going up */
616-
tsr = bgp->conf->sensors[id].registers;
616+
/* Wait for EOCZ going up */
617+
counter = 1000;
618+
while (--counter) {
619+
if (ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) &
620+
tsr->bgap_eocz_mask)
621+
break;
622+
}
617623

618-
while (--counter) {
619-
if (ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) &
620-
tsr->bgap_eocz_mask)
621-
break;
624+
/* Clear Start of Conversion if available */
625+
RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 0);
622626
}
623627

624-
/* Start of Conversion = 0 */
625-
RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 0);
626-
627-
/* Wait for EOCZ going down */
628+
/* Wait for EOCZ going down, always needed even if no bgap_soc_mask */
628629
counter = 1000;
629630
while (--counter) {
630631
if (!(ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) &

0 commit comments

Comments
 (0)