Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5160901imm; Tue, 12 Jun 2018 03:40:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL85KbW1H+OQVzG95RWcqYO6ia/tqCAgsCIixzkNtaEScwQw/fBkO65dN9C/HLWfg9emX8u X-Received: by 2002:a62:9652:: with SMTP id c79-v6mr3321563pfe.114.1528800035036; Tue, 12 Jun 2018 03:40:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528800035; cv=none; d=google.com; s=arc-20160816; b=Gp75fahacWUzm6SB9Vc+A8uZBIxFfRIQ2MMy498Bq9npjMXXEZWDcPWd20OyM9xYOE u2WoF9s9J/T/tjweIkxp4T4bicFbrTv5zD1F6yDHrKxHZQnbIMp4YcJ7tMEEvygY5Pcb WkBK/3BRAo7UCxlWtSf6sLoJfAsaY6bEGicixGN6EhGtANkP7pSiLdD7Tq440jphXfng mXxi2yc9qJ73dOdRS/gcymk8MIvMOe2fbWo8nRymxNwWXxQctVinwk3Tc2aI6hWvJ729 Z3FP/Y1BXALSossTgMzxWYtbuUh4JFUUpCVREWTJA3l5z6XDwwaqGFHlpsej4d3IOo6W 8QSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=buX668ubvpmJekevypntnaFeICyiuMIeR7zZStVYbbc=; b=qyjrKW5/COu8Hd+4y6XHFDXHmYbT2/P4b7/jfkpe2jy0tl35+/usYUOuBE5OnYx08T 6+tyK3nIGnNi19ezeNVxRC14ChvMxmpandr++rwGQmyBuDcMTsv58SpNd6ZXW5X2iGqC 8ydoQHBkAALilnue56aQ5y2y7uKssWGTgz6esPfoT64qkRHqnysI8Vna0IvaeQHqtxdr 73nhY5Sy1l9VJG0aGDUeAVtMp+paj8/2WQ3iKHxffzJMy5nb1cClRPZ+cM3IuBbrr5NM 3H9c+RPwH02fKTxNwq4XqBUdivxaZvrZhcDxPqBKhWkD3usVO4lfuklFeXsflKGyjBuM QX3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@verdurent-com.20150623.gappssmtp.com header.s=20150623 header.b=p0e5uDa+; dkim=fail header.i=@linaro.org header.s=google header.b=e3MvycQr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3-v6si578566pld.309.2018.06.12.03.40.20; Tue, 12 Jun 2018 03:40:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@verdurent-com.20150623.gappssmtp.com header.s=20150623 header.b=p0e5uDa+; dkim=fail header.i=@linaro.org header.s=google header.b=e3MvycQr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932976AbeFLKjy (ORCPT + 99 others); Tue, 12 Jun 2018 06:39:54 -0400 Received: from mail-ot0-f195.google.com ([74.125.82.195]:39969 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932373AbeFLKju (ORCPT ); Tue, 12 Jun 2018 06:39:50 -0400 Received: by mail-ot0-f195.google.com with SMTP id w9-v6so21954746otj.7 for ; Tue, 12 Jun 2018 03:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verdurent-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=buX668ubvpmJekevypntnaFeICyiuMIeR7zZStVYbbc=; b=p0e5uDa+Gdmb3KcUMyaF+PG6TYc9z/g1GjLJ8FtgPA5FYzY8znltxW0Ekpa6sPAMr4 48xKNBEmGHeFmqu4+Vhgui/sDbYlfvdPQx8anKPCNRnVwLpseYvoOe7qSdCcbOrxC4C5 U2KtCLI4rKtQ61b4HhPY2sxTJIlHc5BH4rwK30NiT5+u9i7y+0pcvgQxX+r/Ud+F2p6Y pHSJYpxFO/VvJKuW4fiVTLRelfZWbMTw3VDUaIga06pNJrPLDM0QzUfUcJB9rWKF6aCP /jT3P+kHCgLDfJ/eM+osNcduQJSaXSawcdGByhJ7vYDZY7tuFhCiM1fM7WVwlqD+slrx YzSA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=buX668ubvpmJekevypntnaFeICyiuMIeR7zZStVYbbc=; b=e3MvycQr0A6+h4bp8e2bvSIaCXDd0YZe6gCftKWZ2h/1JCAfRnXun7C3JUfprHh8yN edZPuKmaFrhp/MJCTagTtBFMfKcdeDqHUuLMkrLyppkMwuTFJnm9zSkuVje7t1MlPw+r 68cAkQueWH9vyFckrY6Q9a3saA0j9o53dD7is= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=buX668ubvpmJekevypntnaFeICyiuMIeR7zZStVYbbc=; b=WwKlCPhJd8Ba3/yaHaov5qBA2vj1Wf9HzyNk9xfxml/D2zJnHaGjkBsdewGZaOWN/M UVfBJ9n12tspHwLOvaTOlUh1bDxSNPWxuiaObBKuAcyd62vf3vTidAjFBIxEpl/jWOBN cuf5tFUSgkIEJNjBEPnkdJRpjdxpGx7O8JORkcY9Hc0/YISZCI8qyMjqMC0v8Ibc0lQl f44KMmN8F7UMSLtS/BsO0xaIBAxj+QZWVnGBdxl4CfHmMaec04JZ3XSp7/3jlQkB/6R0 zaDlvL0DA+wn3kTpUg421hwwo9+nQQfYeY4wr9YJbUZxsYrrmuB/t3b7Rjjq7gTK+P0a 7ycw== X-Gm-Message-State: APt69E36LKPJABMUf4G5eBRLChKffcsKucod5m4N1nEJOU18DX0RuSGY H9PZvy09b9e9IYuOIgw6lE7zDB7tLppFnH8aNwqzsVDX X-Received: by 2002:a9d:241:: with SMTP id 59-v6mr2075194otb.71.1528799989960; Tue, 12 Jun 2018 03:39:49 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4a:99ab:0:0:0:0:0 with HTTP; Tue, 12 Jun 2018 03:39:49 -0700 (PDT) In-Reply-To: <20180604150319.GC510@tuxbook-pro> References: <7a0f33cff94f41110bdbff14d28d36074fae2a7d.1527937396.git.amit.kucheria@linaro.org> <20180604150319.GC510@tuxbook-pro> From: Amit Kucheria Date: Tue, 12 Jun 2018 13:39:49 +0300 X-Google-Sender-Auth: Dk34AUMngaaDQ20aSKgWRhtTRVQ Message-ID: Subject: Re: [PATCH 1/2] thermal: tsens: Add support for SDM845 platform To: Bjorn Andersson Cc: linux-arm-msm@vger.kernel.org, Rajendra Nayak , Eduardo Valentin , Zhang Rui , Rob Herring , Mark Rutland , "open list:THERMAL" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 4, 2018 at 6:03 PM, Bjorn Andersson wrote: > On Sat 02 Jun 04:11 PDT 2018, Amit Kucheria wrote: >> diff --git a/drivers/thermal/qcom/tsens-sdm845.c b/drivers/thermal/qcom/tsens-sdm845.c > [..] >> +#define TRDY_OFFSET 0xe4 >> +#define TRDY_READY_BIT BIT(1) > > This is bit 0. Oops, fixed. >> + >> +#define STATUS_OFFSET 0xa0 >> +#define LAST_TEMP_MASK 0xfff >> +#define STATUS_VALID_BIT BIT(21) >> +#define CODE_SIGN_BIT BIT(11) >> + >> +static int get_temp_sdm845(struct tsens_device *tmdev, int id, int *temp) >> +{ >> + struct tsens_sensor *s = &tmdev->sensor[id]; >> + u32 code; >> + unsigned int sensor_addr; >> + int last_temp = 0, last_temp2 = 0, last_temp3 = 0, ret; >> + >> + ret = regmap_read(tmdev->map, TRDY_OFFSET, &code); >> + if (ret) >> + return ret; >> + if (code & TRDY_READY_BIT) >> + return -ENODATA; > > This section is the only difference from 8996, but this register is > identical to 8996 and 8998. So I think you should add this to > tsens-8996.c and we can use that for 8996, 8998 and sdm845. > > Perhaps we should name it tsens-v2, as that seems to be the common > denominator for these, according to the documentation. Thanks for confirming that the block is identical^Wsimilar across 8996, 8998, sdm845 (and possible others). I suspected as much but didn't check in a lot of detail. I expected the 845 to gain more features over time, hence the reason for a separate file and a custom get_temp(). Now, I'll fold all of them into a common tsens-v2 function. We'll also need to change how we regmap the 8998 and sdm845 tsens registers because the offsets are not the same and hence not handled corrently by tsens-common.c/init_common().