Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3198965lqp; Tue, 26 Mar 2024 02:29:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWYwNazw5KAGu0PUsC08fSAhmfsEeSCXWq5SHqIRiAIsP0AI/2enB+5jvs+XgKPkOA8RZw/VXk+dZy6eSIs28UklKTvVhpRDD4OcNbRUw== X-Google-Smtp-Source: AGHT+IEDxGwz1Ua/zdh2nmpSHjIWjaCWvrqBjmN/xALjcCVGxTObYXKtyBBCZCE7yjGMx2RkyCpF X-Received: by 2002:a05:622a:44c:b0:431:7329:9945 with SMTP id o12-20020a05622a044c00b0043173299945mr540069qtx.60.1711445344476; Tue, 26 Mar 2024 02:29:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711445344; cv=pass; d=google.com; s=arc-20160816; b=q2H+VrQ/6sXWdzP5bVTcLsPqJs8JAEHbpZ6yJ2fQWrfwhuaM4q8ffrthtUNeVc50hN oYqK7YSQofNJUfhUzEraUvMBDf07u3WUOcNTiLTrd+9qralq777qbo3AIgaFPprxLPoN UKMLOvYZauJNRxEjFQye/ZIj5YOh1j/2GuEpgTcsK1bwQG1lszlD3Hjk6Ho6VsB/Xbs2 9G70HA86yI2qwaEB6+Hm7fvsBB/OacF+kh8WgxXbKGPszujkGDhpIeuwrRhGiu5Ssppb +Z+1XQFGq3CWOP67XXK+g5Jpli+0Xi84HwgRkjjO1r3TZq3yGsgRdImhGvGSIV8BcnSh AtNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=9mqBK5fvndEsWpNAkbNQpLndQ8qGPZ6WmX0YfzeCO3k=; fh=JL0T/88ejnv5mURc5oy9cb2hiTnfJgtRFcbm+EVGDT8=; b=DpIeorf7Yz0uc/0JuLAz2KYiMNpoAnnlaB1t3s7LhJwJKOkSoreYRiT+rEfqtNErMl Y03DY4HpKkbrTb6rOgy2sJqjvQOwudDkvCYdsaQL9lyUic/iCLz4WlTS1yjkvo9OyqjQ Lpb10XocWNqHQvvHi8zXw3XcvyHxbnzITbSnR/wum4yLtLOS4ivETLRmgPnxPbfT6jTK eMcIrNzxkeogk5Bpk6xvVkQAM4rOPFejfs4wHdMcVgORuLrkJ3BaJCvRGoxkbVlksTvB NfGmSS8AWhOIF6ZiLP+XotESzra6zOek0gQfa99yCe2Vg3ljkm3OB6cSNPynSzRMUfC4 UZhA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XFINn4Da; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-118660-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118660-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v22-20020a05622a131600b00431286f5124si7139517qtk.99.2024.03.26.02.29.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 02:29:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118660-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XFINn4Da; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-118660-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118660-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 299DE1C39C5B for ; Tue, 26 Mar 2024 09:29:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 10AFC12BF10; Tue, 26 Mar 2024 09:20:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XFINn4Da" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 033156FBB7; Tue, 26 Mar 2024 09:20:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711444843; cv=none; b=An8CkD2srOoUwdTYNrTByYUVovVZcXr8Q/7sqhVmSZC3iYkIF4U2PRSAWYphrpREMPI0qgI+MNO3kLZeCWxWvOhhjLT9dCZwiUb5hl9KHTjojYbLl/MIq0ab4e5G3s3TJVn4MpY8BgvTBDATfTqc6cQnCW9BoG3UCiAOe7xrv+w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711444843; c=relaxed/simple; bh=caawVOpxHFy9cm3i7DwECM4693fhFarzsOiGy9doXoc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=L1NM2/UnMfMdZrQZlVkcKyRg0vNigRBPZFTU8emL7tCU1weVWqildqRMKRHZHKnZeP/T0DZBjg0zLfAndiKCKnvO/3Nzwa29OQcw+BR8Kuve24UnwwdatX5gxWSMAwxMmE/zzJAXf96PVJR16FJBR4oPAaCWzYJlxMX53bic84Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XFINn4Da; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 47ECEC3279F; Tue, 26 Mar 2024 09:20:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711444842; bh=caawVOpxHFy9cm3i7DwECM4693fhFarzsOiGy9doXoc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=XFINn4DaLSM3JvDR3ivw9ybi6n2n0N1fOOqf0Dgy3KPRq6S+FtdxGocRtsMYvWq6P IH9jXQ0XRpSofETqPrW6pC0ny79jPdf4A8/buO3rN2mqVCWGuOTohFNM/vSfrci6zd /vt/EPAvISaVlErpXjCs8PNvtDa3nXvXwrw1Nj9DQ0LbRtbWzOhS2l16mzbofUKAsP 9gekGHZSkfrghvaOODDofavBmuUBq9LCAVIrg46vQif1UsAExepWkbYANkTfjd8A2k x74zQQZZsItKVmIktUxPt1isu3I18xyffKk5fUNxJCEXmwM/ASenpd6M0INnIUER+r FTaMOP0p93qIw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4070DCD11DB; Tue, 26 Mar 2024 09:20:42 +0000 (UTC) From: Nikita Shubin via B4 Relay Date: Tue, 26 Mar 2024 12:18:52 +0300 Subject: [PATCH v9 25/38] gpio: ep93xx: add DT support for gpio-ep93xx Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240326-ep93xx-v9-25-156e2ae5dfc8@maquefel.me> References: <20240326-ep93xx-v9-0-156e2ae5dfc8@maquefel.me> In-Reply-To: <20240326-ep93xx-v9-0-156e2ae5dfc8@maquefel.me> To: Linus Walleij , Bartosz Golaszewski Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann , Andy Shevchenko , Bartosz Golaszewski X-Mailer: b4 0.13-dev-e3e53 X-Developer-Signature: v=1; a=ed25519-sha256; t=1711444837; l=4650; i=nikita.shubin@maquefel.me; s=20230718; h=from:subject:message-id; bh=veUYE/VzU1y37Z5M8NkA7tAbUvE+Vs49lzqAWz+krrk=; b=xHClAB+tIAg3s3CXvsedoXpLj6apxNnAcRbwg0SnuwzQBxhCVbDSr7P/9HRzBPWVePRdAjICa0Cj 8NNde3beAhzjy3w6SABVm2R4fv4v3cEFVFPckKqDnEz7Yc3vwNlx X-Developer-Key: i=nikita.shubin@maquefel.me; a=ed25519; pk=vqf5YIUJ7BJv3EJFaNNxWZgGuMgDH6rwufTLflwU9ac= X-Endpoint-Received: by B4 Relay for nikita.shubin@maquefel.me/20230718 with auth_id=65 X-Original-From: Nikita Shubin Reply-To: nikita.shubin@maquefel.me From: Nikita Shubin Add OF ID match table. Reviewed-by: Andy Shevchenko Reviewed-by: Linus Walleij Acked-by: Bartosz Golaszewski Signed-off-by: Nikita Shubin --- drivers/gpio/gpio-ep93xx.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/gpio/gpio-ep93xx.c b/drivers/gpio/gpio-ep93xx.c index a55f635585f4..ab798c848215 100644 --- a/drivers/gpio/gpio-ep93xx.c +++ b/drivers/gpio/gpio-ep93xx.c @@ -12,13 +12,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include struct ep93xx_gpio_irq_chip { void __iomem *base; @@ -138,7 +138,8 @@ static void ep93xx_gpio_irq_mask_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc); - int port_mask = BIT(irqd_to_hwirq(d)); + irq_hw_number_t hwirq = irqd_to_hwirq(d); + int port_mask = BIT(hwirq); if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) eic->int_type2 ^= port_mask; /* switch edge direction */ @@ -147,26 +148,28 @@ static void ep93xx_gpio_irq_mask_ack(struct irq_data *d) ep93xx_gpio_update_int_params(eic); writeb(port_mask, eic->base + EP93XX_INT_EOI_OFFSET); - gpiochip_disable_irq(gc, irqd_to_hwirq(d)); + gpiochip_disable_irq(gc, hwirq); } static void ep93xx_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc); + irq_hw_number_t hwirq = irqd_to_hwirq(d); - eic->int_unmasked &= ~BIT(irqd_to_hwirq(d)); + eic->int_unmasked &= ~BIT(hwirq); ep93xx_gpio_update_int_params(eic); - gpiochip_disable_irq(gc, irqd_to_hwirq(d)); + gpiochip_disable_irq(gc, hwirq); } static void ep93xx_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc); + irq_hw_number_t hwirq = irqd_to_hwirq(d); - gpiochip_enable_irq(gc, irqd_to_hwirq(d)); - eic->int_unmasked |= BIT(irqd_to_hwirq(d)); + gpiochip_enable_irq(gc, hwirq); + eic->int_unmasked |= BIT(hwirq); ep93xx_gpio_update_int_params(eic); } @@ -179,11 +182,11 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc); - irq_hw_number_t offset = irqd_to_hwirq(d); - int port_mask = BIT(offset); + irq_hw_number_t hwirq = irqd_to_hwirq(d); + int port_mask = BIT(hwirq); irq_flow_handler_t handler; - gc->direction_input(gc, offset); + gc->direction_input(gc, hwirq); switch (type) { case IRQ_TYPE_EDGE_RISING: @@ -209,7 +212,7 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type) case IRQ_TYPE_EDGE_BOTH: eic->int_type1 |= port_mask; /* set initial polarity based on current input level */ - if (gc->get(gc, offset)) + if (gc->get(gc, hwirq)) eic->int_type2 &= ~port_mask; /* falling */ else eic->int_type2 |= port_mask; /* rising */ @@ -285,9 +288,8 @@ static int ep93xx_setup_irqs(struct platform_device *pdev, if (girq->num_parents == 0) return -EINVAL; - girq->parents = devm_kcalloc(dev, girq->num_parents, - sizeof(*girq->parents), - GFP_KERNEL); + girq->parents = devm_kcalloc(dev, girq->num_parents, sizeof(*girq->parents), + GFP_KERNEL); if (!girq->parents) return -ENOMEM; @@ -306,7 +308,7 @@ static int ep93xx_setup_irqs(struct platform_device *pdev, girq->parent_handler = ep93xx_gpio_f_irq_handler; for (i = 0; i < girq->num_parents; i++) { - irq = platform_get_irq(pdev, i); + irq = platform_get_irq_optional(pdev, i); if (irq < 0) continue; @@ -359,9 +361,15 @@ static int ep93xx_gpio_probe(struct platform_device *pdev) return devm_gpiochip_add_data(&pdev->dev, gc, egc); } +static const struct of_device_id ep93xx_gpio_match[] = { + { .compatible = "cirrus,ep9301-gpio" }, + { /* sentinel */ } +}; + static struct platform_driver ep93xx_gpio_driver = { .driver = { .name = "gpio-ep93xx", + .of_match_table = ep93xx_gpio_match, }, .probe = ep93xx_gpio_probe, }; -- 2.41.0