Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp293091rwl; Wed, 29 Mar 2023 01:43:29 -0700 (PDT) X-Google-Smtp-Source: AKy350ZsnQAqR6TvoR3rqAYtF9IhDOav8GzXWxdx+vukbFzFk9JBKWznIbS3v4aisqcRdBeAqp4u X-Received: by 2002:a17:902:d14b:b0:1a1:b440:377d with SMTP id t11-20020a170902d14b00b001a1b440377dmr15433575plt.2.1680079408864; Wed, 29 Mar 2023 01:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680079408; cv=none; d=google.com; s=arc-20160816; b=oeaCIqcMePMfa9Lv0U5EzJ5rLCMNLgohjc/RJbbO4ozQfNW3inaP3tPx7cVJYldwdL 1wT75NFzLZtaI4gdjDlT12f15D0aKiJ8bebFZbOg80IEfabd8XMvFfdIau8DbH9w8vVn BlTIQMZUUBWfuikttn5AhvuyerVPBeNor4HghXoG8wyS67yk5TG4hfTWYRJdVdqnc0xi ERQIVUrzviu3DsyYxv62AQnWsEh7ksFAhFz8E1ssWzR6hvd8w9Lig+VNuyhj3S14Yd9X 2aKu92uHz1WoWZZZDlnY6N3wYu9OwY87zGVfM/AK7dX7MrWrbeRLcXhG1HXTozWe0BdQ lQ7Q== 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=fEEjt5KTOiMxdxcRezWpGMm6v+AEsQGVPozQ3NTxWGQ=; b=sR82sLhWNvlbVUlk1jAaCeq/BBJTvcyHumAVDqlT9iqueOBopW2xlAjjRHd4n65s/z YEKJeO3zk0/qdwZLpkBG2oVYbYR082vDIrPdwGh0qhfvEYA+9uHKOF91oWVnnYShWB+F ZPeVfZ8VBuD34BsULDXS/4JgqRVwK/axMp02PrGHHJqjc13wBbFyfKG9hDWOXlVO2LZO unL4kBfP0A6IDtVwHd+CMB/smZmqElQEC/rLLRpfazqAYXGrz6WT4scXZS5FrVYzSJOw +me6NcglBeZUoWFvkdG1UOm5XYLyoNqpUD+XguTn3rl7eoBmyBRXnAoa2wMy++YD0n2Z TGzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RyxRU52z; 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 a190-20020a6390c7000000b0050f66d53c3fsi20304810pge.299.2023.03.29.01.43.17; Wed, 29 Mar 2023 01:43: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; dkim=pass header.i=@linaro.org header.s=google header.b=RyxRU52z; 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 S231179AbjC2Ihc (ORCPT + 99 others); Wed, 29 Mar 2023 04:37:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231169AbjC2Iha (ORCPT ); Wed, 29 Mar 2023 04:37:30 -0400 Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DF1846A3 for ; Wed, 29 Mar 2023 01:37:17 -0700 (PDT) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-54184571389so280183857b3.4 for ; Wed, 29 Mar 2023 01:37:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680079036; 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=fEEjt5KTOiMxdxcRezWpGMm6v+AEsQGVPozQ3NTxWGQ=; b=RyxRU52zrMaY1+rCiw2RsrCGt9/viM3/l3sfw4JQCjh/8bpNfF7lm5FztCSqWhgmdf ssDYQ6iDt8NQablYueMCScBaQNhiokwb0JUI/pUrlXqHvMXCupxNmWWheju/N6FIvc/P HTbInlTEaEK9sK04pzgm1v5UnAqcTGRl7sAr45kkgbFRRvwvsqEnzSyb0A6K9b3q6dKr R/EjzL7WFDTFJv47uBKGwjutYgjEQptSHSmDXIeuDeoqdQXPsE1L5NVsYJX1vvf0/qBm hq8CvAowe7oUE6hVym2BqUo35uDTr+VJ99EVE8AoaIE2TYRC/aNHoX/W6jcj/M0Uqm0Y wQlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680079036; 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=fEEjt5KTOiMxdxcRezWpGMm6v+AEsQGVPozQ3NTxWGQ=; b=U24NMLjilBoM/2uBXTcy7/FDNlGF+QK08YHZfYExM8sMHhuhNwNfgF9bX216ca+KMd F1OZ+Buea+9WF2udPNoHeK3D6matpM7sVhiyhWuGzCFIb/8z0XP4Pl+Z/evGKH0B3IAw c+lgbIqAN4uSWSV15ezdfFgG2p1ALQnA7vLSXpThkMy1PgweHtc/XihvP6CBR73Bykl7 GGXHaCgJFl2KQLjrOImTfxArrqyzx4tpSUfxhTEDCa+ekUKppNMM6fKpbbX2OJPz8iSH JprewSlfJmn4GaT13BEwqomiWw/1rgQaoOWbTYx1MfpFJo26TU5SNuxA7kkYFTm+XJAo /HAg== X-Gm-Message-State: AAQBX9eMVD3U1wvYcGW+a62TGw9EnUwqA3weERm5jXi+Fno3eBxU/rdJ jZIjdX3Sn+O/QSVvM7bTW8oddN8eHChINpqGzjXnDg== X-Received: by 2002:a81:eb02:0:b0:545:883a:544d with SMTP id n2-20020a81eb02000000b00545883a544dmr9195077ywm.9.1680079036640; Wed, 29 Mar 2023 01:37:16 -0700 (PDT) MIME-Version: 1.0 References: <20230325154711.2419569-1-xiang.ye@intel.com> <20230325154711.2419569-5-xiang.ye@intel.com> In-Reply-To: <20230325154711.2419569-5-xiang.ye@intel.com> From: Linus Walleij Date: Wed, 29 Mar 2023 10:37:05 +0200 Message-ID: Subject: Re: [PATCH v7 4/6] gpio: Add support for Intel LJCA USB GPIO driver To: Ye Xiang , Marc Zyngier Cc: Greg Kroah-Hartman , Arnd Bergmann , Matthias Kaehlcke , Lee Jones , Wolfram Sang , Tyrone Ting , Mark Brown , Bartosz Golaszewski , linux-usb@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-gpio@vger.kernel.org, srinivas.pandruvada@intel.com, heikki.krogerus@linux.intel.com, andriy.shevchenko@linux.intel.com, sakari.ailus@linux.intel.com, zhifeng.wang@intel.com, wentong.wu@intel.com, lixu.zhang@intel.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=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 Ye, thanks for your patch! On Sat, Mar 25, 2023 at 4:48=E2=80=AFPM Ye Xiang wrote= : > This patch implements the GPIO function of Intel USB-I2C/GPIO/SPI adapter > device named "La Jolla Cove Adapter" (LJCA). It communicate with LJCA > GPIO module with specific protocol through interfaces exported by LJCA US= B > driver. > > Signed-off-by: Ye Xiang Lots of improvements! here are some comments: > @@ -1253,6 +1253,18 @@ config GPIO_KEMPLD > This driver can also be built as a module. If so, the module wi= ll be > called gpio-kempld. > > +config GPIO_LJCA > + tristate "INTEL La Jolla Cove Adapter GPIO support" > + depends on USB_LJCA > + select GPIOLIB_IRQCHIP > + default USB_LJCA > + help > + Select this option to enable GPIO driver for the INTEL > + La Jolla Cove Adapter (LJCA) board. > + > + This driver can also be built as a module. If so, the module > + will be called gpio-ljca. The GPIO Kconfig has a separate submenu for USB expanders, so put this Kconfig in that submenu. This makes the choice come in a more logical spot and not appear on configs that don't even have USB. (...) > + DECLARE_BITMAP(unmasked_irqs, LJCA_MAX_GPIO_NUM); > + DECLARE_BITMAP(enabled_irqs, LJCA_MAX_GPIO_NUM); > + DECLARE_BITMAP(reenable_irqs, LJCA_MAX_GPIO_NUM); > + u8 *connect_mode; > + /* mutex to protect irq bus */ > + struct mutex irq_lock; (...) With IRQ code like this from a USB callback: > +static void ljca_gpio_event_cb(void *context, u8 cmd, const void *evt_da= ta, int len) > +{ > + const struct gpio_packet *packet =3D evt_data; > + struct ljca_gpio_dev *ljca_gpio =3D context; > + int i; > + int irq; > + > + if (cmd !=3D LJCA_GPIO_INT_EVENT) > + return; > + > + for (i =3D 0; i < packet->num; i++) { > + irq =3D irq_find_mapping(ljca_gpio->gc.irq.domain, packet= ->item[i].index); > + if (!irq) { > + dev_err(ljca_gpio->gc.parent, "gpio_id %u does no= t mapped to IRQ yet\n", > + packet->item[i].index); > + return; > + } > + > + generic_handle_domain_irq(ljca_gpio->gc.irq.domain, irq); > + set_bit(packet->item[i].index, ljca_gpio->reenable_irqs); > + } > + > + schedule_work(&ljca_gpio->work); > +} I don't feel comfortable merging this unless Marc Zyngier has looked at the code first, so please CC him on this patch next time. > +static const struct irq_chip ljca_gpio_irqchip =3D { > + .name =3D "ljca-irq", > + .irq_mask =3D ljca_irq_mask, > + .irq_unmask =3D ljca_irq_unmask, > + .irq_set_type =3D ljca_irq_set_type, > + .irq_bus_lock =3D ljca_irq_bus_lock, > + .irq_bus_sync_unlock =3D ljca_irq_bus_unlock, > + .flags =3D IRQCHIP_IMMUTABLE, > + GPIOCHIP_IRQ_RESOURCE_HELPERS, > +}; Thanks for fixing the immutable irq chip! > + ljca_gpio->auxdev =3D auxdev; > + ljca_gpio->gc.direction_input =3D ljca_gpio_direction_input; > + ljca_gpio->gc.direction_output =3D ljca_gpio_direction_output; Can you implement .get_direction()? It's scanned on probe to determine the initial state of each line so it is very nice to have. Yours, Linus Walleij