From patchwork Mon Nov 22 18:46:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 12693351 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC98AC433EF for ; Mon, 22 Nov 2021 18:49:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=l8BAZsC2MAE8joVCD7O8zhklCl8F8lnN6M702u/8Qjc=; b=3PEIe5dIh6w2lJ bxrpPzmQ5d7t/f0szyglp3Zs2zt0VXstQqMNpgg2HpXfrTDYjjrWj/YJoxoqpSU4JI2oSsCbjl35H o9Or08fs8e6bmdctSg0+fvpiv3jXgXOmD3KeBAaWzzybT46TvtRLQFd/Pr6RCPFRALfmUiQtmykxX R2QXUdTlfitXhNUSCulqK7RX46F3iHcBrnHIFNNGiyuEH60ge9ud+TOGRDnjEKWfnGuh9LrfKkZQy ssc3IJcUo00i+cI6ozltnh1jl9ObhCU5DrvUih+AMWZ27DvSAVr8ONuMdGpPMHSIXYxu7cDtGczmQ HEUNsx+QHOtMEL5uavSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mpELj-00HOJD-BR; Mon, 22 Nov 2021 18:47:31 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mpELS-00HOAA-Us for linux-arm-kernel@lists.infradead.org; Mon, 22 Nov 2021 18:47:17 +0000 Received: by mail-ed1-x536.google.com with SMTP id l25so64380491eda.11 for ; Mon, 22 Nov 2021 10:47:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+w4xKSGr2Zu6+OjnOBXAenD8YjQlbwAZQEVVxErum9c=; b=bd3XcFjOlYJkoNuauwnOZ4WoOKrVjvPD2tfLabA4dd5EVxBgcs1EfqKYQlCK1GCJyA dNOaBCKc8sCGwwdzfG5Sbv0lb3xcUO2yfsmqBmbjA15QC4YlXCxLzhumhpCPU2oMJglI BHFfd4aPH+uuABtD5uVxldU8d4cQxW0o19LYkzoUSDVfXGfr6fDnK86IHzqesQ3M0eqA 5MWwrf6zfAGc/CsFtDenZLcKD4gFLKTZIVVKcNZb3w4XaOUT6XXPVy9lq5MTYFSisZtu B8qL/KR97y2prd2Cyowkn9Ia1pcHruDyfJpbZYJ/ZTOaHlSWyr5pyOStpLsYzyYTt61T B8QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+w4xKSGr2Zu6+OjnOBXAenD8YjQlbwAZQEVVxErum9c=; b=Dx0k0VjDSp6NuBJrusqL4nod4KlZt6BP8qily29KRzylX6g1KKxXcmSm+UuwrL83eG Ay8xpbuxWANauFChhQmD7SrxBxGCSyYBczO45XCwwJhp3i6C7o+FJICqAkFFwBKCfn+o oQJYvJyQscy8XKArZ6AvaV9O3VF89a5mAq4q55NCHeeFK60/hOWLv9bEbxd7BcayHTP+ f4Rgjn/K/ZueA8B9dBQMU6kttwDTfdqvW0Qe9S82sQY1bLeUH8c7Lm4OKzGlY6IriIkj LTjAKMU8IB2PIDU7Lq97hFAhW6mkK3g9hoRyVGuv73XD9WSzzAk8lbbGk2ROteY/tdLy c0cg== X-Gm-Message-State: AOAM530NSMA6H56uFKzqHLp9bh2duEFbxmOG32HRySjx5CE5U/N8e38S oCGP7LtG+agipSgPi37vj+w= X-Google-Smtp-Source: ABdhPJysbwUlkyvCH+XVf6KqRQevoHWgxCWlT5DPGHxL30ztAHwZotkpi7zotZeGy3uRYsgbv4HRxQ== X-Received: by 2002:a17:907:7215:: with SMTP id dr21mr43579240ejc.505.1637606833124; Mon, 22 Nov 2021 10:47:13 -0800 (PST) Received: from kista.localdomain (cpe-86-58-29-253.static.triera.net. [86.58.29.253]) by smtp.gmail.com with ESMTPSA id h10sm4512312edr.95.2021.11.22.10.47.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Nov 2021 10:47:12 -0800 (PST) From: Jernej Skrabec To: linux-media@vger.kernel.org Cc: ezequiel@vanguardiasur.com.ar, nicolas.dufresne@collabora.com, mchehab@kernel.org, robh+dt@kernel.org, mripard@kernel.org, wens@csie.org, p.zabel@pengutronix.de, andrzej.p@collabora.com, gregkh@linuxfoundation.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Jernej Skrabec Subject: [PATCH 1/7] media: hantro: add support for reset lines Date: Mon, 22 Nov 2021 19:46:56 +0100 Message-Id: <20211122184702.768341-2-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211122184702.768341-1-jernej.skrabec@gmail.com> References: <20211122184702.768341-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211122_104715_017522_6036EC47 X-CRM114-Status: GOOD ( 16.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some SoCs like Allwinner H6 use reset lines for resetting Hantro G2. Add support for them. Signed-off-by: Jernej Skrabec --- drivers/staging/media/hantro/hantro.h | 3 +++ drivers/staging/media/hantro/hantro_drv.c | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/hantro/hantro.h b/drivers/staging/media/hantro/hantro.h index 7da23f7f207a..33eb3e092cc1 100644 --- a/drivers/staging/media/hantro/hantro.h +++ b/drivers/staging/media/hantro/hantro.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -171,6 +172,7 @@ hantro_vdev_to_func(struct video_device *vdev) * @dev: Pointer to device for convenient logging using * dev_ macros. * @clocks: Array of clock handles. + * @resets: Array of reset handles. * @reg_bases: Mapped addresses of VPU registers. * @enc_base: Mapped address of VPU encoder register for convenience. * @dec_base: Mapped address of VPU decoder register for convenience. @@ -190,6 +192,7 @@ struct hantro_dev { struct platform_device *pdev; struct device *dev; struct clk_bulk_data *clocks; + struct reset_control *resets; void __iomem **reg_bases; void __iomem *enc_base; void __iomem *dec_base; diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c index ab2467998d29..8c3de31f51b3 100644 --- a/drivers/staging/media/hantro/hantro_drv.c +++ b/drivers/staging/media/hantro/hantro_drv.c @@ -905,6 +905,10 @@ static int hantro_probe(struct platform_device *pdev) return PTR_ERR(vpu->clocks[0].clk); } + vpu->resets = devm_reset_control_array_get(&pdev->dev, false, true); + if (IS_ERR(vpu->resets)) + return PTR_ERR(vpu->resets); + num_bases = vpu->variant->num_regs ?: 1; vpu->reg_bases = devm_kcalloc(&pdev->dev, num_bases, sizeof(*vpu->reg_bases), GFP_KERNEL); @@ -978,10 +982,16 @@ static int hantro_probe(struct platform_device *pdev) pm_runtime_use_autosuspend(vpu->dev); pm_runtime_enable(vpu->dev); + ret = reset_control_deassert(vpu->resets); + if (ret) { + dev_err(&pdev->dev, "Failed to deassert resets\n"); + return ret; + } + ret = clk_bulk_prepare(vpu->variant->num_clocks, vpu->clocks); if (ret) { dev_err(&pdev->dev, "Failed to prepare clocks\n"); - return ret; + goto err_rst_assert; } ret = v4l2_device_register(&pdev->dev, &vpu->v4l2_dev); @@ -1037,6 +1047,8 @@ static int hantro_probe(struct platform_device *pdev) v4l2_device_unregister(&vpu->v4l2_dev); err_clk_unprepare: clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks); +err_rst_assert: + reset_control_assert(vpu->resets); pm_runtime_dont_use_autosuspend(vpu->dev); pm_runtime_disable(vpu->dev); return ret; @@ -1055,6 +1067,7 @@ static int hantro_remove(struct platform_device *pdev) v4l2_m2m_release(vpu->m2m_dev); v4l2_device_unregister(&vpu->v4l2_dev); clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks); + reset_control_assert(vpu->resets); pm_runtime_dont_use_autosuspend(vpu->dev); pm_runtime_disable(vpu->dev); return 0;