Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3688410pxb; Wed, 13 Oct 2021 10:52:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOekmlFL9YCt+JBnR5OD5KeKOaJkrgkcRwWpVxuD49ggSX1aKoe+nq7WdB/Kt2dHyPC3QW X-Received: by 2002:a17:90a:7d05:: with SMTP id g5mr14914504pjl.14.1634147541009; Wed, 13 Oct 2021 10:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634147541; cv=none; d=google.com; s=arc-20160816; b=i0+RH6+pjnGf82nnH+DZL9oiiHs9853ueZsckIwmgjsYaKRwbOuPRIzdkeb1u+1pxS /+8KjMTBWph07WgWc0ed6eaeh+buN+dk6XbnGhwF/zxYGuX/akSWQXFtmCZPpZDpMvte cJl/N6v6Bty5GCJmHlS9kTUjcJrxDQU54oM3rzG2odLdBqmf3QkpCio+NgX81FqYaHJ3 nP7sy+GWoZoc/VgLqHhHTizORgLvBqGnQz8u6q3+Uaatb4ygitX68NkyKYa/qZFhmrso HAXY25VwMfPhgdcHvMinQgJfG+w1iUqD/x2Paz4a4B7fuDlFTN1fmUYZBxoy5ltUGu3/ 0LoQ== 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=tIi5T5N2/yaJwmSaNVNNDL3lEJSP+D3EZbhPxV9bN7g=; b=0CV+eA/3+4G8qUI5FwkVgbHpmU32KxmibZnTHhYPyyL0OQUM/37WfBMcofo6cFUz75 KLizer0eGNWa7unpyZb61+wlNh5rEfUDXeRW/zezstwuTT+JblBx9PAcX8vOicJhJUKi MPKLHWZkswJx0fgfuX+YxE+ED4cSNM/JnOMnrbLFb3dk+Vaz+l5U5Li8B2LMoxty41Xu mrb18w6qwT5uLwRgjKz/9Ko3gTLDeg02DEuv0yihzXD96ER1FPlsjFYATNTNo7tldj3m kgbGbayGLdwCv0F5Ms/tD0OgzbtQR3vNirc+eMFwqr/ntsofeK8VaKh+fcWERv1Dqutp rD8w== 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 x22si180794pll.257.2021.10.13.10.52.07; Wed, 13 Oct 2021 10:52:20 -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 S238539AbhJMRwr (ORCPT + 99 others); Wed, 13 Oct 2021 13:52:47 -0400 Received: from mail-ua1-f41.google.com ([209.85.222.41]:44970 "EHLO mail-ua1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230404AbhJMRwS (ORCPT ); Wed, 13 Oct 2021 13:52:18 -0400 Received: by mail-ua1-f41.google.com with SMTP id e7so6125246ual.11; Wed, 13 Oct 2021 10:50:14 -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=tIi5T5N2/yaJwmSaNVNNDL3lEJSP+D3EZbhPxV9bN7g=; b=lBwUf98Ya9xGJQumHemveoYA3jaTGo9zceF+dlSBGjCHA+Jw2MOMxZ9OB934ZHub28 5V0ABhjVZZlvZ+qWYFw+P9SMRVXTIpguYu7gvrLFzeJfdcNzF1zQ6W5+GJr4ko/qmX33 mNaU3t7S3dcefIkBVLx5WaJaO0wIUUWCcisYJ3M/Khuo1Nc8+ePnQ8t9GOtFD4xJP62a tNJ/V0MdsaVFB7VJj5663dRzvTghbMC3MkfLWjRt6i/7i3gInulrtow0NCcTDSC+mGLe Y8RJWnu649ml0kDDeEFEBJ9TUdlnr37o9CBy+bZSsXfi3ju+3sQvs4Z5+gggZ1nO8gnq smIw== X-Gm-Message-State: AOAM5318vrASNhOp78jMVxYwLNjoIj3Gdwq3n7Y5wXZqlQW/7whZGddO DFdYQixye+6aHB/pDB0ctyRgwEr3UFmuDyTp4DY= X-Received: by 2002:a67:d583:: with SMTP id m3mr967150vsj.41.1634147413827; Wed, 13 Oct 2021 10:50:13 -0700 (PDT) MIME-Version: 1.0 References: <20211012134027.684712-1-kernel@esmil.dk> <20211012134027.684712-13-kernel@esmil.dk> In-Reply-To: From: Geert Uytterhoeven Date: Wed, 13 Oct 2021 19:50:02 +0200 Message-ID: Subject: Re: [PATCH v1 12/16] pinctrl: starfive: Add pinctrl driver for StarFive SoCs To: Andy Shevchenko Cc: Emil Renner Berthing , 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 , Anup Patel , Atish Patra , Matteo Croce , Linux Kernel Mailing List , Huan Feng Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 13, 2021 at 6:58 PM Andy Shevchenko wrote: > On Wed, Oct 13, 2021 at 06:38:14PM +0200, Emil Renner Berthing wrote: > > On Tue, 12 Oct 2021 at 19:03, Andy Shevchenko wrote: > > > On Tue, Oct 12, 2021 at 4:43 PM Emil Renner Berthing wrote: > > > > + v = pinmux[i]; > > > > + dout = ((v & BIT(7)) << (31 - 7)) | ((v >> 24) & 0xffU); > > > > + doen = ((v & BIT(6)) << (31 - 6)) | ((v >> 16) & 0xffU); > > > > + din = (v >> 8) & 0xffU; > > > > > > What is this voodoo for? > > > > In order to do pinmux we need the following pieces of information from > > the device tree for each pin ("GPIO" they call it): > > > > output signal: 0-133 + 1bit reverse flag > > output enable signal: 0-133 + 1bit reverse flag > > optional input signal: 0-74 + special "none" value, right now 0xff > > gpio number: 0-63 > > > > As the code is now all that info is packed into a u32 for each pin > > using the GPIOMUX macro defined in the dt-binding header added in > > patch 10. There is also a diagram for how this packing is done. The > > above voodoo is for unpacking that. > > > > I'd very much like to hear if you have a better solution for how to > > convey that information from the device tree to here. > > At very least this code should have something like above in the comment. And perhaps introduce some helper macros to access the fields? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds