From: Rahul Sharma Subject: [PATCH] drm: exynos: add iommu support in hdmi driver with dt enabled Date: Mon, 05 Nov 2012 20:48:19 +0530 Message-ID: <1352128699-3343-1-git-send-email-rahul.sharma@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by gabe.freedesktop.org (Postfix) with ESMTP id D44009E75F for ; Mon, 5 Nov 2012 06:58:53 -0800 (PST) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MD000FCRS9XR2C0@mailout2.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 05 Nov 2012 23:58:52 +0900 (KST) Received: from localhost.localdomain ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MD000MPJS8G0YA0@mmp2.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 05 Nov 2012 23:58:52 +0900 (KST) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: dri-devel@lists.freedesktop.org Cc: prathyush.k@samsung.com, sw0312.kim@samsung.com, joshi@samsung.com, kyungmin.park@samsung.com, rahul.sharma@samsung.com, prashanth.g@samsung.com, s.shirish@samsung.com List-Id: dri-devel@lists.freedesktop.org This patch adds iommu support for hdmi driver with device tree based search. It searches for sysmmu property in hdmi dt node to get tv iommu device pointer which will be used to configure iommu hw interface. This patch is based on "exynos-drm-next-iommu" branch at http://git.kernel.org/?p=linux/kernel/git/daeinki/drm-exynos.git This patch is having dependency on linux-samsung-soc patchset posted at http://permalink.gmane.org/gmane.linux.kernel.samsung-soc/13556 Signed-off-by: Rahul Sharma Signed-off-by: Prathyush K --- drivers/gpu/drm/exynos/exynos_hdmi.c | 35 ++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index d1a1d71..a04452c 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -34,7 +34,9 @@ #include #include #include +#include #include +#include #include @@ -2275,6 +2277,34 @@ void hdmi_attach_hdmiphy_client(struct i2c_client *hdmiphy) } #ifdef CONFIG_OF + +static int drm_hdmi_dt_init_iommu(struct device *dev) +{ + struct platform_device *pds; + struct device_node *dn, *dns; + const __be32 *parp; + + dn = dev->of_node; + parp = of_get_property(dn, "sysmmu", NULL); + if (parp == NULL) { + dev_err(dev, "failed to find sysmmu property\n"); + return -EINVAL; + } + dns = of_find_node_by_phandle(be32_to_cpup(parp)); + if (dns == NULL) { + dev_err(dev, "failed to find sysmmu node\n"); + return -EINVAL; + } + pds = of_find_device_by_node(dns); + if (pds == NULL) { + dev_err(dev, "failed to find sysmmu platform device\n"); + return -EINVAL; + } + + platform_set_sysmmu(&pds->dev, dev); + return 0; +} + static struct s5p_hdmi_platform_data *drm_hdmi_dt_parse_pdata (struct device *dev) { @@ -2294,6 +2324,11 @@ static struct s5p_hdmi_platform_data *drm_hdmi_dt_parse_pdata goto err_data; } + if (drm_hdmi_dt_init_iommu(dev)) { + DRM_ERROR("no sysmmu property found\n"); + goto err_data; + } + pd->hpd_gpio = of_get_named_gpio_flags(np, "hpd-gpio", 0, &flags); return pd; -- 1.7.0.4