From patchwork Tue Mar 13 20:34:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 7267 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 57AC123E0E for ; Tue, 13 Mar 2012 20:34:47 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id F1A8AA1860B for ; Tue, 13 Mar 2012 20:34:46 +0000 (UTC) Received: by iage36 with SMTP id e36so1676755iag.11 for ; Tue, 13 Mar 2012 13:34:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :dkim-signature:sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=Z0vuRRjpXWibNBO7ymubmEEJDVlJhTDeDYGrxAyoV1U=; b=OAxSAMRiaz3YrQ4knG5mpvInKCD8pZHBJLN2SSx8jgq+hm2W8cxlGwbSlOQFKjJN/G sI0zwNQSxJxoZt3YqI7yYA4v5EccvRFEfUySxB5Zh/6BmUSUr7jEwrSXpieux7QVUc5z ekxLQasuvQT3TrhumUUzejE1GfrrXf+kFYDt0m8wsJxtXFlrIpZpixnKKn3WIFjBzP8d 4xD+x47qmezfC5hvypKpYd5twQEIisNSBmKZbg3v5eiaQVvsS+l8TPORVKjPPGRvoHKj Gth7vlgm2WxLFpNVnZpCfJu8o93MgkacHKCcvHC1/906cqxxsk8GcFNfHh2JUWzPIq04 2tlg== Received: by 10.42.145.72 with SMTP id e8mr35087icv.0.1331670886385; Tue, 13 Mar 2012 13:34:46 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.53.18 with SMTP id k18csp74613ibg; Tue, 13 Mar 2012 13:34:43 -0700 (PDT) Received: by 10.236.201.233 with SMTP id b69mr18582234yho.71.1331670882733; Tue, 13 Mar 2012 13:34:42 -0700 (PDT) Received: from mail-gy0-f178.google.com (mail-gy0-f178.google.com [209.85.160.178]) by mx.google.com with ESMTPS id b16si682190anj.87.2012.03.13.13.34.42 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Mar 2012 13:34:42 -0700 (PDT) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.160.178 as permitted sender) client-ip=209.85.160.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.160.178 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by ghbf1 with SMTP id f1so1241531ghb.37 for ; Tue, 13 Mar 2012 13:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer; bh=Z0vuRRjpXWibNBO7ymubmEEJDVlJhTDeDYGrxAyoV1U=; b=SAr0FVAIJ6AYSQmLoIdV5Kp1HdnJTqErxBIHgjdXPwlDIFsklrKQ5vTi4ol5f1N1xT 8vejbXdpDxw2Yq+LhRXPpoPAGZG0lrT0LcMDe/HQMPDe1J3JPSZ5LLw2mwJCNYSa0t0e uklh785S7cbh2CxxtT0KWhQRhhd1xfA/++aE1zdFwWpG1/fqkGY9eZLf3Ga/uHdEOyzb y6hPWRX0SbngL1qDpAEN33uqxJ5rpNeaLApUp+nk/Uf3gu6QRotMAg1RK5KUTG89uWPk /zxaAeh1uetJyojeIYkn+/792eos1W4IT3wXQ8EzBJgeYtpA8z3rZ7PeV2nlDt7c1/Om XPVw== Received: by 10.60.25.196 with SMTP id e4mr13113013oeg.53.1331670881807; Tue, 13 Mar 2012 13:34:41 -0700 (PDT) Received: from localhost (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id n1sm2429345obm.11.2012.03.13.13.34.40 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Mar 2012 13:34:40 -0700 (PDT) Sender: Rob Clark From: Rob Clark To: dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org Cc: patches@linaro.org, Greg KH , Tomi Valkeinen , Andy Gross , Rob Clark Subject: [PATCH] omap2+: add drm device Date: Tue, 13 Mar 2012 15:34:38 -0500 Message-Id: <1331670878-12951-1-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.5.4 X-Gm-Message-State: ALoCoQkmxsrkXmcOSUKAqOHPl7e6PU6y+nxrl/IQXIb8WIGlZyUKTw9nNHmvJfVDavN8RreJkZvQ From: Andy Gross Register OMAP DRM/KMS platform device, and reserve a CMA region for the device to use for buffer allocation. DMM is split into a separate device using hwmod. Signed-off-by: Andy Gross Signed-off-by: Rob Clark --- arch/arm/mach-omap2/Makefile | 4 ++ arch/arm/mach-omap2/drm.c | 83 +++++++++++++++++++++++++++++++++ arch/arm/plat-omap/common.c | 3 +- arch/arm/plat-omap/include/plat/drm.h | 64 +++++++++++++++++++++++++ 4 files changed, 153 insertions(+), 1 deletions(-) create mode 100644 arch/arm/mach-omap2/drm.c create mode 100644 arch/arm/plat-omap/include/plat/drm.h diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile index bd76394..9e6065b 100644 --- a/arch/arm/mach-omap2/Makefile +++ b/arch/arm/mach-omap2/Makefile @@ -189,6 +189,10 @@ ifneq ($(CONFIG_TIDSPBRIDGE),) obj-y += dsp.o endif +ifneq ($(CONFIG_DRM_OMAP),) +obj-y += drm.o +endif + # Specific board support obj-$(CONFIG_MACH_OMAP_GENERIC) += board-generic.o obj-$(CONFIG_MACH_OMAP_H4) += board-h4.o diff --git a/arch/arm/mach-omap2/drm.c b/arch/arm/mach-omap2/drm.c new file mode 100644 index 0000000..779ae02 --- /dev/null +++ b/arch/arm/mach-omap2/drm.c @@ -0,0 +1,83 @@ +/* + * DRM/KMS device registration for TI OMAP platforms + * + * Copyright (C) 2012 Texas Instruments + * Author: Rob Clark + * + * 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. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#ifdef CONFIG_CMA +# include +#endif + +#include +#include + +#include + +#if defined(CONFIG_DRM_OMAP) || (CONFIG_DRM_OMAP_MODULE) + +static struct omap_drm_platform_data omapdrm_platdata; + +static struct platform_device omap_drm_device = { + .dev = { + .coherent_dma_mask = DMA_BIT_MASK(32), + .platform_data = &omapdrm_platdata, + }, + .name = "omapdrm", + .id = 0, +}; + +static int __init omap_init_drm(void) +{ + struct omap_hwmod *oh = NULL; + struct platform_device *pdev; + + /* lookup and populate the DMM information, if present - OMAP4+ */ + oh = omap_hwmod_lookup("dmm"); + + if (oh) { + pdev = omap_device_build(oh->name, -1, oh, NULL, 0, NULL, 0, + false); + WARN(IS_ERR(pdev), "Could not build omap_device for %s\n", + oh->name); + } + + return platform_device_register(&omap_drm_device); + +} + +arch_initcall(omap_init_drm); + +void omapdrm_reserve_vram(void) +{ +#ifdef CONFIG_CMA + /* + * Create private 32MiB contiguous memory area for omapdrm.0 device + * TODO revisit size.. if uc/wc buffers are allocated from CMA pages + * then the amount of memory we need goes up.. + */ + dma_declare_contiguous(&omap_drm_device.dev, 32 * SZ_1M, 0, 0); +#else +# warning "CMA is not enabled, there may be limitations about scanout buffer allocations on OMAP3 and earlier" +#endif +} + +#endif diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c index 4de7d1e..e027cc7 100644 --- a/arch/arm/plat-omap/common.c +++ b/arch/arm/plat-omap/common.c @@ -21,10 +21,10 @@ #include #include #include +#include #include - #define NO_LENGTH_CHECK 0xffffffff struct omap_board_config_kernel *omap_board_config __initdata; @@ -65,6 +65,7 @@ const void *__init omap_get_var_config(u16 tag, size_t *len) void __init omap_reserve(void) { + omapdrm_reserve_vram(); omapfb_reserve_sdram_memblock(); omap_vram_reserve_sdram_memblock(); omap_dsp_reserve_sdram_memblock(); diff --git a/arch/arm/plat-omap/include/plat/drm.h b/arch/arm/plat-omap/include/plat/drm.h new file mode 100644 index 0000000..df9bc41 --- /dev/null +++ b/arch/arm/plat-omap/include/plat/drm.h @@ -0,0 +1,64 @@ +/* + * DRM/KMS device registration for TI OMAP platforms + * + * Copyright (C) 2012 Texas Instruments + * Author: Rob Clark + * + * 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. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#ifndef __PLAT_OMAP_DRM_H__ +#define __PLAT_OMAP_DRM_H__ + +/* + * Optional platform data to configure the default configuration of which + * pipes/overlays/CRTCs are used.. if this is not provided, then instead the + * first CONFIG_DRM_OMAP_NUM_CRTCS are used, and they are each connected to + * one manager, with priority given to managers that are connected to + * detected devices. Remaining overlays are used as video planes. This + * should be a good default behavior for most cases, but yet there still + * might be times when you wish to do something different. + */ +struct omap_kms_platform_data { + /* overlays to use as CRTCs: */ + int ovl_cnt; + const int *ovl_ids; + + /* overlays to use as video planes: */ + int pln_cnt; + const int *pln_ids; + + int mgr_cnt; + const int *mgr_ids; + + int dev_cnt; + const char **dev_names; +}; + +struct omap_drm_platform_data { + struct omap_kms_platform_data *kms_pdata; +}; + +#if defined(CONFIG_DRM_OMAP) || defined(CONFIG_DRM_OMAP_MODULE) + +void omapdrm_reserve_vram(void); + +#else + +static inline void omapdrm_reserve_vram(void) +{ +} + +#endif + +#endif /* __PLAT_OMAP_DRM_H__ */