From patchwork Thu Jan 24 18:07:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10779819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F98613BF for ; Thu, 24 Jan 2019 18:08:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82407325C3 for ; Thu, 24 Jan 2019 18:08:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 730CA32629; Thu, 24 Jan 2019 18:08:36 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11836325C3 for ; Thu, 24 Jan 2019 18:08:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729408AbfAXSIa (ORCPT ); Thu, 24 Jan 2019 13:08:30 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:35764 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729377AbfAXSI2 (ORCPT ); Thu, 24 Jan 2019 13:08:28 -0500 Received: by mail-pl1-f196.google.com with SMTP id p8so3253857plo.2 for ; Thu, 24 Jan 2019 10:08:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UF0ie0AFcUOJKnp5dQnoc9GbuzcXmNAC6ctNdvT/vFI=; b=NDnnVVg9N0w5j1eh1QJCTCPhT7lwbq9Ao11qqMbunE5BM5940dxN0lbptZCCdXzKU5 Z+Fkc6FcGLYcT/+cPt7sbICMX5UtfFR5j+Ie4Sdx+0YKgPE4+2fyzU8QTKl9ZDNFYbZZ wNgxqaNhvZdfWWIGu16fr+eEZkIyMttuBGx+w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UF0ie0AFcUOJKnp5dQnoc9GbuzcXmNAC6ctNdvT/vFI=; b=eyszLWokv0D4Uoz20ehqp698Vl7kF8S27ZMGKgiVLaxnROsu1dER7bdwPZ20MhJaRI JCMYES/H796tpc6O5+xkPZAk8mnTX1h/HVcRVmCKML5/eiBVoyMcP25pCEc8alqm1cpe afRFVyJ2r6hO4paZaWNQN8lXbsuXIR+v6QVUYE9nvkMZHbd7puqJh+wkB/NlVIv2/ccm p9t3sAPqKSZlIr35UFRVDrRF/7yrb8gu+hQzlGBjhAAhyhoztdy/CGy68eD5dDlsqIMV 2mIw8fJrgZo02fAnB+CZjcEgzkPvrjNXR5mkAC0fVJi1KkXH3pk8non+6oPQoWnDvEI8 qOSA== X-Gm-Message-State: AJcUukdNX7bsPnFpQj0bx12hrlDq52Uu57nxq+yDz338BI8sA0SBBlwO V3q6mWwkc35Dy8RaqNHwJQj3MQ== X-Google-Smtp-Source: ALg8bN6gvz0ooTP/Bgag/ZsaxzHTDVYxLlAJYp+VPyEO8INABlTb5oDJjjG601prTqUveq9BY1KhUA== X-Received: by 2002:a17:902:9a07:: with SMTP id v7mr2332887plp.247.1548353308049; Thu, 24 Jan 2019 10:08:28 -0800 (PST) Received: from localhost.localdomain ([115.97.179.75]) by smtp.gmail.com with ESMTPSA id k15sm36141551pfb.147.2019.01.24.10.08.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 10:08:27 -0800 (PST) From: Jagan Teki To: Yong Deng , Mauro Carvalho Chehab , Maxime Ripard , Chen-Yu Tsai , Rob Herring , Mark Rutland Cc: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Michael Trimarchi , linux-amarula@amarulasolutions.com, devicetree@vger.kernel.org, linux-sunxi@googlegroups.com, Jagan Teki Subject: [PATCH v7 2/5] media: sun6i: Add A64 CSI block support Date: Thu, 24 Jan 2019 23:37:33 +0530 Message-Id: <20190124180736.28408-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190124180736.28408-1-jagan@amarulasolutions.com> References: <20190124180736.28408-1-jagan@amarulasolutions.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP CSI block in Allwinner A64 has similar features as like in H3, but the default CSI_SCLK rate cannot work properly to drive the connected sensor interface. The tested mod cock rate is 300 MHz and BSP vfe media driver is also using the same rate. Unfortunately there is no valid information about clock rate in manual or any other sources except the BSP driver. so more faith on BSP code, because same has tested in mainline. So, add support for A64 CSI block by setting updated mod clock rate. Signed-off-by: Jagan Teki --- drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c index ee882b66a5ea..cd2d33242c17 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -154,6 +155,7 @@ bool sun6i_csi_is_format_supported(struct sun6i_csi *csi, int sun6i_csi_set_power(struct sun6i_csi *csi, bool enable) { struct sun6i_csi_dev *sdev = sun6i_csi_to_dev(csi); + struct device *dev = sdev->dev; struct regmap *regmap = sdev->regmap; int ret; @@ -161,15 +163,20 @@ int sun6i_csi_set_power(struct sun6i_csi *csi, bool enable) regmap_update_bits(regmap, CSI_EN_REG, CSI_EN_CSI_EN, 0); clk_disable_unprepare(sdev->clk_ram); + if (of_device_is_compatible(dev->of_node, "allwinner,sun50i-a64-csi")) + clk_rate_exclusive_put(sdev->clk_mod); clk_disable_unprepare(sdev->clk_mod); reset_control_assert(sdev->rstc_bus); return 0; } + if (of_device_is_compatible(dev->of_node, "allwinner,sun50i-a64-csi")) + clk_set_rate_exclusive(sdev->clk_mod, 300000000); + ret = clk_prepare_enable(sdev->clk_mod); if (ret) { dev_err(sdev->dev, "Enable csi clk err %d\n", ret); - return ret; + goto clk_mod_put; } ret = clk_prepare_enable(sdev->clk_ram); @@ -192,6 +199,9 @@ int sun6i_csi_set_power(struct sun6i_csi *csi, bool enable) clk_disable_unprepare(sdev->clk_ram); clk_mod_disable: clk_disable_unprepare(sdev->clk_mod); +clk_mod_put: + if (of_device_is_compatible(dev->of_node, "allwinner,sun50i-a64-csi")) + clk_rate_exclusive_put(sdev->clk_mod); return ret; } @@ -895,6 +905,7 @@ static const struct of_device_id sun6i_csi_of_match[] = { { .compatible = "allwinner,sun6i-a31-csi", }, { .compatible = "allwinner,sun8i-h3-csi", }, { .compatible = "allwinner,sun8i-v3s-csi", }, + { .compatible = "allwinner,sun50i-a64-csi", }, {}, }; MODULE_DEVICE_TABLE(of, sun6i_csi_of_match);