Received: by 2002:ac0:c50a:0:0:0:0:0 with SMTP id y10csp1260501imi; Fri, 1 Jul 2022 06:25:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v9juovDC2D7XkTiOswDfgtb3sjsPujnwdUBa6CWVUlMC9aYFPGNiQ27bvWKXoepiwDzm0y X-Received: by 2002:a17:90a:ca0f:b0:1ee:d4ab:1f41 with SMTP id x15-20020a17090aca0f00b001eed4ab1f41mr16901399pjt.165.1656681928408; Fri, 01 Jul 2022 06:25:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656681928; cv=none; d=google.com; s=arc-20160816; b=se9E5wU5ann8zwMjaJ8r9UV3K5PLWa0Q7Nnf6ibpbxe6A2Br7fn8T5tGW749rPJ76f fUXP35fMUwA/eh7GJBATFKXojdp6T1/Z59k/armnoCZKRMNoe1QRfKqqytJ+Wp1b42kE f+Jv0ndQDvQockSHXVZW7mLxO6sBKAGSRilRBYnVstUDJUSHJJyRfQ0ZtBEYyJLfchaG kIorO5KuyIJC59BZRTAAxpp53PHaBnjDRGG2kWp3vSg7OmGR3ca7oxXAIRy0g5pyvM+2 8ToKQ9VCQnCQ3mEEeJ0tg8YHZ2KQnn9H/E8ohrlYJ/51/FCmVcWlWvnq1OBG7Vmx/ito xQGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=uRUG/gcXtszOSB+22lc8VcQa2h0LSQzAMRNL7MSrM/4=; b=Fsnq8kr6VRdqcqUl6rDOHQpfkz+7K7PlyyApW9O9oRTIeM40aK/Cfr2/Hi+Xt/UqWB jMtQPUiIQdUwCZiwncNYSKN/olmYduI1LdrcCB4ZWYVM05QUE0Tkf1QMih9XNdTMn8NV TKfXLyzCpyUaqDli8DWHWl+6lCyEhD5JDx+Y9x5Few9c4fa1rSuIFz8cQ2xatU4HVi2n h35SdBlrM8WYL9ltXqQfberJ5IDstKqyFPi8+WF+HqKx0HPP2GqJ5g/9puCyoIDsMiXC R+zx375gNDpIHDdYv2+qRqi7+nZzI5F/xCPczz47d/pkbDuJbA8WNUTGxL8za8FwlRfC jEmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x79-20020a633152000000b003fe36012904si28660169pgx.145.2022.07.01.06.25.16; Fri, 01 Jul 2022 06:25:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235336AbiGANN3 (ORCPT + 99 others); Fri, 1 Jul 2022 09:13:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234017AbiGANN1 (ORCPT ); Fri, 1 Jul 2022 09:13:27 -0400 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E19CCC8; Fri, 1 Jul 2022 06:13:24 -0700 (PDT) Received: from p508fd39e.dip0.t-ipconnect.de ([80.143.211.158] helo=phil.localnet) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1o7GST-0001fu-9M; Fri, 01 Jul 2022 15:13:17 +0200 From: Heiko Stuebner To: Chen-Yu Tsai , Jernej Skrabec , Linus Walleij , linux-arm-kernel@lists.infradead.org Cc: Samuel Holland , Krzysztof Kozlowski , Maxime Ripard , Ondrej Jirman , Rob Herring , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Samuel Holland Subject: Re: [PATCH 6/6] pinctrl: sunxi: Add driver for Allwinner D1/D1s Date: Fri, 01 Jul 2022 15:13:17 +0200 Message-ID: <17090319.JCcGWNJJiE@phil> In-Reply-To: <20220626021148.56740-7-samuel@sholland.org> References: <20220626021148.56740-1-samuel@sholland.org> <20220626021148.56740-7-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_SCC_BODY_TEXT_LINE,T_SPF_HELO_TEMPERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Sonntag, 26. Juni 2022, 04:11:47 CEST schrieb Samuel Holland: > These SoCs contain a pinctrl with a new register layout. Use the variant > parameter to set the right register offsets. This pinctrl also increases > the number of functions per pin from 8 to 16, taking advantage of all 4 > bits in the mux config field (so far, only functions 0-8 and 14-15 are > used). This increases the maximum possible number of functions. > > D1s is a low pin count version of the D1 SoC, with some pins omitted. > The remaining pins have the same function assignments as D1. > > Signed-off-by: Samuel Holland On a D1-Nezha Tested-by: Heiko Stuebner Reviewed-by: Heiko Stuebner with one remark below > diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c > index ec7daaa5666b..350044d4c1b5 100644 > --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c > +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c > @@ -1297,11 +1297,11 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev) > > /* > * Find an upper bound for the maximum number of functions: in > - * the worst case we have gpio_in, gpio_out, irq and up to four > + * the worst case we have gpio_in, gpio_out, irq and up to seven > * special functions per pin, plus one entry for the sentinel. > * We'll reallocate that later anyway. > */ > - pctl->functions = kcalloc(4 * pctl->ngroups + 4, > + pctl->functions = kcalloc(7 * pctl->ngroups + 4, > sizeof(*pctl->functions), > GFP_KERNEL); > if (!pctl->functions) > @@ -1494,9 +1494,15 @@ int sunxi_pinctrl_init_with_variant(struct platform_device *pdev, > pctl->dev = &pdev->dev; > pctl->desc = desc; > pctl->variant = variant; > - pctl->bank_mem_size = BANK_MEM_SIZE; > - pctl->pull_regs_offset = PULL_REGS_OFFSET; > - pctl->dlevel_field_width = DLEVEL_FIELD_WIDTH; > + if (pctl->variant >= PINCTRL_SUN20I_D1) { > + pctl->bank_mem_size = D1_BANK_MEM_SIZE; > + pctl->pull_regs_offset = D1_PULL_REGS_OFFSET; > + pctl->dlevel_field_width = D1_DLEVEL_FIELD_WIDTH; > + } else { > + pctl->bank_mem_size = BANK_MEM_SIZE; > + pctl->pull_regs_offset = PULL_REGS_OFFSET; > + pctl->dlevel_field_width = DLEVEL_FIELD_WIDTH; > + } this is likely ok for _one_ variant (so for now this should be ok) but will get ugly when there are more of them. So in the long term it might make sense to pass these values in from the soc-specific driver maybe? Heiko