From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3DB8C5519F for ; Tue, 17 Nov 2020 08:09:00 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 412E8217A0 for ; Tue, 17 Nov 2020 08:09:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Bn+eU5J3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 412E8217A0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WriLrcpc6wnXB6acJ4Ln6WSMYgGq9jKT9aVpLIHDlYQ=; b=Bn+eU5J3NYF6T0wPmr1UwLMdY hKMSp/yR4cSrzkUy0jZe4QRkoqQZdPQOpGCGHO+oznltWFvvPr0v2keAa2Y6spwMCTeNI0g60+kCp Dk8n5jSA4wuFx8/hAbRultH6rXbPmnKeYjsocyDPKu4vOXB9xJPJ8flZ7ItVgBQCN9h0dXHvWaVqp E26XSQshhndsN1e/IrYGyF7C15SPErvW8zJxgrGnvnN4a3FoNN/fVXL3TUBGJMUt5SflBNorD+Vm6 Q9iRd9jZ6XKY3wBL5O2HeLPkPWieDvX/haEDWMmaZWgnTzwZb1OBnVwf6Y3yxAbzK5isGVQJlTrQJ my97P6C2Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kew2P-0005oT-6O; Tue, 17 Nov 2020 08:08:29 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kew2M-0005nK-AB for linux-arm-kernel@lists.infradead.org; Tue, 17 Nov 2020 08:08:27 +0000 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kew2J-0003Mj-6t; Tue, 17 Nov 2020 09:08:23 +0100 Received: from mtr by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kew2H-0001mh-Jl; Tue, 17 Nov 2020 09:08:21 +0100 Date: Tue, 17 Nov 2020 09:08:21 +0100 From: Michael Tretter To: Hyun Kwon Subject: Re: [PATCH v4 3/4] soc: xilinx: vcu: use vcu-settings syscon registers Message-ID: <20201117080821.GA26611@pengutronix.de> References: <20201109134818.4159342-1-m.tretter@pengutronix.de> <20201109134818.4159342-4-m.tretter@pengutronix.de> <20201113205248.GA1052580@xilinx.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201113205248.GA1052580@xilinx.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 08:57:48 up 271 days, 15:28, 81 users, load average: 0.37, 0.30, 0.28 User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201117_030826_610623_09B2DB25 X-CRM114-Status: GOOD ( 37.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dshah@xilinx.com, tejasp@xilinx.com, gregkh@linuxfoundation.org, rajanv@xilinx.com, michals@xilinx.com, rvisaval@xilinx.com, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 13 Nov 2020 12:52:48 -0800, Hyun Kwon wrote: > On Mon, Nov 09, 2020 at 02:48:17PM +0100, Michael Tretter wrote: > > Switch the "logicoreip" registers to the new xlnx,vcu-settings binding > > to be able to read the settings if the settings are specified in a > > separate device tree node that is shared with other drivers. > > > > If the driver is not able to find a node with the new binding, fall back > > to check for the logicore register bank to be backwards compatible. > > > > Signed-off-by: Michael Tretter > > --- > > drivers/soc/xilinx/Kconfig | 1 + > > drivers/soc/xilinx/xlnx_vcu.c | 94 ++++++++++++++--------------- > > include/linux/mfd/syscon/xlnx-vcu.h | 38 ++++++++++++ > > 3 files changed, 86 insertions(+), 47 deletions(-) > > create mode 100644 include/linux/mfd/syscon/xlnx-vcu.h > > > > diff --git a/drivers/soc/xilinx/Kconfig b/drivers/soc/xilinx/Kconfig > > index 646512d7276f..0b1708dae361 100644 > > --- a/drivers/soc/xilinx/Kconfig > > +++ b/drivers/soc/xilinx/Kconfig > > @@ -4,6 +4,7 @@ menu "Xilinx SoC drivers" > > config XILINX_VCU > > tristate "Xilinx VCU logicoreIP Init" > > depends on HAS_IOMEM > > + select REGMAP_MMIO > > This should be 'depends on'? Please check: https://www.spinics.net/lists/kernel/msg3607924.html No, the 'select' is correct for REGMAP_MMIO. The REGMAP* config options don't have a prompt and are expected to be selected by drivers that are using them. > > The rest look fine to me. After confirming above, for 1/4, 3/4, and 4/4, > please feel free to add, > > Reviewed-by: Hyun Kwon Thanks, Michael > > Thanks! > > -hyun > > > help > > Provides the driver to enable and disable the isolation between the > > processing system and programmable logic part by using the logicoreIP > > diff --git a/drivers/soc/xilinx/xlnx_vcu.c b/drivers/soc/xilinx/xlnx_vcu.c > > index dcd8e7824b06..14daad4efc58 100644 > > --- a/drivers/soc/xilinx/xlnx_vcu.c > > +++ b/drivers/soc/xilinx/xlnx_vcu.c > > @@ -10,39 +10,12 @@ > > #include > > #include > > #include > > +#include > > +#include > > #include > > #include > > #include > > - > > -/* Address map for different registers implemented in the VCU LogiCORE IP. */ > > -#define VCU_ECODER_ENABLE 0x00 > > -#define VCU_DECODER_ENABLE 0x04 > > -#define VCU_MEMORY_DEPTH 0x08 > > -#define VCU_ENC_COLOR_DEPTH 0x0c > > -#define VCU_ENC_VERTICAL_RANGE 0x10 > > -#define VCU_ENC_FRAME_SIZE_X 0x14 > > -#define VCU_ENC_FRAME_SIZE_Y 0x18 > > -#define VCU_ENC_COLOR_FORMAT 0x1c > > -#define VCU_ENC_FPS 0x20 > > -#define VCU_MCU_CLK 0x24 > > -#define VCU_CORE_CLK 0x28 > > -#define VCU_PLL_BYPASS 0x2c > > -#define VCU_ENC_CLK 0x30 > > -#define VCU_PLL_CLK 0x34 > > -#define VCU_ENC_VIDEO_STANDARD 0x38 > > -#define VCU_STATUS 0x3c > > -#define VCU_AXI_ENC_CLK 0x40 > > -#define VCU_AXI_DEC_CLK 0x44 > > -#define VCU_AXI_MCU_CLK 0x48 > > -#define VCU_DEC_VIDEO_STANDARD 0x4c > > -#define VCU_DEC_FRAME_SIZE_X 0x50 > > -#define VCU_DEC_FRAME_SIZE_Y 0x54 > > -#define VCU_DEC_FPS 0x58 > > -#define VCU_BUFFER_B_FRAME 0x5c > > -#define VCU_WPP_EN 0x60 > > -#define VCU_PLL_CLK_DEC 0x64 > > -#define VCU_GASKET_INIT 0x74 > > -#define VCU_GASKET_VALUE 0x03 > > +#include > > > > /* vcu slcr registers, bitmask and shift */ > > #define VCU_PLL_CTRL 0x24 > > @@ -106,11 +79,20 @@ struct xvcu_device { > > struct device *dev; > > struct clk *pll_ref; > > struct clk *aclk; > > - void __iomem *logicore_reg_ba; > > + struct regmap *logicore_reg_ba; > > void __iomem *vcu_slcr_ba; > > u32 coreclk; > > }; > > > > +static struct regmap_config vcu_settings_regmap_config = { > > + .name = "regmap", > > + .reg_bits = 32, > > + .val_bits = 32, > > + .reg_stride = 4, > > + .max_register = 0xfff, > > + .cache_type = REGCACHE_NONE, > > +}; > > + > > /** > > * struct xvcu_pll_cfg - Helper data > > * @fbdiv: The integer portion of the feedback divider to the PLL > > @@ -300,10 +282,12 @@ static int xvcu_set_vcu_pll_info(struct xvcu_device *xvcu) > > int ret, i; > > const struct xvcu_pll_cfg *found = NULL; > > > > - inte = xvcu_read(xvcu->logicore_reg_ba, VCU_PLL_CLK); > > - deci = xvcu_read(xvcu->logicore_reg_ba, VCU_PLL_CLK_DEC); > > - coreclk = xvcu_read(xvcu->logicore_reg_ba, VCU_CORE_CLK) * MHZ; > > - mcuclk = xvcu_read(xvcu->logicore_reg_ba, VCU_MCU_CLK) * MHZ; > > + regmap_read(xvcu->logicore_reg_ba, VCU_PLL_CLK, &inte); > > + regmap_read(xvcu->logicore_reg_ba, VCU_PLL_CLK_DEC, &deci); > > + regmap_read(xvcu->logicore_reg_ba, VCU_CORE_CLK, &coreclk); > > + coreclk *= MHZ; > > + regmap_read(xvcu->logicore_reg_ba, VCU_MCU_CLK, &mcuclk); > > + mcuclk *= MHZ; > > if (!mcuclk || !coreclk) { > > dev_err(xvcu->dev, "Invalid mcu and core clock data\n"); > > return -EINVAL; > > @@ -498,6 +482,7 @@ static int xvcu_probe(struct platform_device *pdev) > > { > > struct resource *res; > > struct xvcu_device *xvcu; > > + void __iomem *regs; > > int ret; > > > > xvcu = devm_kzalloc(&pdev->dev, sizeof(*xvcu), GFP_KERNEL); > > @@ -518,17 +503,32 @@ static int xvcu_probe(struct platform_device *pdev) > > return -ENOMEM; > > } > > > > - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "logicore"); > > - if (!res) { > > - dev_err(&pdev->dev, "get logicore memory resource failed.\n"); > > - return -ENODEV; > > - } > > + xvcu->logicore_reg_ba = > > + syscon_regmap_lookup_by_compatible("xlnx,vcu-settings"); > > + if (IS_ERR(xvcu->logicore_reg_ba)) { > > + dev_info(&pdev->dev, > > + "could not find xlnx,vcu-settings: trying direct register access\n"); > > + > > + res = platform_get_resource_byname(pdev, > > + IORESOURCE_MEM, "logicore"); > > + if (!res) { > > + dev_err(&pdev->dev, "get logicore memory resource failed.\n"); > > + return -ENODEV; > > + } > > > > - xvcu->logicore_reg_ba = devm_ioremap(&pdev->dev, res->start, > > - resource_size(res)); > > - if (!xvcu->logicore_reg_ba) { > > - dev_err(&pdev->dev, "logicore register mapping failed.\n"); > > - return -ENOMEM; > > + regs = devm_ioremap(&pdev->dev, res->start, resource_size(res)); > > + if (!regs) { > > + dev_err(&pdev->dev, "logicore register mapping failed.\n"); > > + return -ENOMEM; > > + } > > + > > + xvcu->logicore_reg_ba = > > + devm_regmap_init_mmio(&pdev->dev, regs, > > + &vcu_settings_regmap_config); > > + if (IS_ERR(xvcu->logicore_reg_ba)) { > > + dev_err(&pdev->dev, "failed to init regmap\n"); > > + return PTR_ERR(xvcu->logicore_reg_ba); > > + } > > } > > > > xvcu->aclk = devm_clk_get(&pdev->dev, "aclk"); > > @@ -560,7 +560,7 @@ static int xvcu_probe(struct platform_device *pdev) > > * Bit 0 : Gasket isolation > > * Bit 1 : put VCU out of reset > > */ > > - xvcu_write(xvcu->logicore_reg_ba, VCU_GASKET_INIT, VCU_GASKET_VALUE); > > + regmap_write(xvcu->logicore_reg_ba, VCU_GASKET_INIT, VCU_GASKET_VALUE); > > > > /* Do the PLL Settings based on the ref clk,core and mcu clk freq */ > > ret = xvcu_set_pll(xvcu); > > @@ -597,7 +597,7 @@ static int xvcu_remove(struct platform_device *pdev) > > return -ENODEV; > > > > /* Add the the Gasket isolation and put the VCU in reset. */ > > - xvcu_write(xvcu->logicore_reg_ba, VCU_GASKET_INIT, 0); > > + regmap_write(xvcu->logicore_reg_ba, VCU_GASKET_INIT, 0); > > > > clk_disable_unprepare(xvcu->pll_ref); > > clk_disable_unprepare(xvcu->aclk); > > diff --git a/include/linux/mfd/syscon/xlnx-vcu.h b/include/linux/mfd/syscon/xlnx-vcu.h > > new file mode 100644 > > index 000000000000..d3edec4b7b1d > > --- /dev/null > > +++ b/include/linux/mfd/syscon/xlnx-vcu.h > > @@ -0,0 +1,38 @@ > > +/* SPDX-License-Identifier: GPL-2.0-only */ > > +/* > > + * Copyright (C) 2020 Pengutronix, Michael Tretter > > + */ > > + > > +#ifndef __XLNX_VCU_H > > +#define __XLNX_VCU_H > > + > > +#define VCU_ECODER_ENABLE 0x00 > > +#define VCU_DECODER_ENABLE 0x04 > > +#define VCU_MEMORY_DEPTH 0x08 > > +#define VCU_ENC_COLOR_DEPTH 0x0c > > +#define VCU_ENC_VERTICAL_RANGE 0x10 > > +#define VCU_ENC_FRAME_SIZE_X 0x14 > > +#define VCU_ENC_FRAME_SIZE_Y 0x18 > > +#define VCU_ENC_COLOR_FORMAT 0x1c > > +#define VCU_ENC_FPS 0x20 > > +#define VCU_MCU_CLK 0x24 > > +#define VCU_CORE_CLK 0x28 > > +#define VCU_PLL_BYPASS 0x2c > > +#define VCU_ENC_CLK 0x30 > > +#define VCU_PLL_CLK 0x34 > > +#define VCU_ENC_VIDEO_STANDARD 0x38 > > +#define VCU_STATUS 0x3c > > +#define VCU_AXI_ENC_CLK 0x40 > > +#define VCU_AXI_DEC_CLK 0x44 > > +#define VCU_AXI_MCU_CLK 0x48 > > +#define VCU_DEC_VIDEO_STANDARD 0x4c > > +#define VCU_DEC_FRAME_SIZE_X 0x50 > > +#define VCU_DEC_FRAME_SIZE_Y 0x54 > > +#define VCU_DEC_FPS 0x58 > > +#define VCU_BUFFER_B_FRAME 0x5c > > +#define VCU_WPP_EN 0x60 > > +#define VCU_PLL_CLK_DEC 0x64 > > +#define VCU_GASKET_INIT 0x74 > > +#define VCU_GASKET_VALUE 0x03 > > + > > +#endif /* __XLNX_VCU_H */ > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel