Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp827211ybe; Fri, 6 Sep 2019 07:56:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSLmW2b4jibmQ1amMQPw7j6uI+p4Lh82AzCv2dHJ6PepMCmB5+D4pr4E6Oswn5qWiXogsy X-Received: by 2002:a63:69c1:: with SMTP id e184mr7950279pgc.198.1567781768222; Fri, 06 Sep 2019 07:56:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567781768; cv=none; d=google.com; s=arc-20160816; b=vbDoImTPT17/Ig5H5UlQBgQaBYBhuaOM3IcCm1SdtfXtmVJDb3/CJ3qiERbBsMPlwi fil4/zVD1FJBGHxL7zaMbzPVK69AiIMkPS2paMU17jyzJYpWOcAcSpQ0qDm82PW/TDYr c3U083huo/bo2N7gCgpW267ZrWPgKvCkNqdA/n6uQ8mYa47EgfGGd7+ZYzOI/VWUlADW mi/C41toyGWOrZKvJfFMYeWwg6eOJIkiE5DQbKYcMr70nFOTSBR3r9l8K/QjGVCFrlsT hfd/hF+QswXgM4REovQ3oH3r9yYfpPGb8Mtkqbv3qrSum9eZ1ad7PE90GU9TZPxZMdML b+Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=yS2JPPHwj4DrGaq8fHKVp/Vqym/XZoNCvaeM+v5gvf4=; b=gzYosM8+MaaVXdAjfWWb1ka7Mmnvihi+P36Z4/kAUmUVq8QF2dVqcfkM8RryjqJZqX jV7Tz12IBw47i8FsFSQIBOocBUdCPQgamAkAGt9NuWoopHK3e77jhwMwxOQ77MOhSaLm qT0rQY0xv+xbRgAsTWiROFd3jrO8pbYtalUaem1MvhPHZjTAtfSoWa/aD+unVzrmVnf6 KjDoLd7E+RzQR/1qnVuadSY/gGNSjmxbNo0Jd+D18N/OthAnSLJvLsUQE12Xl2uab5H+ F30wGSCgtIHX+r9v2QK3+eI1NAVxsemNbsSzv5mTe6nfeSxMKprhRL6eu3I/OyoXavot VpLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p35si4430016pgb.484.2019.09.06.07.55.52; Fri, 06 Sep 2019 07:56:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727004AbfIFLIW (ORCPT + 99 others); Fri, 6 Sep 2019 07:08:22 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:46993 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732465AbfIFLIV (ORCPT ); Fri, 6 Sep 2019 07:08:21 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1i6C6C-000730-PB; Fri, 06 Sep 2019 13:08:16 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 248DD1C0E22; Fri, 6 Sep 2019 13:08:15 +0200 (CEST) Date: Fri, 06 Sep 2019 11:08:15 -0000 From: "tip-bot2 for Jerome Brunet" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] irqchip/meson-gpio: Add support for meson sm1 SoCs Cc: Jerome Brunet , Marc Zyngier , Kevin Hilman , Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <20190829161635.25067-3-jbrunet@baylibre.com> References: <20190829161635.25067-3-jbrunet@baylibre.com> MIME-Version: 1.0 Message-ID: <156776809510.24167.14866614709961308411.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the irq/core branch of tip: Commit-ID: b2fb4b77994abc1107c35547f3e123dce8e9f67d Gitweb: https://git.kernel.org/tip/b2fb4b77994abc1107c35547f3e123dce8e9f67d Author: Jerome Brunet AuthorDate: Thu, 29 Aug 2019 18:16:35 +02:00 Committer: Marc Zyngier CommitterDate: Fri, 30 Aug 2019 15:01:06 +01:00 irqchip/meson-gpio: Add support for meson sm1 SoCs The meson sm1 SoCs uses the same type of GPIO interrupt controller IP block as the other meson SoCs, A total of 100 pins can be spied on: - 223:100 undefined (no interrupt) - 99:97 3 pins on bank GPIOE - 96:77 20 pins on bank GPIOX - 76:61 16 pins on bank GPIOA - 60:53 8 pins on bank GPIOC - 52:37 16 pins on bank BOOT - 36:28 9 pins on bank GPIOH - 27:12 16 pins on bank GPIOZ - 11:0 12 pins in the AO domain Mapping is the same as the g12a family but the sm1 controller allows to trig an irq on both edges of the input signal. This was not possible with the previous SoCs families Signed-off-by: Jerome Brunet Signed-off-by: Marc Zyngier Tested-by: Kevin Hilman Reviewed-by: Kevin Hilman Link: https://lore.kernel.org/r/20190829161635.25067-3-jbrunet@baylibre.com --- drivers/irqchip/irq-meson-gpio.c | 52 ++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/drivers/irqchip/irq-meson-gpio.c b/drivers/irqchip/irq-meson-gpio.c index dcdc23b..829084b 100644 --- a/drivers/irqchip/irq-meson-gpio.c +++ b/drivers/irqchip/irq-meson-gpio.c @@ -24,14 +24,25 @@ #define REG_PIN_47_SEL 0x08 #define REG_FILTER_SEL 0x0c -#define REG_EDGE_POL_MASK(x) (BIT(x) | BIT(16 + (x))) +/* + * Note: The S905X3 datasheet reports that BOTH_EDGE is controlled by + * bits 24 to 31. Tests on the actual HW show that these bits are + * stuck at 0. Bits 8 to 15 are responsive and have the expected + * effect. + */ #define REG_EDGE_POL_EDGE(x) BIT(x) #define REG_EDGE_POL_LOW(x) BIT(16 + (x)) +#define REG_BOTH_EDGE(x) BIT(8 + (x)) +#define REG_EDGE_POL_MASK(x) ( \ + REG_EDGE_POL_EDGE(x) | \ + REG_EDGE_POL_LOW(x) | \ + REG_BOTH_EDGE(x)) #define REG_PIN_SEL_SHIFT(x) (((x) % 4) * 8) #define REG_FILTER_SEL_SHIFT(x) ((x) * 4) struct meson_gpio_irq_params { unsigned int nr_hwirq; + bool support_edge_both; }; static const struct meson_gpio_irq_params meson8_params = { @@ -54,6 +65,11 @@ static const struct meson_gpio_irq_params axg_params = { .nr_hwirq = 100, }; +static const struct meson_gpio_irq_params sm1_params = { + .nr_hwirq = 100, + .support_edge_both = true, +}; + static const struct of_device_id meson_irq_gpio_matches[] = { { .compatible = "amlogic,meson8-gpio-intc", .data = &meson8_params }, { .compatible = "amlogic,meson8b-gpio-intc", .data = &meson8b_params }, @@ -61,11 +77,12 @@ static const struct of_device_id meson_irq_gpio_matches[] = { { .compatible = "amlogic,meson-gxl-gpio-intc", .data = &gxl_params }, { .compatible = "amlogic,meson-axg-gpio-intc", .data = &axg_params }, { .compatible = "amlogic,meson-g12a-gpio-intc", .data = &axg_params }, + { .compatible = "amlogic,meson-sm1-gpio-intc", .data = &sm1_params }, { } }; struct meson_gpio_irq_controller { - unsigned int nr_hwirq; + const struct meson_gpio_irq_params *params; void __iomem *base; u32 channel_irqs[NUM_CHANNEL]; DECLARE_BITMAP(channel_map, NUM_CHANNEL); @@ -168,14 +185,22 @@ static int meson_gpio_irq_type_setup(struct meson_gpio_irq_controller *ctl, */ type &= IRQ_TYPE_SENSE_MASK; - if (type == IRQ_TYPE_EDGE_BOTH) - return -EINVAL; + /* + * New controller support EDGE_BOTH trigger. This setting takes + * precedence over the other edge/polarity settings + */ + if (type == IRQ_TYPE_EDGE_BOTH) { + if (!ctl->params->support_edge_both) + return -EINVAL; - if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) - val |= REG_EDGE_POL_EDGE(idx); + val |= REG_BOTH_EDGE(idx); + } else { + if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) + val |= REG_EDGE_POL_EDGE(idx); - if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_EDGE_FALLING)) - val |= REG_EDGE_POL_LOW(idx); + if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_EDGE_FALLING)) + val |= REG_EDGE_POL_LOW(idx); + } spin_lock(&ctl->lock); @@ -199,7 +224,7 @@ static unsigned int meson_gpio_irq_type_output(unsigned int type) */ if (sense & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) type |= IRQ_TYPE_LEVEL_HIGH; - else if (sense & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) + else type |= IRQ_TYPE_EDGE_RISING; return type; @@ -328,15 +353,13 @@ static int __init meson_gpio_irq_parse_dt(struct device_node *node, struct meson_gpio_irq_controller *ctl) { const struct of_device_id *match; - const struct meson_gpio_irq_params *params; int ret; match = of_match_node(meson_irq_gpio_matches, node); if (!match) return -ENODEV; - params = match->data; - ctl->nr_hwirq = params->nr_hwirq; + ctl->params = match->data; ret = of_property_read_variable_u32_array(node, "amlogic,channel-interrupts", @@ -385,7 +408,8 @@ static int __init meson_gpio_irq_of_init(struct device_node *node, if (ret) goto free_channel_irqs; - domain = irq_domain_create_hierarchy(parent_domain, 0, ctl->nr_hwirq, + domain = irq_domain_create_hierarchy(parent_domain, 0, + ctl->params->nr_hwirq, of_node_to_fwnode(node), &meson_gpio_irq_domain_ops, ctl); @@ -396,7 +420,7 @@ static int __init meson_gpio_irq_of_init(struct device_node *node, } pr_info("%d to %d gpio interrupt mux initialized\n", - ctl->nr_hwirq, NUM_CHANNEL); + ctl->params->nr_hwirq, NUM_CHANNEL); return 0;