Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3326698ybb; Mon, 6 Apr 2020 06:51:00 -0700 (PDT) X-Google-Smtp-Source: APiQypKRkjCDy1Gm4TOW8tQxqLImzpsoDEpiqixMTARlrx3NrTPEUUnk9C+ki6c9qCpOo1ERz59w X-Received: by 2002:a05:6820:319:: with SMTP id l25mr17434027ooe.88.1586181060417; Mon, 06 Apr 2020 06:51:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586181060; cv=none; d=google.com; s=arc-20160816; b=viwW7uprlbnZre25q3qAl7w7Eto067HLkySE/lkBOOVZINZ0k/h8HyumgaYyhxR264 VOuByAmo5ig5yV8An644ZWdyLIGAJpBJN9r9EFppQgyU+T0coM0yBtmETyEDJ70cWiTo H0bzuuk2xz0vge8X1hXC+hggCJcILAfatBLsorsPWrpA7iq9qNzucahxWbkH1Fs1mDYy gCw20w0VZMFInpJ/00wPe29/1H6md+AGKavmJSz0G5qHzE0seqKZPIOBGykgv7gVV1g2 rFn8+D9nJAlY93Abp5fVhpdImTbiJ8SjOXlQQ+nouzsf9Agu+nq7FU7SiT6ZgMWApy0W hucA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=kZlL3hg/1Q69d65tSSFPy5y9wd3uhOcAy6Z/aJ+mR6o=; b=XCmLBTYLyBqR7SP3lOkXO0pBT3eEKQIr1ojKWx9CT3yWRSlDkxo/moRqeVzrJdkLiQ /wOrWsQh9wCkT4Fx2UrmTctrI0rNAvz1lzpcWWn3X1ZsNSC9BQ6IMKGEqoyX3Fj8GkCb dwbp1prX3NZI+j9SNTOxWbPyYSxOWBbyv71gtqomKEXnVgmsBv84zzGKGzr/VqMtUJsS E9I8E9O3iQ8xE2nqryeoLSManp519kPD/+AM77WbDRAiNjmGTNyedsXOMZVVqtRzVtu+ 4MaUYiTXtf/s3Kc//ulHpsOUI4Mt5suEylD+/tcgCaBVSxRYX88m+FWkyAUKEeX7L1p+ AeMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b="TZRMQw/S"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w63si8367895otb.59.2020.04.06.06.50.47; Mon, 06 Apr 2020 06:51:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b="TZRMQw/S"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728458AbgDFNtU (ORCPT + 99 others); Mon, 6 Apr 2020 09:49:20 -0400 Received: from smtprelay-out1.synopsys.com ([149.117.87.133]:40992 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728334AbgDFNtU (ORCPT ); Mon, 6 Apr 2020 09:49:20 -0400 Received: from mailhost.synopsys.com (mdc-mailhost2.synopsys.com [10.225.0.210]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id C55D9C0384; Mon, 6 Apr 2020 13:49:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1586180959; bh=ZlXcrKakS3xNCjgGOMDwWxQfO9zxlDvxLe1htROlAFQ=; h=From:To:Cc:Subject:Date:From; b=TZRMQw/SLJo3cmRDiPXdd7uTAeyG75fKtY0F4K+yQnz8lFjf34livgcdyZAupG6aw zpe0I4LC7QEuhC0OCfrk72Q+VReG2jLlqzwQibl0vxfJKi3QQ+0iepUqIhMXI12j1a sgU6UCfV1+EPLcTdWReFlFJtez0DtROOyp2U2oOeqCFXlAffMY4SJx31eqL5WOiOFX FqyG7kC+Biwq3uvEgTH6LrFRvZivy8fOAUL43ODRjxwGr8IyrIm8CO1lam5wT1WSZp xZ1rvVBwgLmuFeD+sxfrtIXT7SNLuor3Yjm8lShzbUjM7C8I5w26KpvTPvTVGwvXbi mbw4FsdZ8jieQ== Received: from de02dwia024.internal.synopsys.com (de02dwia024.internal.synopsys.com [10.225.19.81]) by mailhost.synopsys.com (Postfix) with ESMTP id 85677A005C; Mon, 6 Apr 2020 13:49:13 +0000 (UTC) From: Angelo Ribeiro To: yannick.fertre@st.com, philippe.cornu@st.com, benjamin.gaignard@st.com, airlied@linux.ie, daniel@ffwll.ch, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, dri-devel@lists.freedesktop.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, pop.adrian61@gmail.com Cc: Angelo Ribeiro , Gustavo Pimentel , Joao Pinto , Jose Abreu Subject: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs Date: Mon, 6 Apr 2020 15:49:03 +0200 Message-Id: X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for the video pattern generator (VPG) BER pattern mode and configuration in runtime. This enables using the debugfs interface to manipulate the VPG after the pipeline is set. Also, enables the usage of the VPG BER pattern. Changes in v2: - Added VID_MODE_VPG_MODE - Solved incompatible return type on __get and __set Reported-by: kbuild test robot Reported-by: Adrian Pop Cc: Gustavo Pimentel Cc: Joao Pinto Cc: Jose Abreu Signed-off-by: Angelo Ribeiro --- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++--- 1 file changed, 90 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c index b18351b..9de3645 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c @@ -91,6 +91,7 @@ #define VID_MODE_TYPE_BURST 0x2 #define VID_MODE_TYPE_MASK 0x3 #define VID_MODE_VPG_ENABLE BIT(16) +#define VID_MODE_VPG_MODE BIT(20) #define VID_MODE_VPG_HORIZONTAL BIT(24) #define DSI_VID_PKT_SIZE 0x3c @@ -221,6 +222,21 @@ #define PHY_STATUS_TIMEOUT_US 10000 #define CMD_PKT_STATUS_TIMEOUT_US 20000 +#ifdef CONFIG_DEBUG_FS +#define VPG_DEFS(name, dsi) \ + ((void __force *)&((*dsi).vpg_defs.name)) + +#define REGISTER(name, mask, dsi) \ + { #name, VPG_DEFS(name, dsi), mask, dsi } + +struct debugfs_entries { + const char *name; + bool *reg; + u32 mask; + struct dw_mipi_dsi *dsi; +}; +#endif /* CONFIG_DEBUG_FS */ + struct dw_mipi_dsi { struct drm_bridge bridge; struct mipi_dsi_host dsi_host; @@ -238,9 +254,12 @@ struct dw_mipi_dsi { #ifdef CONFIG_DEBUG_FS struct dentry *debugfs; - - bool vpg; - bool vpg_horizontal; + struct debugfs_entries *debugfs_vpg; + struct { + bool vpg; + bool vpg_horizontal; + bool vpg_ber_pattern; + } vpg_defs; #endif /* CONFIG_DEBUG_FS */ struct dw_mipi_dsi *master; /* dual-dsi master ptr */ @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi) val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS; #ifdef CONFIG_DEBUG_FS - if (dsi->vpg) { + if (dsi->vpg_defs.vpg) { val |= VID_MODE_VPG_ENABLE; - val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0; + val |= dsi->vpg_defs.vpg_horizontal ? + VID_MODE_VPG_HORIZONTAL : 0; + val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0; } #endif /* CONFIG_DEBUG_FS */ @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = { #ifdef CONFIG_DEBUG_FS +int dw_mipi_dsi_debugfs_write(void *data, u64 val) +{ + struct debugfs_entries *vpg = data; + struct dw_mipi_dsi *dsi; + u32 mode_cfg; + + if (!vpg) + return -ENODEV; + + dsi = vpg->dsi; + + *vpg->reg = (bool)val; + + mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG); + + if (*vpg->reg) + mode_cfg |= vpg->mask; + else + mode_cfg &= ~vpg->mask; + + dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg); + + return 0; +} + +int dw_mipi_dsi_debugfs_show(void *data, u64 *val) +{ + struct debugfs_entries *vpg = data; + + if (!vpg) + return -ENODEV; + + *val = *vpg->reg; + + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show, + dw_mipi_dsi_debugfs_write, "%llu\n"); + +static void debugfs_create_files(void *data) +{ + struct dw_mipi_dsi *dsi = data; + struct debugfs_entries debugfs[] = { + REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi), + REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi), + REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi), + }; + int i; + + dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL); + if (!dsi->debugfs_vpg) + return; + + memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs)); + + for (i = 0; i < ARRAY_SIZE(debugfs); i++) + debugfs_create_file(dsi->debugfs_vpg[i].name, 0644, + dsi->debugfs, &dsi->debugfs_vpg[i], + &fops_x32); +} + static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi) { dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL); @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi) return; } - debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg); - debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs, - &dsi->vpg_horizontal); + debugfs_create_files(dsi); } static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi) { debugfs_remove_recursive(dsi->debugfs); + kfree(dsi->debugfs_vpg); } #else -- 2.7.4