tsens.c (082f20b21de20285da2cbfc1be29656f0714c1b8) tsens.c (d012f9189fda0f3a1b303780ba0bbc7298d0d349)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
4 * Copyright (c) 2019, 2020, Linaro Ltd.
5 */
6
7#include <linux/debugfs.h>
8#include <linux/err.h>

--- 589 unchanged lines hidden (view full) ---

598 struct tsens_priv *priv = s->priv;
599 int hw_id = s->hw_id;
600 u32 temp_idx = LAST_TEMP_0 + hw_id;
601 u32 valid_idx = VALID_0 + hw_id;
602 u32 valid;
603 int ret;
604
605 /* VER_0 doesn't have VALID bit */
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
4 * Copyright (c) 2019, 2020, Linaro Ltd.
5 */
6
7#include <linux/debugfs.h>
8#include <linux/err.h>

--- 589 unchanged lines hidden (view full) ---

598 struct tsens_priv *priv = s->priv;
599 int hw_id = s->hw_id;
600 u32 temp_idx = LAST_TEMP_0 + hw_id;
601 u32 valid_idx = VALID_0 + hw_id;
602 u32 valid;
603 int ret;
604
605 /* VER_0 doesn't have VALID bit */
606 if (tsens_version(priv) >= VER_0_1) {
607 ret = regmap_field_read(priv->rf[valid_idx], &valid);
608 if (ret)
609 return ret;
610 while (!valid) {
611 /* Valid bit is 0 for 6 AHB clock cycles.
612 * At 19.2MHz, 1 AHB clock is ~60ns.
613 * We should enter this loop very, very rarely.
614 */
615 ndelay(400);
616 ret = regmap_field_read(priv->rf[valid_idx], &valid);
617 if (ret)
618 return ret;
619 }
620 }
606 if (tsens_version(priv) == VER_0)
607 goto get_temp;
621
608
609 /* Valid bit is 0 for 6 AHB clock cycles.
610 * At 19.2MHz, 1 AHB clock is ~60ns.
611 * We should enter this loop very, very rarely.
612 * Wait 1 us since it's the min of poll_timeout macro.
613 * Old value was 400 ns.
614 */
615 ret = regmap_field_read_poll_timeout(priv->rf[valid_idx], valid,
616 valid, 1, 20 * USEC_PER_MSEC);
617 if (ret)
618 return ret;
619
620get_temp:
622 /* Valid bit is set, OK to read the temperature */
623 *temp = tsens_hw_to_mC(s, temp_idx);
624
625 return 0;
626}
627
628int get_temp_common(const struct tsens_sensor *s, int *temp)
629{

--- 560 unchanged lines hidden ---
621 /* Valid bit is set, OK to read the temperature */
622 *temp = tsens_hw_to_mC(s, temp_idx);
623
624 return 0;
625}
626
627int get_temp_common(const struct tsens_sensor *s, int *temp)
628{

--- 560 unchanged lines hidden ---