From patchwork Thu Jan 11 16:54:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 10158255 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1A1F6605BA for ; Thu, 11 Jan 2018 17:02:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC575286A8 for ; Thu, 11 Jan 2018 17:02:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAF19288A7; Thu, 11 Jan 2018 17:02:03 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 B9E86286A8 for ; Thu, 11 Jan 2018 17:01:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 744CF6E7D5; Thu, 11 Jan 2018 17:01:10 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x241.google.com (mail-lf0-x241.google.com [IPv6:2a00:1450:4010:c07::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id D4F4D6E7D5 for ; Thu, 11 Jan 2018 17:01:08 +0000 (UTC) Received: by mail-lf0-x241.google.com with SMTP id v74so1584297lfa.7 for ; Thu, 11 Jan 2018 09:01:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:user-agent:date:to:cc:subject:mime-version :content-disposition; bh=/cQVPknNX+0mQFKo8ZOJ32AP8gReNLJiE4dbSifuq4Q=; b=XnyRTE+VMNjkul+5JL+G6KenkdL5VJZGYQc5qRjUFT/A2sAs7HNnk/RppQGkF1epY1 onp3d+z+iXTngYg/YmK5Fd77X1JDT4931cKIZYuovkgznrplOzrt+/8q9jMuKascAg4L 63Y3Hw4bWmXiv4sXq+mbQt2NVzlp0iRINK8wur/3Lt3vjvalp35zjht7ZLGuCvwVu+Jl XmuMSdXxSpmJPRm15vSXgr0i4eal789CdFcab0kY9zLbiEPwB8ek2qan9O7j6A9qdxwl K/foHyQfuaUZCissbOHl8Q16lH1KwGRF98Et4Z3XoXIaMhk8pLvTu+VVYgplHQAcpMcq orog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:user-agent:date:to:cc:subject :mime-version:content-disposition; bh=/cQVPknNX+0mQFKo8ZOJ32AP8gReNLJiE4dbSifuq4Q=; b=uZcFw0/DV4cV3PylQG/g9o7C8XfbuOh6hSCvUeNxii2jdNaJizJoBj5IARU0XAQQMo OwEt0vSu2SSCcmZzmyIw+3qFP6XRFMyG2MtjJzjM2T7NtQufGv2FSdmxhC7vHOhFzmpJ D9juDAfbqzsd3Ca0PkUY+ddsfgRbTjKpcJp7O7G5/p8CLQkQLVJZsiYx5dxySEE/1nhZ DDoIBXjV6HeRnuFmxrVb/wXD82+IGvguXLEr12+K0IIWSmeMFeoQeaIiM/rWWuA9DeHg 5tjFC5/iZdbT4LKg7DNhpqtNLzeAGxn5RHkvId/OSmUkzU4XdEeLbSZ/Ig/6zYAmTZ0I LKBw== X-Gm-Message-State: AKwxytcFnV4tO7aO1K3gsT38EzFPZLpEecSZK9E/5EpnB+BPcyQVSPYs P4rUwNstxcPEreI9X6DXVGBRLA== X-Google-Smtp-Source: ACJfBou/PqXuIQtiyz24mTf5q90virx16MFWc25lPxBQauh24KZJ7+NZGNK4V5ShIEfQ4Tl/sIEMdw== X-Received: by 10.25.228.13 with SMTP id b13mr6902804lfh.61.1515690067025; Thu, 11 Jan 2018 09:01:07 -0800 (PST) Received: from wasted.cogentembedded.com ([31.173.85.218]) by smtp.gmail.com with ESMTPSA id c25sm1201421lja.50.2018.01.11.09.01.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jan 2018 09:01:06 -0800 (PST) From: Sergei Shtylyov X-Google-Original-From: "Sergei Shtylyov" Received: by wasted.cogentembedded.com (sSMTP sendmail emulation); Thu, 11 Jan 2018 20:01:03 +0300 Message-Id: <20180111170103.676775968@cogentembedded.com> User-Agent: quilt/0.64 Date: Thu, 11 Jan 2018 19:54:35 +0300 To: Laurent Pinchart , David Airlie , Rob Herring , Mark Rutland , dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 3/3] drm: rcar-du: add R8A77970 support MIME-Version: 1.0 Content-Disposition: inline; filename=drm-rcar-du-add-R8A77970-support.patch Cc: Sergei Shtylyov X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add support for the R-Car V3M (R8A77970) SoC to the DU driver (this SoC has only 1 display port). Note that there are some differences with the other R-Car gen3 SoCs in the LVDS encoder part, e.g. LVDPLLCR has the same layout as on the R-Car gen2 SoCs... Signed-off-by: Sergei Shtylyov --- Documentation/devicetree/bindings/display/renesas,du.txt | 1 drivers/gpu/drm/rcar-du/rcar_du_drv.c | 23 +++++++++++++++ drivers/gpu/drm/rcar-du/rcar_du_drv.h | 1 drivers/gpu/drm/rcar-du/rcar_du_group.c | 10 +++--- drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 20 +++++++++---- 5 files changed, 45 insertions(+), 10 deletions(-) Index: linux/Documentation/devicetree/bindings/display/renesas,du.txt =================================================================== --- linux.orig/Documentation/devicetree/bindings/display/renesas,du.txt +++ linux/Documentation/devicetree/bindings/display/renesas,du.txt @@ -13,6 +13,7 @@ Required Properties: - "renesas,du-r8a7794" for R8A7794 (R-Car E2) compatible DU - "renesas,du-r8a7795" for R8A7795 (R-Car H3) compatible DU - "renesas,du-r8a7796" for R8A7796 (R-Car M3-W) compatible DU + - "renesas,du-r8a77970" for R8A77970 (R-Car V3M) compatible DU - reg: A list of base address and length of each memory resource, one for each entry in the reg-names property. Index: linux/drivers/gpu/drm/rcar-du/rcar_du_drv.c =================================================================== --- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ linux/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -258,6 +258,28 @@ static const struct rcar_du_device_info .dpll_ch = BIT(1), }; +static const struct rcar_du_device_info rcar_du_r8a77970_info = { + .gen = 3, + .model = R8A77970, + .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK + | RCAR_DU_FEATURE_EXT_CTRL_REGS + | RCAR_DU_FEATURE_VSP1_SOURCE, + .num_crtcs = 1, + .routes = { + /* R8A77970 has one RGB output and one LVDS output. */ + [RCAR_DU_OUTPUT_DPAD0] = { + .possible_crtcs = BIT(0), + .port = 1, + }, + [RCAR_DU_OUTPUT_LVDS0] = { + .possible_crtcs = BIT(0), + .port = 0, + }, + }, + .num_lvds = 1, + .dpll_ch = BIT(1), +}; + static const struct of_device_id rcar_du_of_table[] = { { .compatible = "renesas,du-r8a7743", .data = &rzg1_du_r8a7743_info }, { .compatible = "renesas,du-r8a7745", .data = &rzg1_du_r8a7745_info }, @@ -269,6 +291,7 @@ static const struct of_device_id rcar_du { .compatible = "renesas,du-r8a7794", .data = &rcar_du_r8a7794_info }, { .compatible = "renesas,du-r8a7795", .data = &rcar_du_r8a7795_info }, { .compatible = "renesas,du-r8a7796", .data = &rcar_du_r8a7796_info }, + { .compatible = "renesas,du-r8a77970", .data = &rcar_du_r8a77970_info }, { } }; Index: linux/drivers/gpu/drm/rcar-du/rcar_du_drv.h =================================================================== --- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_drv.h +++ linux/drivers/gpu/drm/rcar-du/rcar_du_drv.h @@ -59,6 +59,7 @@ enum rcar_du_model { R8A7794, R8A7795, R8A7796, + R8A77970, }; /* Index: linux/drivers/gpu/drm/rcar-du/rcar_du_group.c =================================================================== --- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_group.c +++ linux/drivers/gpu/drm/rcar-du/rcar_du_group.c @@ -133,10 +133,12 @@ static void rcar_du_group_setup(struct r rcar_du_group_write(rgrp, DORCR, DORCR_PG1D_DS1 | DORCR_DPRS); /* Apply planes to CRTCs association. */ - mutex_lock(&rgrp->lock); - rcar_du_group_write(rgrp, DPTSR, (rgrp->dptsr_planes << 16) | - rgrp->dptsr_planes); - mutex_unlock(&rgrp->lock); + if (rcdu->info->num_crtcs > 1) { + mutex_lock(&rgrp->lock); + rcar_du_group_write(rgrp, DPTSR, (rgrp->dptsr_planes << 16) | + rgrp->dptsr_planes); + mutex_unlock(&rgrp->lock); + } } /* Index: linux/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c =================================================================== --- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c +++ linux/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c @@ -71,8 +71,10 @@ static int rcar_du_lvdsenc_start(struct struct rcar_du_crtc *rcrtc) { u32 lvdhcr, lvdpllcr, lvdcr0 = lvds->mode << LVDCR0_LVMD_SHIFT; + const struct rcar_du_device_info *info = lvds->dev->info; const struct drm_display_mode *mode = &rcrtc->crtc.mode; - unsigned int gen = lvds->dev->info->gen; + unsigned int gen = info->gen; + enum rcar_du_model model = info->model; unsigned int freq = mode->clock; int ret; @@ -104,7 +106,7 @@ static int rcar_du_lvdsenc_start(struct rcar_lvds_write(lvds, LVDCHCR, lvdhcr); /* PLL clock configuration */ - if (gen < 3) + if (gen < 3 || model == R8A77970) lvdpllcr = rcar_lvds_gen2_lvdpllcr(freq); else lvdpllcr = rcar_lvds_gen3_lvdpllcr(freq); @@ -136,6 +138,12 @@ static int rcar_du_lvdsenc_start(struct rcar_lvds_write(lvds, LVDCR0, lvdcr0); } + /* Turn on the LVDS PHY on R-Car V3M. */ + if (model == R8A77970) { + lvdcr0 |= LVDCR0_LVEN; + rcar_lvds_write(lvds, LVDCR0, lvdcr0); + } + /* Wait for the startup delay. */ usleep_range(100, 150); @@ -177,14 +185,14 @@ int rcar_du_lvdsenc_enable(struct rcar_d void rcar_du_lvdsenc_atomic_check(struct rcar_du_lvdsenc *lvds, struct drm_display_mode *mode) { - struct rcar_du_device *rcdu = lvds->dev; + const struct rcar_du_device_info *info = lvds->dev->info; /* * The internal LVDS encoder has a restricted clock frequency operating - * range (30MHz to 150MHz on Gen2, 25.175MHz to 148.5MHz on Gen3). Clamp - * the clock accordingly. + * range (30MHz to 150MHz on Gen2 and R-Car V3M, 25.175MHz to 148.5MHz + * on Gen3). Clamp the clock accordingly. */ - if (rcdu->info->gen < 3) + if (info->gen < 3 || info->model == R8A77970) mode->clock = clamp(mode->clock, 30000, 150000); else mode->clock = clamp(mode->clock, 25175, 148500);