Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1011427pxf; Thu, 18 Mar 2021 17:59:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZb5iwFyhje/mN+mmWIvRmA259xs9MWcLO+S4yPXyo5Wf5xz1Sj62hni2pwO5JCTUpYUBd X-Received: by 2002:a17:906:1519:: with SMTP id b25mr1514005ejd.254.1616115579250; Thu, 18 Mar 2021 17:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616115579; cv=none; d=google.com; s=arc-20160816; b=sVSv7wwIMqnoM+DlpkvXQ6jLWETdxi5diz1JTaCI96sNFLMkpNoI8SR8QR+3VDRCqj jOIZcuXYqDQRtZqjyzDN1AAJpwEtH2ilGFn5/uFx2BEARvlX4MYloPdD0qlY24GFCNZV 0byQXSqPuDjr48jtZqh2Dtlw56SU3vVBGTl+H9G3EFLkY9Ggcj5bgLwgvXKEs45aSM7y l0AV5ORb1g3U+GFjQ9l/lwNwV8Sa31vppoGLfYITxPwWoNo1mmp5eBkuSV9T9cEIHwPA QowFmwgiKvy1hQBQqBJgMhZnH+Edzy3uHcb3rTuNRQ1dnv1UkiXhnIqhdMhUvjfWhwGd /DXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ht4zFLCjHIKNepjEoTWKseXBzTiNjgPlvBLpquOp4H0=; b=VHmxs/6DSCZbLIfY0Wl3pneSHZjJEoCxA3FfH6Inzyg2l1+vLsE9uiAMfGeDs5fQq2 LkZ7eoJcuUnD5mM2KroGarQ+0FrCjGS91gV3E0fx3F1fEGlWxp6ieA/4CT9G2vgU7yIe vaf/pFMh7SN1opS+Qs9NuQfabesh9VCIr88Jf88aJ39b/D8fmo7mO8ehjq1pLjbXidEP ef39QoZve4nlYnfJLTLukuRjRgJUCa60xQYIYwI5irk83UuxNUVGp3ea7xgRnBFooqsh 57ifHMs9ejSrJ4jvr6LQ9R5iapbm5Keibqj6vp2atHPi/T9TaJfe1ZePicuXKgAVaXdu VCPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LoqNAtUz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si2740514edu.606.2021.03.18.17.59.15; Thu, 18 Mar 2021 17:59:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LoqNAtUz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233544AbhCSAxP (ORCPT + 99 others); Thu, 18 Mar 2021 20:53:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233358AbhCSAwz (ORCPT ); Thu, 18 Mar 2021 20:52:55 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81202C06174A; Thu, 18 Mar 2021 17:52:55 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id b7so6916683ejv.1; Thu, 18 Mar 2021 17:52:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ht4zFLCjHIKNepjEoTWKseXBzTiNjgPlvBLpquOp4H0=; b=LoqNAtUzk1IhOl3fM+F7rr1KccuSClzp48RM7EPXyNojix7QFR3cGHeDVlg+MYzzIi fooDGsU/D1b1Nw5XlC3LSEDt6uJNssKjvEtlqDlVGNkehgODxrhkMid+Pb9viFBvpu+N DMQVYCMecgVVdPW//E2gCzDEZ9/wHcNivtPuZtcAufaGpV5l2yxIwLHs2ewiHXJuprSv fqi/hN8Sp39bCanX+TKs39d+CThD3WHIPtqgG5CT1BrQu0ZTznbZH5TpuZznVkSHk1lX CqxxSHbQSObNQ/2AYNyNyqye6Byj84GBLSC/Ome4xcJgd43jO76xaGYE69/d6TvOuuuS 3ojA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ht4zFLCjHIKNepjEoTWKseXBzTiNjgPlvBLpquOp4H0=; b=ignA2Yau4OvhYgkU1+qx32k5kmWqmJ72+rehLh6rn49jak7e/2sHkz89cOv0wcTBbj +IKupbqSvvEqGw1T3NK45AbTQOZ1473aVqBLhE1tAzb9Xe8S7j7j7bGPJ/WGF2FwZDp7 NsVAwTSU4QCXI4vhy4zVkNWNcqtfwtXUvos4HsdPbD+U82o/fkCki+PyCFjU6TebyXaC +TZhllHc1SiLiEm//Cf4WjI+6Pxx+dIRdW9Y/Wd7AgMWtTzgNZsOPpgllY6d1+J9Hyid zkN/u+PWRYkXOYD62CmmMTKMCMRYv2lBm4aqUbsEpo+H3PqTohfeCURJIrYO+9rdoSZd NXKg== X-Gm-Message-State: AOAM533Yt3D8n5J7tj+xBg0aseGBBoAD8MaZJQgb2BYOoM/ntuW/VCf3 FtDDYAnz7/EHMFKUhIuqrJM= X-Received: by 2002:a17:907:3ea0:: with SMTP id hs32mr1405936ejc.411.1616115174159; Thu, 18 Mar 2021 17:52:54 -0700 (PDT) Received: from Ansuel-xps.localdomain (host-95-233-52-6.retail.telecomitalia.it. [95.233.52.6]) by smtp.googlemail.com with ESMTPSA id q25sm3186976edt.51.2021.03.18.17.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 17:52:53 -0700 (PDT) From: Ansuel Smith To: Thara Gopinath Cc: Ansuel Smith , Andy Gross , Bjorn Andersson , Amit Kucheria , Zhang Rui , Daniel Lezcano , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v11 5/9] drivers: thermal: tsens: Fix bug in sensor enable for msm8960 Date: Fri, 19 Mar 2021 01:52:23 +0100 Message-Id: <20210319005228.1250-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210319005228.1250-1-ansuelsmth@gmail.com> References: <20210319005228.1250-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Device based on tsens VER_0 contains a hardware bug that results in some problem with sensor enablement. Sensor id 6-11 can't be enabled selectively and all of them must be enabled in one step. Signed-off-by: Ansuel Smith --- drivers/thermal/qcom/tsens-8960.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 86585f439985..bdc64d4188bf 100644 --- a/drivers/thermal/qcom/tsens-8960.c +++ b/drivers/thermal/qcom/tsens-8960.c @@ -27,9 +27,9 @@ #define EN BIT(0) #define SW_RST BIT(1) #define SENSOR0_EN BIT(3) +#define MEASURE_PERIOD BIT(18) #define SLP_CLK_ENA BIT(26) #define SLP_CLK_ENA_8660 BIT(24) -#define MEASURE_PERIOD 1 #define SENSOR0_SHIFT 3 /* INT_STATUS_ADDR bitmasks */ @@ -126,17 +126,35 @@ static int resume_8960(struct tsens_priv *priv) static int enable_8960(struct tsens_priv *priv, int id) { int ret; - u32 reg, mask; + u32 reg, mask = BIT(id); ret = regmap_read(priv->tm_map, CNTL_ADDR, ®); if (ret) return ret; - mask = BIT(id + SENSOR0_SHIFT); + /* HARDWARE BUG: + * On platform with more than 6 sensors, all the remaining + * sensors needs to be enabled all togheder or underfined + * results are expected. (Sensor 6-7 disabled, Sensor 3 + * disabled...) In the original driver, all the sensors + * are enabled in one step hence this bug is not triggered. + */ + if (id > 5) { + mask = GENMASK(10, 6); + + /* Sensors already enabled. Skip. */ + if ((reg & mask) == mask) + return 0; + } + + mask <<= SENSOR0_SHIFT; + ret = regmap_write(priv->tm_map, CNTL_ADDR, reg | SW_RST); if (ret) return ret; + reg |= MEASURE_PERIOD; + if (priv->num_sensors > 1) reg |= mask | SLP_CLK_ENA | EN; else -- 2.30.2