From patchwork Fri Feb 2 06:34:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13542140 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E60C0C48291 for ; Fri, 2 Feb 2024 06:31:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=HoKdN5KyzvoIYx3CLrqAap0RNYyIUa0JXRhU8W2BfP4=; b=TmKpdd+pMxcEPopiiY22yr98WF QTylETvj5qGRjyrB7cYytov0r85Iqm/k4FEKhYSzIzv0wELE736fJbx8c18h4/UZjOOaVZTD/m6en QwdzlQPPURaXsYFxUVEcD78kKv7Szb6B09z3Mw0RCWMTE00Eu298g726+Z+689oLa6137nHuTQsDo B2PvH5fS4a90eZY+bdNO8FQYRSY0UHuH856bLq1oOT8sYI78Mr4Le++eVEx0PRVnj+caGFSnzfutf 8nQbxhe2TMFxhZKEqyC8u5/9ALplMHAHV/ONmKHidvG9f0mMf4aIdYCe4kvAokXgMp8gbib1EMloh hCNeuKHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVn4f-0000000AQYj-43uz; Fri, 02 Feb 2024 06:30:53 +0000 Received: from mail-he1eur04on20600.outbound.protection.outlook.com ([2a01:111:f403:260f::600] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVn4c-0000000AQTa-3A1k for linux-arm-kernel@lists.infradead.org; Fri, 02 Feb 2024 06:30:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bhjtLWwiSogMkL9GiHQyFbHghBGBC6oFMLGeR2vWPYhYVT7Kbqes1YnPP2YoXo0DQSkdYZ0lFs7+M8YTThz4fkpLWGFp3sco1Cib3DLWe0PnX6DajWaZMPlIV93K/A3DREgScF+GLUiuy1HTtwcrpSx0tI5juugQLDAiwLgnGoZyyGNahrPVf76b2Frfr4EATKPAetXM34+9+WVdQyMJsQS7Ok49UHcilvIiUd/Uv5GvA3U8TRuwqovyaTtofyKKZJfqFiWLttPK/FYzMlvmznMawsyxCKVDT/5ZhzzXQxtoB/OZAmp30FDJ9Tq5G/kqgo/1zWKEtnbM6s4Dv7X5RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F/+8+PBCrKXHGNNHEE/QQiIcvFqinI1PO5Zudu9T9Xg=; b=MMlzPbV9x1deQrMSBWiUBDOA/8gyUAjOT0onzWpAfum4hLISC0Gli/MCxzhzTkMRwGmSwSDlPABibhLrbDHQ8PDzuDDEJ6Rqw3FKmeE6AcSyUzzd44TUnkmhl0C/QhD7sLqTSa3DztXMvb/mmTU1Vgx5kfIChZQcuySbt7t1Uz/cxDLL1PNHgoB54qXFJJLn9KEAwUZ+KxKi2wDeOekzSKX6hCpJps0Y/LhXu/NxCe1vsJpFyC8CpRdgKPBPUunopYJTD3zVZZKyIPCmZlgVO0QHgmRsvnhaA7NYLxOyqYMhDm4kbdeteF2SUH1NLzfemiMDgDO9ulP1SlmHykJKOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F/+8+PBCrKXHGNNHEE/QQiIcvFqinI1PO5Zudu9T9Xg=; b=XdIdISDKB64YAeb2fpDWnaABB/QkaMVf8K109tmeoFcfAz+UIxr8s7MqqAEwkzXKptTICeQIl5K8VIxvJ2E+wPKetJLarvFcCcETf2o6uLgMUDKIu8XfQ7puVBe/LKcOJOzLlmqVZtYP/2W5l6gvU7IhdYHCWLhJMZqDKqVSMYg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.26; Fri, 2 Feb 2024 06:30:45 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c499:8cef:9bb1:ced6]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c499:8cef:9bb1:ced6%3]) with mapi id 15.20.7249.027; Fri, 2 Feb 2024 06:30:45 +0000 From: "Peng Fan (OSS)" Date: Fri, 02 Feb 2024 14:34:43 +0800 Subject: [PATCH 5/5] firmware: imx: add i.MX95 MISC driver Message-Id: <20240202-imx95-bbm-misc-v1-5-3cb743020933@nxp.com> References: <20240202-imx95-bbm-misc-v1-0-3cb743020933@nxp.com> In-Reply-To: <20240202-imx95-bbm-misc-v1-0-3cb743020933@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sudeep Holla , Cristian Marussi , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706855688; l=4839; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=l1+u1wEujwpxZp3cg566GNVi0f6jUiKSXBYb9aNl0nE=; b=7kFiu0G+0ErsohkFa7SxRb4C2Xj7w1sgzEswV4UpIHy1ERHGa8HUp8YemYmW76B2mC5FsnGtT 2jGGZfASWb5C40TIEQz1T8gpNvOTQz4A0RghbBIqWcHBh2KPlEaT//K X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0048.apcprd02.prod.outlook.com (2603:1096:4:1f5::11) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|AM9PR04MB8604:EE_ X-MS-Office365-Filtering-Correlation-Id: 330b7724-358c-4e29-32e9-08dc23b87cf8 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AF+K50A9/GmAlwMXN9rOfmBjoiMPZ0ubmaXpMS/cQ8S5KlaOhpbs8MN9RjU7UOSt5cs4CAKPNzjY2s0t4y+gxkf6LUba6+2e2aRgiQv55EhrWWVdHMGmlLrp+nEm+z9C2fS9WHWDdi+NIfNBveIQ2rgTYl/r2c97z/llasIAk1lp+ROugKnScLYQz4S+NcG1DGNegW+4G7AMPA4V7AXMdcWnCxS6AEy4117kfp7DSYUgx/08JrCwGNPAj6Hia4qwYWnCO9dsv/fV/qnSG+YlQ8hks6Z6woBcRUCmZaZSMZqduGIPYQ/67GZk0B8PCbyMAJ9ZD+ULNzI/1Q7HFYCds9qH7ARSYEnH0LJE8mGznWuK4CURLyj8HFIElvK0yrro866wg5fyrXTXXO51LYfgEdbUphWdXxIehd32I5IC7t9h+AJgCs0d+L724SuW2LMRSEAUst88orjG0pXMBvYump0qxjXTHsoi/Hv4BwmUq8zb5hRrw1wvTQG2/XkE0D4/igJea2rucll7R+S1xWrLsKKu5Xm8hBy9kF4UFAxXF56llxSkFHZLpERwezbyIM2WAmSxiZfrJQ3u+kUHcg87Gpx4JpHxI6lptq3ouUfHoecNgQoFp+he5SOfcUrn8sJapulBSU8eu0u93skheXw+rA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(39860400002)(346002)(136003)(366004)(396003)(230922051799003)(1800799012)(64100799003)(451199024)(186009)(9686003)(6512007)(6506007)(52116002)(8936002)(921011)(4326008)(7416002)(2906002)(5660300002)(316002)(8676002)(66476007)(86362001)(66556008)(66946007)(38350700005)(26005)(36756003)(110136005)(41300700001)(6486002)(478600001)(83380400001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?xHJ6a5gNL5/jK4y5mvEmSKzOwDmU?= =?utf-8?q?LX13xBxobB56iIPWhXU7dRkEBSdKt0grwMFYl9tUSqLdv/i9vafXvFqloqX28kg27?= =?utf-8?q?qwGFdyCBhQX1+GGuaPivnFBfgJc+eTBIgkK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5aujL+Bfl2l+l4iMdQk?= =?utf-8?q?/UikLZI0bhnm017q2jvE6NokgSxGQ9ODqMcNsjBjdlFvh81kF8fDacbYU+UJUVcG/?= =?utf-8?q?wuPAyO14X23P+gWynha0T3987Mdbs74I1H8qAmws2D5y/CA5jR+c/pP8Iyaxd+KOj?= =?utf-8?q?hYr32kXkLZK4grC++1zCmivLBlNQJTZMgfSG61/zdoLqOL7ZydjIaTQ4U8LtlQ/MW?= =?utf-8?q?KxktixME/UXlKjnS5dGOSuVXnv4P/DnUqQ5MbPNdcQWMC/kVbxpRvbd3kKYEJP4MO?= =?utf-8?q?ZqoKmGAY37L7z7S4HIVlqaoU6eum8+ddIPRvtUZZuwYyahX2MS4WiAgPcONMBZqG4?= =?utf-8?q?sq3sjxY4SMn0yf5hh8Jto2TNAhmTfMTkMSbL6cMM/tDKZ0VEydC9GXDEc69jG+9Zu?= =?utf-8?q?0jd4HiaJ7ai8zvt1a9bdjKl0TbehTxZCGUQq+QIGhjhHYlO9GaY4FmrxhoSK3rxr7?= =?utf-8?q?n0mrhmo3Etrd5GQ8gwZ2a0QpG4PcZzNjwgVN0uCtoi3eltgalauxYGZ9fOa1cKph/?= =?utf-8?q?lO+RZa+y5E1N?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 330b7724-358c-4e29-32e9-08dc23b87cf8 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2024 06:30:45.8310 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vIOm2y5Acm/Adwrpzm24d+6bnHZK2lKRvI+SmXSpzA88LE26mqu91cXwhT7UGgnN5fiYSQWxJKBfDriyxtEoUQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8604 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240201_223050_879183_E1E14FAA X-CRM114-Status: GOOD ( 16.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan The i.MX95 System manager exports SCMI MISC protocol for linux to do various settings, such as set board gpio expander as wakeup source. The driver is to add the support. Signed-off-by: Peng Fan --- drivers/firmware/imx/Makefile | 1 + drivers/firmware/imx/sm-misc.c | 92 +++++++++++++++++++++++++++++++++++++++++ include/linux/firmware/imx/sm.h | 33 +++++++++++++++ 3 files changed, 126 insertions(+) diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index fb20e22074e1..cb9c361d9b81 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_IMX_DSP) += imx-dsp.o obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o obj-${CONFIG_IMX_SCMI_BBM_EXT} += sm-bbm.o +obj-${CONFIG_IMX_SCMI_MISC_EXT} += sm-misc.o diff --git a/drivers/firmware/imx/sm-misc.c b/drivers/firmware/imx/sm-misc.c new file mode 100644 index 000000000000..4410e69d256b --- /dev/null +++ b/drivers/firmware/imx/sm-misc.c @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2024 NXP. + */ + +#include +#include +#include +#include +#include +#include + +static const struct scmi_imx_misc_proto_ops *imx_misc_ctrl_ops; +static struct scmi_protocol_handle *ph; +struct notifier_block scmi_imx_misc_ctrl_nb; + +int scmi_imx_misc_ctrl_set(u32 id, u32 val) +{ + if (!ph) + return -EPROBE_DEFER; + + return imx_misc_ctrl_ops->misc_ctrl_set(ph, id, 1, &val); +}; +EXPORT_SYMBOL(scmi_imx_misc_ctrl_set); + +int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val) +{ + if (!ph) + return -EPROBE_DEFER; + + return imx_misc_ctrl_ops->misc_ctrl_get(ph, id, num, val); +} +EXPORT_SYMBOL(scmi_imx_misc_ctrl_get); + +static int scmi_imx_misc_ctrl_notifier(struct notifier_block *nb, + unsigned long event, void *data) +{ + return 0; +} + +static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + struct device_node *np = sdev->dev.of_node; + u32 src_id, evt_id, wu_num; + int ret, i; + + if (!handle) + return -ENODEV; + + imx_misc_ctrl_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_IMX_MISC, &ph); + if (IS_ERR(imx_misc_ctrl_ops)) + return PTR_ERR(imx_misc_ctrl_ops); + + scmi_imx_misc_ctrl_nb.notifier_call = &scmi_imx_misc_ctrl_notifier; + wu_num = of_property_count_u32_elems(np, "wakeup-sources"); + if (wu_num % 2) { + dev_err(&sdev->dev, "Invalid wakeup-sources\n"); + return -EINVAL; + } + + for (i = 0; i < wu_num; i += 2) { + WARN_ON(of_property_read_u32_index(np, "wakeup-sources", i, &src_id)); + WARN_ON(of_property_read_u32_index(np, "wakeup-sources", i + 1, &evt_id)); + ret = handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_MISC, + evt_id, + &src_id, + &scmi_imx_misc_ctrl_nb); + if (ret) + dev_err(&sdev->dev, "Failed to register scmi misc event: %d\n", src_id); + } + + return 0; + +} + +static const struct scmi_device_id scmi_id_table[] = { + { SCMI_PROTOCOL_IMX_MISC, "imx-misc-ctrl" }, + { }, +}; +MODULE_DEVICE_TABLE(scmi, scmi_id_table); + +static struct scmi_driver scmi_imx_misc_ctrl_driver = { + .name = "scmi-imx-misc-ctrl", + .probe = scmi_imx_misc_ctrl_probe, + .id_table = scmi_id_table, +}; +module_scmi_driver(scmi_imx_misc_ctrl_driver); + +MODULE_AUTHOR("Peng Fan "); +MODULE_DESCRIPTION("IMX SM MISC driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/firmware/imx/sm.h b/include/linux/firmware/imx/sm.h new file mode 100644 index 000000000000..daad4bdf7d1c --- /dev/null +++ b/include/linux/firmware/imx/sm.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2024 NXP + */ + +#ifndef _SCMI_IMX_H +#define _SCMI_IMX_H + +#include +#include + +#define SCMI_IMX_CTRL_PDM_CLK_SEL 0 /* AON PDM clock sel */ +#define SCMI_IMX_CTRL_MQS1_SETTINGS 1 /* AON MQS settings */ +#define SCMI_IMX_CTRL_SAI1_MCLK 2 /* AON SAI1 MCLK */ +#define SCMI_IMX_CTRL_SAI3_MCLK 3 /* WAKE SAI3 MCLK */ +#define SCMI_IMX_CTRL_SAI4_MCLK 4 /* WAKE SAI4 MCLK */ +#define SCMI_IMX_CTRL_SAI5_MCLK 5 /* WAKE SAI5 MCLK */ + +#if IS_ENABLED(CONFIG_IMX_SCMI_MISC_EXT) +int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val); +int scmi_imx_misc_ctrl_set(u32 id, u32 val); +#else +static inline int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val) +{ + return -EOPNOTSUPP; +} + +static inline int scmi_imx_misc_ctrl_set(u32 id, u32 val); +{ + return -EOPNOTSUPP; +} +#endif +#endif