Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp1108207rwl; Thu, 10 Aug 2023 06:39:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFO7TvGeqAZno7x6M16UTPqr8zv6SXJo5NJ/a4JAhA01a6UoOLF3JC/P2VcDh9eoBrRU5Pz X-Received: by 2002:a17:907:78c9:b0:99c:7300:94b8 with SMTP id kv9-20020a17090778c900b0099c730094b8mr2592485ejc.10.1691674760886; Thu, 10 Aug 2023 06:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691674760; cv=none; d=google.com; s=arc-20160816; b=dRxJp9k77hF3keP98r3kWHx0PReSmhb92fUDTeO9alHFzn0mx36+eh8Zn5J7zoT7ik Kab44kL2b06MNuFRPXKTABWv4oHRLdGfsAEcmxFrec9YMtYuM17hzHDihw+7k0fcmRLi dyw7PSvPeB6ZgK6Zxts+OVz/+LYYz/V4TuT5lkeg8OdzF+XIY/EMNZMMtiHPKYMtfejO bnZrShMkXK7gSxXl+VHmKI9xcDb/NpiTbZkK0v9yssvcB6z9tkyLmAuvWI4tQhdT62wm ySg126ueH6Xbg/ZmyJrEacyephI+Yh9cRa6yRbpD8gLxOjEgcLM9GDHig7hlrjWQTy/P 0nCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Hx/5YT6XegydpQ9HDHKXuTgMelH8UKyh2sBTXOs3F14=; fh=p163KS5IKFBZE3iqY3LPciwJkogBV1lDBPpoUzT24II=; b=bKg0A+zlEXL5YYDW9/Mr5dTl1DWWLdD3qQ//cRz7NNQYkvwKU+KF97Tac5XdYKIvix piZdcvlN05MCP3D2KacTLHxDwnWkMAMYj2FlCI5gd1hGygcIAMw/CmjP9sgvWsXYMvLN kGCXVqW2O1Z8X9WdsxSiVgywQTRlaGl5fRITtSHKnF2uGEFX9ixS2wraoPIZTCLgzKZp 6Ym2OLBYQ49DbvBDt+W46R/tSHGyYTyyPOUE8cfShb4/oMxunK81oMXEESGpXqyMpWLE cSgUIRXldR4UDehBf8byC/Ie2qnanxSKjKbPZAhIF2k5MzSbhgYvV50buqWsXGDoz0cy w6+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zI1ChKG6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lh25-20020a170906f8d900b0099cb1e742e7si1430201ejb.224.2023.08.10.06.38.55; Thu, 10 Aug 2023 06:39:20 -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; dkim=pass header.i=@linaro.org header.s=google header.b=zI1ChKG6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235353AbjHJLlm (ORCPT + 99 others); Thu, 10 Aug 2023 07:41:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230391AbjHJLll (ORCPT ); Thu, 10 Aug 2023 07:41:41 -0400 Received: from mail-yw1-x1135.google.com (mail-yw1-x1135.google.com [IPv6:2607:f8b0:4864:20::1135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0778FF5 for ; Thu, 10 Aug 2023 04:41:41 -0700 (PDT) Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-58411e24eefso9812317b3.1 for ; Thu, 10 Aug 2023 04:41:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691667700; x=1692272500; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Hx/5YT6XegydpQ9HDHKXuTgMelH8UKyh2sBTXOs3F14=; b=zI1ChKG6BqfjxsQCmESQ5twa91fhue0geikSkeOpKgnIixMRg4cbf+/FTiCEQzzA8D et5yfTBCE8Y+RPZQzCcubrNaA6ClPkx1nunw3PKvReKZQ6cn0bGbcJEYVX7xFvDbkyfX dQJoKGxA0gvnsBV4wUzwWp6Tcjx8GEMLgHJ72fu4o6Ltp5/u8PVWLavM01Tcy+UjB6RP 6SYeZ4fZwqgmGMHF79vT9z6uMt8ZyP1X1iGojgZmQgdvsXJA0TINASs9X4IJDxl185HX DbeTjG0VcMKsvTtfyAR0MFfbk3AnWaIHZTE74fZ8TabxGTQWIst28ALmXKZyYqKoM9Sp 2W7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691667700; x=1692272500; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hx/5YT6XegydpQ9HDHKXuTgMelH8UKyh2sBTXOs3F14=; b=DUSZLHdej9C9aaPdnXvKvA/MRuIck6naxdLtptx8Ru7fn21IIgkIhInI1ZHNEEcTXZ 6lKe47AzkpgYU0DyX+NWtkDsFVDnA8WtbrnAWWRHhEy4ahF3nyG9LhaBr9CNCJtAHn+q Hhtzo7MMWr20+JWBmY8Zy0yECTNj8rrsNqayQvuLP8I5KUPI5aIUw+bJWEM7smGzSqjc rMSpoW31MXhUph6yVsUbQh4jBubEXw8Zocdsdy/2C1R0Vq3im79lfv+dfIB6OqmHllF/ pDd880qOU4PGJbADKJrfvjKZNdjcH4EUKIbJbtFh4BRe7rvP7XsIZXpW+uBYgBfuvQdy Jz7Q== X-Gm-Message-State: AOJu0Yxp4F8tTwT/54EH3d1DF18ilWqyILoAtVmVCCmIzn/wTXmwXDV6 OTfxZIUnqf1HeQrDNo+whvZ0RVjmGgymd8+sV1oYQw== X-Received: by 2002:a25:6809:0:b0:bcb:9b43:5a89 with SMTP id d9-20020a256809000000b00bcb9b435a89mr2222229ybc.61.1691667700236; Thu, 10 Aug 2023 04:41:40 -0700 (PDT) MIME-Version: 1.0 References: <20230808145601.9401-1-larry.lai@yunjingtech.com> <20230808145601.9401-3-larry.lai@yunjingtech.com> In-Reply-To: <20230808145601.9401-3-larry.lai@yunjingtech.com> From: Linus Walleij Date: Thu, 10 Aug 2023 13:41:29 +0200 Message-ID: Subject: Re: [PATCH V5 2/3] pinctrl: Add support pin control for UP board CPLD/FPGA To: "larry.lai" Cc: lee@kernel.org, andriy.shevchenko@linux.intel.com, pavel@ucw.cz, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-leds@vger.kernel.org, GaryWang@aaeon.com.tw, musa.lin@yunjingtech.com, michael.wang@yunjingtech.com, jack.chang@yunjingtech.com, noah.hung@yunjingtech.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Hi Larry, thanks for your patch! I would really like Andy to look at this, because ACPI and I'm not good at ACPI. On Tue, Aug 8, 2023 at 4:57=E2=80=AFPM larry.lai wrote: > The UP Squared board implements certain > features (pin control) through an on-board FPGA. > > Reported-by: kernel test robot > Signed-off-by: Gary Wang > Signed-off-by: larry.lai (...) > + if (strstr(pctrl->pctldesc->pins[offset[i]].name, "I2C") = || > + strstr(pctrl->pctldesc->pins[offset[i]].name, "PINMUX= ")) { I think there is something like match a string list in the kernel, Andy will know. > +static int upboard_gpio_get(struct gpio_chip *gc, unsigned int offset) > +{ > + struct upboard_pinctrl *pctrl =3D container_of(gc, struct upboard= _pinctrl, chip); > + unsigned int pin =3D pctrl->rpi_mapping[offset]; > + int gpio =3D upboard_rpi_to_native_gpio(gc, offset); > + > + if (gpio < 0) > + return gpio; > + > + /* APL03 board open drain GPIO */ > + if (pctrl->ident =3D=3D BOARD_UP_APL03) { > + int val =3D 0; > + > + switch (pin) { > + case 0: > + case 1: > + case 9: > + case 23: > + val =3D readl(pctrl->pins[pin].regs); > + return val & 0x00000003; > + default: > + break; > + } > + } > + > + return gpiod_get_value(gpio_to_desc(gpio)); I don't really like this construction bouncing us back into the global GPIO numberspace to get to the descriptor of the corresponding native GPIO. gpio_to_desc() is an uglyhack and shall not be used. You need to come up with something better here: request all the underlying GPIO descriptors with gpiod_get(dev, .. ASIS) and store them in an array. Look in e.g. drivers/gpio/gpio-aggregator.c drivers/gpio/gpio-latch.c for examples of how we do this in other drivers. The underlying GPIO lines need to be specified somehow, in worst case using descriptor tables. > +/* DMI Matches for older bios without fpga initialization */ > +static const struct dmi_system_id upboard_dmi_table[] __initconst =3D { > + { > + .ident =3D BOARD_U A DMI table OK.... > +static struct platform_driver upboard_pinctrl_driver =3D { > + .driver =3D { > + .name =3D "upboard-pinctrl", > + }, > +}; > +module_platform_driver_probe(upboard_pinctrl_driver, upboard_pinctrl_pro= be); OK I don't know ACPI, but what I've seen the DMI table is supposed to be used for some kind of lookup, such as checking in .init if the device is there, so I don't get this. Also doesn't ACPI drivers use the ACPI bus? Yours, Linus Walleij