From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71F3742982C for ; Tue, 16 Jun 2026 10:10:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781604623; cv=none; b=R2K3i7rZcn0/NBMTBFPLv87ZL4gbYAfbFqJ9+HlU1i+OeP4lRc6ZP0HWSuJUiVSx+AriLtuOi5BBrOEjgsqH5l1QOgq7VFh6ziPyoiqPYJDA9dt1D1IgsL8YsyoQdIqP80eCBVF8VNNnv3eImyLTi6tLK4pRpIqcnzgvmgyGBSI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781604623; c=relaxed/simple; bh=ufIc8ZHUf4Xrb8lSB6Ws/u1L1tyTF4Z3lOrI6M1Jtms=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Lz0oKU1eNYIIs8hDDaqDOpU+h3a5OcmGWvS2k7nFjW3vp5apuwQzPIaHbRx+455jLmYh+7WbEDQ8Ri1nC0s/atNZMhKeQUFcyGMjn5ONym+q2YoPvek1eP6AVTVWYuv2WekJ0NO6KGtyVpte2tDS5On/db92gaBkpl6uR8nmtGI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=JL1y8v5o; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=W6BvTyor; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="JL1y8v5o"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="W6BvTyor" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 65GA9WQQ249596 for ; Tue, 16 Jun 2026 10:10:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= isNgOMfZ65NTVt8FlgRDQNF31fC0tCGiPVqqs5w87EQ=; b=JL1y8v5owgkaqKiz ua7YLb0l2jDRlQvR7Ja1JNmeM/T0wY+NcJPxcnJEGNV4QNbgCkraByEoOXDqo2JQ QA/9k7+VOVJFCl1N+0bBh1d9ruTH7ZcAlYV7ngB6dbhX6kwiF5xIK+iPQZSzU/nK 2wawpfw2r8ah5rSQpEJDWmKxQUMAflPG6XWluusV4xYyU2KMsRyOkXQ7alkqulys mejl/YSXN4D5LLONspAosjS+WC/gBwB9hfYZJkyacTYFDNpQ1mAEkeyIhXkt/ea5 +Mr4VeRyMFWq6M5FPGFAi0MfhJIGx+9/e+INzScVMpbMGtbil53xJ9Eskfcevb4K klNjkQ== Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4eu2xs8dv3-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 16 Jun 2026 10:10:20 +0000 (GMT) Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-51759082206so12043961cf.3 for ; Tue, 16 Jun 2026 03:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1781604619; x=1782209419; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=isNgOMfZ65NTVt8FlgRDQNF31fC0tCGiPVqqs5w87EQ=; b=W6BvTyorGZTIlkwNPLYSygeT0MfufbD9JO212rOGKrFv70qt3GkCk7ipgkq9WTQ9Pa QW2SAFI+F7yEIdNF2Cp2EhcFVKDcEbbZdg7gBB+EJMM3+TpJgDe/rwApmq9IGvW3BD6M YgrQ0QzB+DzOcpiAj1gxLLNUtZwItMzFWZ6tVBQeaXmfAP0zkWFi9b0r8GZ4G+7bKMzf /A9osp4kHucx90H1QdngjCXziQbR2NjyxqCwk1PrwxQSAQfGq0Hq4wU47dg6UcCB4iRE rADRIwRNJAHE78lmh/zLTQ0i6SvWtpkZNsO2q10+C+WYBiS9KjOlT5L8gwG3wWp1maac 5qcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781604619; x=1782209419; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=isNgOMfZ65NTVt8FlgRDQNF31fC0tCGiPVqqs5w87EQ=; b=rAyxOWWxYQIsi/ZJvCniddVmMso+cZL7XmyLMkJnR8HNZEFRVxWD3yM0Uqm3fTgAiw hvLQSrEpl9/dTnJxl+QUgv+fI1Bddqak8QJHuyRi7Ym4OOM/DilbGBmqx7BSstT2OIu+ 0i2muGjltr7tbz4jauGWxBM5TR5tFdl0EMUI/kz02lkhizjx52+uoE+4zB42yHpP7Tw4 +XZjQFGmblaSjcbVfkryvq2xzYUBz+nUu0vK0E1MmVukU5Rmo2aQnNgbc4kbNBV087EZ TgCfyfpEOZG2T9GZ0aSWVJqTMxiPWzcAMIfrp6Mf2mXdvoe2TPXVPQ2Y1z+NSS2NiTwk A+wQ== X-Forwarded-Encrypted: i=1; AFNElJ8iHR13IDZXdpEsTQBfwvreJPoFKx83E9fZjRjme5Cfw0VqpBZpLwbXlaYHIr2ko1uy2bID4GNZLMFT8f0=@vger.kernel.org X-Gm-Message-State: AOJu0YxdpzMpLA/eVVBOHMPVQHkFY86Uyvj/6j81irURCCbW2cEqrWmL Kjt3/CvVg+Gz+OgrPQV/WkjmpPNkNbP4uUH/4CmCsIL1T03WJM4g9njOKe0pUqpMQi53RRBSY96 0bVaAKZF2Br9zDQZx8mALY3EcZfUvA3t2TqNQ5YW4J6S0DeKIhi/1ZB3zmDjV+Kb7Op4= X-Gm-Gg: Acq92OFc/coJG+kwGuRS+JQ98AY2R6OilNGWtdQJ+vzUQKoSM0MZR6/4tqaTAvEJ8Gy oBMHV34c+A2VYaxpgQ3l7rLscgy1jd1U3nWOQsph/vEi/zR65zsO6L1kJawMaGY4jPl+FDhG7Hi 0id60cBjX/luv6uOJufIgRZQPvvAoZWNG/dqti21/yBIkGjdgX3qrNPCh5GA7ykkQJlU1gdVpHA ag72ZaCp2j+P94IgE+Sw7vH/t6jwMVOJUg8o57iTgHUAd0m1NIBomLrRe95YTBf8uZRH5UaJ1zm 99VQFeHyG2AnAJOi/YL+UNJKf2knv/cb3914etSPI+vWgXprhGb+LSSFSNj4jk7Bb9vmIenmMJR OhDNCtgonlf2u6pSftxEm7pv6+9fJ1BNH2sFPpvTj9C/14g== X-Received: by 2002:a05:620a:8011:b0:91c:9d38:30ac with SMTP id af79cd13be357-91c9d3836a4mr141778885a.4.1781604619593; Tue, 16 Jun 2026 03:10:19 -0700 (PDT) X-Received: by 2002:a05:620a:8011:b0:91c:9d38:30ac with SMTP id af79cd13be357-91c9d3836a4mr141775985a.4.1781604619074; Tue, 16 Jun 2026 03:10:19 -0700 (PDT) Received: from [192.168.120.170] ([178.235.128.140]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c0463a2d1f4sm100157166b.51.2026.06.16.03.10.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jun 2026 03:10:15 -0700 (PDT) Message-ID: <7478c540-a5fc-4238-bba0-5b04547f57c7@oss.qualcomm.com> Date: Tue, 16 Jun 2026 12:10:12 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] thermal: qcom: Add support for Qualcomm MBG thermal monitoring To: Sachin Gupta , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Stephen Boyd , Jishnu Prakash , Kamal Wadhwa , Amit Kucheria , Thara Gopinath Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Satya Priya Kakitapalli , Ajit Pandey , Imran Shaik , Taniya Das , Jagadeesh Kona References: <20260601-spmi-mbg-driver-v1-0-b4892b55a17f@oss.qualcomm.com> <20260601-spmi-mbg-driver-v1-2-b4892b55a17f@oss.qualcomm.com> Content-Language: en-US From: Konrad Dybcio In-Reply-To: <20260601-spmi-mbg-driver-v1-2-b4892b55a17f@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-ORIG-GUID: gje9HvaV5lHJxQsG9f3xioncnUd2AHEq X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE2MDEwMiBTYWx0ZWRfX6v7aVfc1rvo+ 6vVOPn3b+QHHbRAV7g5CWDDP57d24TdOrZc9fzaEVa1mTqhJ2+A7lHKfdKBGTsThiMrvYN+YVJK twOifcL7BZmkyaPUkfHSzNr508179CfSjlA7W2/ZgZn2UQ4l3oKwJO+vgXIz5Tg1ldAflpncrSo W81AP0OiFm+evYZ2+jBsTtn7qMvaikU44el//SDyhyBMp249o4B2cki0PVHP1jyyohfIRqqMYXE 3lYfZEHKKr5lsqjX5GrMy3Og6ZZdfEkdlD8Yv2Up0fJQ8bWmFhOsrnxWkji05DPg1Uq8cFCoWsv +8kPcsRcmrf3L3M9AwkYyqMACSly+7TBwrAdkDvt6z5sQzkztRxzKI4eJ18m1rocSIXRKXxH5az 5ccDdCPse1j5FS+bWNuLhnTG1b5Y1kBVgj5VSDwcZ8BA/ZmKTFV7u/AofTaDTyoOOpZaLX6IJ8o 2dhf+bB5U5E7VT28+Ug== X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE2MDEwMiBTYWx0ZWRfX1DBEO2FjmZEX DS1l4LHTWtIGXQV/LzCFJ47kGRD75danoUxQGbQXVblYPsbmL+4qtvJkvDsZnrNoVzGYqdRRQnP G1GOfXHFd8BDkuNMuLSV+7QKM2ab0UY= X-Authority-Analysis: v=2.4 cv=MdJcfZ/f c=1 sm=1 tr=0 ts=6a31210c cx=c_pps a=EVbN6Ke/fEF3bsl7X48z0g==:117 a=PRfkaYvzSr8QmIIGAkY2Sg==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=COk6AnOGAAAA:8 a=EUspDBNiAAAA:8 a=MUhxgwD4z-eir1BWSc8A:9 a=QEXdDO2ut3YA:10 a=a_PwQJl-kcHnX1M80qC6:22 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-GUID: gje9HvaV5lHJxQsG9f3xioncnUd2AHEq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-16_03,2026-06-15_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 spamscore=0 priorityscore=1501 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606040000 definitions=main-2606160102 On 6/1/26 1:01 PM, Sachin Gupta wrote: > From: Satya Priya Kakitapalli > > Add driver for the Qualcomm MBG thermal monitoring device. It monitors > the die temperature, and when there is a level 1 upper threshold > violation, it receives an interrupt over spmi. The driver reads > the fault status register and notifies thermal accordingly. > > Signed-off-by: Satya Priya Kakitapalli > Co-developed-by: Sachin Gupta > Signed-off-by: Sachin Gupta > --- [...] > +static const struct mbg_map_table map_table[] = { > + /* minT vtemp0 tc */ The struct is defined 2 lines above, the reader can tell the names of the fields > + { -60000, 4337, 1967 }, > + { -40000, 4731, 1964 }, > + { -20000, 5124, 1957 }, > + { 0, 5515, 1949 }, > + { 20000, 5905, 1940 }, > + { 40000, 6293, 1930 }, > + { 60000, 6679, 1921 }, > + { 80000, 7064, 1910 }, > + { 100000, 7446, 1896 }, > + { 120000, 7825, 1878 }, > + { 140000, 8201, 1859 }, > +}; Please add a comment stating this map is not PMIC-specific [...] > + /* The HW has a limitation that the trip set must be above 25C */ > + if (temp > MBG_MIN_TRIP_TEMP && temp < MBG_MAX_SUPPORTED_TEMP) { > + ret = regmap_set_bits(chip->map, chip->base + MBG_TEMP_MON2_MISC_CFG, > + MON2_UP_THRESH_EN); > + if (ret < 0) > + return ret; > + > + ret = regmap_write(chip->map, chip->base + MON2_LVL1_UP_THRESH, > + temp_to_vtemp_mv(temp)); > + if (ret < 0) > + return ret; > + } else { > + dev_dbg(chip->dev, "Set trip b/w 25C and 160C\n"); Should this be an error print, returning an error condition? > + ret = regmap_clear_bits(chip->map, chip->base + MBG_TEMP_MON2_MISC_CFG, > + MON2_UP_THRESH_EN); > + return ret; > + } > + > + /* > + * Configure the last_temp one degree higher, to ensure the > + * violated temp is returned to thermal framework when it reads > + * temperature for the first time after the violation happens. > + * This is needed to account for the inaccuracy in the conversion > + * formula used which leads to the thermal framework setting back > + * the same thresholds in case the temperature it reads does not > + * show violation. > + */ > + chip->last_temp = temp + MBG_TEMP_CONSTANT; Will this work fine if the user tries to set the max temp supported by the hardware (i.e. is there headroom for max+1)? > + > + return ret; > +} > + > +static const struct thermal_zone_device_ops mbg_tm_ops = { > + .get_temp = mbg_tm_get_temp, > + .set_trips = mbg_tm_set_trip_temp, > +}; > + > +static irqreturn_t mbg_tm_isr(int irq, void *data) > +{ > + struct mbg_tm_chip *chip = data; > + int ret, val; > + > + scoped_guard(mutex, &chip->lock) { > + ret = regmap_read(chip->map, chip->base + MBG_TEMP_MON2_FAULT_STATUS, &val); > + if (ret < 0) > + return IRQ_HANDLED; > + } > + > + if (FIELD_GET(MON_FAULT_STATUS_MASK, val) & MON_FAULT_LVL1_UPR) { > + chip->last_thres_crossed = true; > + dev_dbg(chip->dev, "Notifying Thermal, fault status=%d\n", val); > + thermal_zone_device_update(chip->tz_dev, THERMAL_TRIP_VIOLATED); Should the assignment and this call also be guarded by the mutex? Konrad