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=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT 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 E1DD6C433E7 for ; Mon, 12 Oct 2020 20:59:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A25F12222F for ; Mon, 12 Oct 2020 20:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731766AbgJLU7F (ORCPT ); Mon, 12 Oct 2020 16:59:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731678AbgJLU65 (ORCPT ); Mon, 12 Oct 2020 16:58:57 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9236C0613D1; Mon, 12 Oct 2020 13:58:56 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: aratiu) with ESMTPSA id 3CB661F44C33 From: Adrian Ratiu To: Ezequiel Garcia , Philipp Zabel Cc: Mark Brown , Mauro Carvalho Chehab , Fruehberger Peter , kuhanh.murugasen.krishnan@intel.com, Daniel Vetter , kernel@collabora.com, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/18] media: hantro: add reset controller support Date: Mon, 12 Oct 2020 23:59:43 +0300 Message-Id: <20201012205957.889185-5-adrian.ratiu@collabora.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012205957.889185-1-adrian.ratiu@collabora.com> References: <20201012205957.889185-1-adrian.ratiu@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Some SoCs might have a reset controller which disables clocks by default in reset state which then drivers need to unreset before being able to ungate a specific clock. In this specific case, the hantro driver needs to ensure the peripheral clock can be properly ungated otherwise MMIO reg values can't be accessed. If the SoC has no reset controller or there is no "resets" DT property defined, this new code will have no effect. Signed-off-by: Adrian Ratiu Signed-off-by: Ezequiel Garcia --- drivers/staging/media/hantro/hantro.h | 1 + drivers/staging/media/hantro/hantro_drv.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/drivers/staging/media/hantro/hantro.h b/drivers/staging/media/hantro/hantro.h index 65f9f7ea7dcf..bb442eb1974e 100644 --- a/drivers/staging/media/hantro/hantro.h +++ b/drivers/staging/media/hantro/hantro.h @@ -183,6 +183,7 @@ struct hantro_dev { struct platform_device *pdev; struct device *dev; struct clk_bulk_data *clocks; + struct reset_control *reset; 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 3cd00cc0a364..c2ea54552ce9 100644 --- a/drivers/staging/media/hantro/hantro_drv.c +++ b/drivers/staging/media/hantro/hantro_drv.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -747,6 +748,13 @@ static int hantro_probe(struct platform_device *pdev) INIT_DELAYED_WORK(&vpu->watchdog_work, hantro_watchdog); + vpu->reset = devm_reset_control_get_optional_exclusive(&pdev->dev, + NULL); + if (IS_ERR(vpu->reset)) + vpu->reset = NULL; + + reset_control_reset(vpu->reset); + vpu->clocks = devm_kcalloc(&pdev->dev, vpu->variant->num_clocks, sizeof(*vpu->clocks), GFP_KERNEL); if (!vpu->clocks) -- 2.28.0