From patchwork Thu Dec 20 12:54:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 110 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f71.google.com (cartago.priv [10.11.12.1]) by cassiopea (Postfix) with ESMTPS id 91C462E5528 for ; Thu, 20 Dec 2018 13:54:52 +0100 (CET) Received: by mail-wm1-f71.google.com with SMTP id b186sf753118wmc.8 for ; Thu, 20 Dec 2018 04:54:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1545310492; cv=pass; d=google.com; s=arc-20160816; b=p5AWX/NXoKYDyN2fKBCFJBYXQjG4ohNqq2ddTlOcJtHBU/tczip4emlhia4Ii8qgPz AF52xq2HZogLGIKt6i8P6/v+urpGKViBHHIkB+clMJ57o+5Vck5R/UhP9LS8s1KtKFVq 7HAmH3Niy5rTXxBeipW2LcQR1FFrhbAYjmhbGHuC1SCUEWV3Dxy3Cy5ZXtfUiHBmjaES l84G3D+QXnF3nNVUUkDlRWY8ojxaUVkZrpZAme33rmrk8PvVHkhIQtNhgTipbAvuHOa1 rVsZb8xq7a2m/eT6tewUxjfboIYWz1wdrvVBKsaGw146geYy5VS55L+3gMUtYPSdVlec PbmA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LrNl3IwBPVoOT7eCSWC64ChhCwwVumPx0DUceWWWdPc=; b=MkFJxYvAK/2DQ6NqRvzgKn1RvObun9xeaOlGQlBlmKoaGOS9xXpSEUR0N7TVv2nWOe vvJI2W6IeNc6QtBRQjTJ4EOesI3MJgR+LF0mJbrgZs3BVv+PoNY6TF5Sv41ysf8fw8s7 tZDen9UZhispq84o44QIwUCmC/772v8Nf4wsIar7JqpfyPD58Kns0kM1BHSB5vKGMUFZ r1nAS6W2IktKMYYRg2yqEFyecFjjdtVR/uRnPEvlDylIRllbMD+5vGbasclA2Hfa6mNp JcggaFK0SeXFLJFDcZEmfBnAONyPht1J9HHcd9UahQB1M87SjTYlBlIZ4yIHgyTVJS3Z 50ZQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=FhO6jXCT; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=LrNl3IwBPVoOT7eCSWC64ChhCwwVumPx0DUceWWWdPc=; b=ORzTxYgUknlL4H9gk09bi3L3k2VS1Zhy7JIp5fom4W3GVubm7Md1OizmwGlOdVDHYi e+FHj9rEoMy0aYw7rLhSEMfSnwHa7yTXfBguWCqT9+e5UTkwSrgXB6MGEukVZvwC6+GF 1ij68Q38ue3rFUmzaLvbA+1W5eOggUsnzQ+gg= 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=LrNl3IwBPVoOT7eCSWC64ChhCwwVumPx0DUceWWWdPc=; b=HUEmWT1N81i1voucpyzoAGj1k8BNwo2BQPbIHEFzkk685P0B/vgGBwuMWIyXzJ6buS DWNn+xAAPPIU5LtMz6sHvRVKV735a9fqHvzSR7j4tGgeBBPO8jelo32TLfVhfr9tfjfm Sr1LCwWt475HUuonb1htNEEymr9t6wn8KLkSQ+AVIq1vsvdNuIZCB8pniyQUQ5LB8XIm UnonxbPnar8Sx+47LAok718+Ce9DvnKmhxiH4viVKLd5QToH4Dnln/C20ah1wLUAHDqe zd/Ae0vdLCIJjDwEmpx0URBm7cUZcwLeqp0daHWRlINO2A4wgZmir+EE3k+eQbMnqdk/ tTMw== X-Gm-Message-State: AA+aEWab2ozb6ce6DwvAAkPk4NzBW+Wve0wiLxWkCsd0KjoizH3ZlutO UN6LXOxYt3YuUzdGcH4y8piHLVH2 X-Google-Smtp-Source: AFSGD/XlHvk5BDY415r2s8alV5OMxZ1nThcxfmMbSQ4jn2SV2FbcMvNclTP4uK8f1Y0uPe4mfAkx5w== X-Received: by 2002:a05:6000:100d:: with SMTP id a13mr2289718wrx.2.1545310492272; Thu, 20 Dec 2018 04:54:52 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:adf:dc8e:: with SMTP id r14ls5795866wrj.2.gmail; Thu, 20 Dec 2018 04:54:51 -0800 (PST) X-Received: by 2002:adf:9123:: with SMTP id j32mr23695790wrj.122.1545310491839; Thu, 20 Dec 2018 04:54:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545310491; cv=none; d=google.com; s=arc-20160816; b=G5YO+ptD1a13A9AibeKgtSycjxXacWHXvW1eTSWJSGKiP1AIqLuQY9gpQwN/8LDgVS QokkqR1H64ATZniKPiK8IEkmwdCaRVYFAz2YOWyDZ+8MaghhC9/I19V9S/gINIX/oD1n UbGXOshwn4uOFYKXWg2lMeJxWduZF+rXEC0Z8roNia1gxlc67pNttd8MnyUV4Zfc61Wm KVm7WA6h+vnB6XPwogJUWhE/jWFzizavM8SxIhjHX+RG/j+7LpwNW2ZiAl8ETwKSruA6 uW9x3UVb5lOmEEaJMR85I22Ga7kHY2XmEsVzbY1Oet3G7aepJkbWn8f0/AHMaXInanoB eOqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=LrNl3IwBPVoOT7eCSWC64ChhCwwVumPx0DUceWWWdPc=; b=OhRvEV6OPjye+jm7nuWxQL4GrG6YndOM7pOtP0dPQHRo7BOT5jrSgU/mPvOLhVlaPB Vo9/At2MyousSR5ARSEQVA0iH7XkDaW9eZmydi/2ILKNetiL4Ydb953ZvJoUlX7pme2Z mUUvdU3folRemPkatZOctZw1y1pF2ALBwGuQpzstj23YXwaZfcNopBBqNCHDEwNeOyHQ FqJtP79nNRVNYo6t/RbWhgSoZV9oFiT3cV9uG+fUfEa/doe3Kqv/ctlOTveX/buth4HD NFNDvnmlVN+DPucgXzD/pqtqPt/ykuG9LgTkj4Mclx0L7GHwIniyaWu6QuYxt7HWhxt9 LJMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=FhO6jXCT; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v23sor6248030wmj.14.2018.12.20.04.54.51 for (Google Transport Security); Thu, 20 Dec 2018 04:54:51 -0800 (PST) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a1c:d988:: with SMTP id q130mr11902264wmg.41.1545310491536; Thu, 20 Dec 2018 04:54:51 -0800 (PST) Received: from localhost.localdomain (ip-163-240.sn-213-198.clouditalia.com. [213.198.163.240]) by smtp.gmail.com with ESMTPSA id o4sm8732756wrq.66.2018.12.20.04.54.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 04:54:50 -0800 (PST) From: Jagan Teki To: Yong Deng , Mauro Carvalho Chehab , Maxime Ripard , Rob Herring , Mark Rutland , Chen-Yu Tsai , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi , linux-amarula@amarulasolutions.com, Michael Trimarchi Cc: Jagan Teki Subject: [PATCH v5 2/6] media: sun6i: Add mod_rate quirk Date: Thu, 20 Dec 2018 18:24:34 +0530 Message-Id: <20181220125438.11700-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20181220125438.11700-1-jagan@amarulasolutions.com> References: <20181220125438.11700-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=FhO6jXCT; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Unfortunately default CSI_SCLK rate cannot work properly to drive the connected sensor interface, particularly on few Allwinner SoC's like A64. So, add mod_rate quirk via driver data so-that the respective SoC's which require to alter the default mod clock rate can assign the operating clock rate. Signed-off-by: Jagan Teki --- .../platform/sunxi/sun6i-csi/sun6i_csi.c | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c index ee882b66a5ea..fe002beae09c 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 @@ -28,8 +29,13 @@ #define MODULE_NAME "sun6i-csi" +struct sun6i_csi_variant { + unsigned long mod_rate; +}; + struct sun6i_csi_dev { struct sun6i_csi csi; + const struct sun6i_csi_variant *variant; struct device *dev; struct regmap *regmap; @@ -822,33 +828,43 @@ static int sun6i_csi_resource_request(struct sun6i_csi_dev *sdev, return PTR_ERR(sdev->clk_mod); } + if (sdev->variant->mod_rate) + clk_set_rate_exclusive(sdev->clk_mod, sdev->variant->mod_rate); + sdev->clk_ram = devm_clk_get(&pdev->dev, "ram"); if (IS_ERR(sdev->clk_ram)) { dev_err(&pdev->dev, "Unable to acquire dram-csi clock\n"); - return PTR_ERR(sdev->clk_ram); + ret = PTR_ERR(sdev->clk_ram); + goto err_unprotect_clk; } sdev->rstc_bus = devm_reset_control_get_shared(&pdev->dev, NULL); if (IS_ERR(sdev->rstc_bus)) { dev_err(&pdev->dev, "Cannot get reset controller\n"); return PTR_ERR(sdev->rstc_bus); + goto err_unprotect_clk; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "No csi IRQ specified\n"); ret = -ENXIO; - return ret; + goto err_unprotect_clk; } ret = devm_request_irq(&pdev->dev, irq, sun6i_csi_isr, 0, MODULE_NAME, sdev); if (ret) { dev_err(&pdev->dev, "Cannot request csi IRQ\n"); - return ret; + goto err_unprotect_clk; } return 0; + +err_unprotect_clk: + if (sdev->variant->mod_rate) + clk_rate_exclusive_put(sdev->clk_mod); + return ret; } /* @@ -871,6 +887,7 @@ static int sun6i_csi_probe(struct platform_device *pdev) sdev->dev = &pdev->dev; /* The DMA bus has the memory mapped at 0 */ sdev->dev->dma_pfn_offset = PHYS_OFFSET >> PAGE_SHIFT; + sdev->variant = of_device_get_match_data(sdev->dev); ret = sun6i_csi_resource_request(sdev, pdev); if (ret) @@ -887,14 +904,19 @@ static int sun6i_csi_remove(struct platform_device *pdev) struct sun6i_csi_dev *sdev = platform_get_drvdata(pdev); sun6i_csi_v4l2_cleanup(&sdev->csi); + if (sdev->variant->mod_rate) + clk_rate_exclusive_put(sdev->clk_mod); return 0; } +static const struct sun6i_csi_variant sun6i_a31_csi = { +}; + 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,sun6i-a31-csi", .data = &sun6i_a31_csi, }, + { .compatible = "allwinner,sun8i-h3-csi", .data = &sun6i_a31_csi, }, + { .compatible = "allwinner,sun8i-v3s-csi", .data = &sun6i_a31_csi, }, {}, }; MODULE_DEVICE_TABLE(of, sun6i_csi_of_match);