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 86B3238E13E for ; Mon, 16 Mar 2026 10:28:01 +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=1773656882; cv=none; b=OeKz1ADaXTjFJf+xp4Af2N3mx3UPnvKOZExZpYn+I6BsmfLAUipwAmPHx5BvY2SciDAvuFV87pyxfUJtXxOo+8Sl3PgrfAB8v6SdSFHgadB+NG6fuT6jIAqct5Zs1O4MZ03P3V+EycurTW1Mtf9QVeOLrqecRMHidPyqyWgyCsM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773656882; c=relaxed/simple; bh=Z6sgzCyD/+mTUE+CNMr+vHs1IyCsx2ukxqg8nEJr9/o=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=joQuQCCDTlCqxrj1Je24M9+cpaNgzLSWSXOPxmfI32ROnc09nYBxQBJWVcOEZgpF88tAhw/BgOMwRDLbMzKx+QBfA10pITy6A4mVUxxGrFxxOM7P3REauzuLWkQJaQB8qHE+IHppXfU23wQxZ87ssQXVwaDLJ9rABMLlZZqo3ow= 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=OZLRcYlB; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=F4Xr6ah0; 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="OZLRcYlB"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="F4Xr6ah0" 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 62G652OZ664264 for ; Mon, 16 Mar 2026 10:28:01 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= xHYSC2Zh2sIK8c1O1PlQgO469KM9EpxGZDFIyRJHXSM=; b=OZLRcYlBurNoiEbw 0RTpnAqcjdFE2PupVCzw3RdsIsaIy2Or6AeOVmoZ21blvnoJYjuNijvlbWDdljDU OnYeKmLcmFl8qpgvU5IQ2fY0jIlC77N0E4/nfBpRfZ1LyrkFN8Tbn0MudeOc5qbh NG2yDY6qK8Vsw8YBB4AjApf4h8k066x1wxZvNMF4TvQkmERsbpmzsSJCqsan7n+A /aQ+PG+AXHBgo9X1DQBL++/phkxtESaH6FpTCMv+Gs4/rl86vtfBcaFSUOaOyaC5 iJeDrrQGbkTXuKKbs3TeYMfrb6z2bdIacnQBdAm/JLSfEl1UQZasxAi7rRqNczLv htBkyg== Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4cw043n78k-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 16 Mar 2026 10:28:00 +0000 (GMT) Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-89c4cde1f02so9589716d6.1 for ; Mon, 16 Mar 2026 03:28:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1773656880; x=1774261680; 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=xHYSC2Zh2sIK8c1O1PlQgO469KM9EpxGZDFIyRJHXSM=; b=F4Xr6ah0y7TJtlH+1Eci9VSNLuvfv/F3FciMDkyXUwcOM+1Q20mmw7DSAl4p+USN5g NwyMPHl73nV/ptZbuK63nPPD0zw/ZQuRAkt689WrxIg9NcjTyZ3/zjWPyRHEXbngkRnU RwKMfcpqE2KWwXUpoccMzt5gRrLeb6KK6+16J/SjVOb1t12qW/dZ3adRlqGNV5ICRFha gpuuikgYT+vfhofscqdRaZi5OdNop77Ht1ITSYaLVGd9Mg+5l/u1DBeempVSFQa3ZSjZ mB4LdZe5wm+QoADFerJkhRX4wTDv7I01PIDfJsZZb/9tjiRtuMeLfJ6eWGVNDA3W/D4v h3FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773656880; x=1774261680; 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=xHYSC2Zh2sIK8c1O1PlQgO469KM9EpxGZDFIyRJHXSM=; b=Xh71N1mhL03vbZIEQ1jBLSEwjXCxR2pvLAlx9F8tawIjYNdn5q0a0ZvL0+7EPRKMeF 2WeIYzkkGFDKNW8oQhKqVn1DmVn5QcXbha6o8XUlQdJC/PDGvy0gZLQNGA3pe8ijMrr6 JPY/kqctDrc45mHSP1Y659ePOLeqdroRLVkAQ9rSUQQmKdMqsBizm8vTv5INuaW8CwPy IKP6HZNiu1bGGKHu9Rpvnzxm41skHaKr9rM4Brar3FReEBeKyuvUZqTbOPCwyTP5ikBM lUpw2/7ftmTYuTWj6/5yvzWRyPPgqotuYBBxIMg1KvhCo/1KTSFr6yHpfQidehgOEYHf BWMA== X-Forwarded-Encrypted: i=1; AJvYcCXv47KDh/vlmRz4X5W1agoo/FNUMEKGcSHZqMV8+byFicrWltid5euhWlIdL0vR2eJRf9FqadZVlR5o/hw=@vger.kernel.org X-Gm-Message-State: AOJu0Yzv5yJrK7KBlqih1BZ+/YPZCeubd17BKhiV0+DIYLqkOaEznVoU 115YJ1EVees+vhLqD5iDaXk63L0m6Lij7wgq+Bz4oo9W0dNLyVvy+637muOt1f+mL3y1+nO+/hj 1tgLf0YVkUvuyNtzuXBupB9uIkM7OFJjGWeSg2pxPckC3FuPBvblx58UzSUgtPCoJ3ds= X-Gm-Gg: ATEYQzzkETNtppYaT7yg4WTt0BrPXM73mQrhi71HF9YrBkfee4gCPXdGpQkDH/xLwxs Z1MIqOXTTSTP7+s0JvsoyfeTEzB7sQQyHyMvR82ehZq5pfipKNEmmsAfy7ZiLY4eufK+T3HPZCW ZZaW817em3oYiGfcO1A65O09/qpdeu1eV5e1dfIS/hX07U3YfHf8NqQubr05ocBmFaDc6opu7Hf EoIFAWMiz5zorNL9eCtQg5hWLcFcYomcaIO4m5x6mX9cVsccmfgfHlGWHvW7OF0VK1Kzv01dlq1 aDeBvbxTzVvTuyHwDfLuphRgkFC0uZwxce3cCa8eiWanBV3WVCMnSQbK4oUFWUEmh8JIXmCxnzD WnESBOszGhuwvgrurVXyZNh3iwtekb4KQAM/aaMlu5JalIgNSfhotCl/kTqSUoj/G8njRpLnSqo 4rpKM= X-Received: by 2002:a05:622a:46:b0:509:2822:66ff with SMTP id d75a77b69052e-50957cdee07mr139541281cf.3.1773656879555; Mon, 16 Mar 2026 03:27:59 -0700 (PDT) X-Received: by 2002:a05:622a:46:b0:509:2822:66ff with SMTP id d75a77b69052e-50957cdee07mr139541001cf.3.1773656879130; Mon, 16 Mar 2026 03:27:59 -0700 (PDT) Received: from [192.168.119.254] (078088045245.garwolin.vectranet.pl. [78.88.45.245]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6639fe6dc9csm4302297a12.17.2026.03.16.03.27.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Mar 2026 03:27:58 -0700 (PDT) Message-ID: <6eb3a173-c364-431f-93e4-7bbb7a32431e@oss.qualcomm.com> Date: Mon, 16 Mar 2026 11:27:54 +0100 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 v4 2/5] platform: arm64: Add driver for EC found on Qualcomm reference devices To: Anvesh Jain P , Sibi Sankar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Hans de Goede , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, Maya Matuszczyk References: <20260313-v04-add-driver-for-ec-v4-0-ca9d0efd62aa@oss.qualcomm.com> <20260313-v04-add-driver-for-ec-v4-2-ca9d0efd62aa@oss.qualcomm.com> Content-Language: en-US From: Konrad Dybcio In-Reply-To: <20260313-v04-add-driver-for-ec-v4-2-ca9d0efd62aa@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzE2MDA4MCBTYWx0ZWRfXw2aY4OOjrx9H ZThJh98VbJpPMSQsYM2epljYROWETnmbGigVbx1fhcrMpZe49NU3r0mzyqU12gBzY3Ys2LXAotx Q46fLSMAe4YxVBrbhqaX/XE0w5hcRE7EkkLxkx4Tops1p3YkUIbzdPOTNO3mtFaH7fVh1rl0UVc brp2KCv6exLeEBfjdyVMiATQkmTc2EL5Be9jL/S6JRAm7BnV8Q3zfjaz5CY8lywXmYNhLfJvp0l BVZHFkFzSN7wbNaWc04JB/f/UgjtbZYiWZVVZIWHxBdMFrwv9HVyMKfqPgtZ59mKngPsFMztQpt aY/2Hlli9zY/Y8v9y8IkGfFdwck2DfcIhzvygfDcD9b+ws4D87OtswmTatmMLVHuZFwYyaHm8ZV HspP6LpBkIUwlyoLbe13pnhUvCAQpArM0UnCbPnSKgFYVPLZf6cn6/vOtf8VVpKoJ8CzgZPYcpp 96nDAdCltOSDsJRfsIQ== X-Proofpoint-GUID: MPHfgepnvXDs2UcUOfi0j6Gngjqa4-Jp X-Authority-Analysis: v=2.4 cv=fLs0HJae c=1 sm=1 tr=0 ts=69b7db30 cx=c_pps a=7E5Bxpl4vBhpaufnMqZlrw==:117 a=FpWmc02/iXfjRdCD7H54yg==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=pGLkceISAAAA:8 a=Hm7G6JvClKosMBX75qIA:9 a=QEXdDO2ut3YA:10 a=pJ04lnu7RYOZP9TFuWaZ:22 X-Proofpoint-ORIG-GUID: MPHfgepnvXDs2UcUOfi0j6Gngjqa4-Jp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-16_04,2026-03-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 clxscore=1015 adultscore=0 spamscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603160080 On 3/13/26 11:29 AM, Anvesh Jain P wrote: > From: Sibi Sankar > > Add Embedded controller driver support for Hamoa/Purwa/Glymur qualcomm > reference boards. It handles fan control, temperature sensors, access > to EC state changes and supports reporting suspend entry/exit to the > EC. > > Co-developed-by: Maya Matuszczyk > Signed-off-by: Maya Matuszczyk > Signed-off-by: Sibi Sankar > Co-developed-by: Anvesh Jain P > Signed-off-by: Anvesh Jain P > --- [...] > + * ------------------------------------------------------------------------------ > + * | Offset | Name | Description | > + * ------------------------------------------------------------------------------ > + * | 0x00 | Byte count | Number of bytes in response | > + * | | | (exluding byte count) | > + * ------------------------------------------------------------------------------ > + * | 0x02 (LSB) | EC Thermal | Bit 0-1: Number of fans | > + * | 0x3 | Capabilities | Bit 2-4: Type of fan | > + * | | | Bit 5-6: Reserved | > + * | | | Bit 7: Data Valid/Invalid | > + * | | | (Valid - 1, Invalid - 0) | > + * | | | Bit 8-15: Thermistor 0 - 7 presence | > + * | | | (0 present, 1 absent) | ^ huh?? I see that it's not currently used, but I think flipping these bits would make it easier to comprehend down the line [...] > + default: > + dev_dbg(dev, "Unknown EC event: %d\n", val); Maybe dev_notice(), this would be good to log > + break; > + } > + > + return IRQ_HANDLED; > +} > + > +static int qcom_ec_sci_evt_control(struct device *dev, bool enable) > +{ > + struct i2c_client *client = to_i2c_client(dev); > + u8 control = enable ? 1 : 0; > + int ret; > + > + ret = i2c_smbus_write_byte_data(client, EC_SCI_EVT_CONTROL_CMD, control); > + > + return ret; return i2c_smbus_write_byte_data(client, EC_SCI_EVT_CONTROL_CMD, !!enable); [...] > +static int qcom_ec_resume(struct device *dev) > +{ > + struct i2c_client *client = to_i2c_client(dev); > + int ret; > + > + ret = i2c_smbus_write_byte_data(client, EC_MODERN_STANDBY_CMD, EC_MODERN_STANDBY_ENTER); > + > + return ret; In a pattern like this, unless you have some error checking/logging to do, you can just return directly [...] > + ret = qcom_ec_read_fw_version(dev); > + if (ret < 0) > + return dev_err_probe(dev, ret, "Failed to read ec firmware version\n"); "EC" [...] > + for (i = 0; i < ec->thermal_cap.fan_cnt; i++) { > + struct qcom_ec_cooling_dev *ec_cdev = &ec->ec_cdev[i]; > + char name[EC_FAN_NAME_SIZE]; > + > + snprintf(name, EC_FAN_NAME_SIZE, "qcom_ec_fan_%d", i); > + ec_cdev->fan_id = i + 1; > + ec_cdev->parent_dev = dev; > + > + ec_cdev->cdev = thermal_cooling_device_register(name, ec_cdev, > + &qcom_ec_thermal_ops); > + if (IS_ERR(ec_cdev->cdev)) { > + dev_err_probe(dev, PTR_ERR(cdev), > + "Thermal cooling device registration failed\n"); > + ret = -EINVAL; > + goto unroll_cooling_dev; > + } > + } > + > + return 0; > + > +unroll_cooling_dev: For those cases, one would usually add add a devres-managed version of the helper (devm_foo_bar()), removing the need to repeat this in the driver remove callback as well Konrad