From patchwork Sat Feb 1 03:16:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 3564181 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3B563C02DC for ; Sat, 1 Feb 2014 03:28:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2A8C220257 for ; Sat, 1 Feb 2014 03:28:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 08F5320260 for ; Sat, 1 Feb 2014 03:28:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B6E48A666; Fri, 31 Jan 2014 19:28:28 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 437 seconds by postgrey-1.32 at gabe; Fri, 31 Jan 2014 19:28:23 PST Received: from mail.gnurou.org (gnurou.org [207.192.72.5]) by gabe.freedesktop.org (Postfix) with ESMTP id 38D4D88F66; Fri, 31 Jan 2014 19:28:23 -0800 (PST) Received: from aramis.nvidia.com (unknown [203.18.50.4]) by mail.gnurou.org (Postfix) with ESMTPSA id F35893020C; Sat, 1 Feb 2014 12:23:43 +0900 (JST) From: Alexandre Courbot To: Ben Skeggs , nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC 03/16] drm/nouveau: add platform device probing function Date: Sat, 1 Feb 2014 12:16:45 +0900 Message-Id: <1391224618-3794-4-git-send-email-acourbot@nvidia.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1391224618-3794-1-git-send-email-acourbot@nvidia.com> References: <1391224618-3794-1-git-send-email-acourbot@nvidia.com> Cc: gnurou@gmail.com, Eric Brower , Stephen Warren , linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, Terje Bergstrom , Ken Adams X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.8 required=5.0 tests=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 Add a nouveau_drm_platform_probe() function that probes a Nouveau platform device and registers it using drm_platform_init(). Signed-off-by: Alexandre Courbot --- drivers/gpu/drm/nouveau/core/engine/device/base.c | 34 ++++++++++++++++++++++ .../gpu/drm/nouveau/core/include/engine/device.h | 10 +++++++ drivers/gpu/drm/nouveau/nouveau_drm.c | 19 ++++++++++++ 3 files changed, 63 insertions(+) diff --git a/drivers/gpu/drm/nouveau/core/engine/device/base.c b/drivers/gpu/drm/nouveau/core/engine/device/base.c index a6abb51..ba6c2f2 100644 --- a/drivers/gpu/drm/nouveau/core/engine/device/base.c +++ b/drivers/gpu/drm/nouveau/core/engine/device/base.c @@ -543,3 +543,37 @@ done: mutex_unlock(&nv_devices_mutex); return ret; } + +int +nouveau_device_platform_create_(struct platform_device *pdev, u64 name, + const char *sname, const char *cfg, + const char *dbg, int length, void **pobject) +{ + struct nouveau_device *device; + int ret = -EEXIST; + + mutex_lock(&nv_devices_mutex); + list_for_each_entry(device, &nv_devices, head) { + if (device->handle == name) + goto done; + } + + ret = nouveau_engine_create_(NULL, NULL, &nouveau_device_oclass, true, + "DEVICE", "device", length, pobject); + device = *pobject; + if (ret) + goto done; + + device->platformdev = pdev; + device->handle = name; + device->cfgopt = cfg; + device->dbgopt = dbg; + device->name = sname; + + nv_subdev(device)->debug = nouveau_dbgopt(device->dbgopt, "DEVICE"); + nv_engine(device)->sclass = nouveau_device_sclass; + list_add(&device->head, &nv_devices); +done: + mutex_unlock(&nv_devices_mutex); + return ret; +} diff --git a/drivers/gpu/drm/nouveau/core/include/engine/device.h b/drivers/gpu/drm/nouveau/core/include/engine/device.h index b3dd2c4..90056190 100644 --- a/drivers/gpu/drm/nouveau/core/include/engine/device.h +++ b/drivers/gpu/drm/nouveau/core/include/engine/device.h @@ -3,12 +3,22 @@ #include +struct platform_device; + #define nouveau_device_create(p,n,s,c,d,u) \ nouveau_device_create_((p), (n), (s), (c), (d), sizeof(**u), (void **)u) int nouveau_device_create_(struct pci_dev *, u64 name, const char *sname, const char *cfg, const char *dbg, int, void **); +#define nouveau_device_platform_create(p,n,s,c,d,u) \ + nouveau_device_platform_create_((p), (n), (s), (c), (d), sizeof(**u), \ + (void **)u) + +int nouveau_device_platform_create_(struct platform_device *pdev, u64 name, + const char *sname, const char *cfg, + const char *dbg, int, void **); + int nv04_identify(struct nouveau_device *); int nv10_identify(struct nouveau_device *); int nv20_identify(struct nouveau_device *); diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 4cba4d8..8d55a50 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -986,6 +986,25 @@ nouveau_drm_pci_driver = { .driver.pm = &nouveau_pm_ops, }; + +int nouveau_drm_platform_probe(struct platform_device *pdev) +{ + struct nouveau_device *device; + int ret; + + ret = nouveau_device_platform_create(pdev, nouveau_platform_name(pdev), + dev_name(&pdev->dev), nouveau_config, + nouveau_debug, &device); + + ret = drm_platform_init(&driver, pdev); + if (ret) { + nouveau_object_ref(NULL, (struct nouveau_object **)&device); + return ret; + } + + return ret; +} + static int __init nouveau_drm_init(void) {