From nobody Tue Dec 2 00:03:19 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 867F032692D; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081911; cv=none; b=RnXyr+qflnVGOA3mFV7QxaaRtfC2F7PpWrLbyqKgZreG0qiCNvtWkzrdzEw7ShQLgaN0763He3zgyghqbuvVNbChWVSMwwpn8kpKEBRwxvp8NUkpXFsSoYky9ggp4rXGImaggWCVIrdLRSHeiDj6fhSb9sEG7oMOESHuRIAVhvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081911; c=relaxed/simple; bh=XBDSzMYIFkCw09WI3jBNA9MTUk89wi4ZpjMVAgW3SWY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AvBW6IZxnQSyqTKYGOq9C+Xucx02OtGzLkMw2YGKeXmYQvysRSWu8Tlg06YwSQnGNU2iYT27i+7pXJOHzdzlz7l1QDGKwmkf9QzxAxJwcoGVi8adeCt0lX7QXMyjdi/SYtNd/RqobOpQywadlPewfm68KoE1aIJ2S//uiDTyjrA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YEGxOm9c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YEGxOm9c" Received: by smtp.kernel.org (Postfix) with ESMTPS id 09090C116C6; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764081911; bh=XBDSzMYIFkCw09WI3jBNA9MTUk89wi4ZpjMVAgW3SWY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=YEGxOm9cg7W9Mou29C0GZ3AC7mXlMogFvHnZ4TfkrH9V8P7eTv9Zw3AXXwKiDEc6B giSUc5nG7p9typxHoZ+iFFTE9+MygmewJqfOtCcLN98dNv84m+IgJOKEFv4HFFZHWe nJd8FRnRxKQrYpy9Vm280kffEv1Ci9bB+YNRgBSNg20QpyN7G15tMQO4KfGvF/UwEX A59DZnoX27mfbr26dlI/LzdAcZeDZzr4nkrh3SllLHYbH4FEqNyHVkVXrl2w0WlFV3 h9Fcgv3yUw09L8qaSVW+4xAfajIkhWwg2UVTu9u3GRDO9S7FDEj8MUC9Bp+B+SR+fy XzL6QnxP/Nvcg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBF03D0E6F1; Tue, 25 Nov 2025 14:45:10 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 25 Nov 2025 20:15:05 +0530 Subject: [PATCH v2 01/10] serdev: Convert to_serdev_*() helpers to macros and use container_of_const() 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: quoted-printable Message-Id: <20251125-pci-m2-e-v2-1-32826de07cc5@oss.qualcomm.com> References: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> In-Reply-To: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> To: Rob Herring , Greg Kroah-Hartman , Jiri Slaby , Nathan Chancellor , Nicolas Schier , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , "Derek J. Clark" , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley , Marcel Holtmann , Luiz Augusto von Dentz , Bartosz Golaszewski Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-pm@vger.kernel.org, Stephan Gerhold , Dmitry Baryshkov , Manivannan Sadhasivam X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2123; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=gp2plOukmLsK8Wz0sYhXr+7v4Z6uCCCmxZxVG517B/M=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBpJcDyeFLCzWDU7DbBpggspqjnYeo3HN+5r50pB iGA2Xp8WLeJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaSXA8gAKCRBVnxHm/pHO 9RlvB/9CbifjQ3jZwZtMwC+hnrlvILHtu+kiJsXQ3WfhvHxz5q0Fcm0nkfdBBgSUwx/bFhMqidX /GyfwPv1MHx3GEX3AH41y1whdyQO02CzHOwLE+yu7n7gGnz5009PCzMinAD06jW9aZrHWzlx4Qa Voe1JgB5+FRVKs8ppyCu9GEiOdQ2mrnnd2PoWslfpd5KX7DbJvqkAFG2CdPXmWe2f/yJKQZ10S4 KTR3UoQ1qHi3PQQHP35gajlhY+DXW6Ilc4F3HXG5ohmDGa3i8lJ0qsNb//RwdfdGbkGCgYDJg0Z IDLx/gjMjBJuZlTxmgbt6Ot3q3BBG4UnBbmWvKq5nbkoP8/Z X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam If these helpers receive the 'const struct device' pointer, then the const qualifier will get dropped, leading to below warning: warning: passing argument 1 of =E2=80=98to_serdev_device_driver=E2=80=99 di= scards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] This is not an issue as of now, but with the future commits adding serdev device based driver matching, this warning will get triggered. Hence, convert these helpers to macros so that the qualifier get preserved and also use container_of_const() as container_of() is deprecated. Signed-off-by: Manivannan Sadhasivam Reviewed-by: Bartosz Golaszewski --- include/linux/serdev.h | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/include/linux/serdev.h b/include/linux/serdev.h index 34562eb99931..ecde0ad3e248 100644 --- a/include/linux/serdev.h +++ b/include/linux/serdev.h @@ -49,10 +49,7 @@ struct serdev_device { struct mutex write_lock; }; =20 -static inline struct serdev_device *to_serdev_device(struct device *d) -{ - return container_of(d, struct serdev_device, dev); -} +#define to_serdev_device(d) container_of_const(d, struct serdev_device, de= v) =20 /** * struct serdev_device_driver - serdev slave device driver @@ -67,10 +64,7 @@ struct serdev_device_driver { void (*remove)(struct serdev_device *); }; =20 -static inline struct serdev_device_driver *to_serdev_device_driver(struct = device_driver *d) -{ - return container_of(d, struct serdev_device_driver, driver); -} +#define to_serdev_device_driver(d) container_of_const(d, struct serdev_dev= ice_driver, driver) =20 enum serdev_parity { SERDEV_PARITY_NONE, @@ -111,10 +105,7 @@ struct serdev_controller { const struct serdev_controller_ops *ops; }; =20 -static inline struct serdev_controller *to_serdev_controller(struct device= *d) -{ - return container_of(d, struct serdev_controller, dev); -} +#define to_serdev_controller(d) container_of_const(d, struct serdev_contro= ller, dev) =20 static inline void *serdev_device_get_drvdata(const struct serdev_device *= serdev) { --=20 2.48.1 From nobody Tue Dec 2 00:03:19 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9CE0B3246F0; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081911; cv=none; b=O9UNZ5Xy0SHOuMSA4XPhUM+djfVRT6PegYyKnNqWfgfqsx8EOvk0UK1FxqxTdqlZqqd2sqykKdbt9i4pgsXl20d/FuAHSRCQWXKJtEZ3lt/LNMOpd06F2kNC1ISBCJlD8Xaj/pFpBv2t0ILjJNU6VmueMGp8zNmTAR20OEUt1LA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081911; c=relaxed/simple; bh=rR3gz3yzpBRkBDHXSaogJdTENZ1CLw1h0jHGgJLehB8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Sk8wsfTDGL/ogDhkbm1iQJOuc67o8PZbFMKKIZxFt28TZOz432SsB94G/74afK003WGhUeyEJkLTgwF8oqXUtOd4Ab8wyZyv5kuyjHysGyvdoaMIKIWgcyav31nWC6PF4npzv2DMJIjxZfNH6IgUc8vNimBkI0+cthXwyZwMe+Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uMri3jMC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uMri3jMC" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2336BC19424; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764081911; bh=rR3gz3yzpBRkBDHXSaogJdTENZ1CLw1h0jHGgJLehB8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=uMri3jMCRqfuHCVaOSWbll6PTnM0TnPMc8C5vzQM6fRxFtJqOpoWHy6UTPZAPAUb+ 6lJsHRQ7hcKLNwptFIw5YoE042O1OKnxh08s+JrKDRlpelBzsRbyWImmg2tXPjrVQQ wfYjZ6ItFg8MEkyTEsN6ynsLjtrrT2YGIuxdvuD2iK5A2Gst9d1xRiribI7VsjktD/ m9xEHnnWbVq6b357/ogRElVLXHR9tz1/1Xi2d00IGoIx658dqchqSh5OWHiW0LsWjm Wxha7qFSKPfqp7mzm1ZsFLKKnSvnkr3pbZTKqt7s+gV8eOdpokLkXNBzc7yihSzSAI gA/8S9EuIrZNQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CCFDD0E6F4; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 25 Nov 2025 20:15:06 +0530 Subject: [PATCH v2 02/10] serdev: Add serdev device based driver match support 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: quoted-printable Message-Id: <20251125-pci-m2-e-v2-2-32826de07cc5@oss.qualcomm.com> References: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> In-Reply-To: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> To: Rob Herring , Greg Kroah-Hartman , Jiri Slaby , Nathan Chancellor , Nicolas Schier , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , "Derek J. Clark" , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley , Marcel Holtmann , Luiz Augusto von Dentz , Bartosz Golaszewski Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-pm@vger.kernel.org, Stephan Gerhold , Dmitry Baryshkov , Manivannan Sadhasivam X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3979; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=l5Ts3o61IXqTXA6cCJVPncMY06Qk0XS4grwShZ7YiiY=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBpJcDy5aNQTrm4PBQrFGYoE/mpmzlHS14l3KcAg f67d/Vs8WOJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaSXA8gAKCRBVnxHm/pHO 9WM0B/9vOuD1CGvFWE0LFie5T37/3Dlph915pP3GTxIx3fy/Ux553oVeUV7W9wQX2Mpi83Hb/F+ ny6kHH7fV0no6NuuQHmyjyVEGvbG+Qw6zG2FOmkzIBBzVezUph+MvIBNwyrs76QAwW2uAHGQiDY Xdy1FAov0YL439699RHC7LXcD6sg4AvYgXLrIf0yHknev1pnXNtNUHtoMvmHcvFOidBpYuJTF9u LGvizzdk6qCPZj8HpGXD+2UCVGIDRpsK1ei3Qni3oSx4yPHm2zPUFFRwA7SsHjTZEhE9hSI/EEs LXHONCdvpTB80Hzk786sXqWYmP7FXNcojvZDERXUlhPN0hhE X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam Add support to match serdev devices with serdev drivers based on the serdev ID table defined in serdev_device_driver::id_table. The matching function, serdev_driver_match_device() uses the serdev device name to match against the entries in serdev_device_driver::id_table. If there is no serdev id_table for the driver, then serdev_device_match() will fallback to ACPI and DT based matching. Signed-off-by: Manivannan Sadhasivam --- drivers/tty/serdev/core.c | 23 ++++++++++++++++++++++- include/linux/mod_devicetable.h | 7 +++++++ include/linux/serdev.h | 4 ++++ scripts/mod/devicetable-offsets.c | 3 +++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index b33e708cb245..2b5582cd5063 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c @@ -85,12 +85,33 @@ static const struct device_type serdev_ctrl_type =3D { .release =3D serdev_ctrl_release, }; =20 +static int serdev_driver_match_device(struct device *dev, const struct dev= ice_driver *drv) +{ + const struct serdev_device_driver *serdev_drv =3D to_serdev_device_driver= (drv); + struct serdev_device *serdev =3D to_serdev_device(dev); + const struct serdev_device_id *id; + + if (!serdev_drv->id_table) + return 0; + + for (id =3D serdev_drv->id_table; id->name[0]; id++) { + if (!strcmp(dev_name(dev), id->name)) { + serdev->id =3D id; + return 1; + } + } + + return 0; +} + static int serdev_device_match(struct device *dev, const struct device_dri= ver *drv) { if (!is_serdev_device(dev)) return 0; =20 - /* TODO: platform matching */ + if (serdev_driver_match_device(dev, drv)) + return 1; + if (acpi_driver_match_device(dev, drv)) return 1; =20 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetabl= e.h index 6077972e8b45..70c54c4bedba 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -976,4 +976,11 @@ struct coreboot_device_id { kernel_ulong_t driver_data; }; =20 +#define SERDEV_NAME_SIZE 32 + +struct serdev_device_id { + const char name[SERDEV_NAME_SIZE]; + kernel_ulong_t driver_data; +}; + #endif /* LINUX_MOD_DEVICETABLE_H */ diff --git a/include/linux/serdev.h b/include/linux/serdev.h index ecde0ad3e248..aca92e0ee6e7 100644 --- a/include/linux/serdev.h +++ b/include/linux/serdev.h @@ -39,6 +39,7 @@ struct serdev_device_ops { * @ops: Device operations. * @write_comp Completion used by serdev_device_write() internally * @write_lock Lock to serialize access when writing data + * @id: serdev device ID entry */ struct serdev_device { struct device dev; @@ -47,6 +48,7 @@ struct serdev_device { const struct serdev_device_ops *ops; struct completion write_comp; struct mutex write_lock; + const struct serdev_device_id *id; }; =20 #define to_serdev_device(d) container_of_const(d, struct serdev_device, de= v) @@ -55,11 +57,13 @@ struct serdev_device { * struct serdev_device_driver - serdev slave device driver * @driver: serdev device drivers should initialize name field of this * structure. + * @id_table: serdev device ID table * @probe: binds this driver to a serdev device. * @remove: unbinds this driver from the serdev device. */ struct serdev_device_driver { struct device_driver driver; + const struct serdev_device_id *id_table; int (*probe)(struct serdev_device *); void (*remove)(struct serdev_device *); }; diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-of= fsets.c index d3d00e85edf7..c1bfa8eddc4d 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c @@ -280,5 +280,8 @@ int main(void) DEVID(coreboot_device_id); DEVID_FIELD(coreboot_device_id, tag); =20 + DEVID(serdev_device_id); + DEVID_FIELD(serdev_device_id, name); + return 0; } --=20 2.48.1 From nobody Tue Dec 2 00:03:19 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9CF0D325721; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081911; cv=none; b=AVSMFykgHbSjyuHcPt4ZBhUt/ylu00A4nusYxheK/S3vBnGpwvP++bfAeTXhCZtN809LAgCgzIGIgyCi6o993LO/moKXFG27uURM2PR9ZCSIkN0VYOwfLsbMsvH4fFEJKB4tm/HaaOHFOHEcMrdCIb/h1KNTK+U4eNkAyd4LP9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081911; c=relaxed/simple; bh=kKARAoBJmY4phhOwZPINSi5aSNIyhfDpVVPNRI/AEs0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JFlgOPRfy52I7WnPsWFDJQbu/r1s32wAKNGt/KFxTZFLR2mlSe6tz+kDwCHMkbxJ/F1Jv7e7f1tqZQ8jXSPhzccf2LpoYaFWoMqLTw6/XkI6kB1M0F2D4UcxZAL8LqRLdAZJ1JnQmV6ZRp10Ib1pDKlFDyP9P//EwzLTFeD3OI8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Pn5iRIx8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Pn5iRIx8" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2F360C19425; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764081911; bh=kKARAoBJmY4phhOwZPINSi5aSNIyhfDpVVPNRI/AEs0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Pn5iRIx8vDyOD5SlIEDBi6xumlEV8OYGqPZToivt8YgI6ftUC75qJD0StzwMFYJxm 0WRzlFJoi6nPEeUOkDIFTJKHF0u4rjtFEjdUUXUvqtoykssB1pMZTmD/iA6tzGXOGW YAnsmyH8UDApYYPJ2OaiprmZ1FrDfw+sVucMGaprbyDxooT7IfgU6A8b5VZC/ok71A ujF8tU+oaK/cRSVJ11QOK925OmJFKdsLhC+1gxnHmanFTJcnvm8tfQRs5pwNZJO7em DvqcSjzarzk+ZAtC0rkSRJW1wyiJjV46cvkhurYj9E0lBwFgi5rGcZ9y4odWJXohBa u3E8EEuzQIcEA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 208C2D0E6F5; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 25 Nov 2025 20:15:07 +0530 Subject: [PATCH v2 03/10] serdev: Allow passing the serdev device name to serdev_device_add() 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: quoted-printable Message-Id: <20251125-pci-m2-e-v2-3-32826de07cc5@oss.qualcomm.com> References: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> In-Reply-To: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> To: Rob Herring , Greg Kroah-Hartman , Jiri Slaby , Nathan Chancellor , Nicolas Schier , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , "Derek J. Clark" , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley , Marcel Holtmann , Luiz Augusto von Dentz , Bartosz Golaszewski Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-pm@vger.kernel.org, Stephan Gerhold , Dmitry Baryshkov , Manivannan Sadhasivam X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5029; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=VqkKP0yMqzEc5rXPyc78ivknxMIMS47hfAgM0VO8Rbw=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBpJcDy7vd1/KZr9C7oGm/gzrCR04STvMPHHuXUZ aaaG5hA0PCJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaSXA8gAKCRBVnxHm/pHO 9Yf6B/9yg5K8Hh6/zfrVWzHZ/tO261mIR/zaJBhfeHmKfx8Brkh3+0ps7W7KJPQPQzcqe8QrrKv Ef32jaW4PUlRXYIL94R3sJOm8zvK/iLi7aV6SgpLWttA4udxdbUgdzt6BEodUic4hDv4WIIsUnL PE62AkskezaVo4FWrIDWAhurhnQzOusJ693h+HvQklcAOwxHAv2G2u4um5Pgmqy1LeRVpXpAUXl MsNXZYogUgSovKLFN3xTW+BW7dxYmdbZqH7XH97k6t38j9FvgFQmxH8Kf2tcd1GZUcHp1FDAqRC NUOUtFdzsmzOSCkWxvq2wV4bslKJoanEJkH3Kx8GO3O3rf5y X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam Instead of always setting the serdev device name from 'struct device' name, allow the callers to pass an optional name and set it as the serdev device name. This will be used by the future callers passing the serdev device ID as the name. Acked-by: Ilpo J=C3=A4rvinen Signed-off-by: Manivannan Sadhasivam --- drivers/platform/x86/dell/dell-uart-backlight.c | 2 +- .../platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c | 2 +- drivers/platform/x86/x86-android-tablets/core.c | 2 +- drivers/tty/serdev/core.c | 13 +++++++++= ---- include/linux/serdev.h | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/platform/x86/dell/dell-uart-backlight.c b/drivers/plat= form/x86/dell/dell-uart-backlight.c index f323a667dc2d..f076cfac2bc5 100644 --- a/drivers/platform/x86/dell/dell-uart-backlight.c +++ b/drivers/platform/x86/dell/dell-uart-backlight.c @@ -354,7 +354,7 @@ static int dell_uart_bl_pdev_probe(struct platform_devi= ce *pdev) if (!serdev) return -ENOMEM; =20 - ret =3D serdev_device_add(serdev); + ret =3D serdev_device_add(serdev, NULL); if (ret) { dev_err(&pdev->dev, "error %d adding serdev\n", ret); serdev_device_put(serdev); diff --git a/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c b= /drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c index 8551ab4d2c7d..5e568fe1162d 100644 --- a/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c +++ b/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c @@ -260,7 +260,7 @@ static int yt2_1380_fc_pdev_probe(struct platform_devic= e *pdev) /* The fwnode is a managed node, so it will be auto-put on serdev_device_= put() */ fwnode_handle_get(dev_fwnode(&serdev->dev)); =20 - ret =3D serdev_device_add(serdev); + ret =3D serdev_device_add(serdev, NULL); if (ret) { serdev_device_put(serdev); return dev_err_probe(&pdev->dev, ret, "adding serdev\n"); diff --git a/drivers/platform/x86/x86-android-tablets/core.c b/drivers/plat= form/x86/x86-android-tablets/core.c index 6588fae30356..96140f5d4f79 100644 --- a/drivers/platform/x86/x86-android-tablets/core.c +++ b/drivers/platform/x86/x86-android-tablets/core.c @@ -316,7 +316,7 @@ static __init int x86_instantiate_serdev(const struct x= 86_dev_info *dev_info, in ACPI_COMPANION_SET(&serdev->dev, serdev_adev); acpi_device_set_enumerated(serdev_adev); =20 - ret =3D serdev_device_add(serdev); + ret =3D serdev_device_add(serdev, NULL); if (ret) { dev_err(&serdev->dev, "error %d adding serdev\n", ret); serdev_device_put(serdev); diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index 2b5582cd5063..76b89dd0720f 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c @@ -121,14 +121,19 @@ static int serdev_device_match(struct device *dev, co= nst struct device_driver *d /** * serdev_device_add() - add a device previously constructed via serdev_de= vice_alloc() * @serdev: serdev_device to be added + * @name: name of the serdev device (optional) */ -int serdev_device_add(struct serdev_device *serdev) +int serdev_device_add(struct serdev_device *serdev, const char *name) + { struct serdev_controller *ctrl =3D serdev->ctrl; struct device *parent =3D serdev->dev.parent; int err; =20 - dev_set_name(&serdev->dev, "%s-%d", dev_name(parent), serdev->nr); + if (name) + dev_set_name(&serdev->dev, "%s", name); + else + dev_set_name(&serdev->dev, "%s-%d", dev_name(parent), serdev->nr); =20 /* Only a single slave device is currently supported. */ if (ctrl->serdev) { @@ -544,7 +549,7 @@ static int of_serdev_register_devices(struct serdev_con= troller *ctrl) =20 device_set_node(&serdev->dev, of_fwnode_handle(node)); =20 - err =3D serdev_device_add(serdev); + err =3D serdev_device_add(serdev, NULL); if (err) { dev_err(&serdev->dev, "failure adding device. status %pe\n", @@ -692,7 +697,7 @@ static acpi_status acpi_serdev_register_device(struct s= erdev_controller *ctrl, ACPI_COMPANION_SET(&serdev->dev, adev); acpi_device_set_enumerated(adev); =20 - err =3D serdev_device_add(serdev); + err =3D serdev_device_add(serdev, NULL); if (err) { dev_err(&serdev->dev, "failure adding ACPI serdev device. status %pe\n", diff --git a/include/linux/serdev.h b/include/linux/serdev.h index aca92e0ee6e7..ffc6eb13f44b 100644 --- a/include/linux/serdev.h +++ b/include/linux/serdev.h @@ -160,7 +160,7 @@ static inline void serdev_controller_put(struct serdev_= controller *ctrl) } =20 struct serdev_device *serdev_device_alloc(struct serdev_controller *); -int serdev_device_add(struct serdev_device *); +int serdev_device_add(struct serdev_device *serdev, const char *name); void serdev_device_remove(struct serdev_device *); =20 struct serdev_controller *serdev_controller_alloc(struct device *host, --=20 2.48.1 From nobody Tue Dec 2 00:03:19 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 ACC9A32692E; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081911; cv=none; b=Uwc9newBnxm+BXhrWHDBH+CwxrQYDcXCPT/sRdTbf9gonNfBj/Ztce60QE7ywMd+md4WddmCS4zt9b1Ia3Xfj4cmjF4lx/IclHTss8M7P41d0/kr4hNkG203FGiuoUzgQeF1YgFdQDx5V17rJQ1ihhQXrFNdDLnb9uqk33km4ZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081911; c=relaxed/simple; bh=9wiAneIe4PtRYieKALLniV4NVJC0MpqwxX1iHoF/arI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NSreXKZ/yEBRdKMpZB4hbg+6MVxtJaLYJiZvWWyIsUm3MpsCBSHjHdFCUgp3K74/EJuHaEL0YSewKGUfG4GhR6hZW8B6B7fcxufMAYCqDVU4xWyj5E/FOZH0Ez1Y7/Zr7rqmYJ8R38dEszij3x0/hlyGKIFa8QympOQrOmswoZk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fpQ7VFAd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fpQ7VFAd" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3EBECC2BCB1; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764081911; bh=9wiAneIe4PtRYieKALLniV4NVJC0MpqwxX1iHoF/arI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fpQ7VFAd2pqGR6bj0TlULByIgk+6MsIeIZOBqGCjLPpB5Pw3Dn+NdWfEC6SAfD80Z cXg3GC0vHYxXHI4paDkCDNJ4apBtWqME8QJtwYUkeq4vrwIIT0cPw6WZnKBjP2kl8L Rr24CtHFpfAQnYYOI54SVlWUF/2fZhH9Q4jz3fR9Vd22rKgc8O2HUAMjnhiAiNbLNv 40ZsEwlOrp17XPfEwOaIXy3xHLgTaqWe2Gor5dAQ42jiQHdGp2BzhoeKMHHZ57DL0C RIUwV9XQ7yP1wXxNhJgvCYIqYEWu04qhZXt5C9EWZ7E0r4o5FU/oYS7JQkdkzxhX/l VkMSRCQ/RLTDw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33A83D0E6C6; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 25 Nov 2025 20:15:08 +0530 Subject: [PATCH v2 04/10] serdev: Add an API to find the serdev controller associated with the devicetree node 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: quoted-printable Message-Id: <20251125-pci-m2-e-v2-4-32826de07cc5@oss.qualcomm.com> References: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> In-Reply-To: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> To: Rob Herring , Greg Kroah-Hartman , Jiri Slaby , Nathan Chancellor , Nicolas Schier , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , "Derek J. Clark" , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley , Marcel Holtmann , Luiz Augusto von Dentz , Bartosz Golaszewski Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-pm@vger.kernel.org, Stephan Gerhold , Dmitry Baryshkov , Manivannan Sadhasivam X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1955; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=V1p0qX3vrz92sD1qV7R72e5ox9rZKasfmlTpIXqG3AM=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBpJcDyF1/pgOLf1aVGEuv44G7i0XrrfAOqmecw2 mzElUd/v5qJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaSXA8gAKCRBVnxHm/pHO 9bvfB/44AU6EYFmyxS7a2q+VGScl6JakUBZg0CeSHUIPNiLIgltpD0wnO13rOmWVZlBH5iaUmRG eHFX+92RGGqNKq+DblVtUN2wujOTz1iv3YvstidexJufqx6AiAnbMXyIk85S5d5joN0yNQYhhdA ijzPQU9/cij19LvCo3rnTyK8TtU/mV5na5rwUvbKfs4xs9SVTplFPnAW5mmXY2ZCoKNDR3b40eP 2ATF6PeHljysxSNEwGLfEmrgyKduSU2C1FiEf+lTOoZZsJqe8f/rw54zZRbYRQr9/gpUhvgS4XZ daPSu1Th2xsHK4LKi5Q1g4ADiGWwLY9uL6ImU9bLchSUpN95 X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam Add of_find_serdev_controller_by_node() API to find the serdev controller device associated with the devicetree node. Signed-off-by: Manivannan Sadhasivam --- drivers/tty/serdev/core.c | 16 ++++++++++++++++ include/linux/serdev.h | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index 76b89dd0720f..f90095cb778f 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c @@ -530,6 +530,22 @@ struct serdev_controller *serdev_controller_alloc(stru= ct device *host, } EXPORT_SYMBOL_GPL(serdev_controller_alloc); =20 +/** + * of_find_serdev_controller_by_node() - Find the serdev controller associ= ated + * with the devicetree node + * @node: Devicetree node + * + * Return: Pointer to the serdev controller associated with the node. NULL= if + * the controller is not found. + */ +struct serdev_controller *of_find_serdev_controller_by_node(struct device_= node *node) +{ + struct device *dev =3D bus_find_device_by_of_node(&serdev_bus_type, node); + + return (dev && dev->type =3D=3D &serdev_ctrl_type) ? to_serdev_controller= (dev) : NULL; +} +EXPORT_SYMBOL_GPL(of_find_serdev_controller_by_node); + static int of_serdev_register_devices(struct serdev_controller *ctrl) { struct device_node *node; diff --git a/include/linux/serdev.h b/include/linux/serdev.h index ffc6eb13f44b..fa235c92592a 100644 --- a/include/linux/serdev.h +++ b/include/linux/serdev.h @@ -337,4 +337,13 @@ static inline bool serdev_acpi_get_uart_resource(struc= t acpi_resource *ares, } #endif /* CONFIG_ACPI */ =20 +#ifdef CONFIG_OF +struct serdev_controller *of_find_serdev_controller_by_node(struct device_= node *node); +#else +struct serdev_controller *of_find_serdev_controller_by_node(struct device_= node *node) +{ + return NULL; +} +#endif /* CONFIG_OF */ + #endif /*_LINUX_SERDEV_H */ --=20 2.48.1 From nobody Tue Dec 2 00:03:19 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 F19E31C3BEB; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081912; cv=none; b=TbmRSecwfXJ6mlU20lTKir+gLZV1IDZU4cmDJjBR9Rd8Wix72BMAT/bnL6Ius7CGmt7luvV+shVEtRYk116VlST5P5Ac+bfqruRPjr79N/jbbW3z3TAZqf8jdZdD7Kt8WERmeStkWvjxFB9R27LDxa7Y85SPXEwUyi4M++D/Seo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081912; c=relaxed/simple; bh=WVav3iC7Lmw6dUFRYUOqhq8J39HrOTGyqCxxOeDPZ5A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IW022H0uNJGrHiB6Chi+OtQYTYi91RFTHuSX+ZVOFJPf3dKaL2fNtyg+bHCtzSoGF+11sS7brljIz0j0IyCh4Hhyc3k6/vbPin1Owxr3SZLw10LWP8NjwTmGacFmX7LUecScsnH2rQeugzpha8DObeV7HTB4RDYfqhtWUsC548c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fBqllVfV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fBqllVfV" Received: by smtp.kernel.org (Postfix) with ESMTPS id 575ECC4AF15; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764081911; bh=WVav3iC7Lmw6dUFRYUOqhq8J39HrOTGyqCxxOeDPZ5A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fBqllVfVPCgalSP4iJFWfI2UyfIOHGXcSm2bhXWl0XQ0LVzX6wFLET9olLy/1RrNN so08wbM8Iv5fCLbUV/CkOE3WPYOBhuFEnTLvKM6/rEfliPrNWD80HwkGxWk1k5ucav tSFzsD0XTvb3rSOtLLpFtcvLnqUrF79jPjYJLn9QnU+R5uoLMEg9keRDAYk2OJQbb/ QA7w++K0Q+oEXdy9GXOCi1I+uI6KB7vBa3A+s9SSq5YPb40xRVlbhHuxDzxj6c4l/x vlcFyUkLGjWFUhx+bNEzdYpikJh9QQxHTOCRIXXowvSftksjkXYbQd9rB88USvqNZV 9AH7mc6RG2EbA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49F9FD0E6F4; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 25 Nov 2025 20:15:09 +0530 Subject: [PATCH v2 05/10] serdev: Add modalias support for serdev client devices 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: quoted-printable Message-Id: <20251125-pci-m2-e-v2-5-32826de07cc5@oss.qualcomm.com> References: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> In-Reply-To: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> To: Rob Herring , Greg Kroah-Hartman , Jiri Slaby , Nathan Chancellor , Nicolas Schier , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , "Derek J. Clark" , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley , Marcel Holtmann , Luiz Augusto von Dentz , Bartosz Golaszewski Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-pm@vger.kernel.org, Stephan Gerhold , Dmitry Baryshkov , Manivannan Sadhasivam X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2936; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=gjXZ4ODUA/MYLty4jJHXHkQmOHjsSMkGR4F70lFPVI4=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBpJcDy90oxovtDgun6+KJ2wUFBov5MmV5lqLA75 lX1QA8p9MuJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaSXA8gAKCRBVnxHm/pHO 9Yq6B/9ZJq7zIPVB1U+K1aQfSJS3FPRCu0EbLegBLWtdg2XDtd18EPvmO1ZCeEir7I9iXFdKlTD RFLoupiL5hK/8rEBMwh83WP50gunVpd2d/yKUKaJ356NyZEjDk7HuaH4DJCK+Ic5fM0mhMalCU2 K+4rsDUA1pz2dNpv6qKRW/AzOT+Mmg1SFE7QQvnMVgvs8wlYz4rvDAYfQaIgnzNXCqd8qInGxdC MmWoorvY/lvAGLZPIcp1OZQlKFHtZcxbrBONSaGXitRxE0ZFf96bfzPvl3hCGMWpRpBNyzX7D/k UhZPI8MMDrDAZHp2zaFfo2NT3aG5cL3YyEHowXPcNV8f5nBP X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam Add modlias support to serdev so that the serdev client driver can be autoloaded by udev when the serdev client device gets created. Signed-off-by: Manivannan Sadhasivam --- drivers/tty/serdev/core.c | 15 +++++++++++---- include/linux/mod_devicetable.h | 1 + scripts/mod/file2alias.c | 8 ++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index f90095cb778f..8c2a40a537d9 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c @@ -34,7 +34,11 @@ static ssize_t modalias_show(struct device *dev, if (len !=3D -ENODEV) return len; =20 - return of_device_modalias(dev, buf, PAGE_SIZE); + len =3D of_device_modalias(dev, buf, PAGE_SIZE); + if (len !=3D -ENODEV) + return len; + + return sysfs_emit(buf, SERDEV_DEVICE_MODALIAS_FMT "\n", dev_name(dev)); } static DEVICE_ATTR_RO(modalias); =20 @@ -48,13 +52,16 @@ static int serdev_device_uevent(const struct device *de= v, struct kobj_uevent_env { int rc; =20 - /* TODO: platform modalias */ - rc =3D acpi_device_uevent_modalias(dev, env); if (rc !=3D -ENODEV) return rc; =20 - return of_device_uevent_modalias(dev, env); + rc =3D of_device_uevent_modalias(dev, env); + if (rc !=3D -ENODEV) + return rc; + + return add_uevent_var(env, "MODALIAS=3D" SERDEV_DEVICE_MODALIAS_FMT, + dev_name(dev)); } =20 static void serdev_device_release(struct device *dev) diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetabl= e.h index 70c54c4bedba..dad9637cf285 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -976,6 +976,7 @@ struct coreboot_device_id { kernel_ulong_t driver_data; }; =20 +#define SERDEV_DEVICE_MODALIAS_FMT "serdev:%s" #define SERDEV_NAME_SIZE 32 =20 struct serdev_device_id { diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index b3333560b95e..27e9f7c718c4 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1371,6 +1371,13 @@ static void do_coreboot_entry(struct module *mod, vo= id *symval) module_alias_printf(mod, false, "coreboot:t%08X", tag); } =20 +/* Looks like: serdev:S */ +static void do_serdev_entry(struct module *mod, void *symval) +{ + DEF_FIELD_ADDR(symval, serdev_device_id, name); + module_alias_printf(mod, false, SERDEV_DEVICE_MODALIAS_FMT, *name); +} + /* Does namelen bytes of name exactly match the symbol? */ static bool sym_is(const char *name, unsigned namelen, const char *symbol) { @@ -1467,6 +1474,7 @@ static const struct devtable devtable[] =3D { {"usb", SIZE_usb_device_id, do_usb_entry_multi}, {"pnp", SIZE_pnp_device_id, do_pnp_device_entry}, {"pnp_card", SIZE_pnp_card_device_id, do_pnp_card_entry}, + {"serdev", SIZE_serdev_device_id, do_serdev_entry}, }; =20 /* Create MODULE_ALIAS() statements. --=20 2.48.1 From nobody Tue Dec 2 00:03:19 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E81C97B3E1; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081912; cv=none; b=UXkOda5JSex+74cZFC4hYIdFZXpvOiFK4Wn9/6B+z/SIY4Ob2fj108AtHoFOjhHnZwrO0ZIW/qHCOyeRVEHlkCe7i75BDgVky6nruUJWUj2VkPbNMaeoVtPxAnpLMpNRycVN9g/SJWZiuKMI7SmL4DJaoC6qJAAHdHIHfmqRxkU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081912; c=relaxed/simple; bh=/73Is6LSiZFdQQ1Wgzmm55BHcfPO7Tzrd+XL5DP+qdM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Kfol+tpCjlvwy/MhzVVXkDB/DEqmudLs4GhA8n/FglxQDXGypwoL+3NvV81rOxXlm5m6lqmrdsvgsTvOthfq1E7scGyy90QsMyL/nHVf9YjfrMs3aF3Nv4mqh4b2hNgnJ/lL3FnO+IpHj5MUhqDYlOJ+V2hGfobkr8s7qhMEXgk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ux4NijW3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ux4NijW3" Received: by smtp.kernel.org (Postfix) with ESMTPS id 6D06EC2BC86; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764081911; bh=/73Is6LSiZFdQQ1Wgzmm55BHcfPO7Tzrd+XL5DP+qdM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Ux4NijW3UFRboXv9u6LPlRCENKkwrVSZGw09iu6h3TUiFWO6PDC7Y0PEPJCeP5ycw 9JuEM4/ABlvwZNaRZqnf6y4bZ7u0rPuQstCkvCDeh9KNtEemWropv8QWg3jiqfcO5y Zpi9TVppuVbBPxdF6WUOrnI3Em1wFzHdnAqOWWWGdG8evqEBeCiGt41slTywxAN57a ijt9DKlxofrYxI8L4gfmxqY4qQ24lYBtdaQkFTElZdiBuQUpuC62SsWBVjEr1LeTW3 xAc88QY9beU3EcU9bOdOykVvweho+pKTdK0xS8+Lx4m455Bpx/kSQ+iXqOWwqU9ym4 Ai2svALBh7V4g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C5F8D0E6F1; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 25 Nov 2025 20:15:10 +0530 Subject: [PATCH v2 06/10] dt-bindings: serial: Document the graph port 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: quoted-printable Message-Id: <20251125-pci-m2-e-v2-6-32826de07cc5@oss.qualcomm.com> References: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> In-Reply-To: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> To: Rob Herring , Greg Kroah-Hartman , Jiri Slaby , Nathan Chancellor , Nicolas Schier , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , "Derek J. Clark" , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley , Marcel Holtmann , Luiz Augusto von Dentz , Bartosz Golaszewski Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-pm@vger.kernel.org, Stephan Gerhold , Dmitry Baryshkov , Manivannan Sadhasivam X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=924; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=T/idG4KQSOfNt30dCJ08aa+KY4iI2ktYxKaU/4zNwXM=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBpJcDyNiXGRYrPVp6/mZbLWkAyQuBwsrwnBd+/3 3QTUwQiV0uJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaSXA8gAKCRBVnxHm/pHO 9VSfCACLeP9J91KGjkzLmAnSRJjUrVh9amjj5XEExSgeQkxJaA0bSIKjOT1ZqYrQI7azbYt6qqX zkjl/a3qz3YSEmkLZNG9Cy5HPwe1+VliFK0laziN/ChAfWukehX8S3cbzDKDp1eizMb3Uyes5wX yqNID4XZc9uwH1NrkqeTq3I6OMzDnxh72XPwg7O/v4UqkFHRcSHAIg9YnVdc4EPECTkiTWY9YI2 Gi+6cQFpcOMHviCHuD1vhVU5l26gAJBwNpsNOl4yrzQe74EIZ5lTFgzMGhG/FTuVIx9VWwVv6Wu jPWJrbbjVb07i9Mee4GlZ4dSOVXP986oChp2dkFg3o2z/y/j X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam A serial controller could be connected to an external connector like PCIe M.2 for controlling the serial interface of the card. Hence, document the OF graph port. Signed-off-by: Manivannan Sadhasivam --- Documentation/devicetree/bindings/serial/serial.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/serial/serial.yaml b/Documen= tation/devicetree/bindings/serial/serial.yaml index 6aa9cfae417b..96eb1de8771e 100644 --- a/Documentation/devicetree/bindings/serial/serial.yaml +++ b/Documentation/devicetree/bindings/serial/serial.yaml @@ -87,6 +87,9 @@ properties: description: TX FIFO threshold configuration (in bytes). =20 + port: + $ref: /schemas/graph.yaml#/properties/port + patternProperties: "^(bluetooth|bluetooth-gnss|embedded-controller|gnss|gps|mcu|onewire)$": if: --=20 2.48.1 From nobody Tue Dec 2 00:03:19 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E827515853B; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081912; cv=none; b=lkPI8k+U4YOPrcV8p/gQmBBH1bfXMd2MMW+Epxmh83qqGq5t1bgBiMPbP3jqbn9v3T9wWIVXUqTp7AFacq92O78gECdRxH/RCXVEAB+NOb2a4dumtOEIoKa2Ea6MdBuDEnkTOymIUjVbteWIPuOI+wxsCeCIrkq1EuMxrBGY16I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081912; c=relaxed/simple; bh=56s09BLbgnJ1DBqbUoCLxzruZZW7MAhobGQU7FBMcnA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RkdEGA+f/PblkJSRBkvs7+VGrMRZKW9p6vhjx3HXFGwdNgOiP4W/d4iG0ufOU3ppojZ0RLq5Qnr2D4CtGo1IzcOIRsFFjgEOmk//Wq/LykiqmR2SUZU0IfMbq3wJhw3eWjgPGlkn29a5+hWECt/xw/Y01dA1BPVRcgkTvvNPJAU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Av2mepu3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Av2mepu3" Received: by smtp.kernel.org (Postfix) with ESMTPS id 803AEC2BCB2; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764081911; bh=56s09BLbgnJ1DBqbUoCLxzruZZW7MAhobGQU7FBMcnA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Av2mepu3HVgGcH8yT6Hv70rvyq34rsGb/CyT9bCT+9AZWTxSRRSsid5rhSZN/5KoK RQahI3Cf01DU5UyAt0wbs/g2IzP5kXD1lE5yQqWnZfotbxgiNf0cBjdmEGmZugrLjc K/eOtVndULFopNmYP0bm+wufvWSJhCrlTN2CklgAvBMDIlqTP3WG20nP8qjjrd4lAN 8sG1rhBZW51A3eRudZ3/1HmpdZHVbPJgnWuWvUem5z3NjF5bSyntaMxGNprkWysBob ZCw9U1JBa2lD4RcM7f3Hzy1sdNobcgJFgVDB5DlOmMm/tjVuFFaz2GBSUwh/AH26Js 1T90jdhs5ouvA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FB7DD0E6F6; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 25 Nov 2025 20:15:11 +0530 Subject: [PATCH v2 07/10] serdev: Do not return -ENODEV from of_serdev_register_devices() if external connector is used 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: quoted-printable Message-Id: <20251125-pci-m2-e-v2-7-32826de07cc5@oss.qualcomm.com> References: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> In-Reply-To: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> To: Rob Herring , Greg Kroah-Hartman , Jiri Slaby , Nathan Chancellor , Nicolas Schier , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , "Derek J. Clark" , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley , Marcel Holtmann , Luiz Augusto von Dentz , Bartosz Golaszewski Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-pm@vger.kernel.org, Stephan Gerhold , Dmitry Baryshkov , Manivannan Sadhasivam X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1299; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=QcEAYBjlJFUxHXU+Wo92JzR+zJXEhzi3DteqtBBgZqk=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBpJcDyHTNmc+abBx0paWJMqzF+5yCxlIMn7lZAQ loKsu5yL3qJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaSXA8gAKCRBVnxHm/pHO 9czQB/9PcdU/lszhQX1FDeJbUv8qeX3bQlytQfBLiNv2jwbnkmhEhmw42aN14SS2XNKboCv2RP1 MDXleY3i0N1Y8AuuV+mo1Sb8+t9UBj752tJekDjqhlA4NyB94h1DuWjxhxiaYwstI/u7HjF2r5w bPq3EG2ovCurrGjzQb/KJgVpHw+NwIU2jyCTcR5yYCX4O0oIqOQmXS3gQ2o3yzrGoEHHSpukBKT 6E3HNOoSTngB1rTr2O4+EqBbqT2VFKAD9hbtTF+N1RrdmhOWGx81oCaMKcYOGzHWnd5pq0g26yq F62zInTRAB1m+W65UO0GSTZ7gAK+ZrskcaPczJfmwnEdhp6B X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam If an external connector like M.2 is connected to the serdev controller in DT, then the serdev devices may be created dynamically by the connector driver. So do not return -ENODEV from of_serdev_register_devices() if the static nodes are not found and the graph node is used. Signed-off-by: Manivannan Sadhasivam Reviewed-by: Bartosz Golaszewski --- drivers/tty/serdev/core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index 8c2a40a537d9..fba7b98026bb 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -581,7 +582,13 @@ static int of_serdev_register_devices(struct serdev_co= ntroller *ctrl) } else found =3D true; } - if (!found) + + /* + * When the serdev controller is connected to an external connector like + * M.2 in DT, then the serdev devices may be created dynamically by the + * connector driver. + */ + if (!found && !of_graph_is_present(ctrl->dev.of_node)) return -ENODEV; =20 return 0; --=20 2.48.1 From nobody Tue Dec 2 00:03:19 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E849A17C211; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081912; cv=none; b=MYu4hd6cWUeTOR8CY40FmnzQqYUmxSnYdRhrR0Sc4SO8rTQEgiiK7IvJIjUoOiKWG08aK0+oplTYlrVufKqRKSxpTnL+SB6AMeBapRxDR7nfXKFrnyXkM1/UZijEqz32RfgR9SvSXcArPY+nok4g+5yefzB1Uls+PMSmyKrx4Sw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081912; c=relaxed/simple; bh=FyDBDtcrrQWdwI3hnS/pB+Z0Cw9VWFu3vnv9gtL1Pzc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tBhDu1E4qSerDbYTzayw6MQNIs5SStEtyv3QtJujRZvMkpVJar3y4aZ79YCFIN8xOg+3SjWTPtN7k6KYff1xDmqLaD/z8LVdMwvcN6X0Ahd//DWn9jEFulqi0C88/cobGl9lWkJl/EY3gQA6dEi/8m16dvHE2bdvK1e6c4WbUTI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=odVLnF0s; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="odVLnF0s" Received: by smtp.kernel.org (Postfix) with ESMTPS id 8FF84C2BCB8; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764081911; bh=FyDBDtcrrQWdwI3hnS/pB+Z0Cw9VWFu3vnv9gtL1Pzc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=odVLnF0scjlNrhsn/vBt9sRJy+ANSn2EQ2pLGo4zqxux71l7xhwykdlvtBDS2oPjW bZ9736PpZn9BSV8Mt7UlXbDTeYmxisclamqsCehxgoMb4QJ5R0kgO9Ij+KrLNaEtGF X55oCpqT5Simb4KRHpFgQkKwPeOlcdor2pB0c58N5o5irw/bpk+MQMa74sIkG5/0ZC PXce3f8ku9rjrR7bhyJPRitnXLIAq+tgGVS0OymjSrzSDNZ3+KZRHZ0NYydtxBeDFH ybZI0dcrsYnY2GK+MSPhxCr+jo/khL6C2MKGco7Li5jeC87miqJhqUdk07E6v8OEai NrDNq6Am28BdA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82CEDD0E6F5; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 25 Nov 2025 20:15:12 +0530 Subject: [PATCH v2 08/10] dt-bindings: connector: Add PCIe M.2 Mechanical Key E connector 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: quoted-printable Message-Id: <20251125-pci-m2-e-v2-8-32826de07cc5@oss.qualcomm.com> References: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> In-Reply-To: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> To: Rob Herring , Greg Kroah-Hartman , Jiri Slaby , Nathan Chancellor , Nicolas Schier , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , "Derek J. Clark" , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley , Marcel Holtmann , Luiz Augusto von Dentz , Bartosz Golaszewski Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-pm@vger.kernel.org, Stephan Gerhold , Dmitry Baryshkov , Manivannan Sadhasivam X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=7776; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=LsGXQguEIvUP58Y5FXjG9WlZPEnelHy8ukyjl47FhqQ=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBpJcDywix4o/qWbqg69fbCTdfFwwjg3RdzFKiFN gHlI8DHQrOJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaSXA8gAKCRBVnxHm/pHO 9fRHB/9JdOYdNORzpfXaLxa2grUAjr9bG160Ncw7VspOQBbbbAHwgDHlqkyOGGWVZaJy8oiDGhr ymS1ZBlFqUudeRlMoRrufcF237G9//bZPqjDxqfwdTL1IDQeBfyAqY0hNpX2t9+ziV8TU5t/1uu T8L9d/80OJEItmJ1aLkXgzZEMq3JdMv8CJJx0dpMJE8GL0ltmdVQdxTPJZQZMPwC6XthSH0bmrW 6iCImpLciFZaeeZ93r0Py4EjcTA5IP5y0RQbC8fYEbF7cEXkqVgNzXrurTNVtTBeHUXRU/PViFc UDneR3Adh4b1t/L+UgvTMrxd2md8t47fOXRUrZ72tyVxabwh X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam Add the devicetree binding for PCIe M.2 Mechanical Key E connector defined in the PCI Express M.2 Specification, r4.0, sec 5.1.2. This connector provides interfaces like PCIe or SDIO to attach the WiFi devices to the host machine, USB or UART+PCM interfaces to attach the Bluetooth (BT) devices along with additional interfaces like I2C for NFC solution. At any point of time, the connector can only support either PCIe or SDIO as the WiFi interface and USB or UART as the BT interface. The connector provides a primary power supply of 3.3v, along with an optional 1.8v VIO supply for the Adapter I/O buffer circuitry operating at 1.8v sideband signaling. The connector also supplies optional signals in the form of GPIOs for fine grained power management. Signed-off-by: Manivannan Sadhasivam --- .../bindings/connector/pcie-m2-e-connector.yaml | 178 +++++++++++++++++= ++++ MAINTAINERS | 1 + 2 files changed, 179 insertions(+) diff --git a/Documentation/devicetree/bindings/connector/pcie-m2-e-connecto= r.yaml b/Documentation/devicetree/bindings/connector/pcie-m2-e-connector.ya= ml new file mode 100644 index 000000000000..fe2c9a943a21 --- /dev/null +++ b/Documentation/devicetree/bindings/connector/pcie-m2-e-connector.yaml @@ -0,0 +1,178 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/connector/pcie-m2-e-connector.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: PCIe M.2 Mechanical Key E Connector + +maintainers: + - Manivannan Sadhasivam + +description: + A PCIe M.2 E connector node represents a physical PCIe M.2 Mechanical Ke= y E + connector. Mechanical Key E connectors are used to connect Wireless + Connectivity devices including combinations of Wi-Fi, BT, NFC to the host + machine over interfaces like PCIe/SDIO, USB/UART+PCM, and I2C. + +properties: + compatible: + const: pcie-m2-e-connector + + vpcie3v3-supply: + description: A phandle to the regulator for 3.3v supply. + + vpcie1v8-supply: + description: A phandle to the regulator for VIO 1.8v supply. + + ports: + $ref: /schemas/graph.yaml#/properties/ports + description: OF graph bindings modeling the interfaces exposed on the + connector. Since a single connector can have multiple interfaces, ev= ery + interface has an assigned OF graph port number as described below. + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: Connector interfaces for Wi-Fi + + properties: + endpoint@0: + $ref: /schemas/graph.yaml#/properties/endpoint + description: PCIe interface + + endpoint@1: + $ref: /schemas/graph.yaml#/properties/endpoint + description: SDIO interface + + anyOf: + - required: + - endpoint@0 + - required: + - endpoint@1 + + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: Connector interfaces for BT + + properties: + endpoint@0: + $ref: /schemas/graph.yaml#/properties/endpoint + description: USB 2.0 interface + + endpoint@1: + $ref: /schemas/graph.yaml#/properties/endpoint + description: UART interface + + anyOf: + - required: + - endpoint@0 + - required: + - endpoint@1 + + port@2: + $ref: /schemas/graph.yaml#/properties/port + description: PCM/I2S interface + + port@3: + $ref: /schemas/graph.yaml#/properties/port + description: I2C interface + + oneOf: + - required: + - port@0 + + clocks: + description: 32.768 KHz Suspend Clock (SUSCLK) input from the host sys= tem to + the M.2 card. Refer, PCI Express M.2 Specification r4.0, sec 3.1.12.= 1 for + more details. + maxItems: 1 + + w-disable1-gpios: + description: GPIO controlled connection to W_DISABLE1# signal. This si= gnal + is used by the system to disable WiFi radio in the M.2 card. Refer, = PCI + Express M.2 Specification r4.0, sec 3.1.12.3 for more details. + maxItems: 1 + + w-disable2-gpios: + description: GPIO controlled connection to W_DISABLE2# signal. This si= gnal + is used by the system to disable BT radio in the M.2 card. Refer, PCI + Express M.2 Specification r4.0, sec 3.1.12.3 for more details. + maxItems: 1 + + viocfg-gpios: + description: GPIO controlled connection to IO voltage configuration + (VIO_CFG) signal. This signal is used by the M.2 card to indicate to= the + host system that the card supports an independent IO voltage domain = for + the sideband signals. Refer, PCI Express M.2 Specification r4.0, sec + 3.1.15.1 for more details. + maxItems: 1 + + uim-power-src-gpios: + description: GPIO controlled connection to UIM_POWER_SRC signal. This = signal + is used when the NFC solution is implemented and receives the power = output + from WWAN_UIM_PWR signal of the another WWAN M.2 card. Refer, PCI Ex= press + M.2 Specification r4.0, sec 3.1.11.1 for more details. + maxItems: 1 + + uim-power-snk-gpios: + description: GPIO controlled connection to UIM_POWER_SNK signal. This = signal + is used when the NFC solution is implemented and supplies power to t= he + Universal Integrated Circuit Card (UICC). Refer, PCI Express M.2 + Specification r4.0, sec 3.1.11.2 for more details. + maxItems: 1 + + uim-swp-gpios: + description: GPIO controlled connection to UIM_SWP signal. This signal= is + used when the NFC solution is implemented and implements the Single = Wire + Protocol (SWP) interface to the UICC. Refer, PCI Express M.2 Specifi= cation + r4.0, sec 3.1.11.3 for more details. + maxItems: 1 + +required: + - compatible + - vpcie3v3-supply + +additionalProperties: false + +examples: + # PCI M.2 Key E connector for Wi-Fi/BT with PCIe/UART interfaces + - | + #include + + connector { + compatible =3D "pcie-m2-e-connector"; + vpcie3v3-supply =3D <&vreg_wcn_3p3>; + vpcie1v8-supply =3D <&vreg_l15b_1p8>; + w-disable1-gpios =3D <&tlmm 117 GPIO_ACTIVE_LOW>; + w-disable2-gpios =3D <&tlmm 116 GPIO_ACTIVE_LOW>; + + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + port@0 { + #address-cells =3D <1>; + #size-cells =3D <0>; + + reg =3D <0>; + + endpoint@0 { + reg =3D <0>; + remote-endpoint =3D <&pcie4_port0_ep>; + }; + }; + + port@1 { + #address-cells =3D <1>; + #size-cells =3D <0>; + + reg =3D <1>; + + endpoint@1 { + reg =3D <1>; + remote-endpoint =3D <&uart14_ep>; + }; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 9b3f689d1f50..f707f29d0a37 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20478,6 +20478,7 @@ PCIE M.2 POWER SEQUENCING M: Manivannan Sadhasivam L: linux-pci@vger.kernel.org S: Maintained +F: Documentation/devicetree/bindings/connector/pcie-m2-e-connector.yaml F: Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml F: drivers/power/sequencing/pwrseq-pcie-m2.c =20 --=20 2.48.1 From nobody Tue Dec 2 00:03:19 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4FA8F3271E7; Tue, 25 Nov 2025 14:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081912; cv=none; b=dcKDjG8RrTYwgn7PaolmfjSe8xRfD+g2nzgyDohzTqMOoVUmNEvQeGHVXZl5hzphgBBh8tlv3UlVsfTjCSalt7jjK7VPLOjEjaasHiPPUQVQacSi+yiG70FUiYUJe+CMAPaxSOBRJ1PdLbNyaA+EvlUYSeh5VPDiz7FDnP1AF4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081912; c=relaxed/simple; bh=fQZr7pUYhOD/jEojYwd8ZDtbZU5QJsTZEvoo6g+VOqM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X7RQ9FsnpNizpFq9H84PlEj2GVuGQoIX6uGm8OpAAnNhR97jPpoOMLSzw5hPXrM/446YO1FefWT3BaoU4hEm8eclFICumqNFu7z6wq5S6pJIv2D7zUhLv8K9BmwVQxiYy9/ktk2crvpy0YrBYtNoM3n5kdL9WDFLTU703qmkN8g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k6VClFIs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="k6VClFIs" Received: by smtp.kernel.org (Postfix) with ESMTPS id A26FDC19422; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764081911; bh=fQZr7pUYhOD/jEojYwd8ZDtbZU5QJsTZEvoo6g+VOqM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=k6VClFIsVWbv8FvSi9LyVIUAs3350bj5ucgvFUvJqfgj8b9XHvTfjzsEtlyRFahqh qIUxRXjv4F9LFlLgCW7H02/Ax4vSqoZUij3DAsGzmEqGPT591rQ+LngcgrxLnwNTO5 OPBAGnCK+vLfQPDKEtKsas7yM/2hw6wg0Vw59oXOnxPHi9TtoWQuQU3ShZdrnpiBGm 7XDZmz8wI5LzeP/J8WDOVNcuSJ1mr/RuUNlE1VIRM0thSVK6kbaGW4LILzIreLbYFX nSNLhryg4fexmvAiK+7XM0DWHhiRh1g2AQiOreSj5PAa8vkqeBTkAuaA6o7YDJ/1+7 FXmA1KwUU6OSg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95FABD0E6C6; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 25 Nov 2025 20:15:13 +0530 Subject: [PATCH v2 09/10] Bluetooth: hci_qca: Add support for WCN7850 PCIe M.2 card 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: quoted-printable Message-Id: <20251125-pci-m2-e-v2-9-32826de07cc5@oss.qualcomm.com> References: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> In-Reply-To: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> To: Rob Herring , Greg Kroah-Hartman , Jiri Slaby , Nathan Chancellor , Nicolas Schier , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , "Derek J. Clark" , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley , Marcel Holtmann , Luiz Augusto von Dentz , Bartosz Golaszewski Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-pm@vger.kernel.org, Stephan Gerhold , Dmitry Baryshkov , Manivannan Sadhasivam X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2637; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=zEZ8rEadVzPrGNr8RLnULvokKFhVGX7/QBoqApf/dmI=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBpJcDzqRvhavEAtyIdpgbq7HdybyTkQukIfRcUV vXmEyI7PJWJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaSXA8wAKCRBVnxHm/pHO 9aQDB/wPxF9hhA7J5V9ZkfTIoBhTIN04bqoZH2i2TrRvvdp+9G18kp/R+SHrCxQtycJZbHPRkx/ DoBUmhkTkkeK7rwp5WIPR97L0JRCUVp7v3oajBLCtUhzuE07rBX4StDpHyFBscYoV8tdITB8Jup OsSCbEScWfaNh7TrL3/7EOqiF5s0sTGMYffGC5+Ta0sJgHYQMz7ApJ/mwtK01nYC9Tt9kUc5+Bo P9HcpV6cBQSZ/GcYn9xtG+8l4ZWMV4LEBdCKcRPmK9Oythi2wZy4gAGtLCOS1udXANa8PuP2RY8 ppz4zSvUZ9mvpGwDs/BCeEPfde5jQtO9OFuO2ns4HZxQNRcf X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam The WCN7850 PCIe M.2 card connected to the UART controller exposes the 'WCN7850' serdev device and is controlled using the pwrseq framework. Hence, add support for it in the driver. It reuses the existing 'qca_soc_data_wcn7850' driver data. Signed-off-by: Manivannan Sadhasivam Reviewed-by: Bartosz Golaszewski --- drivers/bluetooth/hci_qca.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 4cff4d9be313..35d08b455e40 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -2344,6 +2345,9 @@ static int qca_serdev_probe(struct serdev_device *ser= dev) =20 qcadev->serdev_hu.serdev =3D serdev; data =3D device_get_match_data(&serdev->dev); + if (!data && serdev->id) + data =3D (const struct qca_device_data *) serdev->id->driver_data; + serdev_device_set_drvdata(serdev, qcadev); device_property_read_string_array(&serdev->dev, "firmware-name", qcadev->firmware_name, ARRAY_SIZE(qcadev->firmware_name)); @@ -2384,6 +2388,14 @@ static int qca_serdev_probe(struct serdev_device *se= rdev) case QCA_WCN6855: case QCA_WCN7850: case QCA_WCN6750: + if (of_graph_is_present(dev_of_node(&serdev->ctrl->dev))) { + qcadev->bt_power->pwrseq =3D devm_pwrseq_get(&serdev->ctrl->dev, + "uart"); + if (IS_ERR(qcadev->bt_power->pwrseq)) + return PTR_ERR(qcadev->bt_power->pwrseq); + break; + } + if (!device_property_present(&serdev->dev, "enable-gpios")) { /* * Backward compatibility with old DT sources. If the @@ -2740,6 +2752,12 @@ static const struct acpi_device_id qca_bluetooth_acp= i_match[] =3D { MODULE_DEVICE_TABLE(acpi, qca_bluetooth_acpi_match); #endif =20 +static const struct serdev_device_id qca_bluetooth_serdev_match[] =3D { + { "WCN7850", (kernel_ulong_t)&qca_soc_data_wcn7850 }, + { }, +}; +MODULE_DEVICE_TABLE(serdev, qca_bluetooth_serdev_match); + #ifdef CONFIG_DEV_COREDUMP static void hciqca_coredump(struct device *dev) { @@ -2756,6 +2774,7 @@ static void hciqca_coredump(struct device *dev) static struct serdev_device_driver qca_serdev_driver =3D { .probe =3D qca_serdev_probe, .remove =3D qca_serdev_remove, + .id_table =3D qca_bluetooth_serdev_match, .driver =3D { .name =3D "hci_uart_qca", .of_match_table =3D of_match_ptr(qca_bluetooth_of_match), --=20 2.48.1 From nobody Tue Dec 2 00:03:19 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4FC353271E8; Tue, 25 Nov 2025 14:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081912; cv=none; b=utpVDjNWPohFNHDdcrQ3Z/m4vaIJMT5/KfgdNcZNY9iz/4KhoMpNO+D8orKdt5ocqNeONWXfXLQbnMnaBmnKc8rg34z4EVUkyLnG/PwHvu/7pJFOzD1ZcXG7fn5xBtaN388Il6csQSPmzsyIGcB4ROopD74HUaM46YI9EdTjxXw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764081912; c=relaxed/simple; bh=uVTeK5QXYJAKEXrVJHIu2uAlEF+bu5ja7nlz/3qqyE4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GRnmxNJkRAtccyjl4nrbrsSdD8TPJ8GGHtT5crOW615gZw7VdiybISbMxeYak95eJ5or7BWgC6gmGg0CHyXBYx1XtdoD0PtDFpn8Dzj5cL5CHq/UkJXuEdDDUJghNAZ///diUAvO6tcipj7C6PA7ozEusuRs0J50NhjTjKP07bg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fqQ8izpo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fqQ8izpo" Received: by smtp.kernel.org (Postfix) with ESMTPS id B69B5C116B1; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764081911; bh=uVTeK5QXYJAKEXrVJHIu2uAlEF+bu5ja7nlz/3qqyE4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fqQ8izpodQMCH+c8ZXRjf2Xmt6GXMylMvl6jYZdOMs2anrq86fp4RQM9uIkMopm5E I9w5V0ke3VqPc5P33DB+LHWOiui4MU1R1AiJmXuLYE6ZMaU/1eI3n9UrMECl8I91u0 XQ5CCPp16HljY6Kvp+b7JTKkqIiuKKTYCzK5lEXt3a4f22W1LfH9chF6p4esIoHxQK bPyYNNIfiaWMLorZFH9Le5fbHVRjYBTMNqUydxJkpKsMEAmAfCG9fL4aDm+AGn3u6i iHvx0GGt1XxYtAogIwO2yT1ecH4CmHhi776NguShj0BFkjDuUbbmhPUJ6V+pOwPPam eFLUOqzaBFwaA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7B30D0E6F4; Tue, 25 Nov 2025 14:45:11 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 25 Nov 2025 20:15:14 +0530 Subject: [PATCH v2 10/10] power: sequencing: pcie-m2: Add support for PCIe M.2 Key E connectors 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: quoted-printable Message-Id: <20251125-pci-m2-e-v2-10-32826de07cc5@oss.qualcomm.com> References: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> In-Reply-To: <20251125-pci-m2-e-v2-0-32826de07cc5@oss.qualcomm.com> To: Rob Herring , Greg Kroah-Hartman , Jiri Slaby , Nathan Chancellor , Nicolas Schier , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , "Derek J. Clark" , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley , Marcel Holtmann , Luiz Augusto von Dentz , Bartosz Golaszewski Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-pm@vger.kernel.org, Stephan Gerhold , Dmitry Baryshkov , Manivannan Sadhasivam X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=11211; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=icdy0cEagCCZDZk1SjAL+YixAm1oqa2r7NEVrGE9+pI=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBpJcDzqQgUp84ba4lBRijiZIEuI2jtoWHH5P4lM f13O6DkJGiJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaSXA8wAKCRBVnxHm/pHO 9YjfCACVhKLtculT1OE7fu9pKGjRV5hGxnTMVHrl+x80lI65ilz4P7vvOYX90oa5ZG8taVBj/kP g9p6YagWgCUF9pQ6jHglIcOtyiqH9S9iN0LMRd30hMNcnK3GwCuVjQ2108UG8mUFPqtVtd8MYZv 7UOTggxKtT2S9T/1hOUPY1FUPbW8T9MnZxEpAe2sf/PPDTd+TAS1pF1aUAbsCqPx/w3eLVldozX AOxr6wwtUDiRSdpfc7o8vp0dLr7LnpkxbA6733M4Qo+1/WOqsJgbkvdGZDXORud258ZzO3NtiUr VuYb8c4rGhKwNiahaUYuYpBC3T3VyuChRs/ndWB8h3pIfniH X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam Add support for handling the power sequence of the PCIe M.2 Key E connectors. These connectors are used to attach the Wireless Connectivity devices to the host machine including combinations of WiFi, BT, NFC using interfaces such as PCIe/SDIO for WiFi, USB/UART for BT and I2C for NFC. Currently, this driver supports only the PCIe interface for WiFi and UART interface for BT. The driver also only supports driving the 3.3v/1.8v power supplies and W_DISABLE{1/2}# GPIOs. The optional signals of the Key E connectors are not currently supported. For supporting Bluetooth over the non-discoverable UART interface, the driver currently creates the serdev interface after enumerating the PCIe interface. This is mandatory since the device ID is only known after the PCIe enumeration and the ID is used for creating the serdev device. Signed-off-by: Manivannan Sadhasivam --- drivers/power/sequencing/Kconfig | 1 + drivers/power/sequencing/pwrseq-pcie-m2.c | 205 ++++++++++++++++++++++++++= +++- 2 files changed, 199 insertions(+), 7 deletions(-) diff --git a/drivers/power/sequencing/Kconfig b/drivers/power/sequencing/Kc= onfig index f5fff84566ba..29bd204319cc 100644 --- a/drivers/power/sequencing/Kconfig +++ b/drivers/power/sequencing/Kconfig @@ -38,6 +38,7 @@ config POWER_SEQUENCING_TH1520_GPU config POWER_SEQUENCING_PCIE_M2 tristate "PCIe M.2 connector power sequencing driver" depends on OF || COMPILE_TEST + depends on PCI help Say Y here to enable the power sequencing driver for PCIe M.2 connectors. This driver handles the power sequencing for the M.2 diff --git a/drivers/power/sequencing/pwrseq-pcie-m2.c b/drivers/power/sequ= encing/pwrseq-pcie-m2.c index 4835d099d967..c2cc129f6917 100644 --- a/drivers/power/sequencing/pwrseq-pcie-m2.c +++ b/drivers/power/sequencing/pwrseq-pcie-m2.c @@ -5,14 +5,17 @@ */ =20 #include +#include #include #include #include #include #include +#include #include #include #include +#include #include =20 struct pwrseq_pcie_m2_pdata { @@ -25,17 +28,20 @@ struct pwrseq_pcie_m2_ctx { const struct pwrseq_pcie_m2_pdata *pdata; struct regulator_bulk_data *regs; size_t num_vregs; + struct gpio_desc *w_disable1_gpio; + struct gpio_desc *w_disable2_gpio; struct notifier_block nb; + struct device *dev; }; =20 -static int pwrseq_pcie_m2_m_vregs_enable(struct pwrseq_device *pwrseq) +static int pwrseq_pcie_m2_vregs_enable(struct pwrseq_device *pwrseq) { struct pwrseq_pcie_m2_ctx *ctx =3D pwrseq_device_get_drvdata(pwrseq); =20 return regulator_bulk_enable(ctx->num_vregs, ctx->regs); } =20 -static int pwrseq_pcie_m2_m_vregs_disable(struct pwrseq_device *pwrseq) +static int pwrseq_pcie_m2_vregs_disable(struct pwrseq_device *pwrseq) { struct pwrseq_pcie_m2_ctx *ctx =3D pwrseq_device_get_drvdata(pwrseq); =20 @@ -44,18 +50,84 @@ static int pwrseq_pcie_m2_m_vregs_disable(struct pwrseq= _device *pwrseq) =20 static const struct pwrseq_unit_data pwrseq_pcie_m2_vregs_unit_data =3D { .name =3D "regulators-enable", - .enable =3D pwrseq_pcie_m2_m_vregs_enable, - .disable =3D pwrseq_pcie_m2_m_vregs_disable, + .enable =3D pwrseq_pcie_m2_vregs_enable, + .disable =3D pwrseq_pcie_m2_vregs_disable, }; =20 -static const struct pwrseq_unit_data *pwrseq_pcie_m2_m_unit_deps[] =3D { +static const struct pwrseq_unit_data *pwrseq_pcie_m2_unit_deps[] =3D { &pwrseq_pcie_m2_vregs_unit_data, NULL }; =20 +static int pwrseq_pci_m2_e_uart_enable(struct pwrseq_device *pwrseq) +{ + struct pwrseq_pcie_m2_ctx *ctx =3D pwrseq_device_get_drvdata(pwrseq); + + return gpiod_set_value_cansleep(ctx->w_disable2_gpio, 0); +} + +static int pwrseq_pci_m2_e_uart_disable(struct pwrseq_device *pwrseq) +{ + struct pwrseq_pcie_m2_ctx *ctx =3D pwrseq_device_get_drvdata(pwrseq); + + return gpiod_set_value_cansleep(ctx->w_disable2_gpio, 1); +} + +static const struct pwrseq_unit_data pwrseq_pcie_m2_e_uart_unit_data =3D { + .name =3D "uart-enable", + .deps =3D pwrseq_pcie_m2_unit_deps, + .enable =3D pwrseq_pci_m2_e_uart_enable, + .disable =3D pwrseq_pci_m2_e_uart_disable, +}; + +static int pwrseq_pci_m2_e_pcie_enable(struct pwrseq_device *pwrseq) +{ + struct pwrseq_pcie_m2_ctx *ctx =3D pwrseq_device_get_drvdata(pwrseq); + + return gpiod_set_value_cansleep(ctx->w_disable1_gpio, 0); +} + +static int pwrseq_pci_m2_e_pcie_disable(struct pwrseq_device *pwrseq) +{ + struct pwrseq_pcie_m2_ctx *ctx =3D pwrseq_device_get_drvdata(pwrseq); + + return gpiod_set_value_cansleep(ctx->w_disable1_gpio, 1); +} + +static const struct pwrseq_unit_data pwrseq_pcie_m2_e_pcie_unit_data =3D { + .name =3D "pcie-enable", + .deps =3D pwrseq_pcie_m2_unit_deps, + .enable =3D pwrseq_pci_m2_e_pcie_enable, + .disable =3D pwrseq_pci_m2_e_pcie_disable, +}; + static const struct pwrseq_unit_data pwrseq_pcie_m2_m_pcie_unit_data =3D { .name =3D "pcie-enable", - .deps =3D pwrseq_pcie_m2_m_unit_deps, + .deps =3D pwrseq_pcie_m2_unit_deps, +}; + +static int pwrseq_pcie_m2_e_pwup_delay(struct pwrseq_device *pwrseq) +{ + /* + * FIXME: This delay is only required for some Qcom WLAN/BT cards like + * WCN7850 and not for all devices. But currently, there is no way to + * identify the device model before enumeration. + */ + msleep(50); + + return 0; +} + +static const struct pwrseq_target_data pwrseq_pcie_m2_e_uart_target_data = =3D { + .name =3D "uart", + .unit =3D &pwrseq_pcie_m2_e_uart_unit_data, + .post_enable =3D pwrseq_pcie_m2_e_pwup_delay, +}; + +static const struct pwrseq_target_data pwrseq_pcie_m2_e_pcie_target_data = =3D { + .name =3D "pcie", + .unit =3D &pwrseq_pcie_m2_e_pcie_unit_data, + .post_enable =3D pwrseq_pcie_m2_e_pwup_delay, }; =20 static const struct pwrseq_target_data pwrseq_pcie_m2_m_pcie_target_data = =3D { @@ -63,11 +135,21 @@ static const struct pwrseq_target_data pwrseq_pcie_m2_= m_pcie_target_data =3D { .unit =3D &pwrseq_pcie_m2_m_pcie_unit_data, }; =20 +static const struct pwrseq_target_data *pwrseq_pcie_m2_e_targets[] =3D { + &pwrseq_pcie_m2_e_pcie_target_data, + &pwrseq_pcie_m2_e_uart_target_data, + NULL +}; + static const struct pwrseq_target_data *pwrseq_pcie_m2_m_targets[] =3D { &pwrseq_pcie_m2_m_pcie_target_data, NULL }; =20 +static const struct pwrseq_pcie_m2_pdata pwrseq_pcie_m2_e_of_data =3D { + .targets =3D pwrseq_pcie_m2_e_targets, +}; + static const struct pwrseq_pcie_m2_pdata pwrseq_pcie_m2_m_of_data =3D { .targets =3D pwrseq_pcie_m2_m_targets, }; @@ -92,6 +174,96 @@ static int pwrseq_pcie_m2_match(struct pwrseq_device *p= wrseq, return PWRSEQ_NO_MATCH; } =20 +static int pwrseq_m2_pcie_notify(struct notifier_block *nb, unsigned long = action, + void *data) +{ + struct pwrseq_pcie_m2_ctx *ctx =3D container_of(nb, struct pwrseq_pcie_m2= _ctx, nb); + struct pci_dev *pdev =3D to_pci_dev(data); + struct device_node *pci_remote __free(device_node) =3D NULL; + struct device_node *serdev_remote __free(device_node) =3D NULL; + struct serdev_controller *serdev_ctrl; + struct serdev_device *serdev; + struct device *dev =3D ctx->dev; + int ret; + + /* + * Check whether the PCI device is associated with this M.2 connector or + * not, by comparing the OF node of the PCI device parent and the Port 0 + * (PCIe) remote node parent OF node. + */ + pci_remote =3D of_graph_get_remote_node(dev_of_node(ctx->dev), 0, 0); + if (!pci_remote || (pci_remote !=3D pdev->dev.parent->of_node)) + return NOTIFY_DONE; + + switch (action) { + case BUS_NOTIFY_ADD_DEVICE: + /* Create serdev device for WCN7850 */ + if (pdev->vendor =3D=3D PCI_VENDOR_ID_QCOM && pdev->device =3D=3D 0x1107= ) { + serdev_remote =3D of_graph_get_remote_node(dev_of_node(ctx->dev), 1, 1); + if (!serdev_remote) + return NOTIFY_DONE; + + serdev_ctrl =3D of_find_serdev_controller_by_node(serdev_remote); + if (!serdev_ctrl) + return NOTIFY_DONE; + + serdev =3D serdev_device_alloc(serdev_ctrl); + if (!serdev) + return NOTIFY_BAD; + + ret =3D serdev_device_add(serdev, "WCN7850"); + if (ret) { + dev_err(dev, "Failed to add serdev for WCN7850: %d\n", ret); + serdev_device_put(serdev); + return NOTIFY_BAD; + } + } + break; + } + + return NOTIFY_OK; +} + +static bool pwrseq_pcie_m2_check_remote_node(struct device *dev, u8 port, = u8 endpoint, + const char *node) +{ + struct device_node *remote __free(device_node) =3D NULL; + + remote =3D of_graph_get_remote_node(dev_of_node(dev), port, endpoint); + if (remote && of_node_name_eq(remote, node)) + return true; + + return false; +} + +/* + * If the connector exposes a non-discoverable bus like UART, the respecti= ve + * protocol device needs to be created manually with the help of the notif= ier + * of the discoverable bus like PCIe. + */ +static int pwrseq_pcie_m2_register_notifier(struct pwrseq_pcie_m2_ctx *ctx= , struct device *dev) +{ + int ret; + + /* + * Register a PCI notifier for Key E connector that has PCIe as Port + * 0/Endpoint 0 interface and Serial as Port 1/Endpoint 1 interface. + */ + if (pwrseq_pcie_m2_check_remote_node(dev, 1, 1, "serial")) { + if (pwrseq_pcie_m2_check_remote_node(dev, 0, 0, "pcie")) { + ctx->dev =3D dev; + ctx->nb.notifier_call =3D pwrseq_m2_pcie_notify; + ret =3D bus_register_notifier(&pci_bus_type, &ctx->nb); + if (ret) { + dev_err_probe(dev, ret, "Failed to register notifier for serdev\n"); + return ret; + } + } + } + + return 0; +} + static int pwrseq_pcie_m2_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; @@ -119,6 +291,16 @@ static int pwrseq_pcie_m2_probe(struct platform_device= *pdev) return dev_err_probe(dev, ret, "Failed to get all regulators\n"); =20 + ctx->w_disable1_gpio =3D devm_gpiod_get_optional(dev, "w-disable1", GPIOD= _OUT_HIGH); + if (IS_ERR(ctx->w_disable1_gpio)) + return dev_err_probe(dev, PTR_ERR(ctx->w_disable1_gpio), + "Failed to get the W_DISABLE_1# GPIO\n"); + + ctx->w_disable2_gpio =3D devm_gpiod_get_optional(dev, "w-disable2", GPIOD= _OUT_HIGH); + if (IS_ERR(ctx->w_disable2_gpio)) + return dev_err_probe(dev, PTR_ERR(ctx->w_disable2_gpio), + "Failed to get the W_DISABLE_2# GPIO\n"); + ctx->num_vregs =3D ret; =20 config.parent =3D dev; @@ -134,14 +316,23 @@ static int pwrseq_pcie_m2_probe(struct platform_devic= e *pdev) "Failed to register the power sequencer\n"); } =20 - return 0; + /* + * Register a notifier for creating protocol devices for + * non-discoverable busses like UART. + */ + return pwrseq_pcie_m2_register_notifier(ctx, dev); } =20 + static const struct of_device_id pwrseq_pcie_m2_of_match[] =3D { { .compatible =3D "pcie-m2-m-connector", .data =3D &pwrseq_pcie_m2_m_of_data, }, + { + .compatible =3D "pcie-m2-e-connector", + .data =3D &pwrseq_pcie_m2_e_of_data, + }, { } }; MODULE_DEVICE_TABLE(of, pwrseq_pcie_m2_of_match); --=20 2.48.1