Received: by 2002:a17:906:6698:b0:a28:f940:7a27 with SMTP id z24csp1849493ejo; Sun, 7 Jan 2024 08:57:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHb6GtnP3yb0LdmAUahSDeYVdjjMq5FByxKKfDWmEw6FtrT3qpdgTW5OJq/nwkEy6G/M0ZI X-Received: by 2002:a05:620a:1a1d:b0:781:5881:aa6a with SMTP id bk29-20020a05620a1a1d00b007815881aa6amr3409634qkb.1.1704646651536; Sun, 07 Jan 2024 08:57:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704646651; cv=none; d=google.com; s=arc-20160816; b=NyF1zWSJC8jEB5ujm2AST+QUiXIPka6+olCu6ncrlo49S9w1WzgZq9o11Z/j2tZGZr TpjuPcGHIRghnXbpZDvoof7vsVmuBfMLhhw6rT4ilGPAxdgDiR0pThX0L/KD84LnUkK+ t4iLPZgKqtK+oedKIBfmCRlQz8jgLJ5HxxtLACAodU9nrHzkadQsBXgg+sy0wMKZJjcG ESZf6OzhjjPPYps6OGFUH7qbE9GiPS2+CJKMvHSSGuGK4zOd6JI50h9c5LcG8Pz7S6/x mARryLXjDuNPCZS6Q6AIgNS2v7plMj14ysX/WtjMzBYVKYHcwCluqbLS+ZRyXeFLdJL0 YvIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=Iq8Y5yMM9yB95mE/Oe79R4F4jxbBO9DlK4fUkRgZxIg=; fh=lkJ8bnsb+E7lC0TyS1z7PaQ29EdiPyWkP0iCl2/TEcg=; b=sPubgmcGTPSV6PTmC7+TEjTLAFO5LBVzy1QWgasQ7pjE6ooeR33qtw4LhV8mQpdiDi yJa5c0xBGgf715XwyPPMx5h4LenGDCmci0c0cNWnov3ddqd8Z2wyb2mzbzFxPGZNT9rv JFFT+zTo8jzag7ZsJ6LyCmtRh/F8MI5KB6Qoeo9EKjqxYrBj7Fr0myhLcbyA0dSGXSzo PAd+mYxqiclHCD5NYhiMaf0tMKrAcOUcFHb9dmLHoIi6SsDNgbpcmNPKMp2EKdbkHJ+k 9rVbBflPh3GSCHw5WDbaLJkNwLF6lSRv+f6DJ+LNNFh7YUHp8+BjNPE4XRM3WlVucjHH +kew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=i3uSgXAg; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y14-20020a05620a25ce00b007818450b8adsi6214114qko.255.2024.01.07.08.57.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 07 Jan 2024 08:57:31 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=i3uSgXAg; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rMWSj-0007CU-RU; Sun, 07 Jan 2024 11:57:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rMWSg-0007Bf-SW; Sun, 07 Jan 2024 11:57:22 -0500 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rMWSf-0003oB-2p; Sun, 07 Jan 2024 11:57:22 -0500 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2ccb4adbffbso11198711fa.0; Sun, 07 Jan 2024 08:57:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704646638; x=1705251438; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Iq8Y5yMM9yB95mE/Oe79R4F4jxbBO9DlK4fUkRgZxIg=; b=i3uSgXAgKvRHr+k7L/wCGjhF5yzh6swiDdYbJq39LNJ7YkczqeUQn1Q08y692EF1DP VyHQbQiQ1LZqLAjCASBtJ2JtFA6tZt8LWAbSegrPSAoz04qKZQVkB75oXR+QzMUPzk1v EGTEJLEju1TIKOs0BWmCorK3xgmsts8b5PeJOLBa7rzi3bH9I192vhA3rngRciExxET4 RPR4ZECK+Cng9x2/qHD/81FBOZW97GwyJNdQ5iypqhivwp7aioI2Asd7wa9/eApTXFwu v596dZRqOPk6gpwDarNs6rxQMiLc8zFVH+cD2Qb8S9PZR9lNLOqyg4bM/B/puKsXLik+ Etow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704646638; x=1705251438; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Iq8Y5yMM9yB95mE/Oe79R4F4jxbBO9DlK4fUkRgZxIg=; b=kbm7bjKV+UpMF37GVcSRdMkuV+KuiBTncSJX11IIVCvoCA6WkZIsvJX5GTcmAhbZ1y tGkB0EaaePanANfB63gmhYZwI5qmNgrb5kqQfJtYMZgG4+44nhxL4cpWQgPbr6ZwEQps KBMDy7ydgF8fVOXwLGPMyPfHitelzSQHYUZwZeRDSNghdpjbMOootZldSzJKHbtQdUE6 K8APDj4XhxdU4gd7LKlAUfRRBghAbXwR3BXrxSHV/5P6HcoVS5p/8LGgsTubnNZISiHH nGSmIGANpgEJjbRg1mD7lOk4er32jGruRPjk1FpHRk7sXv5UCrYT6PqCMcEyRVQ/E9NG PoNw== X-Gm-Message-State: AOJu0Yx3OLCbEjSjFUZ8gpHP/pfs4liQjpfYJIfIc0LSoDmxgq6jbIsO kQZ4qMFLvdBdxszM5D6L+QFhrrNYK6rHIw2YduU= X-Received: by 2002:a2e:a590:0:b0:2cc:6210:1dce with SMTP id m16-20020a2ea590000000b002cc62101dcemr1157877ljp.4.1704646637956; Sun, 07 Jan 2024 08:57:17 -0800 (PST) Received: from localhost.localdomain ([176.120.189.69]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9658000000b002cd52b9a020sm281671ljh.94.2024.01.07.08.57.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jan 2024 08:57:17 -0800 (PST) From: Nikita Ostrenkov To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Jean-Christophe Dubois , Peter Maydell , Paolo Bonzini , Nikita Ostrenkov Subject: [PATCH] hw/arm: add PCIe to Freescale i.MX6 Date: Sun, 7 Jan 2024 16:57:02 +0000 Message-Id: <20240107165702.47819-1-n.ostrenkov@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::234; envelope-from=n.ostrenkov@gmail.com; helo=mail-lj1-x234.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: Ceqc98ADVJfP Signed-off-by: Nikita Ostrenkov --- hw/arm/Kconfig | 3 +++ hw/arm/fsl-imx6.c | 25 ++++++++++++++++++++++ include/hw/arm/fsl-imx6.h | 44 ++++++++++++++++++++------------------- 3 files changed, 51 insertions(+), 21 deletions(-) diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 660f49db49..575bb68c76 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -530,13 +530,16 @@ config FSL_IMX31 config FSL_IMX6 bool + imply PCI_DEVICES imply I2C_DEVICES select A9MPCORE + select PCI select IMX select IMX_FEC select IMX_I2C select IMX_USBPHY select WDT_IMX2 + select PCI_EXPRESS_DESIGNWARE select SDHCI config ASPEED_SOC diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c index b2153022c0..27702b6d6d 100644 --- a/hw/arm/fsl-imx6.c +++ b/hw/arm/fsl-imx6.c @@ -22,6 +22,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "hw/arm/fsl-imx6.h" +#include "hw/misc/unimp.h" #include "hw/usb/imx-usb-phy.h" #include "hw/boards.h" #include "hw/qdev-properties.h" @@ -102,6 +103,8 @@ static void fsl_imx6_init(Object *obj) object_initialize_child(obj, "eth", &s->eth, TYPE_IMX_ENET); + + object_initialize_child(obj, "pcie", &s->pcie, TYPE_DESIGNWARE_PCIE_HOST); } static void fsl_imx6_realize(DeviceState *dev, Error **errp) @@ -109,6 +112,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) MachineState *ms = MACHINE(qdev_get_machine()); FslIMX6State *s = FSL_IMX6(dev); uint16_t i; + qemu_irq irq; unsigned int smp_cpus = ms->smp.cpus; if (smp_cpus > FSL_IMX6_NUM_CPUS) { @@ -421,6 +425,27 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) FSL_IMX6_WDOGn_IRQ[i])); } + /* + * PCIe + */ + sysbus_realize(SYS_BUS_DEVICE(&s->pcie), &error_abort); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->pcie), 0, FSL_IMX6_PCIe_REG_ADDR); + + irq = qdev_get_gpio_in(DEVICE(&s->a9mpcore), FSL_IMX6_PCIE1_IRQ); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 0, irq); + irq = qdev_get_gpio_in(DEVICE(&s->a9mpcore), FSL_IMX6_PCIE2_IRQ); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 1, irq); + irq = qdev_get_gpio_in(DEVICE(&s->a9mpcore), FSL_IMX6_PCIE3_IRQ); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 2, irq); + irq = qdev_get_gpio_in(DEVICE(&s->a9mpcore), FSL_IMX6_PCIE4_IRQ); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 3, irq); + + /* + * PCIe PHY + */ + create_unimplemented_device("pcie-phy", FSL_IMX6_PCIe_ADDR, + FSL_IMX6_PCIe_SIZE); + /* ROM memory */ if (!memory_region_init_rom(&s->rom, OBJECT(dev), "imx6.rom", FSL_IMX6_ROM_SIZE, errp)) { diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h index 519b871014..61c593ffd2 100644 --- a/include/hw/arm/fsl-imx6.h +++ b/include/hw/arm/fsl-imx6.h @@ -32,6 +32,7 @@ #include "hw/net/imx_fec.h" #include "hw/usb/chipidea.h" #include "hw/usb/imx-usb-phy.h" +#include "hw/pci-host/designware.h" #include "exec/memory.h" #include "cpu.h" #include "qom/object.h" @@ -55,27 +56,28 @@ struct FslIMX6State { DeviceState parent_obj; /*< public >*/ - ARMCPU cpu[FSL_IMX6_NUM_CPUS]; - A9MPPrivState a9mpcore; - IMX6CCMState ccm; - IMX6SRCState src; - IMX7SNVSState snvs; - IMXSerialState uart[FSL_IMX6_NUM_UARTS]; - IMXGPTState gpt; - IMXEPITState epit[FSL_IMX6_NUM_EPITS]; - IMXI2CState i2c[FSL_IMX6_NUM_I2CS]; - IMXGPIOState gpio[FSL_IMX6_NUM_GPIOS]; - SDHCIState esdhc[FSL_IMX6_NUM_ESDHCS]; - IMXSPIState spi[FSL_IMX6_NUM_ECSPIS]; - IMX2WdtState wdt[FSL_IMX6_NUM_WDTS]; - IMXUSBPHYState usbphy[FSL_IMX6_NUM_USB_PHYS]; - ChipideaState usb[FSL_IMX6_NUM_USBS]; - IMXFECState eth; - MemoryRegion rom; - MemoryRegion caam; - MemoryRegion ocram; - MemoryRegion ocram_alias; - uint32_t phy_num; + ARMCPU cpu[FSL_IMX6_NUM_CPUS]; + A9MPPrivState a9mpcore; + IMX6CCMState ccm; + IMX6SRCState src; + IMX7SNVSState snvs; + IMXSerialState uart[FSL_IMX6_NUM_UARTS]; + IMXGPTState gpt; + IMXEPITState epit[FSL_IMX6_NUM_EPITS]; + IMXI2CState i2c[FSL_IMX6_NUM_I2CS]; + IMXGPIOState gpio[FSL_IMX6_NUM_GPIOS]; + SDHCIState esdhc[FSL_IMX6_NUM_ESDHCS]; + IMXSPIState spi[FSL_IMX6_NUM_ECSPIS]; + IMX2WdtState wdt[FSL_IMX6_NUM_WDTS]; + IMXUSBPHYState usbphy[FSL_IMX6_NUM_USB_PHYS]; + ChipideaState usb[FSL_IMX6_NUM_USBS]; + IMXFECState eth; + DesignwarePCIEHost pcie; + MemoryRegion rom; + MemoryRegion caam; + MemoryRegion ocram; + MemoryRegion ocram_alias; + uint32_t phy_num; }; -- 2.34.1