From patchwork Wed Jun 1 12:53:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 12866890 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 AD631C433EF for ; Wed, 1 Jun 2022 12:56:54 +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=mun4OQyMX2K/LO2l1JXpHs1Vh9x50coBiAp3ff/4u44=; b=XCIyh3U9NR/HAj vw3VseMmWe+TK1ppsKFjRL0TOMU9HLuKaoG9mTue4CtWMafa5rTn9ZIiGh82cex8x2b/mjRuo6UJP Rc/ppL4wEYadVrj5sb5BQ7HYWzSiRgQTVXp83nA36YKgmsecXEzM/GvZRXJlzFjJaV2OIYMEDBHLU kUwFY4JWKMid9LaI+lsmsVJ4x5Bl/h+aqDEOe7/ZaiEFMVNLHdDG6q8af4TFY50P6Z92GuIzUaY4q E58l5p+qCe/o2iHB9d/TNKqEK3tsVJ4B97kz4pOripQ5GN7nc6dBHv04/1aX8LdjO9C388e5RsJcH +eKae4xIFiaLWuVSsrvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwNsz-00G86z-7U; Wed, 01 Jun 2022 12:55:41 +0000 Received: from mout.kundenserver.de ([217.72.192.73]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwNrZ-00G7Xe-VW; Wed, 01 Jun 2022 12:54:16 +0000 Received: from localhost.localdomain ([37.4.249.170]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N9doJ-1nhrg12yCj-015ao5; Wed, 01 Jun 2022 14:54:04 +0200 From: Stefan Wahren To: Florian Fainelli , Ray Jui , Scott Branden , Nicolas Saenz Julienne , Lee Jones Cc: Peter Robinson , Melissa Wen , Phil Elwell , bcm-kernel-feedback-list@broadcom.com, Maxime Ripard , devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Stefan Wahren Subject: [PATCH V2 08/11] soc: bcm: bcm2835-power: Refactor ASB control Date: Wed, 1 Jun 2022 14:53:41 +0200 Message-Id: <20220601125344.60602-9-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220601125344.60602-1-stefan.wahren@i2se.com> References: <20220601125344.60602-1-stefan.wahren@i2se.com> MIME-Version: 1.0 X-Provags-ID: V03:K1:Ig4+vtjVmnUOYvMLZ2d4Qk3vLDd8u7U6svJsfy+ssKl3gEGWgJA VZB7WC0Qn8GPRH87kxuYceKCOFjQ/2pW3Dp5EFwzDfVv9UUcxsmdYcFd02+fWIagA+l2hfi JkzaF5ojVXxkyobvyNQRHaJMonSeE51rtTxNnA0SqK/ut52wdaX5/4IJBNd7npSnPl6iCNd 2Is3LedXgP6pKQeMhMYpg== X-UI-Out-Filterresults: notjunk:1;V03:K0:8afz+10XBLI=:t+cC3CIIwTk+CWNjSDMwPa 1MW9daXkLIfKMPF9MyYEELoqTEMuJSL+Jqh9+uoUgsFBaYfqJqSWTZwcu/mGb/nwlfPZN/N3g O/ZStFJuX282EBKUSdkpNQ6PFlRx7mhbfwMqt4+MbNy4bmxJwwzH/KZrOBizDjtAjtcrxjpEJ km6ANnPGzUBZpE0wz/99YjmMitNv6vw8D2PNG9QvR6d7JohEzY9QIp5KCiTNYoM19oUmPb7Ar EtAghpqNuRbU70wMLAmS1ULZPacjvtWE23bcpHVV3miYtAfo1zdErJT455n53dIk0HqOJ7hjF WyxDWYVQf4nUD4DpEnLyL+GImqb9imAWVYwnVuZRYbP9h2uRcSaEdJ9u7gR9GqA8cwgsZFUe0 s81kLjoIeuV1t/Dnlp0Kd0CH/QUMzICxnrrFGleQKQ9TOZSHfTiVY50XGd7xA37/wzwaTtV+I 9HeYAQPY2jdFhONmIr63KBW9IMdm/4a9WZM5lRGnUZfY1GR/iZQxvIy5tfJXACYRWT8R+Zlvi v0BVzVYDtHizpSsBhyijeg6DuuTeA77JTwwNusvpLV3bdfwSpD8XO4rEUDONrL1mrKVuWmP2m MNmU/eZHTUKyf9TWkp+oCGlFUsDBsi1acETDGC/pWFNl7it342AJe/kJjbyWv4JOJbkMq365h gvdXcTy4dGjc4BWTIG50eZ9n5ytGzQ17JDbqn+y249sZaZBImKiyeNHMAtjr24r0Mvruv6zxz fSsVVzVfU2Yhrj9Yb/tptwvpjKIgWI/xk98IqJTwIY4aBDkuUb3ln6OU7Rs= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_055414_415790_4DBE653F X-CRM114-Status: GOOD ( 13.55 ) 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 The functions to control the async AXI bridges are almost identical. So define a general function to handle it and keep the original ones as wrapper. This should make this driver easier to extend. Signed-off-by: Stefan Wahren Reviewed-by: Peter Robinson --- drivers/soc/bcm/bcm2835-power.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c index 1e0041ec8132..77dc9e62b207 100644 --- a/drivers/soc/bcm/bcm2835-power.c +++ b/drivers/soc/bcm/bcm2835-power.c @@ -148,7 +148,7 @@ struct bcm2835_power { struct reset_controller_dev reset; }; -static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) +static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable) { u64 start; @@ -158,7 +158,12 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) start = ktime_get_ns(); /* Enable the module's async AXI bridges. */ - ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP); + if (enable) { + ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP); + } else { + ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP); + } + while (ASB_READ(reg) & ASB_ACK) { cpu_relax(); if (ktime_get_ns() - start >= 1000) @@ -168,24 +173,14 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) return 0; } -static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg) +static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) { - u64 start; - - if (!reg) - return 0; - - start = ktime_get_ns(); - - /* Enable the module's async AXI bridges. */ - ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP); - while (!(ASB_READ(reg) & ASB_ACK)) { - cpu_relax(); - if (ktime_get_ns() - start >= 1000) - return -ETIMEDOUT; - } + return bcm2835_asb_control(power, reg, true); +} - return 0; +static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg) +{ + return bcm2835_asb_control(power, reg, false); } static int bcm2835_power_power_off(struct bcm2835_power_domain *pd, u32 pm_reg)