From patchwork Tue Dec 18 15:37:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 10736859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3A366C2 for ; Wed, 19 Dec 2018 08:41:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D50E32AE9A for ; Wed, 19 Dec 2018 08:41:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D30F12AEAB; Wed, 19 Dec 2018 08:41:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 67AFB2AE9A for ; Wed, 19 Dec 2018 08:41:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CD6156EE17; Wed, 19 Dec 2018 08:40:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from shell.v3.sk (shell.v3.sk [90.176.6.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id AC08A6EC49 for ; Tue, 18 Dec 2018 15:38:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 500D2CA22D; Tue, 18 Dec 2018 16:38:22 +0100 (CET) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 5STz-TF0tLAK; Tue, 18 Dec 2018 16:38:07 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 7CB60CA2C9; Tue, 18 Dec 2018 16:37:51 +0100 (CET) X-Virus-Scanned: amavisd-new at zimbra.v3.sk Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 8fw0If0S5zm5; Tue, 18 Dec 2018 16:37:48 +0100 (CET) Received: from belphegor.brq.redhat.com (nat-pool-brq-t.redhat.com [213.175.37.10]) by zimbra.v3.sk (Postfix) with ESMTPSA id 5F594CA2DC; Tue, 18 Dec 2018 16:37:47 +0100 (CET) From: Lubomir Rintel To: dri-devel@lists.freedesktop.org Subject: [RFC 11/16] drm/armada: add OF reserved memory support Date: Tue, 18 Dec 2018 16:37:37 +0100 Message-Id: <20181218153742.1313125-12-lkundrak@v3.sk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181218153742.1313125-1-lkundrak@v3.sk> References: <20181218153742.1313125-1-lkundrak@v3.sk> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 19 Dec 2018 08:40:40 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Russell King , James Cameron Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Russell King Existing Armada DRM makes use of reserved memory for allocating contiguous screen buffers, which currently prevents its use with DT systems. Add support for this for DT systems. Signed-off-by: Russell King --- drivers/gpu/drm/armada/Makefile | 3 ++ drivers/gpu/drm/armada/armada_drv.c | 24 ++++++++++++-- drivers/gpu/drm/armada/armada_rmem.c | 49 ++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/armada/armada_rmem.c diff --git a/drivers/gpu/drm/armada/Makefile b/drivers/gpu/drm/armada/Makefile index 9bc3c3213724..d34843e121c7 100644 --- a/drivers/gpu/drm/armada/Makefile +++ b/drivers/gpu/drm/armada/Makefile @@ -5,3 +5,6 @@ armada-y += armada_510.o armada-$(CONFIG_DEBUG_FS) += armada_debugfs.o obj-$(CONFIG_DRM_ARMADA) := armada.o + +armada-rmem-$(CONFIG_DRM_ARMADA) += armada_rmem.o +obj-y += $(armada-rmem-y) $(armada-rmem-m) diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index 9f2eb02df295..c1d3cbefd4d8 100644 --- a/drivers/gpu/drm/armada/armada_drv.c +++ b/drivers/gpu/drm/armada/armada_drv.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -75,6 +76,9 @@ static int armada_drm_bind(struct device *dev) return -EINVAL; } + if (!mem && dev->of_node) + mem = dev->platform_data; + if (!mem) return -ENXIO; @@ -226,9 +230,17 @@ static int armada_drm_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; int ret; - ret = drm_of_component_probe(dev, compare_dev_name, &armada_master_ops); - if (ret != -EINVAL) + if (dev->of_node) { + ret = of_reserved_mem_device_init(dev); + if (ret && ret != -ENODEV) + return ret; + + ret = drm_of_component_probe(dev, compare_of, + &armada_master_ops); + if (ret) + of_reserved_mem_device_release(dev); return ret; + } if (dev->platform_data) { char **devices = dev->platform_data; @@ -263,6 +275,7 @@ static int armada_drm_probe(struct platform_device *pdev) static int armada_drm_remove(struct platform_device *pdev) { component_master_del(&pdev->dev, &armada_master_ops); + of_reserved_mem_device_release(&pdev->dev); return 0; } @@ -276,11 +289,18 @@ static const struct platform_device_id armada_drm_platform_ids[] = { }; MODULE_DEVICE_TABLE(platform, armada_drm_platform_ids); +static const struct of_device_id armada_drm_dt_ids[] = { + { .compatible = "marvell,dove-display-subsystem", }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, armada_drm_dt_ids); + static struct platform_driver armada_drm_platform_driver = { .probe = armada_drm_probe, .remove = armada_drm_remove, .driver = { .name = "armada-drm", + .of_match_table = armada_drm_dt_ids, }, .id_table = armada_drm_platform_ids, }; diff --git a/drivers/gpu/drm/armada/armada_rmem.c b/drivers/gpu/drm/armada/armada_rmem.c new file mode 100644 index 000000000000..36bb20e426b6 --- /dev/null +++ b/drivers/gpu/drm/armada/armada_rmem.c @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2017 Russell King +#include +#include +#include +#include + +static int armada_rmem_dev_init(struct reserved_mem *rmem, struct device *dev) +{ + struct resource *r; + + if (dev->platform_data) + return -EBUSY; + + r = kzalloc(sizeof(*r), GFP_KERNEL); + if (!r) + return -ENOMEM; + + r->start = rmem->base; + r->end = rmem->base + rmem->size - 1; + r->flags = IORESOURCE_MEM; + + rmem->priv = r; + dev->platform_data = r; + + return 0; +} + +static void armada_rmem_dev_release(struct reserved_mem *rmem, + struct device *dev) +{ + kfree(rmem->priv); + rmem->priv = NULL; + dev->platform_data = NULL; +} + +static const struct reserved_mem_ops armada_rmem_ops = { + .device_init = armada_rmem_dev_init, + .device_release = armada_rmem_dev_release, +}; + +static int __init armada_rmem_init(struct reserved_mem *rmem) +{ + rmem->ops = &armada_rmem_ops; + return 0; +} + +RESERVEDMEM_OF_DECLARE(armada_rmem, "marvell,dove-framebuffer", + armada_rmem_init);