Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2222975/?format=api
{ "id": 2222975, "url": "http://patchwork.ozlabs.org/api/patches/2222975/?format=api", "web_url": "http://patchwork.ozlabs.org/project/rtc-linux/patch/20260414-s2mu005-pmic-v4-12-7fe7480577e6@disroot.org/", "project": { "id": 9, "url": "http://patchwork.ozlabs.org/api/projects/9/?format=api", "name": "Linux RTC development", "link_name": "rtc-linux", "list_id": "linux-rtc.vger.kernel.org", "list_email": "linux-rtc@vger.kernel.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260414-s2mu005-pmic-v4-12-7fe7480577e6@disroot.org>", "list_archive_url": null, "date": "2026-04-14T06:33:04", "name": "[v4,12/13] extcon: add support for Samsung S2M series PMIC extcon devices", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "739e613f86c8a47714c576435bbdaaeb5f4d7cf3", "submitter": { "id": 88698, "url": "http://patchwork.ozlabs.org/api/people/88698/?format=api", "name": "Kaustabh Chakraborty", "email": "kauschluss@disroot.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/rtc-linux/patch/20260414-s2mu005-pmic-v4-12-7fe7480577e6@disroot.org/mbox/", "series": [ { "id": 499781, "url": "http://patchwork.ozlabs.org/api/series/499781/?format=api", "web_url": "http://patchwork.ozlabs.org/project/rtc-linux/list/?series=499781", "date": "2026-04-14T06:32:53", "name": "Support for Samsung S2MU005 PMIC and its sub-devices", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/499781/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2222975/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2222975/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linux-rtc+bounces-6328-incoming=patchwork.ozlabs.org@vger.kernel.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "linux-rtc@vger.kernel.org" ], "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=disroot.org header.i=@disroot.org header.a=rsa-sha256\n header.s=mail header.b=crsm1dL6;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-rtc+bounces-6328-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)", "smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org\n header.b=\"crsm1dL6\"", "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=178.21.23.139", "smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=disroot.org", "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=disroot.org" ], "Received": [ "from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fvvlM0cLnz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 16:39:43 +1000 (AEST)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 86DA430E4515\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 06:34:39 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 7612236EAB1;\n\tTue, 14 Apr 2026 06:34:37 +0000 (UTC)", "from layka.disroot.org (layka.disroot.org [178.21.23.139])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 664A836DA02;\n\tTue, 14 Apr 2026 06:34:35 +0000 (UTC)", "from [127.0.0.1] (localhost [127.0.0.1])\n\tby disroot.org (Postfix) with ESMTP id 15F0225D82;\n\tTue, 14 Apr 2026 08:34:34 +0200 (CEST)", "from layka.disroot.org ([127.0.0.1])\n by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id cC0JtstnYg3G; Tue, 14 Apr 2026 08:34:32 +0200 (CEST)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776148477; cv=none;\n b=sDUBTkb5K/C5B3OAf9QCXkQLW6Gp6SjoRGRDdJ48/EHf09QNvH6xU4Mka7Hl9gi3JpnXqOB+1zyNjJ7pAVqvTe01TBXSIf8GMeygHG5ro/F/HWYHgZX9k+joMHPGBfOq5ttA0LNeQ4l/jiVJRmwVjLweppIAPO9bu7Ko9J1Csz0=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776148477; c=relaxed/simple;\n\tbh=ExAsA7oVSTfNEb+bhr5NGywWjobSfCT3DOJXhwk4x5w=;\n\th=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References:\n\t In-Reply-To:To:Cc;\n b=ZxHi9zr4O8cEJxmAL+pIfL2ST9uhChUGyIoWEj61MtGHv9gsrZZ5GK013Z/JQpMsVNObWsZGRtlQ0ifs/lzuqIxi83sXYXhBmmX0GA/HyFfx6KhxcdDBqsEZRDqw8Qb681PRvg3c16JQpEKLkGhsx6LD0g+zqsIXIqNl3J/gFOk=", "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=disroot.org;\n spf=pass smtp.mailfrom=disroot.org;\n dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org\n header.b=crsm1dL6; arc=none smtp.client-ip=178.21.23.139", "X-Virus-Scanned": "SPAM Filter at disroot.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail;\n\tt=1776148472; bh=ExAsA7oVSTfNEb+bhr5NGywWjobSfCT3DOJXhwk4x5w=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc;\n\tb=crsm1dL660S392+Nwc5YcQZRJ548OWnFRh2o7l+uUwK/nXULG+AUbJnfJNuRuP3ca\n\t 5UDxTpARqQX4AK2d7WYJBmHTJxU6/eR/W0yqTja/uEtIH4YNK4QOyO4v0EMZAg4/CI\n\t 6QYuDaAHMPVlDCxWnWQaNIfuWHg9xiTBzXMelvSTivBt+j/7SW6KUNrhiDtAk38aRn\n\t r/863KG9ygnq+28lapiUi+PWdMV2JJKKFRVMuV1Kliw2jjf5C4qId9AxeDT540D59Y\n\t XS7vcA9GX2ASp4ciQsdPI6xFgxMYPhB7EHRVIy9pWendyu1pHBd3gb2p+DqYI9hIr2\n\t z7ml85yMIh/0Q==", "From": "Kaustabh Chakraborty <kauschluss@disroot.org>", "Date": "Tue, 14 Apr 2026 12:03:04 +0530", "Subject": "[PATCH v4 12/13] extcon: add support for Samsung S2M series PMIC\n extcon devices", "Precedence": "bulk", "X-Mailing-List": "linux-rtc@vger.kernel.org", "List-Id": "<linux-rtc.vger.kernel.org>", "List-Subscribe": "<mailto:linux-rtc+subscribe@vger.kernel.org>", "List-Unsubscribe": "<mailto:linux-rtc+unsubscribe@vger.kernel.org>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20260414-s2mu005-pmic-v4-12-7fe7480577e6@disroot.org>", "References": "<20260414-s2mu005-pmic-v4-0-7fe7480577e6@disroot.org>", "In-Reply-To": "<20260414-s2mu005-pmic-v4-0-7fe7480577e6@disroot.org>", "To": "Lee Jones <lee@kernel.org>, Pavel Machek <pavel@kernel.org>,\n Rob Herring <robh@kernel.org>, Krzysztof Kozlowski <krzk+dt@kernel.org>,\n Conor Dooley <conor+dt@kernel.org>, MyungJoo Ham <myungjoo.ham@samsung.com>,\n Chanwoo Choi <cw00.choi@samsung.com>, Sebastian Reichel <sre@kernel.org>,\n Krzysztof Kozlowski <krzk@kernel.org>,\n =?utf-8?q?Andr=C3=A9_Draszik?= <andre.draszik@linaro.org>,\n Alexandre Belloni <alexandre.belloni@bootlin.com>,\n Jonathan Corbet <corbet@lwn.net>, Shuah Khan <skhan@linuxfoundation.org>,\n Nam Tran <trannamatk@gmail.com>,\n =?utf-8?b?xYF1a2FzeiBMZWJpZWR6acWEc2tp?= <kernel@lvkasz.us>", "Cc": "linux-leds@vger.kernel.org, devicetree@vger.kernel.org,\n linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,\n linux-samsung-soc@vger.kernel.org, linux-rtc@vger.kernel.org,\n linux-doc@vger.kernel.org, Kaustabh Chakraborty <kauschluss@disroot.org>" }, "content": "Add a driver for MUIC devices found in certain Samsung S2M series PMICs\nThese are USB port accessory detectors. These devices report multiple\ncable states depending on the ID-GND resistance measured by an internal\nADC.\n\nThe driver includes initial support for the S2MU005 PMIC extcon.\n\nSigned-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>\n---\n drivers/extcon/Kconfig | 10 ++\n drivers/extcon/Makefile | 1 +\n drivers/extcon/extcon-s2m.c | 354 ++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 365 insertions(+)", "diff": "diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig\nindex 68d9df7d2dae0..19c712e591955 100644\n--- a/drivers/extcon/Kconfig\n+++ b/drivers/extcon/Kconfig\n@@ -183,6 +183,16 @@ config EXTCON_RT8973A\n \t and switch that is optimized to protect low voltage system\n \t from abnormal high input voltage (up to 28V).\n \n+config EXTCON_S2M\n+\ttristate \"Samsung S2M series PMIC EXTCON support\"\n+\tdepends on MFD_SEC_CORE\n+\tselect REGMAP_IRQ\n+\thelp\n+\t This option enables support for MUIC devices found in certain\n+\t Samsung S2M series PMICs, such as the S2MU005. These devices\n+\t have internal ADCs measuring the ID-GND resistance, thereby\n+\t can be used as a USB port accessory detector.\n+\n config EXTCON_SM5502\n \ttristate \"Silicon Mitus SM5502/SM5504/SM5703 EXTCON support\"\n \tdepends on I2C\ndiff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile\nindex 6482f2bfd6611..e3939786f3474 100644\n--- a/drivers/extcon/Makefile\n+++ b/drivers/extcon/Makefile\n@@ -23,6 +23,7 @@ obj-$(CONFIG_EXTCON_PALMAS)\t+= extcon-palmas.o\n obj-$(CONFIG_EXTCON_PTN5150)\t+= extcon-ptn5150.o\n obj-$(CONFIG_EXTCON_QCOM_SPMI_MISC) += extcon-qcom-spmi-misc.o\n obj-$(CONFIG_EXTCON_RT8973A)\t+= extcon-rt8973a.o\n+obj-$(CONFIG_EXTCON_S2M)\t+= extcon-s2m.o\n obj-$(CONFIG_EXTCON_SM5502)\t+= extcon-sm5502.o\n obj-$(CONFIG_EXTCON_USB_GPIO)\t+= extcon-usb-gpio.o\n obj-$(CONFIG_EXTCON_USBC_CROS_EC) += extcon-usbc-cros-ec.o\ndiff --git a/drivers/extcon/extcon-s2m.c b/drivers/extcon/extcon-s2m.c\nnew file mode 100644\nindex 0000000000000..f57573f279755\n--- /dev/null\n+++ b/drivers/extcon/extcon-s2m.c\n@@ -0,0 +1,354 @@\n+// SPDX-License-Identifier: GPL-2.0\n+/*\n+ * Extcon Driver for Samsung S2M series PMICs.\n+ *\n+ * Copyright (c) 2015 Samsung Electronics Co., Ltd\n+ * Copyright (C) 2025 Kaustabh Chakraborty <kauschluss@disroot.org>\n+ */\n+\n+#include <linux/delay.h>\n+#include <linux/extcon-provider.h>\n+#include <linux/interrupt.h>\n+#include <linux/mfd/samsung/core.h>\n+#include <linux/mfd/samsung/s2mu005.h>\n+#include <linux/module.h>\n+#include <linux/of.h>\n+#include <linux/platform_device.h>\n+#include <linux/regmap.h>\n+\n+struct s2m_muic {\n+\tstruct device *dev;\n+\tstruct regmap *regmap;\n+\tstruct extcon_dev *extcon;\n+\tstruct s2m_muic_irq_data *irq_data;\n+\tconst unsigned int *extcon_cable;\n+\tbool attached;\n+};\n+\n+struct s2m_muic_irq_data {\n+\tconst char *name;\n+\tint (*const handler)(struct s2m_muic *);\n+\tint irq;\n+};\n+\n+static int s2mu005_muic_detach(struct s2m_muic *priv)\n+{\n+\tint ret;\n+\tint i;\n+\n+\tret = regmap_set_bits(priv->regmap, S2MU005_REG_MUIC_CTRL1,\n+\t\t\t S2MU005_MUIC_MAN_SW);\n+\tif (ret < 0) {\n+\t\tdev_err(priv->dev, \"failed to disable manual switching\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\tret = regmap_set_bits(priv->regmap, S2MU005_REG_MUIC_CTRL3,\n+\t\t\t S2MU005_MUIC_ONESHOT_ADC);\n+\tif (ret < 0) {\n+\t\tdev_err(priv->dev, \"failed to enable ADC oneshot mode\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\tret = regmap_clear_bits(priv->regmap, S2MU005_REG_MUIC_SWCTRL, ~0);\n+\tif (ret < 0) {\n+\t\tdev_err(priv->dev, \"failed to clear switch control register\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\t/* Find all set states and clear them */\n+\tfor (i = 0; priv->extcon_cable[i]; i++) {\n+\t\tunsigned int state = priv->extcon_cable[i];\n+\n+\t\tif (extcon_get_state(priv->extcon, state) == true)\n+\t\t\textcon_set_state_sync(priv->extcon, state, false);\n+\t}\n+\n+\tpriv->attached = false;\n+\n+\treturn 0;\n+}\n+\n+static int s2mu005_muic_attach(struct s2m_muic *priv)\n+{\n+\tunsigned int type;\n+\tint ret;\n+\n+\t/* If any device is already attached, detach it */\n+\tif (priv->attached) {\n+\t\ts2mu005_muic_detach(priv);\n+\t\tmsleep(100);\n+\t}\n+\n+\tret = regmap_read(priv->regmap, S2MU005_REG_MUIC_DEV1, &type);\n+\tif (ret < 0) {\n+\t\tdev_err(priv->dev, \"failed to read DEV1 register\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\t/*\n+\t * All USB connections which require communication via its D+\n+\t * and D- wires need it.\n+\t */\n+\tif (type & (S2MU005_MUIC_OTG | S2MU005_MUIC_DCP | S2MU005_MUIC_SDP)) {\n+\t\tret = regmap_update_bits(priv->regmap, S2MU005_REG_MUIC_SWCTRL,\n+\t\t\t\t\t S2MU005_MUIC_DM_DP,\n+\t\t\t\t\t FIELD_PREP(S2MU005_MUIC_DM_DP,\n+\t\t\t\t\t\t S2MU005_MUIC_DM_DP_USB));\n+\t\tif (ret < 0) {\n+\t\t\tdev_err(priv->dev, \"failed to configure DM/DP pins\\n\");\n+\t\t\treturn ret;\n+\t\t}\n+\t}\n+\n+\t/*\n+\t * For OTG connections, enable manual switching and ADC oneshot\n+\t * mode. Since the port will now be supplying power, the\n+\t * internal ADC (measuring the ID-GND resistance) is made to\n+\t * poll periodically for any changes, so as to prevent any\n+\t * damages due to power.\n+\t */\n+\tif (type & S2MU005_MUIC_OTG) {\n+\t\tret = regmap_clear_bits(priv->regmap, S2MU005_REG_MUIC_CTRL1,\n+\t\t\t\t\tS2MU005_MUIC_MAN_SW);\n+\t\tif (ret < 0) {\n+\t\t\tdev_err(priv->dev, \"failed to enable manual switching\\n\");\n+\t\t\treturn ret;\n+\t\t}\n+\n+\t\tret = regmap_clear_bits(priv->regmap, S2MU005_REG_MUIC_CTRL3,\n+\t\t\t\t\tS2MU005_MUIC_ONESHOT_ADC);\n+\t\tif (ret < 0) {\n+\t\t\tdev_err(priv->dev, \"failed to disable ADC oneshot mode\\n\");\n+\t\t\treturn ret;\n+\t\t}\n+\t}\n+\n+\tswitch (type) {\n+\tcase S2MU005_MUIC_OTG:\n+\t\tdev_dbg(priv->dev, \"USB OTG connection detected\\n\");\n+\t\textcon_set_state_sync(priv->extcon, EXTCON_USB_HOST, true);\n+\t\tpriv->attached = true;\n+\t\tbreak;\n+\tcase S2MU005_MUIC_CDP:\n+\t\tdev_dbg(priv->dev, \"USB CDP connection detected\\n\");\n+\t\textcon_set_state_sync(priv->extcon, EXTCON_USB, true);\n+\t\textcon_set_state_sync(priv->extcon, EXTCON_CHG_USB_CDP, true);\n+\t\tpriv->attached = true;\n+\t\tbreak;\n+\tcase S2MU005_MUIC_SDP:\n+\t\tdev_dbg(priv->dev, \"USB SDP connection detected\\n\");\n+\t\textcon_set_state_sync(priv->extcon, EXTCON_USB, true);\n+\t\textcon_set_state_sync(priv->extcon, EXTCON_CHG_USB_SDP, true);\n+\t\tpriv->attached = true;\n+\t\tbreak;\n+\tcase S2MU005_MUIC_DCP:\n+\t\tdev_dbg(priv->dev, \"USB DCP connection detected\\n\");\n+\t\textcon_set_state_sync(priv->extcon, EXTCON_USB, true);\n+\t\textcon_set_state_sync(priv->extcon, EXTCON_CHG_USB_DCP, true);\n+\t\tpriv->attached = true;\n+\t\tbreak;\n+\tcase S2MU005_MUIC_UART:\n+\t\tdev_dbg(priv->dev, \"UART connection detected\\n\");\n+\t\textcon_set_state_sync(priv->extcon, EXTCON_JIG, true);\n+\t\tpriv->attached = true;\n+\t\tbreak;\n+\t}\n+\n+\tif (!priv->attached)\n+\t\tdev_warn(priv->dev, \"failed to recognize the device attached\\n\");\n+\n+\treturn ret;\n+}\n+\n+static int s2mu005_muic_init(struct s2m_muic *priv)\n+{\n+\tint ret = 0;\n+\n+\tret = regmap_update_bits(priv->regmap, S2MU005_REG_MUIC_LDOADC_L,\n+\t\t\t\t S2MU005_MUIC_VSET,\n+\t\t\t\t FIELD_PREP(S2MU005_MUIC_VSET,\n+\t\t\t\t\t S2MU005_MUIC_VSET_3P0V));\n+\tif (ret < 0) {\n+\t\tdev_err(priv->dev, \"failed to set internal ADC voltage regulator\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\tret = regmap_update_bits(priv->regmap, S2MU005_REG_MUIC_LDOADC_H,\n+\t\t\t\t S2MU005_MUIC_VSET,\n+\t\t\t\t FIELD_PREP(S2MU005_MUIC_VSET,\n+\t\t\t\t\t S2MU005_MUIC_VSET_3P0V));\n+\tif (ret < 0) {\n+\t\tdev_err(priv->dev, \"failed to set internal ADC voltage regulator\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\tret = regmap_clear_bits(priv->regmap, S2MU005_REG_MUIC_CTRL1,\n+\t\t\t\tS2MU005_MUIC_IRQ);\n+\tif (ret < 0) {\n+\t\tdev_err(priv->dev, \"failed to enable MUIC interrupts\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\treturn s2mu005_muic_attach(priv);\n+}\n+\n+static const unsigned int s2mu005_muic_extcon_cable[] = {\n+\tEXTCON_USB,\n+\tEXTCON_USB_HOST,\n+\tEXTCON_CHG_USB_SDP,\n+\tEXTCON_CHG_USB_DCP,\n+\tEXTCON_CHG_USB_CDP,\n+\tEXTCON_JIG,\n+\tEXTCON_NONE,\n+};\n+\n+static struct s2m_muic_irq_data s2mu005_muic_irq_data[] = {\n+\t{\n+\t\t.name = \"attach\",\n+\t\t.handler = s2mu005_muic_attach\n+\t}, {\n+\t\t.name = \"detach\",\n+\t\t.handler = s2mu005_muic_detach\n+\t}, {\n+\t\t/* sentinel */\n+\t}\n+};\n+\n+static irqreturn_t s2m_muic_irq_func(int virq, void *data)\n+{\n+\tstruct s2m_muic *priv = data;\n+\tconst struct s2m_muic_irq_data *irq_data = priv->irq_data;\n+\tint ret;\n+\tint i;\n+\n+\tfor (i = 0; irq_data[i].handler; i++) {\n+\t\tif (virq != irq_data[i].irq)\n+\t\t\tcontinue;\n+\n+\t\tret = irq_data[i].handler(priv);\n+\t\tif (ret < 0)\n+\t\t\tdev_err(priv->dev, \"failed to handle interrupt for %s (%d)\\n\",\n+\t\t\t\tirq_data[i].name, ret);\n+\t\tbreak;\n+\t}\n+\n+\treturn IRQ_HANDLED;\n+}\n+\n+static int s2m_muic_probe(struct platform_device *pdev)\n+{\n+\tstruct device *dev = &pdev->dev;\n+\tstruct sec_pmic_dev *pmic_drvdata = dev_get_drvdata(dev->parent);\n+\tstruct s2m_muic *priv;\n+\tint ret;\n+\tint i;\n+\n+\tpriv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);\n+\tif (!priv)\n+\t\treturn -ENOMEM;\n+\n+\tplatform_set_drvdata(pdev, priv);\n+\tpriv->dev = dev;\n+\tpriv->regmap = pmic_drvdata->regmap_pmic;\n+\n+\tswitch (platform_get_device_id(pdev)->driver_data) {\n+\tcase S2MU005:\n+\t\tpriv->extcon_cable = s2mu005_muic_extcon_cable;\n+\t\tpriv->irq_data = s2mu005_muic_irq_data;\n+\t\t/* Initialize MUIC */\n+\t\tret = s2mu005_muic_init(priv);\n+\t\tbreak;\n+\tdefault:\n+\t\treturn dev_err_probe(dev, -ENODEV,\n+\t\t\t\t \"device type %d is not supported by driver\\n\",\n+\t\t\t\t pmic_drvdata->device_type);\n+\t}\n+\tif (ret < 0)\n+\t\treturn dev_err_probe(dev, ret, \"failed to initialize MUIC\\n\");\n+\n+\tpriv->extcon = devm_extcon_dev_allocate(&pdev->dev, priv->extcon_cable);\n+\tif (IS_ERR(priv->extcon))\n+\t\treturn dev_err_probe(dev, PTR_ERR(priv->extcon),\n+\t\t\t\t \"failed to allocate memory for extcon\\n\");\n+\n+\tret = devm_extcon_dev_register(dev, priv->extcon);\n+\tif (ret)\n+\t\treturn dev_err_probe(dev, ret, \"failed to register extcon device\\n\");\n+\n+\tfor (i = 0; priv->irq_data[i].handler; i++) {\n+\t\tint irq = platform_get_irq_byname_optional(pdev,\n+\t\t\t\t\t\t\t priv->irq_data[i].name);\n+\t\tif (irq == -ENXIO)\n+\t\t\tcontinue;\n+\t\tif (irq <= 0)\n+\t\t\treturn dev_err_probe(dev, -EINVAL, \"failed to get IRQ %s\\n\",\n+\t\t\t\t\t priv->irq_data[i].name);\n+\n+\t\tpriv->irq_data[i].irq = irq;\n+\t\tret = devm_request_threaded_irq(dev, irq, NULL,\n+\t\t\t\t\t\ts2m_muic_irq_func, IRQF_ONESHOT,\n+\t\t\t\t\t\tpriv->irq_data[i].name, priv);\n+\t\tif (ret)\n+\t\t\treturn dev_err_probe(dev, ret, \"failed to request IRQ\\n\");\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static void s2m_muic_remove(struct platform_device *pdev)\n+{\n+\tstruct s2m_muic *priv = dev_get_drvdata(&pdev->dev);\n+\n+\t/*\n+\t * Disabling the MUIC device is important as it disables manual\n+\t * switching mode, thereby enabling auto switching mode.\n+\t *\n+\t * This is to ensure that when the board is powered off, it\n+\t * goes into LPM charging mode when a USB charger is connected.\n+\t */\n+\tswitch (platform_get_device_id(pdev)->driver_data) {\n+\tcase S2MU005:\n+\t\ts2mu005_muic_detach(priv);\n+\t\tbreak;\n+\t}\n+}\n+\n+static const struct platform_device_id s2m_muic_id_table[] = {\n+\t{ \"s2mu005-muic\", S2MU005 },\n+\t{ /* sentinel */ },\n+};\n+MODULE_DEVICE_TABLE(platform, s2m_muic_id_table);\n+\n+/*\n+ * Device is instantiated through parent MFD device and device matching\n+ * is done through platform_device_id.\n+ *\n+ * However if device's DT node contains proper compatible and driver is\n+ * built as a module, then the *module* matching will be done through DT\n+ * aliases. This requires of_device_id table. In the same time this will\n+ * not change the actual *device* matching so do not add .of_match_table.\n+ */\n+static const struct of_device_id s2m_muic_of_match_table[] = {\n+\t{\n+\t\t.compatible = \"samsung,s2mu005-muic\",\n+\t\t.data = (void *)S2MU005,\n+\t}, {\n+\t\t/* sentinel */\n+\t},\n+};\n+MODULE_DEVICE_TABLE(of, s2m_muic_of_match_table);\n+\n+static struct platform_driver s2m_muic_driver = {\n+\t.driver = {\n+\t\t.name = \"s2m-muic\",\n+\t},\n+\t.probe = s2m_muic_probe,\n+\t.remove = s2m_muic_remove,\n+\t.id_table = s2m_muic_id_table,\n+};\n+module_platform_driver(s2m_muic_driver);\n+\n+MODULE_DESCRIPTION(\"Extcon Driver For Samsung S2M Series PMICs\");\n+MODULE_AUTHOR(\"Kaustabh Chakraborty <kauschluss@disroot.org>\");\n+MODULE_LICENSE(\"GPL\");\n", "prefixes": [ "v4", "12/13" ] }