From patchwork Thu Aug 8 16:02:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13757793 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2046.outbound.protection.outlook.com [40.107.105.46]) (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 23ABB190497; Thu, 8 Aug 2024 16:02:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723132962; cv=fail; b=q78CFxzJrifWck1zHBbQyuWVHAt1RRi8g4TSJ4MFyBsoi8HnDJ9trxGcCFZdm8YSrwlZgaIoIm+EROU9MmDpzjzjdzw+kHvTLam9Br+JErVNnIo22x+QNTM8QLaDE8bbbnKaSXw76t04OUicfWvWS1rhhYXE14EtUDOBrJ19If0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723132962; c=relaxed/simple; bh=IT58rxx6GAnzyh6EZ4QitPY28FLzxZxYWgpVhHaKNbo=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=VQ2qeD3oDETUzAgbjDS+osex9C/lAXKuqp7SKbDo0+2/Fs+/c1p082xDmvwbOcQh6O9jHMf9dg/Qt0Cx7IvFpUVgFDhV4tT4gCg/c78Qsbhbu6MjJ/skPWQQmIpVR9TjEIHcjfMDnU7T+59n8sMX6eM+Pxvrj+HH65IrL/B5/Z4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=T3czJqX4; arc=fail smtp.client-ip=40.107.105.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="T3czJqX4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pzrnY5HF0W8ogN0zOWUOUn/ZrK3cadnA9WOS9nL8eYtu5lUFdva/9zSvrB52lrhVty0VXcbOm6rJGJmy3DmK6B9No8ZE1ABmhqg39oeXCYJHekYSCWK4lyDH9nDTjQ1EC50ZGRMKX2Z9mZF2FNop7c0KPfGJUG/n5WzZ8rjhpMnxKoHb7jQtfQW60P4IpdpWl7sIFQU+tYmmeW1lH9XaYKTH5m9FFflBL9GcYDYTjENNTz1phhUfYLmhPCGPlpmD5NJ1UTxuPi5Ju+JIabZiwpHCT+AolihaSIk92+YwDjvnr1GiU93qZtts1tptosKtRlUVYBg/kOPhWCAa+tFPMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=WJffP1cPktpVmM6FnqFa8Gx/n+Dxs02ZuGkd1H1Qokg=; b=s/Bav082vPtLrLAAtdHNYyMeyNWM2jZyyhlQC3/k08TIYIp+lPNxR53+er0uw4P0RRMzociLF38nJSI5w7hDz7VYIu55UHv/9PFMjOeoBr/c3/0IssyqpqU2Hww1N5KizdI8LQ71ftt0vUF3QgJP39Re+EZ8PCq25qU5u8i9zNPWQ6U7swHxtt8gmHNcejDs3tTNZ7yLAmF44z1r97oD3iM0G9H3iaMtobKIOI0nEuwSuAg1YklbKteGAIoZLFMKGu1yZQBy9RpjarlIwGePQyZGDT9wui00RdbslGU3Hc/K7q6eiJP6f6/cs6lkd5cLPZS2W7Q8A3Cul3rycw4pHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WJffP1cPktpVmM6FnqFa8Gx/n+Dxs02ZuGkd1H1Qokg=; b=T3czJqX4GvSP+6kVMkU9gvHDG293FMn0f+1nQokV+jqiPml8xyN1KxU1Chjwhb5W4CInVo8tmaDbaw/YsDKwLcykJaX0o9KeY2eGvR5l0kwWkCJBrO5kxHTj9XUQA+IUiaOVen+u2QZW7P/hq/kpfmofcrpJJW9k8yWMYjSUwVp4S59vnUG+yun946bhzT1iXsncwvXeCa3LRj6ff2gdppus+yJtXZ/Eu/lem8ezjsBpmY839tMIG+adsSalkJpg3p5Xst5uJZS08y8gV7ub6XtWZZlEQVO3faToR/YehRwHcgbAXn5uQxkkN1DrHhGYW+a/ZSaV4JTAxMk4EJZS3w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by PA4PR04MB9568.eurprd04.prod.outlook.com (2603:10a6:102:26e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27; Thu, 8 Aug 2024 16:02:37 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.7828.023; Thu, 8 Aug 2024 16:02:37 +0000 From: Frank Li Date: Thu, 08 Aug 2024 12:02:16 -0400 Subject: [PATCH 3/4] PCI: mobiveil: Drop layerscape-gen4 support Message-Id: <20240808-mobivel_cleanup-v1-3-f4f6ea5b16de@nxp.com> References: <20240808-mobivel_cleanup-v1-0-f4f6ea5b16de@nxp.com> In-Reply-To: <20240808-mobivel_cleanup-v1-0-f4f6ea5b16de@nxp.com> To: Bjorn Helgaas , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Zhiqiang.Hou@nxp.com Cc: linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1723132945; l=8722; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=IT58rxx6GAnzyh6EZ4QitPY28FLzxZxYWgpVhHaKNbo=; b=CVEdZtYbfOsojj7KEEMR0N7pWndr+FXQoZ0k5Lhm0NO//dtiaGzO/1CiYKX3feUIdqKm+QMH0 ZDtcy0ZlO+QDCAs9ZUhA91jS6EfVP3V+IMLyOrf21mPmILC3jxSXmd3 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0203.namprd13.prod.outlook.com (2603:10b6:a03:2c3::28) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|PA4PR04MB9568:EE_ X-MS-Office365-Filtering-Correlation-Id: ccec03b4-715d-4c7a-7413-08dcb7c38638 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|52116014|366016|7416014|38350700014; X-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XD0jRmViYTUJLCWfpjLCibVZI4Tn4mP3o7ntkf0xpuTNPwPh+cDO3QRs?= =?utf-8?q?Y7N4vlwCKH2Zc3C51hFWomE999ybB//xOszUNaLkvSsnR0cHKFU7TT7Ii1SPTpCIw?= =?utf-8?q?/5uA5Ocpro8+mcdfNEmrwD8Vm47LtRzzuqbFtMc36dtNguBRqU694ND8zrMci+Tql?= =?utf-8?q?LuwLgOXPAhBpwraUaZrUDI5DAnegTVSbBTZ/LwMPyKnubsfsoN0rO4THmAlfJ+SFj?= =?utf-8?q?ahdxXs5Ovj/iCTxHftR62QDtJvGtupPsJKBiPmeq0bAmc6tB++M0xyiwE2Ji8J3eV?= =?utf-8?q?ms9x/KI+cC0MQleiQdLNqP8xVmEFSZpfs+PEF3gXWlyXO/PWQxbjlp6DxGZYy2Z35?= =?utf-8?q?JMtS6wH5osLXgYBZrMG8ZUem/9pdPvDp60NYW1hCrAvSjeXnR7hdyLvDMqdq4t0wP?= =?utf-8?q?8u449opLQvB9dpo4J4w3qHqZFq4D/acMqLHcwXY98jCtFmBdaLK8u4tRnjx+mgGOI?= =?utf-8?q?XknWzFFkSSv3N1yib7d8w2EM6HMkk1Maow=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(52116014)(366016)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?a1KQF9vvNtXf6xKv8PoPUZeclul2?= =?utf-8?q?KuImyOfJ+OTeHgxo2mnr7hNC3bX2Hfj1ZFMlktL72JFANr7DO7geWs8w3dQX1J7i+?= =?utf-8?q?5uv/qvOrVa7oxIcKJckz0b0u4YXvOrFkFN1pM0vi1TBy3Rl1z2UoUFqHx60ddq5Uq?= =?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3lhLwc5UVBJ97XYsXYqxVmyC7ZYKGFQGYDugfvLk3KOBUGT5xcdY8KlbN91?= =?utf-8?q?oHFjmdGB4AluRCCf7Pib7rAwpsdjSbARfweuDqgECOUx2FgF1/q4CoQMBzvd/55E7?= =?utf-8?q?Kkkv3uoaH/nWo4y/wFMnUVo5ouhmwjJu/ainqJP99xz7VCTAoC4fWGo09fquyHWOn?= =?utf-8?q?VkkXRx/TPcV/LVkACWl19OvB7eWjReb+Y587zX254r7GFye7NA3N1g2w3lCHRsc4k?= =?utf-8?q?5Gv6g0OAl1x0pRbHTLuJVMYMfzfJJkDKiEvFYUFEOGRa3CA93mfoanQrBKvaZR7Ai?= =?utf-8?q?cxVD8spuhC0xQ68v6+BNIXV3iqGWmnaK2F4zHyD4jhWUz9KB7n52zfYFOILECVoly?= =?utf-8?q?noAxYAFdbMDW2l1eM32VzXhx5CYKH0k1PBd0g37MvSdrwnFBvbOH0d+Q90tr+rx9Y?= =?utf-8?q?iflbaHUU/wPNtpvh1bmlzOzrsSy59PJ7hxioL0ny9p6Wj0HKJ2a9Ev/vuiJegY2mK?= =?utf-8?q?EN4mwyphtk7w?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ccec03b4-715d-4c7a-7413-08dcb7c38638 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2024 16:02:37.8813 (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: b94emaEUeI6CX+U693s7I7g1uCh6DH82v12/lOL2JJqWqoRK9H1shfL/gzZiLSg90n+3+VUQn6SMyqdgvSOyPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9568 Only lx2160 rev1 use mobiveil PCIe controller. Rev2 switch to designware PCIe controller. Rev2 is mass production chip and Rev1 will be not supported. So drop related code. Signed-off-by: Frank Li --- drivers/pci/controller/mobiveil/Kconfig | 9 - drivers/pci/controller/mobiveil/Makefile | 1 - .../pci/controller/mobiveil/pcie-layerscape-gen4.c | 255 --------------------- 3 files changed, 265 deletions(-) diff --git a/drivers/pci/controller/mobiveil/Kconfig b/drivers/pci/controller/mobiveil/Kconfig index 58ce034f701ab..89b8ce9e1262f 100644 --- a/drivers/pci/controller/mobiveil/Kconfig +++ b/drivers/pci/controller/mobiveil/Kconfig @@ -11,15 +11,6 @@ config PCIE_MOBIVEIL_HOST depends on PCI_MSI select PCIE_MOBIVEIL -config PCIE_LAYERSCAPE_GEN4 - bool "Freescale Layerscape Gen4 PCIe controller" - depends on ARCH_LAYERSCAPE || COMPILE_TEST - depends on PCI_MSI - select PCIE_MOBIVEIL_HOST - help - Say Y here if you want PCIe Gen4 controller support on - Layerscape SoCs. - config PCIE_MOBIVEIL_PLAT bool "Mobiveil AXI PCIe controller" depends on ARCH_ZYNQMP || COMPILE_TEST diff --git a/drivers/pci/controller/mobiveil/Makefile b/drivers/pci/controller/mobiveil/Makefile index 99d879de32d6e..9fb6d1c6504dc 100644 --- a/drivers/pci/controller/mobiveil/Makefile +++ b/drivers/pci/controller/mobiveil/Makefile @@ -2,4 +2,3 @@ obj-$(CONFIG_PCIE_MOBIVEIL) += pcie-mobiveil.o obj-$(CONFIG_PCIE_MOBIVEIL_HOST) += pcie-mobiveil-host.o obj-$(CONFIG_PCIE_MOBIVEIL_PLAT) += pcie-mobiveil-plat.o -obj-$(CONFIG_PCIE_LAYERSCAPE_GEN4) += pcie-layerscape-gen4.o diff --git a/drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c b/drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c deleted file mode 100644 index 5af22bee913bd..0000000000000 --- a/drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c +++ /dev/null @@ -1,255 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * PCIe Gen4 host controller driver for NXP Layerscape SoCs - * - * Copyright 2019-2020 NXP - * - * Author: Zhiqiang Hou - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "pcie-mobiveil.h" - -/* LUT and PF control registers */ -#define PCIE_LUT_OFF 0x80000 -#define PCIE_PF_OFF 0xc0000 -#define PCIE_PF_INT_STAT 0x18 -#define PF_INT_STAT_PABRST BIT(31) - -#define PCIE_PF_DBG 0x7fc -#define PF_DBG_LTSSM_MASK 0x3f -#define PF_DBG_LTSSM_L0 0x2d /* L0 state */ -#define PF_DBG_WE BIT(31) -#define PF_DBG_PABR BIT(27) - -#define to_ls_g4_pcie(x) platform_get_drvdata((x)->pdev) - -struct ls_g4_pcie { - struct mobiveil_pcie pci; - struct delayed_work dwork; - int irq; -}; - -static inline u32 ls_g4_pcie_pf_readl(struct ls_g4_pcie *pcie, u32 off) -{ - return ioread32(pcie->pci.csr_axi_slave_base + PCIE_PF_OFF + off); -} - -static inline void ls_g4_pcie_pf_writel(struct ls_g4_pcie *pcie, - u32 off, u32 val) -{ - iowrite32(val, pcie->pci.csr_axi_slave_base + PCIE_PF_OFF + off); -} - -static int ls_g4_pcie_link_up(struct mobiveil_pcie *pci) -{ - struct ls_g4_pcie *pcie = to_ls_g4_pcie(pci); - u32 state; - - state = ls_g4_pcie_pf_readl(pcie, PCIE_PF_DBG); - state = state & PF_DBG_LTSSM_MASK; - - if (state == PF_DBG_LTSSM_L0) - return 1; - - return 0; -} - -static void ls_g4_pcie_disable_interrupt(struct ls_g4_pcie *pcie) -{ - struct mobiveil_pcie *mv_pci = &pcie->pci; - - mobiveil_csr_writel(mv_pci, 0, PAB_INTP_AMBA_MISC_ENB); -} - -static void ls_g4_pcie_enable_interrupt(struct ls_g4_pcie *pcie) -{ - struct mobiveil_pcie *mv_pci = &pcie->pci; - u32 val; - - /* Clear the interrupt status */ - mobiveil_csr_writel(mv_pci, 0xffffffff, PAB_INTP_AMBA_MISC_STAT); - - val = PAB_INTP_INTX_MASK | PAB_INTP_MSI | PAB_INTP_RESET | - PAB_INTP_PCIE_UE | PAB_INTP_IE_PMREDI | PAB_INTP_IE_EC; - mobiveil_csr_writel(mv_pci, val, PAB_INTP_AMBA_MISC_ENB); -} - -static int ls_g4_pcie_reinit_hw(struct ls_g4_pcie *pcie) -{ - struct mobiveil_pcie *mv_pci = &pcie->pci; - struct device *dev = &mv_pci->pdev->dev; - u32 val, act_stat; - int to = 100; - - /* Poll for pab_csb_reset to set and PAB activity to clear */ - do { - usleep_range(10, 15); - val = ls_g4_pcie_pf_readl(pcie, PCIE_PF_INT_STAT); - act_stat = mobiveil_csr_readl(mv_pci, PAB_ACTIVITY_STAT); - } while (((val & PF_INT_STAT_PABRST) == 0 || act_stat) && to--); - if (to < 0) { - dev_err(dev, "Poll PABRST&PABACT timeout\n"); - return -EIO; - } - - /* clear PEX_RESET bit in PEX_PF0_DBG register */ - val = ls_g4_pcie_pf_readl(pcie, PCIE_PF_DBG); - val |= PF_DBG_WE; - ls_g4_pcie_pf_writel(pcie, PCIE_PF_DBG, val); - - val = ls_g4_pcie_pf_readl(pcie, PCIE_PF_DBG); - val |= PF_DBG_PABR; - ls_g4_pcie_pf_writel(pcie, PCIE_PF_DBG, val); - - val = ls_g4_pcie_pf_readl(pcie, PCIE_PF_DBG); - val &= ~PF_DBG_WE; - ls_g4_pcie_pf_writel(pcie, PCIE_PF_DBG, val); - - mobiveil_host_init(mv_pci, true); - - to = 100; - while (!ls_g4_pcie_link_up(mv_pci) && to--) - usleep_range(200, 250); - if (to < 0) { - dev_err(dev, "PCIe link training timeout\n"); - return -EIO; - } - - return 0; -} - -static irqreturn_t ls_g4_pcie_isr(int irq, void *dev_id) -{ - struct ls_g4_pcie *pcie = (struct ls_g4_pcie *)dev_id; - struct mobiveil_pcie *mv_pci = &pcie->pci; - u32 val; - - val = mobiveil_csr_readl(mv_pci, PAB_INTP_AMBA_MISC_STAT); - if (!val) - return IRQ_NONE; - - if (val & PAB_INTP_RESET) { - ls_g4_pcie_disable_interrupt(pcie); - schedule_delayed_work(&pcie->dwork, msecs_to_jiffies(1)); - } - - mobiveil_csr_writel(mv_pci, val, PAB_INTP_AMBA_MISC_STAT); - - return IRQ_HANDLED; -} - -static int ls_g4_pcie_interrupt_init(struct mobiveil_pcie *mv_pci) -{ - struct ls_g4_pcie *pcie = to_ls_g4_pcie(mv_pci); - struct platform_device *pdev = mv_pci->pdev; - struct device *dev = &pdev->dev; - int ret; - - pcie->irq = platform_get_irq_byname(pdev, "intr"); - if (pcie->irq < 0) - return pcie->irq; - - ret = devm_request_irq(dev, pcie->irq, ls_g4_pcie_isr, - IRQF_SHARED, pdev->name, pcie); - if (ret) { - dev_err(dev, "Can't register PCIe IRQ, errno = %d\n", ret); - return ret; - } - - return 0; -} - -static void ls_g4_pcie_reset(struct work_struct *work) -{ - struct delayed_work *dwork = container_of(work, struct delayed_work, - work); - struct ls_g4_pcie *pcie = container_of(dwork, struct ls_g4_pcie, dwork); - struct mobiveil_pcie *mv_pci = &pcie->pci; - u16 ctrl; - - ctrl = mobiveil_csr_readw(mv_pci, PCI_BRIDGE_CONTROL); - ctrl &= ~PCI_BRIDGE_CTL_BUS_RESET; - mobiveil_csr_writew(mv_pci, ctrl, PCI_BRIDGE_CONTROL); - - if (!ls_g4_pcie_reinit_hw(pcie)) - return; - - ls_g4_pcie_enable_interrupt(pcie); -} - -static const struct mobiveil_rp_ops ls_g4_pcie_rp_ops = { - .interrupt_init = ls_g4_pcie_interrupt_init, -}; - -static const struct mobiveil_pab_ops ls_g4_pcie_pab_ops = { - .link_up = ls_g4_pcie_link_up, -}; - -static int __init ls_g4_pcie_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct pci_host_bridge *bridge; - struct mobiveil_pcie *mv_pci; - struct ls_g4_pcie *pcie; - struct device_node *np = dev->of_node; - int ret; - - if (!of_parse_phandle(np, "msi-parent", 0)) { - dev_err(dev, "Failed to find msi-parent\n"); - return -EINVAL; - } - - bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie)); - if (!bridge) - return -ENOMEM; - - pcie = pci_host_bridge_priv(bridge); - mv_pci = &pcie->pci; - - mv_pci->pdev = pdev; - mv_pci->ops = &ls_g4_pcie_pab_ops; - mv_pci->rp.ops = &ls_g4_pcie_rp_ops; - mv_pci->rp.bridge = bridge; - - platform_set_drvdata(pdev, pcie); - - INIT_DELAYED_WORK(&pcie->dwork, ls_g4_pcie_reset); - - ret = mobiveil_pcie_host_probe(mv_pci); - if (ret) { - dev_err(dev, "Fail to probe\n"); - return ret; - } - - ls_g4_pcie_enable_interrupt(pcie); - - return 0; -} - -static const struct of_device_id ls_g4_pcie_of_match[] = { - { .compatible = "fsl,lx2160a-pcie", }, - { }, -}; - -static struct platform_driver ls_g4_pcie_driver = { - .driver = { - .name = "layerscape-pcie-gen4", - .of_match_table = ls_g4_pcie_of_match, - .suppress_bind_attrs = true, - }, -}; - -builtin_platform_driver_probe(ls_g4_pcie_driver, ls_g4_pcie_probe);