Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1153608rbb; Sun, 25 Feb 2024 23:36:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCURaciGvRgEcGmYLVymjedLGQeG3jsoqXIomyzAsKHEBpOfcGFP2X4f3cpEbyXOBFrkEp261eom2ySLoDqWKRea40SALqtH00KQTBg2Ig== X-Google-Smtp-Source: AGHT+IFX6g08bj2/fGkF80Mt2VlOzWLf16AXfatmTajJt3OGPLD/43Pm7R+cpZJak4OnI/aWt80N X-Received: by 2002:aa7:d9ca:0:b0:565:f9c1:d925 with SMTP id v10-20020aa7d9ca000000b00565f9c1d925mr950912eds.0.1708933016890; Sun, 25 Feb 2024 23:36:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708933016; cv=pass; d=google.com; s=arc-20160816; b=ZDbBBAL9y7jw1kigffDygCHDqKs/EGWeh6krgOxJU4/YOcgH5xylmO6COUoGX6qnpW K6ddnhiYfrOPiUa8/un5QnCvJMberVY/PV40bJknXsH44w0SCvm7wbACQDHYrQhteg1v mQ0Sozt37ajYADUnecrWNqiV7Gq44DnS3cr3fr6qMiV/bEbWe8j2rpIqS8tHW1ZblAja d7M2MlMDkgYzvmIHS1+96FCOJX+Blm1Q4VX/qgYQe+OTgfU2XgFzjewCasn1PEHKLNBT haqU/tiepVU1AEJLUxOmvXMjm/vuvDLcRIhjesI+9TuvFxzvoGth4knhqkVSAmCljdD8 2WpQ== 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=ZWON4GpVhxe8E+6ytbDrYWgUKMwlBeOpmjH1o1UcHSOSHAL5Y07Q/OhSv3Hf824+fK 8PXfodFylHGfKkDJnx7xkt8n1Q1SJc+GiKpprS4rAs4K3hNA1r4zpQ48fXAuoC2BH/v6 GukgeNGVxiqz9yl71PV7PKjg4ElQsOVnZB5BRwAGiSIWRIvBlK8e3iCF3yLUX35+8A4/ LpWwe5rBDHXX+joXGdd+kbvPXZ7Z31HOCv9faK4LRJJlpvyvhEMd0cKIEeQADOLKei5k 3Ux+QD0aAEewSmjFkZ8zWTY2wJIpSOBjMYOZHGbjg01vunxYf1Z9mb/ttPnBxlNSzpR6 BOvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dTGOWEJj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80659-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80659-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i29-20020a50871d000000b005657ae92735si1855751edb.376.2024.02.25.23.36.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 23:36:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80659-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dTGOWEJj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80659-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80659-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 818291F21E6C for ; Mon, 26 Feb 2024 07:36:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 16171524AD; Mon, 26 Feb 2024 07:31:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dTGOWEJj" 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 92FE81CD36; Mon, 26 Feb 2024 07:31:23 +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=1708932683; cv=none; b=cu0q/jYLgQazqbraIk3jNO1ff/Yghpyfk6hu6a2MRrhbGbI5B3IjhIbPgR+0LW8NeDOAofYEZkNDEqe42NvjlO8gXhoYQMc5rzXpWl2MqHW5FNjxyZXMJmIJPxBVEbcwN+k7Ls9T1KGAs0Xg6hipiQNuooPGf4CbhmIM/ZvA36E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708932683; c=relaxed/simple; bh=caawVOpxHFy9cm3i7DwECM4693fhFarzsOiGy9doXoc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=o+n4rY6751/G+d4LjG92M3ksGtLuIlTOe5bYowbiiJAP80IqbOAoiXXVXnniqDdDV1PeTlFDjOVGr+wO643ICknx9J+qQoZgm3lUAqSHZ5Jccixr9p6lQ7WPKMNQyrXwOkFr/X0d3N9nMQ5jPjAfvfG/twjT3uQTnJoTFhu89N4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dTGOWEJj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 4FA81C4E684; Mon, 26 Feb 2024 07:31:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708932683; bh=caawVOpxHFy9cm3i7DwECM4693fhFarzsOiGy9doXoc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=dTGOWEJj+ULmKl/yjEVeUxLX8CFRPsmPilpwQxv3AxDfhEJZXHkqrKCO6IeS0gwQK oJ2Kf4AKUae7xErt+lBRieUou6fp9ipcDjCCRAjFehURCKzXoJV8ihbzHuG9z4ieDV qELJmjicM7wzvocg1BtLXJfnPIx4ZAC/Q3OJRtwaz8FhWBuE69zWW3E1+SrU4+y2K1 3oVLiRl7+MnkBTc6UusdSva4BLfzqql6UoJXPLqbGFDl6VfCcHdG1wTKX9/+2nh2B3 2gNSVavXkYzxDZdR5kLziSEDXoWZbynRr/ofJ9p3SKwmC6KUOMhcJD12J/mVgmVkSf aqFbxp+M4k85g== 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 3E109C54E4A; Mon, 26 Feb 2024 07:31:23 +0000 (UTC) From: Nikita Shubin via B4 Relay Date: Mon, 26 Feb 2024 10:30:21 +0300 Subject: [PATCH v8 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: <20240226-ep93xx-v8-25-3136dca7238f@maquefel.me> References: <20240226-ep93xx-v8-0-3136dca7238f@maquefel.me> In-Reply-To: <20240226-ep93xx-v8-0-3136dca7238f@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=1708932678; l=4650; i=nikita.shubin@maquefel.me; s=20230718; h=from:subject:message-id; bh=veUYE/VzU1y37Z5M8NkA7tAbUvE+Vs49lzqAWz+krrk=; =?utf-8?q?b=3Dxp+3tulwl4Wg?= =?utf-8?q?u7pH0QHdYv2pIEzgDmI/0TP/QMh5Up3Jb4OULgIkcUdPz/iCI/rf2jgSIyGHgqqR?= gqzmal9gACnpUfKRU0UsmS6ZNL/YKiG+u85/FCxMm2ws9HfPeEGv 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