Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2513183pxb; Tue, 12 Oct 2021 08:08:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdc3J+oJZQZhQgeJ/RaaoetPv9ZHO/vK1qOj7Pcwz+v5Gqw/leyGkT3mjauRHwB3PA3vI/ X-Received: by 2002:a17:90b:188b:: with SMTP id mn11mr6736941pjb.170.1634051330009; Tue, 12 Oct 2021 08:08:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634051330; cv=none; d=google.com; s=arc-20160816; b=CeDa+qzTHOUZd2SDfYzQLDpJ0odldMjMOA9jlo8n486XFbftBAvbfG1Up4q+tWwKf3 7eSNcRBvOX7CACV049WU2EOqJ/B7vQx9TLM11AIjfs707jjkqOn+6Sf1xVEWERn7OrdK 5i8jfdClpYDGIX8l4TxgL58UU9c2fcwxYrLvzKDtgVRrccnqAY7XLOPowzlL/DZZKuvc 7FAGTL7yXsq8zjMVDuynmU3RLov0yZ57xxRpWrKTIa7LjugjMFShgJAHkN/dRDTH/uQv sm761jkwFZO2yvgbyqeIwzCDbzVrvcNHDZRJ/eOYLRXf3sGyK+keUi76GkDL69fKYS0w GYUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=hdJDtZAfGIdmZ/ukdHpeB6ObCJRx81CajNUOCsrybQI=; b=kZjALeTDxr3Thfj/HUHQCPpZbCsrS+MyfQEiUNmN7nZwiRGYy1XN4OfRJITjX+9Kk5 cr2/UeOTs6+ErLfpobIRtFIgUkKpnYGsJ7P0fgLv4nP+mXJ7l61Jb0P+kraUbkjkvllE pXSmIg8thlzGHDWZYUSfVPamG69m8B4GYakwHo3Msi4twCCG6CG2lEmilLcuTFWNQiQT VonLLMk+oUW6XSG15QL0wSLSqYzKMFThwXzVQR0GegY+xFIPdiqP9Z++z72Iqvb14o/3 AETYQi+9AM8/JOFINYuXXnpcksr9p+SfyD3tW72kuWYifLXrB/Spx6r9Fn5dllp1b5iC Jayg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si10901077pgc.115.2021.10.12.08.08.26; Tue, 12 Oct 2021 08:08:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237293AbhJLPHE (ORCPT + 99 others); Tue, 12 Oct 2021 11:07:04 -0400 Received: from mail-pf1-f177.google.com ([209.85.210.177]:38684 "EHLO mail-pf1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237223AbhJLPHD (ORCPT ); Tue, 12 Oct 2021 11:07:03 -0400 Received: by mail-pf1-f177.google.com with SMTP id k26so17810137pfi.5; Tue, 12 Oct 2021 08:05:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hdJDtZAfGIdmZ/ukdHpeB6ObCJRx81CajNUOCsrybQI=; b=PLODMfvtk0akldX2uKuW3OfA8uRa9S2MSPgbhHny7guY2xuIOIBNg2FKgf0F16h9gz 1ZQpB58gQrvKlii1NheXBLFGfoOMdCz3R8BkzJhfAMxqeqbSxvS8JcHTOY16lOP3KWgd RWJ3PuIS79mjngoa84d7DwO7U/9nAybKQtf3By4ioA2y9iilbpLA4Vc54zDhE8tUYQ8W s8vE58lrTTKofu460M46eLmO3h1K8BA+6DPvqx6+TtY6F5VKXYiuhp+HWDNKMSKi2Y49 RfEewfNDPke9JF6zh0kFOMMNSRdI85BA7K4pCwFS0v5Z42AT3WqH6UI7ehdTpq9hFJ3d FDJw== X-Gm-Message-State: AOAM531G6sDhSraynjZ3qRa1fAWYAhd40u4sRhINO2jDYft/lBxLxoQs E+KVX8gAq3WPk2zhWhFqVU31bqxPjAoYpltM7F8= X-Received: by 2002:a63:b11:: with SMTP id 17mr23103923pgl.51.1634051101136; Tue, 12 Oct 2021 08:05:01 -0700 (PDT) MIME-Version: 1.0 References: <20211012134027.684712-1-kernel@esmil.dk> <20211012134027.684712-10-kernel@esmil.dk> <99ddc44924bcb89110a74d3182b1d3eea623dce1.camel@pengutronix.de> In-Reply-To: <99ddc44924bcb89110a74d3182b1d3eea623dce1.camel@pengutronix.de> From: Emil Renner Berthing Date: Tue, 12 Oct 2021 17:04:49 +0200 Message-ID: Subject: Re: [PATCH v1 09/16] reset: starfive-jh7100: Add StarFive JH7100 reset driver To: Philipp Zabel Cc: linux-riscv , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , linux-clk@vger.kernel.org, "open list:GPIO SUBSYSTEM" , linux-serial@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Rob Herring , Michael Turquette , Stephen Boyd , Thomas Gleixner , Marc Zyngier , Linus Walleij , Greg Kroah-Hartman , Daniel Lezcano , Andy Shevchenko , Jiri Slaby , Maximilian Luz , Sagar Kadam , Drew Fustini , Geert Uytterhoeven , Anup Patel , Atish Patra , Matteo Croce , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 Oct 2021 at 16:31, Philipp Zabel wrote: > > On Tue, 2021-10-12 at 15:40 +0200, Emil Renner Berthing wrote: > > Add a driver for the StarFive JH7100 reset controller. > > > > Signed-off-by: Emil Renner Berthing > > --- > > MAINTAINERS | 7 ++ > > drivers/reset/Kconfig | 8 ++ > > drivers/reset/Makefile | 1 + > > drivers/reset/reset-starfive-jh7100.c | 164 ++++++++++++++++++++++++++ > > 4 files changed, 180 insertions(+) > > create mode 100644 drivers/reset/reset-starfive-jh7100.c > > > [...] > > diff --git a/drivers/reset/reset-starfive-jh7100.c b/drivers/reset/reset-starfive-jh7100.c > > new file mode 100644 > > index 000000000000..26bc5b59c1f3 > > --- /dev/null > > +++ b/drivers/reset/reset-starfive-jh7100.c > > @@ -0,0 +1,164 @@ > [...] > > +static int jh7100_reset_update(struct reset_controller_dev *rcdev, > > + unsigned long id, bool assert) > > +{ > > + struct jh7100_reset *data = jh7100_reset_from(rcdev); > > + unsigned long offset = id / 32; > > + void __iomem *reg_assert = data->base + JH7100_RESET_ASSERT0 + 4 * offset; > > + void __iomem *reg_status = data->base + JH7100_RESET_STATUS0 + 4 * offset; > > + u32 mask = BIT(id % 32); > > + u32 done = jh7100_reset_asserted[offset] & mask; > > + unsigned long flags; > > + u32 value; > > + > > + if (!assert) > > + done ^= mask; > > + > > + spin_lock_irqsave(&data->lock, flags); > > + > > + value = readl(reg_assert); > > + if (assert) > > + value |= mask; > > + else > > + value &= ~mask; > > + writel(value, reg_assert); > > + > > + do { > > + value = readl(reg_status) & mask; > > + } while (value != done); > > Looking at the barebox driver, this could loop indefinitely if the > caller forgets to enable the corresponding peripheral clock. Maybe > use readl_poll_timeout() as a safety net. You're right. Asserting without the clock enabled is fine, but deasserting will hang forever. At least for the temperature sensor clock/resets I tried it with. I'll add the timeout, thanks! /Emil