From patchwork Sat May 18 17:12:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 2589281 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 17A48DF2E5 for ; Sat, 18 May 2013 22:08:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EA2FEE5DBA for ; Sat, 18 May 2013 15:08:03 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ee0-f48.google.com (mail-ee0-f48.google.com [74.125.83.48]) by gabe.freedesktop.org (Postfix) with ESMTP id 18061E5DC0 for ; Sat, 18 May 2013 10:12:29 -0700 (PDT) Received: by mail-ee0-f48.google.com with SMTP id b47so3251835eek.35 for ; Sat, 18 May 2013 10:12:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=8y+wVrZ+HRnlFY6O5tGg3FZWt0FhMaJU3aonGjKCHHA=; b=ODHIeLWCeaG2wqUG2qv6pMDKCko8B17WH1yZ6Tu5NS8Ww7S8w5FClgxfPM2aL+fbM8 B7LtrOJD9trJxqKbzSr2nePnh+DWIzOEbYy0xQ4G50AmkasveVYrKx5cfghKtR0lcsxu ToyOSeXphgFTT3HgP6WPrKxFf8OjSvu6Cn2wSmsbuziamxiv6egc6dyLgYIIkUa5Wsl+ SQN6RLnX6fckASgGZ5k1depKSwzauaWxvUe3avW+ps9lm7Bt7I+3giSt0JkC/sc0f4sj ikg/ij9xuuzUHhImE7ll8xStJ0rOvG5vH+yrM34SrqvdsyMNDwFtX8hotijGelhOQGfe VnIg== X-Received: by 10.15.26.6 with SMTP id m6mr145078840eeu.4.1368897149328; Sat, 18 May 2013 10:12:29 -0700 (PDT) Received: from topkick.lan (dslc-082-083-251-181.pools.arcor-ip.net. [82.83.251.181]) by mx.google.com with ESMTPSA id bp51sm26774371eeb.5.2013.05.18.10.12.26 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 18 May 2013 10:12:27 -0700 (PDT) Received: from edge.lan (magicgate.lan [192.168.1.1]) by topkick.lan (Postfix) with ESMTPSA id CA80E605EF; Sat, 18 May 2013 19:11:43 +0200 (CEST) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [RFC 3/4] DRM: add OF support for Dove DRM driver Date: Sat, 18 May 2013 19:12:18 +0200 Message-Id: <1368897139-25485-4-git-send-email-sebastian.hesselbarth@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1368897139-25485-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <20130516192510.GV18614@n2100.arm.linux.org.uk> <1368897139-25485-1-git-send-email-sebastian.hesselbarth@gmail.com> X-Mailman-Approved-At: Sat, 18 May 2013 15:03:35 -0700 Cc: Jean-Francois Moine , Russell King , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, Jason Cooper 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+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org This adds OF support for the Dove DRM driver recently posted as RFC by Russell King. Signed-off-by: Sebastian Hesselbarth --- Cc: Russell King Cc: linux-arm-kernel@lists.infradead.org Cc: dri-devel@lists.freedesktop.org Cc: Jason Cooper Cc: Jean-Francois Moine --- drivers/gpu/drm/dove/Kconfig | 4 ++ drivers/gpu/drm/dove/Makefile | 1 + drivers/gpu/drm/dove/dove_card.c | 110 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 drivers/gpu/drm/dove/dove_card.c diff --git a/drivers/gpu/drm/dove/Kconfig b/drivers/gpu/drm/dove/Kconfig index 718d3c5..a943ea5 100644 --- a/drivers/gpu/drm/dove/Kconfig +++ b/drivers/gpu/drm/dove/Kconfig @@ -28,4 +28,8 @@ config DRM_DOVE_TDA1998X config DRM_DOVE_CURSOR bool "Enable Dove DRM hardware cursor support" +config DRM_DOVE_OF + bool "Enable Dove DRM OF video card" + depends on OF + endif diff --git a/drivers/gpu/drm/dove/Makefile b/drivers/gpu/drm/dove/Makefile index 65c701e..f0b6eed 100644 --- a/drivers/gpu/drm/dove/Makefile +++ b/drivers/gpu/drm/dove/Makefile @@ -5,5 +5,6 @@ dove-y := dove_crtc.o dove_drv.o dove_fb.o dove_fbdev.o \ dove-$(CONFIG_DEBUG_FS) += dove_debugfs.o dove-$(CONFIG_DRM_DOVE_TDA1998X) += dove_tda19988.o +dove-$(CONFIG_DRM_DOVE_OF) += dove_card.o obj-$(CONFIG_DRM_DOVE) := dove.o diff --git a/drivers/gpu/drm/dove/dove_card.c b/drivers/gpu/drm/dove/dove_card.c new file mode 100644 index 0000000..e4bcb5b --- /dev/null +++ b/drivers/gpu/drm/dove/dove_card.c @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2013 + * Sebastian Hesselbarth + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#define DOVE_LCD0_BASE 0x20000 +#define DOVE_LCD1_BASE 0x10000 + +static struct resource dove_drm_resources[5]; +static struct platform_device dove_drm_platform_device = { + .name = "dove-drm", + .id = 0, + .dev = { .coherent_dma_mask = ~0, }, + .resource = dove_drm_resources, +}; + +static int dove_card_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct device_node *lcdnp; + struct resource *res = dove_drm_resources; + int ret, n = 0, crtcs = 0; + + /* get video memory resource */ + if (of_address_to_resource(np, 0, &res[n++])) { + dev_err(&pdev->dev, "invalid or missing video memory\n"); + return -EINVAL; + } + + /* get reg and irq resource from each enabled lcdc */ + for_each_compatible_node(lcdnp, NULL, "marvell,dove-lcd") { + struct clk_lookup *cl; + struct clk *clk; + int lcd; + + if (!of_device_is_available(lcdnp)) + continue; + + ret = of_address_to_resource(lcdnp, 0, &res[n]); + if (ret) + return ret; + lcd = ((res[n].start & 0xfffff) == DOVE_LCD1_BASE); + n++; + + ret = of_irq_to_resource(lcdnp, 0, &res[n]); + if (ret < 0) + return ret; + n++; + + crtcs++; + + clk = clk_get(&pdev->dev, NULL); + if (IS_ERR(clk)) { + ret = PTR_ERR(clk); + if (ret == -ENOENT) + return -EPROBE_DEFER; + return ret; + } + + /* add clock alias for dovefb.0 */ + cl = clkdev_alloc(clk, "extclk", "dovefb.0"); + if (cl) + clkdev_add(cl); + clk_put(clk); + } + + if (!crtcs) + return -ENODEV; + + dove_drm_platform_device.num_resources = n; + ret = platform_device_register(&dove_drm_platform_device); + if (ret) { + dev_err(&pdev->dev, "unable to register drm device\n"); + return ret; + } + + return 0; +} + +static const struct of_device_id dove_card_of_ids[] = { + { .compatible = "marvell,dove-video-card", }, + { } +}; +MODULE_DEVICE_TABLE(of, dove_card_of_ids); + +static struct platform_driver dove_card_driver = { + .probe = dove_card_probe, + .driver = { + .owner = THIS_MODULE, + .name = "dove-drm-card", + .of_match_table = of_match_ptr(dove_card_of_ids), + }, +}; +module_platform_driver(dove_card_driver); + +MODULE_AUTHOR("Sebastian Hesselbarth "); +MODULE_DESCRIPTION("Dove DRM Graphics Card"); +MODULE_LICENSE("GPL");