Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2033055lqo; Sun, 19 May 2024 09:56:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXIQWpXavpdsZZvgB9arPq0wWnGFSBXgaNQEE0DPOiZ4ANpwBYAoh5Ej9d3xtKkGehgooBCPRX53KZ0nHLmO3Vb9IFgI/2Ze0/oAPESFg== X-Google-Smtp-Source: AGHT+IEQr2aHemhblDJAE3dbM4ko6N0HbhmbLSqiHei5ocScpo9TaA0amhdcX8RAtH5Qp+Rd61xl X-Received: by 2002:ac8:574d:0:b0:436:8611:8575 with SMTP id d75a77b69052e-43dfdaaa072mr308988331cf.18.1716137793978; Sun, 19 May 2024 09:56:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716137793; cv=pass; d=google.com; s=arc-20160816; b=PP/f6RmUuTU55W+64ywCzV6meOOynF3oRe3c5IGVJkrgJmDziZ1CCA+q3COxff2yX+ ZmePE6v5C8InvCt3aXRYHjZokwHf8mByLiKz3ZwOLz6J+sEOMaqI1lRnew9KT6wSEtWh EXvparHgnaDqREGbKrKZk7U2Sf5BuYGn/0L4xeykmctYB3KyA14IG2u3mQBEM0UzKS4F YgIpkNvD62sflULyQzTNAuVOeRbQUOVAP3yhy40BG5Pd0YK1LeqowyAl9cyq3r5gnAzG rEaCHwtmTYdkpbGmvxz47lDTiEfW8FKMIixfz9dJLCbIAu9WZ/WnOwxj02p8fy5Lczdd 6YGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=lv5jd6YpkxTgUWKKDJB7a8iSYY106QolNH90JNd3E68=; fh=Mx+BJ0Zegwoq+pIWLfBBdNviDVJx9ufihb/fzE11nms=; b=XE7j2EKlL6BBXIG2/qflEaHbmXAZaNse/FBxTKrVvuXmf7vfuDMMVpZNkv8G1+Eyl1 u30/mYhTB4EsGbTQPAJgDdQ+qMfuu1VTCn/j2qM6sx1uVMngHKX5CZNBbVAMzLueJmM/ Hcl4NHvpNvpHV/QnECQxwEWi27rA5Z06vCZmWX/WtblCPZsDl85XEyR6080g2Vt/3uNs oz4oQ71BZ/m0Ykw1Edi+irNV8zJ5jLrzNfILNzTWTSPqe15jariconVYh3fg4kvskrDE QRM66Z1FTwTJRnHBiyfNBh7mZxPOiqln/KrHKQW6HpOtRBlon5tb5ZMDT8gJSWs5BfxX oshg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=T6oBLJen; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-183161-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183161-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43df56cba26si240262871cf.643.2024.05.19.09.56.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 May 2024 09:56:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183161-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=T6oBLJen; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-183161-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183161-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A247A1C20D11 for ; Sun, 19 May 2024 16:56:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17883487B0; Sun, 19 May 2024 16:56:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="T6oBLJen" Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) (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 A35AE45979 for ; Sun, 19 May 2024 16:56:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.185 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716137784; cv=none; b=YH9M3W4ZvMbQWfGMEBFRJDfqOQ0TIXFtpMbkiyYKSDHfQzSUiI3BRTaqRBhMbZ4nRoX9KxezyTEIe5al9SYVBQiO/Rd3YS749c6FttNVxWqXRyBw8mtq45GL27FG0z7A9J4CInTPiWYljOQfM1HPQze++n5Kc9FOrAkqR1taqU0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716137784; c=relaxed/simple; bh=k8kBfwr/tS4NEVIrA6MHQ1PbVNWQJaoN3iq9wpGQQ2Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NqnBbaVXA9Szg3DmOnQYC7/d0rEm5J1Em5POIUyol+c9pFs3jBYDpaAcEq1SCwyOU8Taz4lE1gbm3kUPcGw3Kv7El/QX3zjqyvw0CSr3S0xHTTtJJnX0jHrjpiBpKKL1Zuhut6p2zF3zljjgw+ATp9tx5ZUGDNwYbrn2J0JgLow= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=T6oBLJen; arc=none smtp.client-ip=91.218.175.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: l.stach@pengutronix.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1716137780; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lv5jd6YpkxTgUWKKDJB7a8iSYY106QolNH90JNd3E68=; b=T6oBLJen2ATEOekueDtdB73oWxqXFf5EZl9koIGBL+W74DmXuZw+lDsSDG9KLHYJktRSpZ 5Tn3BJYgPfM8/Q6xVQVE3dRJop+PqnZ3v646/cb+GYObD5wc32uMNwl75UckGGWJFnmle0 oxTv7rDGEbyuXSO9sudc5PrPo4rG2uA= X-Envelope-To: linux+etnaviv@armlinux.org.uk X-Envelope-To: christian.gmeiner@gmail.com X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: etnaviv@lists.freedesktop.org X-Envelope-To: dri-devel@lists.freedesktop.org X-Envelope-To: sui.jingfeng@linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sui Jingfeng To: Lucas Stach Cc: Russell King , Christian Gmeiner , linux-kernel@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Sui Jingfeng Subject: [etnaviv-next v14 8/8] drm/etnaviv: Add support for vivante GPU cores attached via PCIe device Date: Mon, 20 May 2024 00:53:21 +0800 Message-Id: <20240519165321.2123356-9-sui.jingfeng@linux.dev> In-Reply-To: <20240519165321.2123356-1-sui.jingfeng@linux.dev> References: <20240519165321.2123356-1-sui.jingfeng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Previouly, the component framework is being used to bind multiple platform GPU devices to a virtual master. The virtual master is manually created by the driver, and is also a platform device. This is fine and works well for various SoCs, yet there some hardware venders integrate Vivante GPU cores into PCIe card and the driver lacks the support for PCIe devices. Create virtual platform devices as a representation for each GPU IP core, the manually created platform devices are functional as subcomponent, and all of them are child of the PCIe master device. The master is real for PCIe devices, as the PCIe device has already been created by the time the etnaviv.ko is loaded. Hence, bind all of the virtual child to the real master, this design reflects the hardware layout perfectly and is extensible. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/etnaviv/Kconfig | 9 ++ drivers/gpu/drm/etnaviv/Makefile | 2 + drivers/gpu/drm/etnaviv/etnaviv_drv.c | 12 +- drivers/gpu/drm/etnaviv/etnaviv_drv.h | 2 + drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 75 ++++++++-- drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 4 + drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c | 161 ++++++++++++++++++++++ drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h | 44 ++++++ 8 files changed, 293 insertions(+), 16 deletions(-) create mode 100644 drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c create mode 100644 drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h diff --git a/drivers/gpu/drm/etnaviv/Kconfig b/drivers/gpu/drm/etnaviv/Kconfig index faa7fc68b009..7cb44f72d512 100644 --- a/drivers/gpu/drm/etnaviv/Kconfig +++ b/drivers/gpu/drm/etnaviv/Kconfig @@ -15,6 +15,15 @@ config DRM_ETNAVIV help DRM driver for Vivante GPUs. +config DRM_ETNAVIV_PCI_DRIVER + bool "enable ETNAVIV PCI driver support" + depends on DRM_ETNAVIV + depends on PCI + default n + help + Compile in support for Vivante GPUs attached via PCIe card. + Say Y if you have such hardwares. + config DRM_ETNAVIV_THERMAL bool "enable ETNAVIV thermal throttling" depends on DRM_ETNAVIV diff --git a/drivers/gpu/drm/etnaviv/Makefile b/drivers/gpu/drm/etnaviv/Makefile index 46e5ffad69a6..6829e1ebf2db 100644 --- a/drivers/gpu/drm/etnaviv/Makefile +++ b/drivers/gpu/drm/etnaviv/Makefile @@ -16,4 +16,6 @@ etnaviv-y := \ etnaviv_perfmon.o \ etnaviv_sched.o +etnaviv-$(CONFIG_DRM_ETNAVIV_PCI_DRIVER) += etnaviv_pci_drv.o + obj-$(CONFIG_DRM_ETNAVIV) += etnaviv.o diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index dc3556aad134..90ee60b00c24 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -24,6 +24,7 @@ #include "etnaviv_gpu.h" #include "etnaviv_gem.h" #include "etnaviv_mmu.h" +#include "etnaviv_pci_drv.h" #include "etnaviv_perfmon.h" /* @@ -568,6 +569,10 @@ static int etnaviv_bind(struct device *dev) if (ret < 0) goto out_free_priv; + ret = etnaviv_register_irq_handler(dev, priv); + if (ret) + goto out_unbind; + load_gpu(drm); ret = drm_dev_register(drm, 0); @@ -596,7 +601,7 @@ static void etnaviv_unbind(struct device *dev) etnaviv_private_fini(priv); } -static const struct component_master_ops etnaviv_master_ops = { +const struct component_master_ops etnaviv_master_ops = { .bind = etnaviv_bind, .unbind = etnaviv_unbind, }; @@ -740,6 +745,10 @@ static int __init etnaviv_init(void) if (ret != 0) goto unregister_gpu_driver; + ret = etnaviv_register_pci_driver(); + if (ret) + goto unregister_platform_driver; + /* * If the DT contains at least one available GPU device, instantiate * the DRM platform device. @@ -769,6 +778,7 @@ module_init(etnaviv_init); static void __exit etnaviv_exit(void) { etnaviv_destroy_platform_device(&etnaviv_drm); + etnaviv_unregister_pci_driver(); platform_driver_unregister(&etnaviv_platform_driver); platform_driver_unregister(&etnaviv_gpu_driver); } diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.h b/drivers/gpu/drm/etnaviv/etnaviv_drv.h index 4612843ff9f6..6db26d384cbe 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.h @@ -27,6 +27,8 @@ struct etnaviv_gem_object; struct etnaviv_gem_submit; struct etnaviv_iommu_global; +extern const struct component_master_ops etnaviv_master_ops; + #define ETNAVIV_SOFTPIN_START_ADDRESS SZ_4M /* must be >= SUBALLOC_SIZE */ struct etnaviv_file_private { diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index 3a14e187388a..2b5955693fbb 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,7 @@ static const struct platform_device_id gpu_ids[] = { { .name = "etnaviv-gpu,2d" }, + { .name = "etnaviv-gpu,3d" }, { }, }; @@ -1543,14 +1545,22 @@ static void dump_mmu_fault(struct etnaviv_gpu *gpu) static irqreturn_t irq_handler(int irq, void *data) { - struct etnaviv_gpu *gpu = data; + struct etnaviv_drm_private *priv = data; irqreturn_t ret = IRQ_NONE; + int i; - u32 intr = gpu_read(gpu, VIVS_HI_INTR_ACKNOWLEDGE); - - if (intr != 0) { + for (i = 0; i < priv->num_gpus; i++) { + struct etnaviv_gpu *gpu = priv->gpu[i]; + u32 intr; int event; + if (!gpu) + continue; + + intr = gpu_read(gpu, VIVS_HI_INTR_ACKNOWLEDGE); + if (!intr) + continue; + pm_runtime_mark_last_busy(gpu->dev); dev_dbg(gpu->dev, "intr 0x%08x\n", intr); @@ -1881,10 +1891,44 @@ static const struct of_device_id etnaviv_gpu_match[] = { }; MODULE_DEVICE_TABLE(of, etnaviv_gpu_match); +/* + * dev point to the master. For platform device, it is virtual. + * For PCI(e) device, it is real. + */ +int etnaviv_register_irq_handler(struct device *dev, + struct etnaviv_drm_private *priv) +{ + bool is_pci = dev_is_pci(dev); + int ret = 0; + + if (is_pci) { + struct pci_dev *pdev = to_pci_dev(dev); + + ret = request_irq(pdev->irq, irq_handler, IRQF_SHARED, + dev_name(dev), priv); + } else { + int i; + + for (i = 0; i < priv->num_gpus; i++) { + struct etnaviv_gpu *gpu = priv->gpu[i]; + + ret = devm_request_irq(gpu->dev, gpu->irq, irq_handler, + 0, dev_name(dev), priv); + if (ret) { + dev_err(dev, "failed to request IRQ handler: %d\n", ret); + break; + } + } + } + + return ret; +} + static int etnaviv_gpu_platform_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct etnaviv_gpu *gpu; + bool is_pci; int err; gpu = devm_kzalloc(dev, sizeof(*gpu), GFP_KERNEL); @@ -1900,22 +1944,23 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev) if (IS_ERR(gpu->mmio)) return PTR_ERR(gpu->mmio); + is_pci = dev->parent ? dev_is_pci(dev->parent) : false; + /* Get Interrupt: */ - gpu->irq = platform_get_irq(pdev, 0); + if (is_pci) + gpu->irq = to_pci_dev(dev->parent)->irq; + else + gpu->irq = platform_get_irq(pdev, 0); + if (gpu->irq < 0) return gpu->irq; - err = devm_request_irq(dev, gpu->irq, irq_handler, 0, - dev_name(dev), gpu); - if (err) { - dev_err(dev, "failed to request IRQ%u: %d\n", gpu->irq, err); - return err; - } - /* Get Clocks: */ - err = etnaviv_gpu_clk_get(gpu); - if (err) - return err; + if (!is_pci) { + err = etnaviv_gpu_clk_get(gpu); + if (err) + return err; + } /* TODO: figure out max mapped size */ dev_set_drvdata(dev, gpu); diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h index 197e0037732e..78222f62725f 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h @@ -196,6 +196,10 @@ static inline u32 gpu_read_power(struct etnaviv_gpu *gpu, u32 reg) int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value); int etnaviv_gpu_init(struct etnaviv_gpu *gpu); + +int etnaviv_register_irq_handler(struct device *dev, + struct etnaviv_drm_private *priv); + bool etnaviv_fill_identity_from_hwdb(struct etnaviv_gpu *gpu); #ifdef CONFIG_DEBUG_FS diff --git a/drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c new file mode 100644 index 000000000000..9d505bfead1f --- /dev/null +++ b/drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c @@ -0,0 +1,161 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include + +#include "etnaviv_drv.h" +#include "etnaviv_pci_drv.h" + +static const struct etnaviv_pci_gpu_data +gccore_platform_data[GCCORE_PCI_CHIP_ID_LAST] = { + { + .chip_id = GCCORE_PCI_CHIP_ID_UNKNOWN, + }, + { + .chip_id = JM9100, + .num_core = 1, + .num_vram = 2, + .vram_bars = {0, 2}, + .mmio_bar = 1, + .ip_block = {{0, 0x00900000, 0x00010000, "etnaviv-gpu,3d"},}, + .has_dedicated_vram = true, + .market_name = "JingJia Micro JM9100", + }, + { + .chip_id = JD9230P, + .num_core = 2, + .num_vram = 2, + .vram_bars = {0, 2}, + .mmio_bar = 1, + .ip_block = {{0, 0x00900000, 0x00010000, "etnaviv-gpu,3d"}, + {1, 0x00910000, 0x00010000, "etnaviv-gpu,3d"},}, + .has_dedicated_vram = true, + .market_name = "JingJia Micro JD9230P", + }, + { + .chip_id = GP102, + .num_core = 2, + .num_vram = 1, + .vram_bars = {0,}, + .mmio_bar = 2, + .ip_block = {{0, 0x00040000, 0x00010000, "etnaviv-gpu,3d"}, + {0, 0x000C0000, 0x00010000, "etnaviv-gpu,2d"},}, + .has_dedicated_vram = true, + .market_name = "LingJiu GP102", + }, +}; + +static const struct etnaviv_pci_gpu_data * +etnaviv_pci_get_platform_data(const struct pci_device_id *entity) +{ + enum etnaviv_pci_chip_id chip_id = entity->driver_data; + + if (chip_id == GCCORE_PCI_CHIP_ID_UNKNOWN || + chip_id >= GCCORE_PCI_CHIP_ID_LAST) + return NULL; + + return &gccore_platform_data[chip_id]; +} + +static int etnaviv_pci_probe(struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + const struct etnaviv_pci_gpu_data *pdata; + struct device *dev = &pdev->dev; + struct component_match *matches = NULL; + unsigned int i; + unsigned int num_core; + int ret; + + ret = pcim_enable_device(pdev); + if (ret) + return ret; + + pci_set_master(pdev); + + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); + if (ret) + return ret; + + pdata = etnaviv_pci_get_platform_data(ent); + if (!pdata) + return -ENODEV; + + num_core = pdata->num_core; + + dev_info(dev, "%s has %u GPU cores\n", pdata->market_name, num_core); + + for (i = 0; i < num_core; i++) { + const struct vivante_gc_ip_block *pblock = &pdata->ip_block[i]; + struct platform_device *virtual_child; + resource_size_t start; + struct resource res; + + start = pci_resource_start(pdev, pdata->mmio_bar); + memset(&res, 0, sizeof(res)); + res.flags = IORESOURCE_MEM; + res.name = "register"; + res.start = start + pblock->offset; + res.end = start + pblock->offset + pblock->size - 1; + + ret = etnaviv_create_platform_device(dev, + pblock->compatible, + pblock->id, + &res, + (void *)pdata, + &virtual_child); + if (ret) + return ret; + + component_match_add(dev, &matches, component_compare_dev, + &virtual_child->dev); + } + + return component_master_add_with_match(dev, &etnaviv_master_ops, matches); +} + +static int platform_device_remove_callback(struct device *dev, void *data) +{ + struct platform_device *pdev = to_platform_device(dev); + + etnaviv_destroy_platform_device(&pdev); + + return 0; +} + +static void etnaviv_pci_remove(struct pci_dev *pdev) +{ + struct device *dev = &pdev->dev; + + component_master_del(dev, &etnaviv_master_ops); + + device_for_each_child(dev, NULL, platform_device_remove_callback); + + pci_clear_master(pdev); +} + +static const struct pci_device_id etnaviv_pci_id_list[] = { + {0x0731, 0x9100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, JM9100}, + {0x0731, 0x9230, PCI_ANY_ID, PCI_ANY_ID, 0, 0, JD9230P}, + {0x0709, 0x0001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, GP102}, + { } +}; + +static struct pci_driver etnaviv_pci_driver = { + .name = "etnaviv", + .id_table = etnaviv_pci_id_list, + .probe = etnaviv_pci_probe, + .remove = etnaviv_pci_remove, +}; + +int etnaviv_register_pci_driver(void) +{ + return pci_register_driver(&etnaviv_pci_driver); +} + +void etnaviv_unregister_pci_driver(void) +{ + pci_unregister_driver(&etnaviv_pci_driver); +} + +MODULE_DEVICE_TABLE(pci, etnaviv_pci_id_list); diff --git a/drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h b/drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h new file mode 100644 index 000000000000..6782481a0c0b --- /dev/null +++ b/drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __ETNAVIV_PCI_DRV_H__ +#define __ETNAVIV_PCI_DRV_H__ + +#ifdef CONFIG_DRM_ETNAVIV_PCI_DRIVER + +enum etnaviv_pci_chip_id { + GCCORE_PCI_CHIP_ID_UNKNOWN = 0, + JM9100 = 1, + JD9230P = 2, + GP102 = 3, + GCCORE_PCI_CHIP_ID_LAST, +}; + +struct vivante_gc_ip_block { + u32 id; + u32 offset; + u32 size; + char compatible[20]; +}; + +struct etnaviv_pci_gpu_data { + enum etnaviv_pci_chip_id chip_id; + u32 num_core; + u32 num_vram; + u32 vram_bars[2]; + u32 mmio_bar; + struct vivante_gc_ip_block ip_block[ETNA_MAX_PIPES]; + bool has_dedicated_vram; + char market_name[24]; +}; + +int etnaviv_register_pci_driver(void); +void etnaviv_unregister_pci_driver(void); + +#else + +static inline int etnaviv_register_pci_driver(void) { return 0; } +static inline void etnaviv_unregister_pci_driver(void) { } + +#endif + +#endif -- 2.34.1