From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7665EC4332F for ; Fri, 22 Oct 2021 15:59:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EDAC60FBF for ; Fri, 22 Oct 2021 15:59:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233577AbhJVQCK (ORCPT ); Fri, 22 Oct 2021 12:02:10 -0400 Received: from mail-pg1-f182.google.com ([209.85.215.182]:40452 "EHLO mail-pg1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233539AbhJVQCD (ORCPT ); Fri, 22 Oct 2021 12:02:03 -0400 Received: by mail-pg1-f182.google.com with SMTP id q5so3703244pgr.7; Fri, 22 Oct 2021 08:59:45 -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=ve3WMv+ekDk2TdI4V72WJsoDE4qRPggIm2D4MYgIa/s=; b=YoSiSqNcsi/ce2Uu1fcFeaqpii6hTMjVDm7gJVw9xDH7AdC8PIx4gZ6uPuL7xRMfKC 54vOTvPfjthY2XSwrFXUfAZ2vUmPFxcdmIjrVK9CB27pMhIzll+qEDfnDQXo0s/LiDVf dWF8W7ei5gGRo647Wr5c6gl5mtJtGFEoXxxy8I01BTGmgrqSaevViH5qTX9xyNlbam7d jERbu6pqN3qPhlmXHpFpLvtQmdhKZJ7K4Xyx36X/iWI8B0kd/8j/TebiebSz9ztK3k5i 8REQfczYggfpmdnmJptxwh77Sesn5dLd6oDTEceHOpqJAhKrDemxDA0/Hs/W3CJl4d3m uGwg== X-Gm-Message-State: AOAM532FBU6tFdSW+DWL7GGC++DXZ0CowbtFTlczbdBiSIOgY3GHbEGa d7+gGptSPuK9PthIGgoSDNCFIkrkN41OTYu6xCQ= X-Google-Smtp-Source: ABdhPJytmeUKXJ3sdL/RoZcFfoUxkwHNf715Lzot8ru5O13Qs3evLOYJia2m3U02KPExB+40zvfLAu1iZcMn5ibdDp4= X-Received: by 2002:a63:2d46:: with SMTP id t67mr414276pgt.15.1634918385517; Fri, 22 Oct 2021 08:59:45 -0700 (PDT) MIME-Version: 1.0 References: <20211021174223.43310-1-kernel@esmil.dk> <20211021174223.43310-10-kernel@esmil.dk> In-Reply-To: From: Emil Renner Berthing Date: Fri, 22 Oct 2021 17:59:34 +0200 Message-ID: Subject: Re: [PATCH v2 09/16] reset: starfive-jh7100: Add StarFive JH7100 reset driver To: Andy Shevchenko Cc: linux-riscv , devicetree , linux-clk , "open list:GPIO SUBSYSTEM" , "open list:SERIAL DRIVERS" , Palmer Dabbelt , Paul Walmsley , Rob Herring , Michael Turquette , Stephen Boyd , Thomas Gleixner , Marc Zyngier , Philipp Zabel , Linus Walleij , Greg Kroah-Hartman , Daniel Lezcano , Jiri Slaby , Maximilian Luz , Sagar Kadam , Drew Fustini , Geert Uytterhoeven , Michael Zhu , Fu Wei , 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-gpio@vger.kernel.org On Fri, 22 Oct 2021 at 17:55, Andy Shevchenko wrote: > On Fri, Oct 22, 2021 at 05:36:21PM +0200, Emil Renner Berthing wrote: > > On Fri, 22 Oct 2021 at 17:25, Andy Shevchenko wrote: > > > On Fri, Oct 22, 2021 at 5:56 PM Emil Renner Berthing wrote: > > > > On Fri, 22 Oct 2021 at 16:50, Andy Shevchenko wrote: > > > > > On Fri, Oct 22, 2021 at 5:25 PM Emil Renner Berthing wrote: > > ... > > > > > > AFAICS they are sequential 4 32-bit registers. > > > > > > > > That's right, but we're on a 64bit machine, so DECLARE_BITMAP will > > > > give us an unsigned long array that doesn't match that. > > > > > > I didn't get it, sorry. > > > You will have a bitmap array which you will split to 32-bit values. > > > What you will probably need is to move xgpio_get_value32() and void > > > xgpio_set_value32() to the one of bitmap related headers (look for > > > bitmap_get_value8() and friends). > > > > > > > > So bitmap is exactly what is suitable here, you are right! > > > > > See gpio-xilinx and gpio-pca953x on how to use bitmaps in the GPIO drivers. > > > > > > > > None of them has a pre-initialized const DECLARE_BITMAP, so they don't > > > > have to deal with the 4 vs. 2 commas problem. > > > > > > I believe it's well possible to refactor this to look much better with > > > bitmaps (as it represents the hardware very well). > > > > Right, but how exactly? This works on on 64bit, but not with 32bit COMPILE_TEST: > > > > static const DECLARE_BITMAP(jh7100_reset_asserted, JH7100_RSTN_END) = { > > /* STATUS0 register */ > > BIT_MASK(JH7100_RST_U74) | > > BIT_MASK(JH7100_RST_VP6_DRESET) | > > BIT_MASK(JH7100_RST_VP6_BRESET) | > > /* STATUS1 register */ > > BIT_MASK(JH7100_RST_HIFI4_DRESET) | > > BIT_MASK(JH7100_RST_HIFI4_BRESET), > > /* STATUS2 register */ > > BIT_MASK(JH7100_RST_E24) | > > /* STATUS3 register */ > > 0, > > }; > > BITMAP_FROM_U64() ? So you think this is better? static const DECLARE_BITMAP(jh7100_reset_asserted, JH7100_RSTN_END) = { BITMAP_FROM_U64( /* STATUS0 register */ BIT_MASK(JH7100_RST_U74) | BIT_MASK(JH7100_RST_VP6_DRESET) | BIT_MASK(JH7100_RST_VP6_BRESET) | /* STATUS1 register */ BIT_MASK(JH7100_RST_HIFI4_DRESET) | BIT_MASK(JH7100_RST_HIFI4_BRESET) ), BITMAP_FROM_U64( /* STATUS2 register */ BIT_MASK(JH7100_RST_E24) | /* STATUS3 register */ 0 ), }; > > > > > > Also is there a macro for handling that we'd then need 4 commas on > > > > > > 32bit COMPILE_TEST and 2 commas on 64bit? > > > > > > If you have some other way in mind you'll have to be a lot more explicit again. > > > > > > > > > > > > The point of the jh7100_reset_asserted array is that it exactly > > > > > > mirrors the values of the status registers when the lines are > > > > > > asserted. > > -- > With Best Regards, > Andy Shevchenko > > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64268C433F5 for ; Fri, 22 Oct 2021 16:00:00 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id EBEA960F50 for ; Fri, 22 Oct 2021 15:59:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EBEA960F50 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=esmil.dk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=31b+9wlDpwAlaPO6nstksJj5nXP355l54L6CmXEPDb0=; b=rUx1qLhcDwod9Y rd/ArkQJfW6wbKaWlS9mcPuJTBwgMmqK5dcm47HE5AZdA9IkNswFwdhSKNwO7bkNEMscGsMp7VJAd W8fNH2q38ZjeZVAxVHco7Hn3EKNLEiQbnUPoLtuFGE44+D33M+SYbTrNwa/zZEN8sdivrnQBSUJlI 3muOlT2QgmeDtZ/smIxjvvBFtiy7YfdY50FitakFnrdeKOZV7eUgPUul/IYOEaiZVWQoZI+vGspvD 7JJ9y4pNtVcdIxZwxSp6WPmjLxSiwym0NXtZWdNifOhIopsA69pJ1wSYG/hynx9lXdpSShr1d90UI QLpNWfplPe/8HtkfFpxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdwxR-00BTfH-HE; Fri, 22 Oct 2021 15:59:49 +0000 Received: from mail-pf1-f170.google.com ([209.85.210.170]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdwxO-00BTeT-8q for linux-riscv@lists.infradead.org; Fri, 22 Oct 2021 15:59:48 +0000 Received: by mail-pf1-f170.google.com with SMTP id m14so4015077pfc.9 for ; Fri, 22 Oct 2021 08:59:45 -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=ve3WMv+ekDk2TdI4V72WJsoDE4qRPggIm2D4MYgIa/s=; b=is+D0r68gJnLmjkxA4aMiByrdRNevFhJlROpFVNoiwePg4k5gZBx8K9NthyUEttv5A 4tPCskrF0gbFL3YSts4YcSBwq++UDPQCW7H5vrSEnYX4Eq34ffS2UA8Z6y2aTHxTBUgV FJ1N+HZlWpcZI64YmmDwUW6Z39dZx87aMHXYRB808A7Fxn58o/j1+64gabB2xavCtydv zrYVXVZ3kW/ZN1GeHG7+xnjOLOB+4/WBai7WPiTsm9TusAqMcGKRyMs+JUZITYpedsR8 QDk192kvnOkXEU05fExV2OaZLtHT3Ngbhei31bh0E5Dv3ogBRIpFcDUNFWWCIGEHoaoc Sr0w== X-Gm-Message-State: AOAM533ylBGwOvUreuGskTVGwKPLi/oYcsVLpUiWnX+W48LHrKc0N8hZ PlYiqBhFz3pcH9U8TBxlQoaZ7gFozYG3I5q/dCM= X-Google-Smtp-Source: ABdhPJytmeUKXJ3sdL/RoZcFfoUxkwHNf715Lzot8ru5O13Qs3evLOYJia2m3U02KPExB+40zvfLAu1iZcMn5ibdDp4= X-Received: by 2002:a63:2d46:: with SMTP id t67mr414276pgt.15.1634918385517; Fri, 22 Oct 2021 08:59:45 -0700 (PDT) MIME-Version: 1.0 References: <20211021174223.43310-1-kernel@esmil.dk> <20211021174223.43310-10-kernel@esmil.dk> In-Reply-To: From: Emil Renner Berthing Date: Fri, 22 Oct 2021 17:59:34 +0200 Message-ID: Subject: Re: [PATCH v2 09/16] reset: starfive-jh7100: Add StarFive JH7100 reset driver To: Andy Shevchenko Cc: linux-riscv , devicetree , linux-clk , "open list:GPIO SUBSYSTEM" , "open list:SERIAL DRIVERS" , Palmer Dabbelt , Paul Walmsley , Rob Herring , Michael Turquette , Stephen Boyd , Thomas Gleixner , Marc Zyngier , Philipp Zabel , Linus Walleij , Greg Kroah-Hartman , Daniel Lezcano , Jiri Slaby , Maximilian Luz , Sagar Kadam , Drew Fustini , Geert Uytterhoeven , Michael Zhu , Fu Wei , Anup Patel , Atish Patra , Matteo Croce , Linux Kernel Mailing List X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211022_085946_337651_566B642B X-CRM114-Status: GOOD ( 32.01 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Fri, 22 Oct 2021 at 17:55, Andy Shevchenko wrote: > On Fri, Oct 22, 2021 at 05:36:21PM +0200, Emil Renner Berthing wrote: > > On Fri, 22 Oct 2021 at 17:25, Andy Shevchenko wrote: > > > On Fri, Oct 22, 2021 at 5:56 PM Emil Renner Berthing wrote: > > > > On Fri, 22 Oct 2021 at 16:50, Andy Shevchenko wrote: > > > > > On Fri, Oct 22, 2021 at 5:25 PM Emil Renner Berthing wrote: > > ... > > > > > > AFAICS they are sequential 4 32-bit registers. > > > > > > > > That's right, but we're on a 64bit machine, so DECLARE_BITMAP will > > > > give us an unsigned long array that doesn't match that. > > > > > > I didn't get it, sorry. > > > You will have a bitmap array which you will split to 32-bit values. > > > What you will probably need is to move xgpio_get_value32() and void > > > xgpio_set_value32() to the one of bitmap related headers (look for > > > bitmap_get_value8() and friends). > > > > > > > > So bitmap is exactly what is suitable here, you are right! > > > > > See gpio-xilinx and gpio-pca953x on how to use bitmaps in the GPIO drivers. > > > > > > > > None of them has a pre-initialized const DECLARE_BITMAP, so they don't > > > > have to deal with the 4 vs. 2 commas problem. > > > > > > I believe it's well possible to refactor this to look much better with > > > bitmaps (as it represents the hardware very well). > > > > Right, but how exactly? This works on on 64bit, but not with 32bit COMPILE_TEST: > > > > static const DECLARE_BITMAP(jh7100_reset_asserted, JH7100_RSTN_END) = { > > /* STATUS0 register */ > > BIT_MASK(JH7100_RST_U74) | > > BIT_MASK(JH7100_RST_VP6_DRESET) | > > BIT_MASK(JH7100_RST_VP6_BRESET) | > > /* STATUS1 register */ > > BIT_MASK(JH7100_RST_HIFI4_DRESET) | > > BIT_MASK(JH7100_RST_HIFI4_BRESET), > > /* STATUS2 register */ > > BIT_MASK(JH7100_RST_E24) | > > /* STATUS3 register */ > > 0, > > }; > > BITMAP_FROM_U64() ? So you think this is better? static const DECLARE_BITMAP(jh7100_reset_asserted, JH7100_RSTN_END) = { BITMAP_FROM_U64( /* STATUS0 register */ BIT_MASK(JH7100_RST_U74) | BIT_MASK(JH7100_RST_VP6_DRESET) | BIT_MASK(JH7100_RST_VP6_BRESET) | /* STATUS1 register */ BIT_MASK(JH7100_RST_HIFI4_DRESET) | BIT_MASK(JH7100_RST_HIFI4_BRESET) ), BITMAP_FROM_U64( /* STATUS2 register */ BIT_MASK(JH7100_RST_E24) | /* STATUS3 register */ 0 ), }; > > > > > > Also is there a macro for handling that we'd then need 4 commas on > > > > > > 32bit COMPILE_TEST and 2 commas on 64bit? > > > > > > If you have some other way in mind you'll have to be a lot more explicit again. > > > > > > > > > > > > The point of the jh7100_reset_asserted array is that it exactly > > > > > > mirrors the values of the status registers when the lines are > > > > > > asserted. > > -- > With Best Regards, > Andy Shevchenko > > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv