From patchwork Thu Mar 9 07:46:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 66636 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp156809wrd; Wed, 8 Mar 2023 23:56:05 -0800 (PST) X-Google-Smtp-Source: AK7set87Hy/TgH7X1VOBJAEbbUs4WwCj7jXr0INiSWp5Q5ZtpSzmd0IvMC+pyr5UqC2dRhSSg8eq X-Received: by 2002:a17:902:c10c:b0:19a:bbd0:c5ca with SMTP id 12-20020a170902c10c00b0019abbd0c5camr18857745pli.48.1678348564823; Wed, 08 Mar 2023 23:56:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678348564; cv=none; d=google.com; s=arc-20160816; b=anxOZ6Om9fe/r8A7VqwKDypzDAq9jn+mgJfhzHAIKLiqvFJc8g7AhknvQnYQTEDJh6 0e5ATdsBG701u+0Un9ykcSxd1YM/s+3yGYSbwp/mgsTbfYtDIyOhmc8pRc3PrAl5YEcb N0U1yjfpkjXLgOqs/NvwMiERMIXxAEmgCa9gnsiNf0MjF34bHixTGk9U85/hkOAWAjoR qywFSW6xAks9K6s0fdhtSSCoRNV0tes1ZsGhV7Ux6rO3d5RCsnrQIVpyQKPuCYcXVy0/ O5V8uanXP9jXm9KwNPjkfWLq00K7c8YeutWwymeVI0OTVMyLlA7rEBTiB516GZ2XftTJ GiaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Pkmx+b8ik/C6bLfv+4RBCDp/VEmyhMZOMZzx00ojykk=; b=XiFayvZmtvRsLifLdqM4VZkv1O57ifem3EwUaslW/FxqXf3O0quK4VgLYBkjtUrKuZ //3wkanB0DhIgP8ta0DOL7tb0H/lnvhm9ZSkvvW5zfveFJUypGBjBjySRnpE2Uu+GU7l 0tj/nuVzDJBztwxDlo8CdxvOUhBM2KN0+T1dRnGJP4fgTzuGpoEqIZ+nH7jv/Uj1Qr97 k5lxpFM6fgSgbMwIFR2XhQVsexGkilzogRSE3jaZPcdtW5afPoxzqPKnxSJ0rKVheeY3 xfbyPBVrk4OEm9B5W6Vi4H4p7l055kfb6E0/DTrsT2+hJeLGWEDxkC6R0GfgRwr1Ucpz dYzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="p3Kr/WFN"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u8-20020a17090282c800b0019cba5dd485si16122743plz.358.2023.03.08.23.55.52; Wed, 08 Mar 2023 23:56:04 -0800 (PST) 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="p3Kr/WFN"; 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 S230147AbjCIHrE (ORCPT + 99 others); Thu, 9 Mar 2023 02:47:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230261AbjCIHqb (ORCPT ); Thu, 9 Mar 2023 02:46:31 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8A1EDDB19 for ; Wed, 8 Mar 2023 23:46:08 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id r27so1135114lfe.10 for ; Wed, 08 Mar 2023 23:46:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678347968; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Pkmx+b8ik/C6bLfv+4RBCDp/VEmyhMZOMZzx00ojykk=; b=p3Kr/WFNbbKFk66agzCT4u42Y5KITAZpT48aFDNPE9ZUZHzzWb76fkK8FF1mTSwXvA YN00K6GTgQC1XC+mSoGVipsLmUmGGI2Ditgn5WnNaGmdlVcaT0n1cQsDlfgsKhlAdyIG 0VD4mueZ56RA8/YbfkwoduJ4nCXDurAqKFa6Rt8oQHpjXxLFrUWlgtfVwrrAoMGpKt0w aariaDW/AIcCYsIghKFcThCHY0OPYL8YkfwbdKEkF8qSKkpnlYYSD99dkFG0/dqduNje gSlB2/gHJo7+OIQaV7pAaEMDPRnenW8c0PzItdFAYuv0gBV0pV2zXHmS6KtCDIR3Fn+W Eg0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678347968; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pkmx+b8ik/C6bLfv+4RBCDp/VEmyhMZOMZzx00ojykk=; b=XaxOMzX+/BrLMnZW6upnRJhRzSZwjUfc45UhEeZczz/zdkdvPsEkhydS0lMNytqD3z 2cCgzSx+QEXISAjvsLmVH7eujUPxPmGT/Zyv93cMVivPTsdQGkv4zfbOySg0uVyM0Q+d vY4Jy+X7FXZETuVsN7guZ1GBIdTZEFKszzQHw2lbjjJ5AbMcH3B+z6rk0l7f2N8PyQIf HPznrPRCnSeC1OYo804tOcFak/v3aF/ERw1zxEtkgzehYk7NEfl4eRM9XWOkc9JbGxRn k2KzQdnRtWVZUF9WpKcDd/5YrkH/++HVIRj++0ixcnzuMJw+/A91gFK9N5JXaYzTOvL7 zenA== X-Gm-Message-State: AO0yUKVELHDs82zHKwo21Wykc31+oVpTMbSKUgBYSoEovQGcnaECSmVd UdLb/OY7gWqdMlARYSzhgxnyxQ== X-Received: by 2002:ac2:5dfa:0:b0:4b6:e405:1027 with SMTP id z26-20020ac25dfa000000b004b6e4051027mr6046717lfq.14.1678347968374; Wed, 08 Mar 2023 23:46:08 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.219]) by smtp.gmail.com with ESMTPSA id a6-20020a056512020600b004bb766e01a4sm2568972lfo.245.2023.03.08.23.46.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 23:46:08 -0800 (PST) From: Linus Walleij Date: Thu, 09 Mar 2023 08:46:00 +0100 Subject: [PATCH v3 12/17] gpio: mlxbf2: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230215-immutable-chips-v3-12-972542092a77@linaro.org> References: <20230215-immutable-chips-v3-0-972542092a77@linaro.org> In-Reply-To: <20230215-immutable-chips-v3-0-972542092a77@linaro.org> To: Mun Yew Tham , Bartosz Golaszewski , Joel Stanley , Andrew Jeffery , Alban Bedel , Orson Zhai , Baolin Wang , Chunyan Zhang , Jay Fang , Daniel Palmer , Romain Perier , Santosh Shilimkar , Kevin Hilman , William Breathitt Gray Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-omap@vger.kernel.org, Linus Walleij , Marc Zyngier X-Mailer: b4 0.12.1 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759876024778868635?= X-GMAIL-MSGID: =?utf-8?q?1759876024778868635?= Convert the driver to immutable irq-chip with a bit of intuition. Cc: Marc Zyngier Acked-by: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/gpio/gpio-mlxbf2.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpio-mlxbf2.c b/drivers/gpio/gpio-mlxbf2.c index 77a41151c921..6abe01bc39c3 100644 --- a/drivers/gpio/gpio-mlxbf2.c +++ b/drivers/gpio/gpio-mlxbf2.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -65,10 +66,10 @@ struct mlxbf2_gpio_context_save_regs { /* BlueField-2 gpio block context structure. */ struct mlxbf2_gpio_context { struct gpio_chip gc; - struct irq_chip irq_chip; /* YU GPIO blocks address */ void __iomem *gpio_io; + struct device *dev; struct mlxbf2_gpio_context_save_regs *csave_regs; }; @@ -237,6 +238,7 @@ static void mlxbf2_gpio_irq_enable(struct irq_data *irqd) unsigned long flags; u32 val; + gpiochip_enable_irq(gc, irqd_to_hwirq(irqd)); raw_spin_lock_irqsave(&gs->gc.bgpio_lock, flags); val = readl(gs->gpio_io + YU_GPIO_CAUSE_OR_CLRCAUSE); val |= BIT(offset); @@ -261,6 +263,7 @@ static void mlxbf2_gpio_irq_disable(struct irq_data *irqd) val &= ~BIT(offset); writel(val, gs->gpio_io + YU_GPIO_CAUSE_OR_EVTEN0); raw_spin_unlock_irqrestore(&gs->gc.bgpio_lock, flags); + gpiochip_disable_irq(gc, irqd_to_hwirq(irqd)); } static irqreturn_t mlxbf2_gpio_irq_handler(int irq, void *ptr) @@ -322,6 +325,24 @@ mlxbf2_gpio_irq_set_type(struct irq_data *irqd, unsigned int type) return 0; } +static void mlxbf2_gpio_irq_print_chip(struct irq_data *irqd, + struct seq_file *p) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); + struct mlxbf2_gpio_context *gs = gpiochip_get_data(gc); + + seq_printf(p, dev_name(gs->dev)); +} + +static const struct irq_chip mlxbf2_gpio_irq_chip = { + .irq_set_type = mlxbf2_gpio_irq_set_type, + .irq_enable = mlxbf2_gpio_irq_enable, + .irq_disable = mlxbf2_gpio_irq_disable, + .irq_print_chip = mlxbf2_gpio_irq_print_chip, + .flags = IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + /* BlueField-2 GPIO driver initialization routine. */ static int mlxbf2_gpio_probe(struct platform_device *pdev) @@ -340,6 +361,8 @@ mlxbf2_gpio_probe(struct platform_device *pdev) if (!gs) return -ENOMEM; + gs->dev = dev; + /* YU GPIO block address */ gs->gpio_io = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(gs->gpio_io)) @@ -376,13 +399,8 @@ mlxbf2_gpio_probe(struct platform_device *pdev) irq = platform_get_irq(pdev, 0); if (irq >= 0) { - gs->irq_chip.name = name; - gs->irq_chip.irq_set_type = mlxbf2_gpio_irq_set_type; - gs->irq_chip.irq_enable = mlxbf2_gpio_irq_enable; - gs->irq_chip.irq_disable = mlxbf2_gpio_irq_disable; - girq = &gs->gc.irq; - girq->chip = &gs->irq_chip; + gpio_irq_chip_set_chip(girq, &mlxbf2_gpio_irq_chip); girq->handler = handle_simple_irq; girq->default_type = IRQ_TYPE_NONE; /* This will let us handle the parent IRQ in the driver */