From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 B74CB4483AB for ; Fri, 7 Aug 2026 06:21:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786083714; cv=none; b=nuFd2ERqTQfRJURD7QvIpMnW73/yxaK0mKZi1dxOX+L2TYqLmXQ6Z2rJy1Eld5a9T2XlOR3GXM8c8FOnAbYZ4lZij4m6KFxEO6bH4rxvmcA2l3XM7Td8nUIk+4MxnZJBgJcBXun7r38K59DdFsl3KmN8GwU9cfUIYu6whL9YR9c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786083714; c=relaxed/simple; bh=R6AK7dQHatN/EGJBdvgFmvrcbFS4f0sk4D7CoXsPDr0=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=f7C0d/2ycy0xv3bZtJEOJRaOWBuTWR9aimtBpyMSCyErUnoGW6gG6Hi2VDNMufrlgpEUuADlj+TfSMZpG4VhSceXB0aCiOnGrWDKzkajwAjH7g3V/VQ51zeGvQMn0cwZ8M0tQ2TaaUE4Jo9IzJJHqSkheQYYT4dUEZJl7PrjGaM= 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=GqK2D3/E; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=P12kwIWE; arc=none smtp.client-ip=205.220.180.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="GqK2D3/E"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="P12kwIWE" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6770HBrD3478244 for ; Fri, 7 Aug 2026 06:21:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=MbjI3enVhu9e1mM/DRlJHe uCjBiCSKcE83GyUKU52Xw=; b=GqK2D3/E4pM6QCKt56ja0Jp/wMOsL5plFYMmkx XePDSbOz+PrOPTU2DoWWItdsR4IhpzNwmUXNPIexq0SLm/VMO6Wci1xRHfIIuSgQ oRhRu7Qq0ocDmYdVPRCz6zcDLrREnAnJuC0AUq+/ezcg2zV34vKS6d/y39aKpSmi CH0Q3ysmP3zfVyT6KDG+5OENJBxfAcMdw7/Ow91bExp0OGVFKgyVW+m+/xkGKqFB nAgBQVix4b+1nGep8Edhc8N+am411ryTST0EO04fSS0lu02SlKyTUwCtFBOKHOxx i6IsCIKUtH3NaUqjE/9MDotnmUFMqPDOQ3mqKzmlkkYXUVlg== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fvy6hajbj-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 07 Aug 2026 06:21:51 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-38e8fee6af3so3226926a91.1 for ; Thu, 06 Aug 2026 23:21:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1786083711; x=1786688511; darn=vger.kernel.org; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=MbjI3enVhu9e1mM/DRlJHeuCjBiCSKcE83GyUKU52Xw=; b=P12kwIWE1qI2gEQ4scBJ99lIzNRfvJ8F1XOl4m9I1oEFDDTEk+cvMD2XQPDP9cN/zC avfEB3sIwS1hEfXaXkQ8YMFybugs+WmJRFBSUpHtg0tCXTUOQNb87JwyNQ7Ms6nxrlaA OJMBN6q6wJFJ3yUTyWs+7Hi9KzZ7j5DuwWqankz9gJo7GHtZ3TabmuYYGExmeVpNljly F6Lou3xRi6ZSwj2RZWxNS2NbJgY0yacgEyfFy5bSjlmko4fM1/VOUa//Z/wAqFugp8X6 towCYwV7mtQTKk+X167hYEIfiVXjHQc7FhD8/8xlw8999E9rJRZPCNLjf2zkfzZGGAGa c0vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786083711; x=1786688511; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=MbjI3enVhu9e1mM/DRlJHeuCjBiCSKcE83GyUKU52Xw=; b=NuoS8Ca1pBRDyURYebVt/+4vNFX9VbxYgI2vK8Jx8hYhf/TMXCsMVaOOjhO072OiH0 Cu+9uZDpRisYvn695kUxmekvhTZFcMjthyQKubDzAKbIJX/BYI6KIf9wSBqpF4KGXvBU bnFAVAXWoRmzTD9mdt3K99m40fDU14c+1vCc9niYo9C6U0YagJd+qNFlaZmSRiqrw6HA 1fmOYkBYXZBoPMxLddTAnYjTx2c4yDse5Vy0qQ/XfAyziHGU/V+SP9Ci6Ahgw5vjpDdp Y4QTrdBkD3kwZaLFwc/ssDadpJKz5id7BF9y6kIzy4G9MMIqX2qiLpbys/OCCcY2URu2 aYyw== X-Forwarded-Encrypted: i=1; AHgh+Ro+HfWlo7xtTKrdzzFsllyUnt4I8B9SDZSHeljQYGel5KOet1RbU/hf9NAA/4xC4onBS0roj/PPN5aLPqU=@vger.kernel.org X-Gm-Message-State: AOJu0YzyxMzbbg3dxO2INSG1HOigMNzPK20VSlCgqz0u+lcZH1AV0bP9 CD00asGZLwZYsHq315v0Fpobu91GLMOC0+sr5geJ7Yr3y/fl9c/7dPblEKnbG0TKPfTaJhrrjOg jet9j+1hXvBHEEPv0aXDYhoR3oPdOkE5/UMySskLg+f0kXHrKhfH/ZJqDYhCl/ERpDUs= X-Gm-Gg: AR+sD10b+SoxHy6aOIMWafFBadKWXM5DtBIYbIyPTzbCtC79E6OQTsKZfP2q+LW6wXK z3AvUH1szNImw5aC+IOwwWo781OHRCvPSXxn0ekzTiCauISpwBPE58SYLP8u+ZNvKqg/ip+EoE7 waQ+rwhEUgZEQoDK4pTaoY2c4zRN8g04wlVM2uOB3R36AESkyNJqADxt4wQ+5ns6C6dxWdMDZBR JqbfnM2qYcipGcQzkvOjpn+xH/IJ5P9QPvlEMIC9OBFU06T8VQSbszABhyQDsstTTn9u5JSVbAZ FRT0VHWkWGRIQrkDblIH099OQM4Z6fjP08ted9ZQ5V6gBlTBYZ6enOUKvmH593aQGHuQd7BTKJ8 ewF9EA4eWLwUJp2wp7HYo1hTiE7gCUEctSR/tOCnUD9FUzcL+gpsK X-Received: by 2002:a17:90a:d443:b0:38e:7168:281 with SMTP id 98e67ed59e1d1-3903c594637mr23020165a91.10.1786083710382; Thu, 06 Aug 2026 23:21:50 -0700 (PDT) X-Received: by 2002:a17:90a:d443:b0:38e:7168:281 with SMTP id 98e67ed59e1d1-3903c594637mr23020105a91.10.1786083709823; Thu, 06 Aug 2026 23:21:49 -0700 (PDT) Received: from hu-fenglinw-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3925ff24552sm1047301a91.10.2026.08.06.23.21.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 23:21:49 -0700 (PDT) From: Fenglin Wu Subject: [PATCH v6 0/2] input: misc: Add an initial driver for haptics inside Qcom PMIH010x PMIC Date: Thu, 06 Aug 2026 23:21:39 -0700 Message-Id: <20260806-qcom-spmi-haptics-v6-0-19fcecd5204f@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAHN5dWoC/33PwW7DIAwG4FepOI8KbAphp73HtEMAZ0FamjR00 aYq7z6nl/ZAdrH0I/szvolCc6YiXg83MdOSSx7PHOzLQcS+PX+SzImzAAVWWW3lJY6DLNOQZd9 O1xyLxBi9IxcAgQTPTTN1+eduvn9w7nO5jvPvfcWit9f/tEVLJRMYMgCJbDBvYynHy3f7xa3Dk YvY0AWeIDA1CBgKXuuGrOqQcAfCB+Q01iBkKHrUIbgYvOl2IPMMuRpkth+pjhQlVI3xO9DpATW qetqJIec0NBRCSpAq0Lquf1kbbnPdAQAA X-Change-ID: 20260616-qcom-spmi-haptics-3cc97e7b232e To: linux-arm-msm@vger.kernel.org, Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Stephen Boyd , Bjorn Andersson , Konrad Dybcio Cc: David Collins , Subbaraman Narayanamurthy , Kamal Wadhwa , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Fenglin Wu , Krzysztof Kozlowski X-Mailer: b4 0.16-dev-17187 X-Developer-Signature: v=1; a=ed25519-sha256; t=1786083708; l=7359; i=fenglin.wu@oss.qualcomm.com; s=20260324; h=from:subject:message-id; bh=R6AK7dQHatN/EGJBdvgFmvrcbFS4f0sk4D7CoXsPDr0=; b=gUmJKYT03Po1Z+pl1CGOOqldJApwik5FYtpUAVv3i4D+5LzHYQPfOxlfaVDDerUQva1DJ9WsN nh8xtl4OdleANZjcEDp/VYhE3b2k5LpCuz3SP9GNFrNS5uOaVzQoG8J X-Developer-Key: i=fenglin.wu@oss.qualcomm.com; a=ed25519; pk=hJdt3E7o54lql+miD2GaxwF74cDyhgNwMbmFOZ46bRU= X-Proofpoint-GUID: RE2vMw50yjS9Amz_k5k-JRx6NUHJUL4r X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA3MDA0NSBTYWx0ZWRfX72jtEgezKHZX h2eYeZGvG20yaikIyHEr7Mcu0cDzNsrqzdvZ/HzS3Q9vDSD6R/hnHBVEBlL3TRxr2kHB82c3+Du jj5cacMGUntZxalK16RQ8tlEhAaxZmv4Ga49xHnu8hLTs6Qp6reqZzqHjS7TiifES8aeDyRjE0W Mh5AbO5ee8208/d82L3jyFpiXctiCqnLtHkGLuM2eE06zTK553HTJzxIVjmcdcn2lsbDwUTqaqN CwGWHpFazN67rOsI/gJzKHQ/wOO3ZRSOfXQz5vMQqmZqf8qStIFL6AMMumt1WXB05HSgy/xQgk0 BFmtXlKw86sjAP1NpxjdWKAgodRANtsau6McuUvOYT0qKoS93mjrtIVKRI5p4eVFJnItYYgoU5I M8b7k4SRylCLQa3yNmyXUSyNPTkk9iEQE1lvqmmt36hHREOG4BMUGuzp9V75lM8JQ0kBLabZz5j mZTZEa6ytaWv0Gwnegw== X-Proofpoint-Spam-Info: AW1haW4tMjYwODA3MDA0NSBTYWx0ZWRfX8CMVaUpPrFca 1DTmNC2xN6nwUaoiniBeTIAA2XfmvPH0Tw+2r98s8JEt8bFWS/xxuiK4KYL2sUFqmgB/2zkmYcC X+IAhQP6+IqOrpgxClVC83p67XpJhis= X-Proofpoint-ORIG-GUID: RE2vMw50yjS9Amz_k5k-JRx6NUHJUL4r X-Authority-Analysis: v=2.4 cv=MbpcfZ/f c=1 sm=1 tr=0 ts=6a75797f cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=VwQbUJbxAAAA:8 a=bC-a23v3AAAA:8 a=EUspDBNiAAAA:8 a=wqtGLH9dRC1TDm73MfMA:9 a=QEXdDO2ut3YA:10 a=uKXjsCUrEbL0IQVhDsJ9:22 a=FO4_E8m0qiDe52t0p3_H:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-07_01,2026-08-06_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608070045 Qualcomm PMIH0108 PMIC has a haptics module inside and it could drive a LRA actuator with several play modes, including: DIRECT_PLAY, FIFO, PAT_MEM, SWR, etc. Add an initial driver to support two of the play modes using the input force-feedback framework: -- FF_CONSTANT effect for DIRECT_PLAY mode which drives sinusoidual waveforms with fixed period and amplitude, which would generate a constant vibration effect on the LRA actuator. -- FF_PERIODIC effect with FF_CUSTOM for FIFO streaming mode, which can play an arbitrary waveform composed of a sequence of 8-bit samples at a configurable play rate. Also, add the device node in the existing pmih0108 dtsi files, and enble the haptics device for several boards by updating the vmax and lra-period sttings according to the LRA components that mounted on each of them. Signed-off-by: Fenglin Wu --- Changes in v6: Drop patch [2/3] as it has been applied in https://lore.kernel.org/linux-input/178602255123.2917765.7426706813083510078.b4-ty@b4/ Fixed Sashiko review comments: - Add FF_SINE waveform support since FF_RUMBLE would be converted to FF_PERIODIC effect with FF_SINE waveform, and it is required to be supported. Also, clamp the FIFO play length with replay.length, also document the limitation of supporting replay.delay, u.periodic.magnitude and the envelope - Add a separate worker to handle timeout stop, which gives a clear way to distinguish timeout stop requests from actual play stop requests. - Replace disable_delayed_work_sync() in close() to cancel_delayed_work_sync() as it caused an issue that the work would be disabled permanently. - Move haptics_enable_module(h, false) into the reset action(). Calling it in close() would desynchronize the runtime PM state and could cause issues if a play is triggered after close() and before the auto suspend timer expires. - Link to v5: https://patch.msgid.link/20260804-qcom-spmi-haptics-v5-0-77128ebbdd2d@oss.qualcomm.com Changes in v5: Fixed review comments from Dmitry: - Change to use "err" for the "ret" which hold error code - Remove "haptics_queue_pending(...)" functtion and inline it into the caller. - In haptics_fifo_empty_irq() when writing FIFO chunk failed, instead of stop the plan immediately, just clear the FIFO threshold to mask the interrupt. - Add "lockdep_assert_held(&h->play_lock)" for the helper functions which require to be called when the lock is held. - Add "gain_work" to handle set_gain() immediately. - Set input device bus_type to "BUS_HOST". - Move the remove teardown to input device close() - Link to v4: https://patch.msgid.link/20260717-qcom-spmi-haptics-v4-0-b0fe0ed30849@oss.qualcomm.com Changes in v4: Fixed Sashiko AI review comments in the driver: - In haptics_start_fifo(), remove the goto and do the clear in the error paths directly, also add a comment to explain that disabling the IRQ synchronously won't cause a deadlock. - When data refilling failed in IRQ handler, stop the play and disable the IRQ to avoid the potential IRQ storming issue - in play_work(), check if the effect_id in the request is the one which under playing before stopping the play. - Link to v3: https://patch.msgid.link/20260713-qcom-spmi-haptics-v3-0-c931bb7cb94f@oss.qualcomm.com Also, add trailers in the binding changes. Changes in v3: In the binding: - Removed the ref for qcom,vmax-microvolt as the property with standard unit already has a ref in dtschema - Added 'qcom,pmih0108-haptics' as a device-specific compatible In the driver, fixed Sashiko AI review comments with below changes: - Added a list to queue and serialize all of the request, which helps to avoid the races between playback(), which is protected by evdev's event_lock, and play_work(), which is protected by play_lock. - Changed to use guard(mutex) or scoped_guard(mutex, ) for cleaner mutex logic usages, and update protection section to prevent race conditions. - Added runtime pm control in haptics_stop() function, use it as an unified interface under the guard of 'play_lock' in play_work()/erase()/remove()/suspend(), to ensure the runtime pm control correctness in race conditions. - Removed unnecessary stop play sequence in fifo_empty_irq() as the HW would automatically stop after the FIFO samples are played out. - Added a common interface haptics_clear_effect() to clear the FIFO data with gaurd of 'fifo_lock', and use it before upload() and in erase() to prevent race condition. - used __free() for safe memory cleanup - Checked play_rate against negative value when loading FF_PERIOD effect - Limited the custom_data length to 48K prevent potential OOM - Link to v2: https://patch.msgid.link/20260624-qcom-spmi-haptics-v2-0-b9118e60f3e3@oss.qualcomm.com Changes in v2: Dropped dtsi change and I will resend them after the driver and binding changes get accepted. Updated haptics binding and addressed review comments from Krzysztof and Konrad: - Extended the description to clarify the 'PAT_MEM' mode (not yet supported in the driver) by comparing it with the 'FIFO' mode. - Updated the compatible string to 'qcom,spmi-haptics' to match the file name and removed the PMIC wildcard. - Simplified register names to 'cfg' and 'ptn'. - Corrected the unit naming for the 'qcom,vmax-microvolt' property. - Added an additional clarification for the 'qcom,lra-period-us' property. Updated the driver to address review comments from Konrad and Julian: - In haptics_write_fifo_chunk(), separated variable declaration and assignment, and added comments explaining the 4-byte and 1-byte FIFO writes. - Replaced manual 'x * n / d' calculations with mult_frac(). - Switched to disable_irq() to prevent late IRQs after device removal. - Replaced property reads with device_property_read_u32(). - Remove the 'INPUT' dependency in Kconfig Updated the driver to address feedback from Sashiko AI: - Guarded pm_runtime_resume()/suspend() with 'pm_ref_held' to prevent runtime PM reference leaks. - Replaced spinlock with a mutex to protect FIFO data during playback and avoid calling sleepable regmap APIs under spinlock. - Adjusted suspend/remove() sequence to stop playback before canceling work, and freed FIFO buffers to prevent potential memory leaks. - In FF_PERIODIC handling, allocated 'fifo_data' before assigning data to ensure its consistency with 'data_len'. - Registered the input device after enabling runtime PM. - Unify to use 'h->dev' pointer in probe() - Link to v1: https://patch.msgid.link/20260616-qcom-spmi-haptics-v1-0-d24e422de6b4@oss.qualcomm.com --- Fenglin Wu (2): dt-bindings: input: Add Qualcomm SPMI PMIC haptics input: misc: Add Qualcomm SPMI PMIC haptics driver .../bindings/input/qcom,spmi-haptics.yaml | 136 +++ drivers/input/misc/Kconfig | 11 + drivers/input/misc/Makefile | 1 + drivers/input/misc/qcom-spmi-haptics.c | 1252 ++++++++++++++++++++ 4 files changed, 1400 insertions(+) --- base-commit: 66725039f7090afe14c31bd259e2059a68f04023 change-id: 20260616-qcom-spmi-haptics-3cc97e7b232e Best regards, -- Fenglin Wu