From patchwork Wed Aug 22 20:41:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 144861 Delivered-To: patch@linaro.org Received: by 2002:a2e:164a:0:0:0:0:0 with SMTP id 10-v6csp401755ljw; Wed, 22 Aug 2018 13:41:49 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxlfobjDdR6wIAwmHWK78Vm1nHSLkpqKuXCrY8XRxY65EJFNOUYzYsYlrV49vsRv9F1QCx4 X-Received: by 2002:a17:902:6501:: with SMTP id b1-v6mr55648939plk.31.1534970508934; Wed, 22 Aug 2018 13:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534970508; cv=none; d=google.com; s=arc-20160816; b=ynO4qrydgkNXNsc0b3sKBfz4s1tdvFCAaaEK2tN3zeqmDUaTQ28Pj4rh6bUWBycovs 9mWT1kV0MTb9kLnj4+j2oobdVarRygdeeCOisBBQOETxvV/maXFq+B93QhLdnucP61lh 4yf57JQh0y+tc0Yu94p7c71YaR9ZwYwcKweLUO87wXkGzI+4qj/UhPZOvGlDd0arWVAB SCgrtr6mQn+7FHPt2fcjwwTKImOr7PsAbFLiAdi6yNd5XGr0bjlBBcI/U79hZOIp0mTq uyD9XdmuOoF8odDnIS6p2kJ1pVZr0a32PN8UqqomVw3xW5vgduQMpXK7vPrf+b0r6WhN 538g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=og9F5K3DV5Z4i7H1Ak0q8ntuvtl8V20+7qYiuklDr38=; b=WlzAXUKYvSuL7vcemJKH7EoteiyIeWxtRr7odsDuyQpREP2vaARYDZMhpTr9uG+7jU Y31zZgGd/hWDHFg8+lL0H4klsLqANVr9QeqRZK72lwotpr0KD0RcmnVfRHuTMX3hmV4U srnpR6ExfTEyE+cMRdkzPyYmkUS++jM7TR9qNuVT+Qm5+EzdUTNzJnxlte7a66uwAyYY agAam0vCbsoWE0TIspZoyv9Dk0Gwe6NKxtVCdkLSWs+lfsOCIt1vZq91wysawuAJrFG4 ObIYdWeyrFh0+qsJ2DXa9p6fRCFOo6qjkg04voMuYwhVta4pAc70JPz8ccQGUE7/kaI/ JoEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RhrllJJ+; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t23-v6si2559068pgi.301.2018.08.22.13.41.48; Wed, 22 Aug 2018 13:41:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RhrllJJ+; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-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 S1727545AbeHWAIL (ORCPT + 5 others); Wed, 22 Aug 2018 20:08:11 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:46708 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727395AbeHWAIL (ORCPT ); Wed, 22 Aug 2018 20:08:11 -0400 Received: by mail-lj1-f193.google.com with SMTP id 203-v6so2428412ljj.13 for ; Wed, 22 Aug 2018 13:41:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=og9F5K3DV5Z4i7H1Ak0q8ntuvtl8V20+7qYiuklDr38=; b=RhrllJJ+9MgmonM/Nii3ozuXN1a5eVF3XqE+RI4BvRt4qpkklcpUpCa/IOPoaCsxzo sTgggxF7VZD5kdzcYqcO8yz6i/alvi/QwUt+QTF7EnS4zDwWFy4Bh6NZCZWnb9SqYJWz 0vx/zUiu8erdapj1IwZ5UO4ZB6eiwGQ71FSl8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=og9F5K3DV5Z4i7H1Ak0q8ntuvtl8V20+7qYiuklDr38=; b=UrrR28xobc+Ei5ciVD1SmjZH/Rh9MQ63wQSAPMotEtRAUFAyNk25il6hgc2X8xU0ey RuX9j1hQcEzKEjBnxUFC05CDyJQchD26Ygf+pISX0XlMw9fMPpQAQ9qdTul0QE5CAJCQ EEW8m62snBv1yjPXRCZvZkkOVfZYMVGMuSG5YUtdZ1+C8lydTgez3K2g6wAQK6GRBzkV v8CX8tc4Jc5D+CrQWlmnFlnC9CIBYIIJ+q5C71fqmYnZj0Xl8JsSDtnNyK1S4w97sGcA mXDdDrNAuhfJuzp+ym7dxwg0DedUhm/95ylZ/owW4woYRIYuMUg5Mg4C94+nryGJZIoa AJMw== X-Gm-Message-State: AOUpUlFRnPnclvgOqtPiMf88Tlr/+d85+c9qgrJdK7WtrVjqLBY0u6HO 4PZnHpQlM5Rey8Bjy6rC30CTug== X-Received: by 2002:a2e:9bc9:: with SMTP id w9-v6mr32551315ljj.33.1534970505401; Wed, 22 Aug 2018 13:41:45 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id q128-v6sm431515ljq.72.2018.08.22.13.41.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 Aug 2018 13:41:44 -0700 (PDT) From: Linus Walleij To: H Hartley Sweeten , Alexander Sverdlin Cc: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, Linus Walleij Subject: [PATCH 10/11] gpio: ep93xx: Cut gpio_to_irq() usage Date: Wed, 22 Aug 2018 22:41:10 +0200 Message-Id: <20180822204111.9581-11-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180822204111.9581-1-linus.walleij@linaro.org> References: <20180822204111.9581-1-linus.walleij@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This removes the callback into the gpiolib creating a circular call to convert between GPIO numbers and IRQs and pushes the whole business into the driver, just using an array of IRQ bases for the three IRQ capable ports. This way we get rid of including that no driver should include. Signed-off-by: Linus Walleij --- drivers/gpio/gpio-ep93xx.c | 48 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) -- 2.17.1 diff --git a/drivers/gpio/gpio-ep93xx.c b/drivers/gpio/gpio-ep93xx.c index 1248d83f860b..d45d8ac3b525 100644 --- a/drivers/gpio/gpio-ep93xx.c +++ b/drivers/gpio/gpio-ep93xx.c @@ -17,8 +17,6 @@ #include #include #include -/* FIXME: this is here for gpio_to_irq() - get rid of this! */ -#include #define EP93XX_GPIO_F_INT_STATUS 0x5c #define EP93XX_GPIO_A_INT_STATUS 0xa0 @@ -30,6 +28,15 @@ /* Maximum value for irq capable line identifiers */ #define EP93XX_GPIO_LINE_MAX_IRQ 23 +/* + * IRQ numbers used by this driver is 64 ..87 + * + * Map GPIO A0..A7 (0..7) to irq 64..71, + * B0..B7 (7..15) to irq 72..79, and + * F0..F7 (16..24) to irq 80..87. + */ +static unsigned int ep93xx_gpio_irq_base[3] = { 64, 72, 80 }; + struct ep93xx_gpio { void __iomem *base; struct gpio_chip gc[8]; @@ -112,13 +119,13 @@ static void ep93xx_gpio_ab_irq_handler(struct irq_desc *desc) stat = readb(epg->base + EP93XX_GPIO_A_INT_STATUS); for_each_set_bit(offset, &stat, 8) { - int gpio_irq = gpio_to_irq(0) + offset; + int gpio_irq = ep93xx_gpio_irq_base[0] + offset; generic_handle_irq(gpio_irq); } stat = readb(epg->base + EP93XX_GPIO_B_INT_STATUS); for_each_set_bit(offset, &stat, 8) { - int gpio_irq = gpio_to_irq(8) + offset; + int gpio_irq = ep93xx_gpio_irq_base[1] + offset; generic_handle_irq(gpio_irq); } @@ -130,12 +137,12 @@ static void ep93xx_gpio_f_irq_handler(struct irq_desc *desc) /* * map discontiguous hw irq range to continuous sw irq range: * - * IRQ_EP93XX_GPIO{0..7}MUX -> gpio_to_irq(EP93XX_GPIO_LINE_F({0..7}) + * IRQ_EP93XX_GPIO{0..7}MUX -> EP93XX_GPIO_LINE_F{0..7} */ struct irq_chip *irqchip = irq_desc_get_chip(desc); unsigned int irq = irq_desc_get_irq(desc); int port_f_idx = ((irq + 1) & 7) ^ 4; /* {19..22,47..50} -> {0..7} */ - int gpio_irq = gpio_to_irq(16) + port_f_idx; + int gpio_irq = ep93xx_gpio_irq_base[2] + port_f_idx; chained_irq_enter(irqchip, desc); generic_handle_irq(gpio_irq); @@ -268,27 +275,24 @@ static void ep93xx_gpio_init_irq(struct platform_device *pdev, int i; /* The A bank */ - for (gpio_irq = gpio_to_irq(0); - gpio_irq < gpio_to_irq(8); - gpio_irq++) { + for (i = 0; i < 8; i++) { + gpio_irq = ep93xx_gpio_irq_base[0] + i; irq_set_chip_data(gpio_irq, &epg->gc[0]); irq_set_chip_and_handler(gpio_irq, &ep93xx_gpio_irq_chip, handle_level_irq); irq_clear_status_flags(gpio_irq, IRQ_NOREQUEST); } /* The B bank */ - for (gpio_irq = gpio_to_irq(8); - gpio_irq < gpio_to_irq(16); - gpio_irq++) { + for (i = 0; i < 8; i++) { + gpio_irq = ep93xx_gpio_irq_base[1] + i; irq_set_chip_data(gpio_irq, &epg->gc[1]); irq_set_chip_and_handler(gpio_irq, &ep93xx_gpio_irq_chip, handle_level_irq); irq_clear_status_flags(gpio_irq, IRQ_NOREQUEST); } /* The F bank */ - for (gpio_irq = gpio_to_irq(16); - gpio_irq < gpio_to_irq(EP93XX_GPIO_LINE_MAX_IRQ); - gpio_irq++) { + for (i = 0; i < 8; i++) { + gpio_irq = ep93xx_gpio_irq_base[2] + i; irq_set_chip_data(gpio_irq, &epg->gc[5]); irq_set_chip_and_handler(gpio_irq, &ep93xx_gpio_irq_chip, handle_level_irq); @@ -350,19 +354,15 @@ static int ep93xx_gpio_set_config(struct gpio_chip *gc, unsigned offset, return 0; } -/* - * Map GPIO A0..A7 (0..7) to irq 64..71, - * B0..B7 (7..15) to irq 72..79, and - * F0..F7 (16..24) to irq 80..87. - */ -static int ep93xx_gpio_to_irq(struct gpio_chip *chip, unsigned offset) +static int ep93xx_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { - int gpio = chip->base + offset; + int port = ep93xx_gpio_port(gc); - if (gpio > EP93XX_GPIO_LINE_MAX_IRQ) + /* Those are the ports supporting IRQ */ + if (port != 0 && port != 1 && port != 5) return -EINVAL; - return 64 + gpio; + return ep93xx_gpio_irq_base[port] + offset; } static int ep93xx_gpio_add_bank(struct gpio_chip *gc, struct device *dev,