Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp202540rdb; Thu, 18 Jan 2024 00:30:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNKcxposuku6ukWUP20Ybwjq0oclcTCGqiqEksOX1Z5IRQr++6rsbGWtPTjzK5/Lborpb4 X-Received: by 2002:a05:6808:1b23:b0:3bd:93bd:170b with SMTP id bx35-20020a0568081b2300b003bd93bd170bmr567212oib.77.1705566614334; Thu, 18 Jan 2024 00:30:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705566614; cv=pass; d=google.com; s=arc-20160816; b=kJUu2vxdOF9Lmc6YDUHI8IJD5/0v35V1cNa0eOwQPl7VLARUg8nynMS9mD37uAd8yt gOEoX+s2zos4pKEYNCdMyNd27wgKR6u8TUqaXBOMHL9AHOefvPD1Ikklw7dxlAFauZYW 5dVI8Bv70ZJYBjZfcw4rkbAfBSnyaAtUwNtkjWzyfsr/cp5sFE1q4j6EuObCM80kWw8S Yj3qmJJ4+MRNcjkYMIDeftDftvkoog+qBL8ceDmccP36CBTPrP+Wcy3Hr0nOWzRDRMVx Mga6KeuBiC8HTdi1XdujHmxBsHdZARogHM3+vgNb1fW5A+co/068Vhh/eT7W+ragLVlX 1IDw== 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=0e8JQKznVgjbX6V+oFJlIz7MELkDV2I4qJF0jQJZVwbQNuz2IvD26/Lq59EqWSSYFt P9FnjZgFtbhqdvLp4DaqXEOR3brEU78WJMn0h8rBLvM2k22wigyTit7LkTGrfHPjk/dV OLRIljfBiisaemBOL4clE480NkWOpeSDA8AasIYSU6KaEQZ0i1ZS+XpmZbijVMv72W5E LB3H5PKWbtdN30IcxA3caZBA3Aq0XzbpblHVxN26BLGORYgvn7kavxtxG6PJFxNoW9au SEk0FgC/bQ2x2FM4BARRxyY9SkWgKpdod2hCghS6C36QKr1H58gW+fkns1X0+oAukW7r PtiQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q3tctYZl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-29875-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29875-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 e6-20020ac85986000000b00429c4813550si13755014qte.345.2024.01.18.00.30.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 00:30:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29875-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=Q3tctYZl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-29875-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29875-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 343621C2098D for ; Thu, 18 Jan 2024 08:30:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49FD82DF92; Thu, 18 Jan 2024 08:23:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q3tctYZl" 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 106F41F61E; Thu, 18 Jan 2024 08:23:00 +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=1705566180; cv=none; b=vFDfdbkQsi22aHhF7AWkEyiCLwPXrd7Ncsaba91QoV/NAO1HnFmTgQSpIv2bjL7sw7Bb69763U7PmpFUXey27Oq5nnlNeGGwMWttkchC2QnSYwbpsi4K9YMOs8QWTE6B2f6M+iOCms+kh8Ovz5/LIiMbwJ2R2SZ1hdTVXkF3Hjw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705566180; c=relaxed/simple; bh=caawVOpxHFy9cm3i7DwECM4693fhFarzsOiGy9doXoc=; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key: X-Endpoint-Received:X-Original-From:Reply-To; b=kGg7NNKG4NgCLan3iUDpj0/fLC5XQyYJ+QkHIKy8dsvMuSyBmohT0sIp02B5+hQBWfRXk0t+hwd3esoPRcdNgW23GFY8nCtc1C5FGv9gUZDgqC/wtM3Wce4idZYu+D6qkFM0iDZ2x5KhBZ2ArFyiY6F7lKVv4d+JZ/6lTjgDVco= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q3tctYZl; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id E46C2C3279F; Thu, 18 Jan 2024 08:22:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705566179; bh=caawVOpxHFy9cm3i7DwECM4693fhFarzsOiGy9doXoc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Q3tctYZlE3F8KTFiBWoxLgygJEsy4PQUNx815zXv2o6YEifS8+dZY9gP9cV9catzS HxbmK11saSzmdv4/Et5X3bkizyLcJv9UODcPksSSNuFfkarOgLUf96a18lNUNGAnht zdrWPrgVNRBlqvcozT91ugN/mOSy7qVCbR575vwT9Ae1WdHqYuk+U4SkR56lFi1bx0 u1aycJ4rYqYQh74tud7/uiHrO0/s/aSeYbm3Hhu23JCyWespgF/E2ls1yJv1Vy6Rgq 3tMSlUZnNislRokctY0LB9+mU+SZ+p+bG6n77iXoRm8g6LLX+RKNAry5U/yqYJTibr RYjiHUJsHKc1A== 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 D5AE0C4707B; Thu, 18 Jan 2024 08:22:59 +0000 (UTC) From: Nikita Shubin via B4 Relay Date: Thu, 18 Jan 2024 11:21:09 +0300 Subject: [PATCH v7 26/39] 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: <20240118-ep93xx-v7-26-d953846ae771@maquefel.me> References: <20240118-ep93xx-v7-0-d953846ae771@maquefel.me> In-Reply-To: <20240118-ep93xx-v7-0-d953846ae771@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=1705566176; l=4650; i=nikita.shubin@maquefel.me; s=20230718; h=from:subject:message-id; bh=veUYE/VzU1y37Z5M8NkA7tAbUvE+Vs49lzqAWz+krrk=; =?utf-8?q?b=3DJTMG/qh/vDZe?= =?utf-8?q?kFRgJzcyfaGrSO16q59j+ZSCqkVPNE/iwmFTqTM0PAw+MouQO26uAVuPu0nPykhZ?= THLAZeJ2BYF9RQ1QqxaquxZ6m8myDdjycGJkZxQ9wWdcHV05Qb1L 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: 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