Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp345452pxp; Wed, 9 Mar 2022 04:16:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxFbuGJ1N4ukeka0fD5SkLu9HGWALtrr9mm544dP83ixHY2RQQdGAWLikwG5+sy0AF4typw X-Received: by 2002:a63:1d44:0:b0:373:5612:629b with SMTP id d4-20020a631d44000000b003735612629bmr17988148pgm.352.1646828193492; Wed, 09 Mar 2022 04:16:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646828193; cv=none; d=google.com; s=arc-20160816; b=JQsuciiBjXoM/pCc+OS5uka4xW9uFZYPAvCwBfzR9tey4UmkEeUdnn5VPproo7ayn7 FTgi1IdxqnYQPFs8kC0t20/bfpIbJVu38DGHyYN2zCog1UwTgzWHex6TaId9oosr54HI upGW3rOJM5ZTS0eMbTHhYD/ko1rMj06ubZ56wf5wuGQ4MQsaSaw0PuLDaEdOdwCoA+fB d/I0HMxFjMSVulF+t9/soEEdGmT5BcKJHujGQ3b7GbNXUfw6iuTEzajovjOTyFP3LMOw VtPSWp0+jQlMgvcvH6t8y8+GdLn5NTyrUtGwGhujPNVRH19ocIcFDWNuA0EF3zAx2Zr7 47Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=AcqsyaUAYvmbqtP7P9b+TRzWTjt75kKMkxbPSvHkyrM=; b=xC67k+E7c03/C27AFSRx9cG6hnITJ9tmc1/gyI5uKhAJkeKW2qSbIi9HEJpJp+3z8C nYEWYsBWzWOigI5XBVc0N5Q02bgXZRUrxSt6n1oTN5pLkAYryQSeWZ5k1AadEBVzYfr8 fs/jybA6/2nfGwhMgBUg2El5HqGuynXGIZhcYMmzCfPkxoadw22DuiC9o0z2l7BVEqya h5LxcqFUQs58pywFNto5/trLd3aIXwaP8p79MeJA24PCRraOFJWbRXpu19V0rbvfTY4+ f9fL+N+iEfX7f9EMA70x3G/CcKlhvJwQND+uHhUTsN2ZoEfNqHoz1DivXUt2w8aZxAez 060w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YEdWK7as; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o9-20020a170902d4c900b00153004495e1si1916228plg.333.2022.03.09.04.16.11; Wed, 09 Mar 2022 04:16:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YEdWK7as; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231815AbiCILjZ (ORCPT + 99 others); Wed, 9 Mar 2022 06:39:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230188AbiCILjX (ORCPT ); Wed, 9 Mar 2022 06:39:23 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 790411D0E5 for ; Wed, 9 Mar 2022 03:38:22 -0800 (PST) Date: Wed, 09 Mar 2022 11:38:19 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1646825900; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AcqsyaUAYvmbqtP7P9b+TRzWTjt75kKMkxbPSvHkyrM=; b=YEdWK7as0XnlR2ZcQ6rfWVzv9VLYC5wMQ4Le6AwcmK4A0JsUGGCLGPpyxOas1bJu0fxSsU PWa289UJ+fBzXg8RwJ6jbhFgjVNg1tPM8AidOFRUe1CZ6oH6dM0lC995ODfPLLAsa0+ZDw QFO8SmyXu6iXe3R/8v/6CXtpo2gnQnq4WSsrbHX9A6kpnwojUNGFxtIjTFSpUIXrjbjWsM dCMovbqhDe/30253ZMle96ycIqzEbg/leW9SaNNpr5LtrddRTGx2v3zCBmy+DcDLka9yUs qYPemRqEU+O/Wm1D52eNwxuILCvxul1xs7LLX4fIE3LgnkiVXwEQ9aFya7GC1A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1646825900; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AcqsyaUAYvmbqtP7P9b+TRzWTjt75kKMkxbPSvHkyrM=; b=SOmTn9O9QZsmLyb4ByfOPu7O1DngeeO8s9gW66o3PrZZtElh6Zu8Z0GqpDL5JbR5QYbAET DY6r1DOqSIR6LOAw== From: "irqchip-bot for Qianggui Song" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-kernel@vger.kernel.org Subject: [irqchip: irq/irqchip-next] irqchip/meson-gpio: Add support for meson s4 SoCs Cc: Qianggui Song , Marc Zyngier , tglx@linutronix.de In-Reply-To: <20220225055207.1048-5-qianggui.song@amlogic.com> References: <20220225055207.1048-5-qianggui.song@amlogic.com> MIME-Version: 1.0 Message-ID: <164682589927.16921.10086882193156342940.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the irq/irqchip-next branch of irqchip: Commit-ID: d6c47d21a0ef9a76c537f8c5258b49d61f2e160f Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/d6c47d21a0ef9a76c537f8c5258b49d61f2e160f Author: Qianggui Song AuthorDate: Fri, 25 Feb 2022 13:52:06 +08:00 Committer: Marc Zyngier CommitterDate: Wed, 09 Mar 2022 11:19:56 irqchip/meson-gpio: Add support for meson s4 SoCs The meson s4 SoCs support 12 gpio irq lines compared with previous serial chips and have something different, details are as below. IRQ Number: - 80:68 13 pins on bank Z - 67:48 20 pins on bank X - 47:36 12 pins on bank H - 35:24 12 pins on bank D - 23:22 2 pins on bank E - 21:14 8 pins on bank C - 13:0 13 pins on bank B Signed-off-by: Qianggui Song [maz: fixed some W=1 build warnings] Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220225055207.1048-5-qianggui.song@amlogic.com --- drivers/irqchip/irq-meson-gpio.c | 65 +++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+) diff --git a/drivers/irqchip/irq-meson-gpio.c b/drivers/irqchip/irq-meson-gpio.c index 7b5863e..2aaa9aa 100644 --- a/drivers/irqchip/irq-meson-gpio.c +++ b/drivers/irqchip/irq-meson-gpio.c @@ -26,6 +26,8 @@ /* use for A1 like chips */ #define REG_PIN_A1_SEL 0x04 +/* Used for s4 chips */ +#define REG_EDGE_POL_S4 0x1c /* * Note: The S905X3 datasheet reports that BOTH_EDGE is controlled by @@ -53,6 +55,8 @@ static void meson_a1_gpio_irq_sel_pin(struct meson_gpio_irq_controller *ctl, static void meson_a1_gpio_irq_init(struct meson_gpio_irq_controller *ctl); static int meson8_gpio_irq_set_type(struct meson_gpio_irq_controller *ctl, unsigned int type, u32 *channel_hwirq); +static int meson_s4_gpio_irq_set_type(struct meson_gpio_irq_controller *ctl, + unsigned int type, u32 *channel_hwirq); struct irq_ctl_ops { void (*gpio_irq_sel_pin)(struct meson_gpio_irq_controller *ctl, @@ -101,6 +105,17 @@ struct meson_gpio_irq_params { .pin_sel_mask = 0x7f, \ .nr_channels = 8, \ +#define INIT_MESON_S4_COMMON_DATA(irqs) \ + INIT_MESON_COMMON(irqs, meson_a1_gpio_irq_init, \ + meson_a1_gpio_irq_sel_pin, \ + meson_s4_gpio_irq_set_type) \ + .support_edge_both = true, \ + .edge_both_offset = 0, \ + .edge_single_offset = 12, \ + .pol_low_offset = 0, \ + .pin_sel_mask = 0xff, \ + .nr_channels = 12, \ + static const struct meson_gpio_irq_params meson8_params = { INIT_MESON8_COMMON_DATA(134) }; @@ -131,6 +146,10 @@ static const struct meson_gpio_irq_params a1_params = { INIT_MESON_A1_COMMON_DATA(62) }; +static const struct meson_gpio_irq_params s4_params = { + INIT_MESON_S4_COMMON_DATA(82) +}; + 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 }, @@ -140,6 +159,7 @@ static const struct of_device_id meson_irq_gpio_matches[] = { { .compatible = "amlogic,meson-g12a-gpio-intc", .data = &axg_params }, { .compatible = "amlogic,meson-sm1-gpio-intc", .data = &sm1_params }, { .compatible = "amlogic,meson-a1-gpio-intc", .data = &a1_params }, + { .compatible = "amlogic,meson-s4-gpio-intc", .data = &s4_params }, { } }; @@ -308,6 +328,51 @@ static int meson8_gpio_irq_set_type(struct meson_gpio_irq_controller *ctl, return 0; } +/* + * gpio irq relative registers for s4 + * -PADCTRL_GPIO_IRQ_CTRL0 + * bit[31]: enable/disable all the irq lines + * bit[12-23]: single edge trigger + * bit[0-11]: polarity trigger + * + * -PADCTRL_GPIO_IRQ_CTRL[X] + * bit[0-16]: 7 bits to choose gpio source for irq line 2*[X] - 2 + * bit[16-22]:7 bits to choose gpio source for irq line 2*[X] - 1 + * where X = 1-6 + * + * -PADCTRL_GPIO_IRQ_CTRL[7] + * bit[0-11]: both edge trigger + */ +static int meson_s4_gpio_irq_set_type(struct meson_gpio_irq_controller *ctl, + unsigned int type, u32 *channel_hwirq) +{ + u32 val = 0; + unsigned int idx; + + idx = meson_gpio_irq_get_channel_idx(ctl, channel_hwirq); + + type &= IRQ_TYPE_SENSE_MASK; + + meson_gpio_irq_update_bits(ctl, REG_EDGE_POL_S4, BIT(idx), 0); + + if (type == IRQ_TYPE_EDGE_BOTH) { + val |= BIT(ctl->params->edge_both_offset + idx); + meson_gpio_irq_update_bits(ctl, REG_EDGE_POL_S4, + BIT(ctl->params->edge_both_offset + idx), val); + return 0; + } + + if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_EDGE_FALLING)) + val |= BIT(ctl->params->pol_low_offset + idx); + + if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) + val |= BIT(ctl->params->edge_single_offset + idx); + + meson_gpio_irq_update_bits(ctl, REG_EDGE_POL, + BIT(idx) | BIT(12 + idx), val); + return 0; +}; + static unsigned int meson_gpio_irq_type_output(unsigned int type) { unsigned int sense = type & IRQ_TYPE_SENSE_MASK;