From patchwork Tue Feb 2 09:00:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "M.h. Lian" X-Patchwork-Id: 8187571 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3B6309F4DD for ; Tue, 2 Feb 2016 09:01:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 169B4202AE for ; Tue, 2 Feb 2016 09:01:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 78B3A2027D for ; Tue, 2 Feb 2016 09:01:48 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQWot-0006QG-N5; Tue, 02 Feb 2016 09:00:19 +0000 Received: from mail-by2on0070.outbound.protection.outlook.com ([207.46.100.70] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQWoh-0005D4-Sx for linux-arm-kernel@lists.infradead.org; Tue, 02 Feb 2016 09:00:10 +0000 Received: from CH1PR03CA012.namprd03.prod.outlook.com (10.255.156.157) by SN1PR0301MB2064.namprd03.prod.outlook.com (10.163.227.151) with Microsoft SMTP Server (TLS) id 15.1.396.15; Tue, 2 Feb 2016 08:59:46 +0000 Received: from BL2FFO11FD024.protection.gbl (10.255.156.132) by CH1PR03CA012.outlook.office365.com (10.255.156.157) with Microsoft SMTP Server (TLS) id 15.1.390.13 via Frontend Transport; Tue, 2 Feb 2016 08:59:45 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11FD024.mail.protection.outlook.com (10.173.161.103) with Microsoft SMTP Server (TLS) id 15.1.409.7 via Frontend Transport; Tue, 2 Feb 2016 08:59:45 +0000 Received: from lmh.ap.freescale.net (lmh.ap.freescale.net [10.193.20.20]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u128xbcR004454; Tue, 2 Feb 2016 01:59:42 -0700 From: Minghuan Lian To: Subject: [PATCH 2/2 v3] irqchip/Layerscape: Add SCFG MSI controller support Date: Tue, 2 Feb 2016 17:00:48 +0800 Message-ID: <1454403648-5551-2-git-send-email-Minghuan.Lian@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454403648-5551-1-git-send-email-Minghuan.Lian@nxp.com> References: <1454403648-5551-1-git-send-email-Minghuan.Lian@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 130988771861658292; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD024; 1:6OSecM8lgsj15Dy72ubOvBVnerdwa26vYCykBhKv/O1JRh4UK7vZhYGUYYcdJvKNSzSQaxysVDd+4wZ/JC/6vk1Fie4iLCZxQ48A+vu95QnIyUVAte3qNaEK/F5FdDt7554hfaoWbyOQwALHdoerl/IAd+nSS+MaNDAgGBZdFNRPT5Oj05h+zScB8OZgcmEv4/kCjfQ05vhUVsGWFEAgr/F7gLIsb1qY0snK/Q94Yk7W95JIR8MCSeUwJpJt/rlkbt5WczHByYQ4wFkWVdP8MgrONhDvwNYpo8WtDA8FAe08hAyL5zG/bkaPumlZJcMiBMsZXkDwlbw5SYA7f+unse7vQl5+zKAyGyJ8ZGwk38h0Y+xNiqZCdW8ctP58Ev9a4H40Y3WA8d3KwgaP/fFdSarRgR84uCNzpBKOk4kHY4c+07HDce+lF1uT5S0EgCcwPbx9zFSVOksNIMb0iW0keUWSomU8cDtcY8O6uhRs3gQ/9ZAW+u5r1eCOF3OB7WjZOpQMKc96QWdxKXvP+9gENQgwIQOymzHPMso/ruc/XCMGL8SLf1XGL+hfpRuh7EGBHaXYvFMOxcUNDadFKn1W0o5VVlcu4h7F1f03ud0fVaI= X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(54534003)(1096002)(19580405001)(76176999)(1220700001)(189998001)(50986999)(50226001)(586003)(106466001)(105606002)(5003940100001)(5008740100001)(3470700001)(2351001)(6806005)(86362001)(92566002)(104016004)(2906002)(229853001)(48376002)(77096005)(4326007)(85426001)(19580395003)(5001960100002)(2950100001)(47776003)(36756003)(11100500001)(110136002)(87936001)(50466002)(7059030)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0301MB2064; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 0ddb49ec-91ff-44e8-9953-08d32baf32d5 X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB2064; 2:86N2T9uI8IqDI3mxrHj1BB3ceinXJ1qArCBmR3KwtJchdsiPWQ4rOQ7CsX7om0WVOMomHBNwrWLm8W6ieqMD5JwtW6VUgzKYSOLEzMSGWWw8F1dUPTCzpMe5OcnYkECjnRFd4oQURh8pz4dfcU1GiEoIWj0Ta5Vfe9v6RHLlIWkS/XaTulZGLBSdZ6VBnVDy; 3:1lJ/bokxd1vZapROTuBjopW/4CBUrM+mC4OeX+VEvYSx1oWRew+QBt/hbWTtw17b+8miyPDoUqGYOsgd3SvlvAp7N3hqfDJif2Kf9KGKAK8YbJnSleENnR0FsT6nmSWNtc9HVXc7nHp554aW7hFg896nFsJwhhkK2k9fS9N4uQFz85n8QXEQizDb2DJSb0CSsIKw/o+Id/t0JkMqwt27xuGh76Ls1ahjqt3gewvvjFI=; 25:XR+ybvQOUn03XTk+gC89uoPFEVqs32PEaGrnq5dDa8gHvb391pGU7ILxebaCXsuhDkf3rRtuiCPfCMdzbfWsq0syjKBy5W2tcpYk4CH6t/2l2shlIOgG+7mC8AzCN2JVKOu63mcqtUAvQd3s7hbBx6vPRtO+6AEASlo6bD16edIbCsKNgwVgy/05XuXgtMqh9JSyEuT30dcVxq/cfQpbz0GqckmDTjLg1E0e//7V1FfvxClpyHRSAHB6TY22QkZt X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR0301MB2064; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13023025)(5005006)(13024025)(13018025)(13015025)(8121501046)(13017025)(10201501046)(3002001); SRVR:SN1PR0301MB2064; BCL:0; PCL:0; RULEID:(400006); SRVR:SN1PR0301MB2064; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB2064; 4:A4XRl0C86jmROcn+6dFVAFBrzjpTRZaJZKm+Y1SW3OLqg6RYHbkfd4QfsugItgbxiN3j+B4ssMjv410hCrXfTft3lxVCMpzyQoIwrTSQjzCIhaV5jb3lsSzoyxwPJaWoMzo9M/XpEiE99i/+H4O24MP/Wx1k3JRtMrzXBoX41F345IMhIUxqYzUOEUAoKBC2VfaM3EGRCCl22VeY/jLR8RzweT63XjfkBz7R5d3rJkYh8/2b57yBUJXE7DcedCz5tjmKUbfkp5E/5De89bIC9pWMbFIWw1/YdNm2dTZO3n4zZnkQ4EEhpJQp71t9KUHOBfNP8hRABT2GXzDKnAeOjDZZi5AhkdZWPogyonNHDyBT6FvqXYlmtNgP3w0APk6OWD90RLZiLCI/BgTMj7ranGzJpjoVKR6R+WQMX55Jg7FV8x8SqJLQaedDVyN9y3scCANjX09findJiUqov3RRGjdUhMDcvT7i5nROAv7ApLTr5dxio0GYSdXR/7C3sL0o X-Forefront-PRVS: 084080FC15 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0301MB2064; 23:8wRceV+dVcoUPDylcqV2xV3lpz8ioCm80g9Qb2G?= =?us-ascii?Q?roXmPJQQjsR+r1JBH7fZ3v1XTWvwMbuccVR0HpTAcY6gluKEjRD3Oau7vRPU?= =?us-ascii?Q?e7n1SRiyX+6nNeoeo6F2TMzWZuRhAkINvlRO+d0NCxQ98Ipyhdmg3mPtBt+/?= =?us-ascii?Q?qcIdzNzfS6qdB/TKTCZ2zjyObMi8HYMDJM9ni1Bzx/xjo4GNXRV2lf0A6uH/?= =?us-ascii?Q?CDoqZ6IUZY8/RbcBVIYiWcJhUbYg8qDQY3XQqhy+pD8FWNrICRLqGmkMzbWq?= =?us-ascii?Q?NzOmPOf5etY3yG8LpDV4Q33YnkOPHybnx54O3pdOzzXJkDfjXQ75NZZznkR+?= =?us-ascii?Q?aYfsDZM5M1KBOFbiReTk7UoiEImzn46CHSq9yScw9Wc4DF5kvYRmdv7ZfyPY?= =?us-ascii?Q?68P9lPYo9JJjIH8Vb+Q3QQ9zMC2PljCDFyUSBaq0Lf2oUvLLrCTaJdSJO7C+?= =?us-ascii?Q?3LAqU660WLezHHY2tLrNjIAVr+GTczHn+zofdHx8Quk6GEuFdg9YPj5vWOy9?= =?us-ascii?Q?Ys5JtgxkqYNKzIQLyK8K0VFwjsKXv0jfervvhOKs8I46QA3XlSY7Asx4jOKl?= =?us-ascii?Q?AG6XgGuHVUbhC98XY5q2Vs8jp8/abDS7fpb0Urlf/qTjCHFotkMU9HUykhSP?= =?us-ascii?Q?qaMHVavyL8gtSBig0nRcHM5lYfWU1Zo6vZ43Pq80neD/50r22Hd5LI73OVdk?= =?us-ascii?Q?IE+SKLy1BHifvmQI0C/sJwzbpZGuqFaRQuDha/2vZggrl3BUB2eJN2m05bf2?= =?us-ascii?Q?PqATBpaDd8NsWZNhh0sAr7e7n82xPZT+QfhE+PeQUiwup4i/+7iLPqzBzEQa?= =?us-ascii?Q?2BOUswe9Q0kn+PAL8LLWOtDfKz5BwCHinZ6qCag6UGjE7JQmEhUxIjw+0VR1?= =?us-ascii?Q?sFPw3TJMO/IcTydXZF9hQ+MbI4g7NowqhPOiQcEFFJSyMqU4MERopmjGNJz6?= =?us-ascii?Q?1KW/KRMgsin8jF6vQriegsrh+VByuLKaKWwuU3/5Cd/r/da/XuJFeRGPvBFb?= =?us-ascii?Q?Z74OzUsTv2xcb4WXNUV2Vtm7UD3QZyfpltOllOmVtQsTtv9sKvZw8hnVaLSY?= =?us-ascii?Q?0W8Dwn6K5iCwxee7nLwX6j/m5QY1pQP8mIDnqFt+NB05mMgF/ox3BH4G3+kr?= =?us-ascii?Q?eJG29qqCZ3ow=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB2064; 5:/7tQhyYfUlBlffsQzwraKSYmPCYLm1VXvnjTJH8LmL4t1SFV/StP8ilBINbKbAj3ZgZ1jbC3UQeLscYpPFxs5aX+ZxBp62sndRyINdmLSVdWWcxgLw/Afm+chLkdsaXPDLbM1bMo9bpXnVo5ubYSrITZ9KAFN+7K5lkTYmxsbkM=; 24:BCUM0Y1iyzouzQB96g7wafcpH9cqU5GKPABZ9U7oKL/WjPr8B/NI743K68ozQRhI9ho0/0P0cnC30d8WpHa+njqyIA3Hh+0LtnK54SGsa1s= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2016 08:59:45.9318 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0301MB2064 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160202_010008_211090_EE3F1695 X-CRM114-Status: GOOD ( 19.28 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roy Zang , Jason Cooper , Marc Zyngier , Stuart Yoder , Yang-Leo Li , Minghuan Lian , Thomas Gleixner , Mingkai Hu Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some kind of NXP Layerscape SoC provides a MSI implementation which uses two SCFG registers MSIIR and MSIR to support 32 MSI interrupts for each PCIe controller. The patch is to support it. Signed-off-by: Minghuan Lian --- Change log v3: 1. call of_node_to_fwnode() v2: 1. rename ls1-msi to ls-scfg-msi 2. remove reg-names MSIIR MSIR 3. remove calling set_irq_flags() drivers/irqchip/Kconfig | 5 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-ls-scfg-msi.c | 244 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 250 insertions(+) create mode 100644 drivers/irqchip/irq-ls-scfg-msi.c diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index fb50911..0f2a3c3 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -218,3 +218,8 @@ config IRQ_MXS def_bool y if MACH_ASM9260 || ARCH_MXS select IRQ_DOMAIN select STMP_DEVICE + +config LS_SCFG_MSI + def_bool y if SOC_LS1021A || ARCH_LAYERSCAPE + depends on PCI && PCI_MSI + select PCI_MSI_IRQ_DOMAIN diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 18caacb..37e12de 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -59,3 +59,4 @@ obj-$(CONFIG_ARCH_SA1100) += irq-sa11x0.o obj-$(CONFIG_INGENIC_IRQ) += irq-ingenic.o obj-$(CONFIG_IMX_GPCV2) += irq-imx-gpcv2.o obj-$(CONFIG_PIC32_EVIC) += irq-pic32-evic.o +obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scfg-msi.o diff --git a/drivers/irqchip/irq-ls-scfg-msi.c b/drivers/irqchip/irq-ls-scfg-msi.c new file mode 100644 index 0000000..f57a72c --- /dev/null +++ b/drivers/irqchip/irq-ls-scfg-msi.c @@ -0,0 +1,244 @@ +/* + * NXP SCFG MSI(-X) support + * + * Copyright (C) 2016 NXP Semiconductor. + * + * Author: Minghuan Lian + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MSI_MAX_IRQS 32 +#define MSI_IBS_SHIFT 3 +#define MSIR 4 + +struct ls_scfg_msi { + spinlock_t lock; + struct platform_device *pdev; + struct irq_domain *parent; + struct irq_domain *msi_domain; + void __iomem *regs; + phys_addr_t msiir_addr; + u32 nr_irqs; + int irq; + DECLARE_BITMAP(used, MSI_MAX_IRQS); +}; + +static struct irq_chip ls_scfg_msi_irq_chip = { + .name = "MSI", + .irq_enable = pci_msi_unmask_irq, + .irq_disable = pci_msi_mask_irq, + .irq_mask = pci_msi_mask_irq, + .irq_unmask = pci_msi_unmask_irq, +}; + +static struct msi_domain_info ls_scfg_msi_domain_info = { + .flags = (MSI_FLAG_USE_DEF_DOM_OPS | + MSI_FLAG_USE_DEF_CHIP_OPS | + MSI_FLAG_PCI_MSIX), + .chip = &ls_scfg_msi_irq_chip, +}; + +static void ls_scfg_msi_compose_msg(struct irq_data *data, struct msi_msg *msg) +{ + struct ls_scfg_msi *msi_data = irq_data_get_irq_chip_data(data); + + msg->address_hi = upper_32_bits(msi_data->msiir_addr); + msg->address_lo = lower_32_bits(msi_data->msiir_addr); + msg->data = data->hwirq << MSI_IBS_SHIFT; +} + +static int ls_scfg_msi_set_affinity(struct irq_data *irq_data, + const struct cpumask *mask, bool force) +{ + return -EINVAL; +} + +static struct irq_chip ls_scfg_msi_parent_chip = { + .name = "LS SCFG MSI", + .irq_compose_msi_msg = ls_scfg_msi_compose_msg, + .irq_set_affinity = ls_scfg_msi_set_affinity, +}; + +static int ls_scfg_msi_domain_irq_alloc(struct irq_domain *domain, + unsigned int virq, + unsigned int nr_irqs, + void *args) +{ + struct ls_scfg_msi *msi_data = domain->host_data; + int pos, err = 0; + + WARN_ON(nr_irqs != 1); + + spin_lock(&msi_data->lock); + pos = find_first_zero_bit(msi_data->used, msi_data->nr_irqs); + if (pos < msi_data->nr_irqs) + __set_bit(pos, msi_data->used); + else + err = -ENOSPC; + spin_unlock(&msi_data->lock); + + if (err) + return err; + + irq_domain_set_info(domain, virq, pos, + &ls_scfg_msi_parent_chip, msi_data, + handle_simple_irq, NULL, NULL); + + return 0; +} + +static void ls_scfg_msi_domain_irq_free(struct irq_domain *domain, + unsigned int virq, unsigned int nr_irqs) +{ + struct irq_data *d = irq_domain_get_irq_data(domain, virq); + struct ls_scfg_msi *msi_data = irq_data_get_irq_chip_data(d); + int pos; + + pos = d->hwirq; + if (pos < 0 || pos >= msi_data->nr_irqs) { + pr_err("failed to teardown msi. Invalid hwirq %d\n", pos); + return; + } + + spin_lock(&msi_data->lock); + __clear_bit(pos, msi_data->used); + spin_unlock(&msi_data->lock); +} + +static const struct irq_domain_ops ls_scfg_msi_domain_ops = { + .alloc = ls_scfg_msi_domain_irq_alloc, + .free = ls_scfg_msi_domain_irq_free, +}; + +static void ls_scfg_msi_irq_handler(struct irq_desc *desc) +{ + struct ls_scfg_msi *msi_data = irq_desc_get_handler_data(desc); + unsigned long val; + int pos, virq; + + chained_irq_enter(irq_desc_get_chip(desc), desc); + + val = ioread32be(msi_data->regs + MSIR); + for_each_set_bit(pos, &val, msi_data->nr_irqs) { + virq = irq_find_mapping(msi_data->parent, (31 - pos)); + if (virq) + generic_handle_irq(virq); + } + + chained_irq_exit(irq_desc_get_chip(desc), desc); +} + +static int ls_scfg_msi_domains_init(struct ls_scfg_msi *msi_data) +{ + /* Initialize MSI domain parent */ + msi_data->parent = irq_domain_add_linear(NULL, + msi_data->nr_irqs, + &ls_scfg_msi_domain_ops, + msi_data); + if (!msi_data->parent) { + dev_err(&msi_data->pdev->dev, "failed to create IRQ domain\n"); + return -ENOMEM; + } + + msi_data->msi_domain = pci_msi_create_irq_domain( + of_node_to_fwnode(msi_data->pdev->dev.of_node), + &ls_scfg_msi_domain_info, + msi_data->parent); + if (!msi_data->msi_domain) { + dev_err(&msi_data->pdev->dev, "failed to create MSI domain\n"); + irq_domain_remove(msi_data->parent); + return -ENOMEM; + } + + return 0; +} + +static int ls_scfg_msi_probe(struct platform_device *pdev) +{ + struct ls_scfg_msi *msi_data; + struct resource *res; + int ret; + + msi_data = devm_kzalloc(&pdev->dev, sizeof(*msi_data), GFP_KERNEL); + if (!msi_data) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + msi_data->regs = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(msi_data->regs)) { + dev_err(&pdev->dev, "failed to initialize 'regs'\n"); + return PTR_ERR(msi_data->regs); + } + msi_data->msiir_addr = res->start; + + msi_data->irq = platform_get_irq(pdev, 0); + if (msi_data->irq <= 0) { + dev_err(&pdev->dev, "failed to get MSI irq\n"); + return -ENODEV; + } + + msi_data->pdev = pdev; + msi_data->nr_irqs = MSI_MAX_IRQS; + spin_lock_init(&msi_data->lock); + + ret = ls_scfg_msi_domains_init(msi_data); + if (ret) + return ret; + + irq_set_chained_handler_and_data(msi_data->irq, + ls_scfg_msi_irq_handler, + msi_data); + + platform_set_drvdata(pdev, msi_data); + + return 0; +} + +static int ls_scfg_msi_remove(struct platform_device *pdev) +{ + struct ls_scfg_msi *msi_data = platform_get_drvdata(pdev); + + irq_set_chained_handler_and_data(msi_data->irq, NULL, NULL); + + irq_domain_remove(msi_data->msi_domain); + irq_domain_remove(msi_data->parent); + + platform_set_drvdata(pdev, NULL); + + return 0; +} + +static const struct of_device_id ls_scfg_msi_id[] = { + { .compatible = "fsl,1s1021a-msi", }, + { .compatible = "fsl,1s1043a-msi", }, + {}, +}; + +static struct platform_driver ls_scfg_msi_driver = { + .driver = { + .name = "ls-scfg-msi", + .of_match_table = ls_scfg_msi_id, + }, + .probe = ls_scfg_msi_probe, + .remove = ls_scfg_msi_remove, +}; + +module_platform_driver(ls_scfg_msi_driver); + +MODULE_AUTHOR("Minghuan Lian "); +MODULE_DESCRIPTION("NXP Layerscape SCFG MSI controller driver"); +MODULE_LICENSE("GPL v2");