From patchwork Tue Jun 4 17:37:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13685722 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 144EC5F860; Tue, 4 Jun 2024 17:37:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717522639; cv=none; b=vBSBsaN6+aP/0aWtPcASQNwZh3jf1lp0zbwuUvk6+YjoB+angU2jDL0kW52Q+NHrYnysZIZgw6DajqCaEcLjuX/kwwj1+SjTgzwSGHITspg6uWOTO4APtsiMzmzypzYQjrzAXZ4lTyxrHmNF70S8ishKcqOAzM7JfAubERLa88s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717522639; c=relaxed/simple; bh=09624Uvl4RmQCINwToZEhRJYPakiiQvYLm0KFzqnoLE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uaZ7mOrPsbLe2Vn9nfLOjE5A7cQ6IFeg/zDzMe2UanJLdewipx1dpm7ZeqOVCQmOhxWcsy+MPSY0F+SgcLFZseIeU6MRi9xVNNXhuhrUXjbDIVtxNQLq3N2BY6NOTqbo37elmyQPKQsutVG5JrAbBGsujUWDJRFt/B6ihyAnmYk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OE5z2INF; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OE5z2INF" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-42155143cb0so5652215e9.2; Tue, 04 Jun 2024 10:37:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717522636; x=1718127436; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2jAQz1OzNuVRV4MMQBkIujhUPrDPoUbZI6wfidAz600=; b=OE5z2INFDpDlEwv3xAcKEcE1js7BRyoh4MGV3qr4N/u0YEnmuulYHRK5HtsgFgVm6d I3ATcGnywE36ckqyJ0DqFIfs5NRdMj67/yQkiZ95tX00Yd5osuL/B4f/QeY5+K89j/9z vacf/wgSNoJcMyxW4UIh3m697HNy2WlsLtRJPEnvt1/b/apGxqZV9Z39G56t09Wylg5S pPuzvRsxJ3a9aYaH1SB7ua/BNz/sDMtoiQavwXmg62MVAGSRXqz8RGpR5N15xFl2P8mE pwdQmXFO++LjzlHKkRurdoa2qwcVX4tFHBtgR4suaZiyLh1eQbjNt1FeojWlsRNTANV9 8Wgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717522636; x=1718127436; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2jAQz1OzNuVRV4MMQBkIujhUPrDPoUbZI6wfidAz600=; b=J7nQR24+36+D9G7JUF9n3rfRtkC6r2dHtQarLXrP5YXKk30F87RPOUKoq0Ji1Ib2w7 H1X3dGllhDu24vlgAo+y58GAqVGWzn9JlROkm7YH7kE16TtDiuFk1WrmSaBD7WP7Kd+J gZZkPwraecEeiumelWDZroFz82qxAq0+gDqNzIBjyCM6+MMylmlUYSZSTM/Q6MMXRNg6 UD+3kZW7IOl4ULkmAD5+1GvBFSGa9bHD7jT/3nsF5Yq9etAKlPQ/1TzjYHtNIUTowmAK 1XJMLMmEnuDpreztYvu7/sHjry0pClTIVSoO9Kk0pbXFk21Vmo6ctizrSZhGv8SZHkT5 tKGQ== X-Forwarded-Encrypted: i=1; AJvYcCV4aMZeoc5uIkSBfChf5obwAC2GCwTg868ePKWT3Nl4XruoOYWEs0xxFMft2szl4fBq6ZcKYcjdtZMflxtZ5JrBbDTfBpPHVsp8DWbB4dTi+A4TcsA+cywiLvaAwe/7T2X1gyxBBa1eVaVl9VHv X-Gm-Message-State: AOJu0YxJ7xiiAjS2nnV5C3nnCMgBwFcYQ89ChSDy8pA8lqTFAoUkPQ+5 dj2Ynbldcwak6N/dKCx4I8vwZML8GQWNPlqsF2TXII4N3XcgTA1O X-Google-Smtp-Source: AGHT+IHB1tn7ck8JPoGD530Qb9woIIz7zTI/7EqwQtLtT9qBSg0rq9BLfZX/k7nHm8//up6dmU8xIQ== X-Received: by 2002:a05:600c:19c6:b0:421:1717:2cf0 with SMTP id 5b1f17b1804b1-421562df8e7mr3129345e9.24.1717522636317; Tue, 04 Jun 2024 10:37:16 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:2595:4364:d152:dff3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4213c6629bdsm87844085e9.8.2024.06.04.10.37.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 10:37:15 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Geert Uytterhoeven , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Magnus Damm Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Lad Prabhakar , Krzysztof Kozlowski Subject: [PATCH v5 1/2] dt-bindings: interrupt-controller: renesas,rzg2l-irqc: Document RZ/Five SoC Date: Tue, 4 Jun 2024 18:37:09 +0100 Message-Id: <20240604173710.534132-2-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604173710.534132-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240604173710.534132-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Document RZ/Five (R9A07G043F) IRQC bindings. The IRQC block on the RZ/Five SoC is almost identical to the one found on the RZ/G2L SoC, with the only difference being that it has additional mask control registers for NMI/IRQ/TINT. Hence new compatible string "renesas,r9a07g043f-irqc" is added for RZ/Five SoC. Signed-off-by: Lad Prabhakar Acked-by: Krzysztof Kozlowski Reviewed-by: Geert Uytterhoeven --- v4->v5 - No change v3->v4 - No change v2->v3 - Dropped items for rz/five - Collected the RB tags v1->v2 - Dropped the checks for interrupts as its already handled - Added SoC specific compat string --- .../renesas,rzg2l-irqc.yaml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/interrupt-controller/renesas,rzg2l-irqc.yaml b/Documentation/devicetree/bindings/interrupt-controller/renesas,rzg2l-irqc.yaml index daef4ee06f4e..44b6ae5fc802 100644 --- a/Documentation/devicetree/bindings/interrupt-controller/renesas,rzg2l-irqc.yaml +++ b/Documentation/devicetree/bindings/interrupt-controller/renesas,rzg2l-irqc.yaml @@ -21,13 +21,16 @@ description: | properties: compatible: - items: - - enum: - - renesas,r9a07g043u-irqc # RZ/G2UL - - renesas,r9a07g044-irqc # RZ/G2{L,LC} - - renesas,r9a07g054-irqc # RZ/V2L - - renesas,r9a08g045-irqc # RZ/G3S - - const: renesas,rzg2l-irqc + oneOf: + - items: + - enum: + - renesas,r9a07g043u-irqc # RZ/G2UL + - renesas,r9a07g044-irqc # RZ/G2{L,LC} + - renesas,r9a07g054-irqc # RZ/V2L + - renesas,r9a08g045-irqc # RZ/G3S + - const: renesas,rzg2l-irqc + + - const: renesas,r9a07g043f-irqc # RZ/Five '#interrupt-cells': description: The first cell should contain a macro RZG2L_{NMI,IRQX} included in the From patchwork Tue Jun 4 17:37:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13685723 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 919F614A09A; Tue, 4 Jun 2024 17:37:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717522641; cv=none; b=ayiHnVF5QA2Axxez0XhXvPEKgxH4wn+EmABaH8ytV8YjSyFY7L8CvzUC1tZrsH2oL/vGtSAEcFQ64VarGj1X1DlG2hGpoUAljrUo0ujOwI65bdUZZZb3pE7RGyQu67FPzK0cXXYG17PORfhOnHkWW1RpZwCCHy+/pihtOAGt5+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717522641; c=relaxed/simple; bh=22g2YRq/yOk6TXxIk8B1NPIgi5iFQvER/ySBUuJME7E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VAehly6NjZzGrbWoemy5MDlgDGMIz2/EaTqZFCXQe3peqRW+wB5qny7Euaj5kmJaLgXn9slmbeA8uYwT+iVNhpZ6w8tq6NX3Veu8HgsIqKYTfkXG2LiGb7hXxaPcdW4pti7ME2JSnVI4/gq777Fj19U7ZGAIky4adMVU3HEfMZM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UzJgWGJR; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UzJgWGJR" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-52b90038cf7so4609775e87.0; Tue, 04 Jun 2024 10:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717522638; x=1718127438; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t9i9+lVOAIcYQ4JpUKOIFfasPtU3V0Xq2VmgmWFAe70=; b=UzJgWGJRukelN1QAgW6loMBQb0PaF84Sl5riBs3ub+wpOZ8ss135FXoS/Xy0m5soI7 ey59NKj0Hh4/QlDYi3pJh44pYop6p3+rvhbwrhsBWJcICowQ1fqyAohp8mbfBWjQyxgX f5IIo4ugR1FmJKAKMUxJ3nFATWrvUw2tfPvQSCSz5iNBMOQeanLpU4Acdj/f+Pr7pQf1 G2NpR0fZJWTRNqfRqYPHLZlU7yXbv2+/me9szX5IIAMCHAwBVB8ipU4sfi6liykllGHy 6c5pXDxtpT+g/KPIXNA5yutMK9jeq67VacM1hdwe8xZX3YW1e3w4bM4UZtsUJNK3J+Zd aLmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717522638; x=1718127438; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t9i9+lVOAIcYQ4JpUKOIFfasPtU3V0Xq2VmgmWFAe70=; b=NSE0l1txOOz9RuIYUsHhQD0DHAt1mSj2qhWmaBhHrcAw5xXy1hRLDFzqXeddwa2nmH TxZ7h2w+Qa2lQFARnM5gWYcHx4Bhe9C7dat9olggQK4+ymnqbO8RMQCkkk/hYtwiJS9q nH9cXjGByE3EUwj6W3z4z1+3cVw836AofXcnAB7XFkNHJP9GnbJPxkXxkZ450CoscpzJ yBLSgA3v1e0EJMOpeq9R+3LhBGU0zUGY/lGnwOxcFLmS/mv6fTJO1+ouPaGknnH9oaNO KldZg+58ub/tTAEU0xiJEbQaCc8FX1BVCC8ThECG5wdXM1bXn+dTYw1W0IKU+3MaHKQp jDiA== X-Forwarded-Encrypted: i=1; AJvYcCWBunUlcSl1fb0F2uDYN5Ty/gN5t90KHau5cUEzLbzpC9oImUVXKuo9nRPlLGnqgQ/ozNyNKuz0Ii9BdC9fAuev2Wud6WE0RRdOJ6JEiBw52HUi6ApLcGIYMw82Y4jwjSWsE1s3Y4+irNuforvu X-Gm-Message-State: AOJu0YxKYDrb5Gc3MpqSdurPCH/2Kjx3LHDMS1V2Rg1QP4JsVSwiUgSp ipSx54wLsSbHSMFWyjlg/JHkkDmpZxIX2T2SlGTtVKz5GOIb/7e0Ydr6FUNJ X-Google-Smtp-Source: AGHT+IHmsXa2GaB3v6/1bzFtgsSEsQ6WiTMpOilk5KogWa7uLarMyOKHJCwHEMEAEB13fB6ZCc4xoQ== X-Received: by 2002:ac2:4adc:0:b0:523:41ba:a297 with SMTP id 2adb3069b0e04-52bab4b1291mr159637e87.5.1717522637412; Tue, 04 Jun 2024 10:37:17 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:2595:4364:d152:dff3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4213c6629bdsm87844085e9.8.2024.06.04.10.37.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 10:37:16 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Geert Uytterhoeven , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Magnus Damm Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Lad Prabhakar Subject: [PATCH v5 2/2] irqchip/renesas-rzg2l: Add support for RZ/Five SoC Date: Tue, 4 Jun 2024 18:37:10 +0100 Message-Id: <20240604173710.534132-3-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604173710.534132-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240604173710.534132-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar The IX45 block has additional mask registers (NMSK/IMSK/TMSK) compared to the RZ/G2L (family) SoC. A new rzfive_irqc_chip irq_chip is introduced for RZ/Five, where function pointers for irq_(un)mask and irq_(dis/en)able handle the (un)masking of the interrupts. The irq_chip pointer is now passed as an init callback and stored in the priv pointer to differentiate between RZ/G2L and RZ/Five. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven --- Hi Geert, I've restored your RB tag with v5 change (hope that's OK) Cheers, Prabhakar v4->v5 - Reversed the operations in rzfive_irqc_irq_disable(). v3->v4 - Renamed rzg2l_irqc_init_helper -> rzg2l_irqc_common_init - Moved the locks into callers for (un)mask and (en/dis)able functions - Collected RB tag from Geert v2->v3 - Added RZ/Five specific irqchip instead of polluting the functions - Fixed review comments pointed by Biju and Geert - Updated commit message - moved locking to respective read/write functions v1->v2 - Added IRQCHIP_MATCH() for RZ/Five - Retaining a copy of OF data in priv - Rebased the changes --- drivers/irqchip/irq-renesas-rzg2l.c | 148 +++++++++++++++++++++++++++- 1 file changed, 145 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-renesas-rzg2l.c b/drivers/irqchip/irq-renesas-rzg2l.c index f6484bf15e0b..861a0e5a3e97 100644 --- a/drivers/irqchip/irq-renesas-rzg2l.c +++ b/drivers/irqchip/irq-renesas-rzg2l.c @@ -37,6 +37,8 @@ #define TSSEL_SHIFT(n) (8 * (n)) #define TSSEL_MASK GENMASK(7, 0) #define IRQ_MASK 0x3 +#define IMSK 0x10010 +#define TMSK 0x10020 #define TSSR_OFFSET(n) ((n) % 4) #define TSSR_INDEX(n) ((n) / 4) @@ -69,12 +71,14 @@ struct rzg2l_irqc_reg_cache { /** * struct rzg2l_irqc_priv - IRQ controller private data structure * @base: Controller's base address + * @irqchip: Pointer to struct irq_chip * @fwspec: IRQ firmware specific data * @lock: Lock to serialize access to hardware registers * @cache: Registers cache for suspend/resume */ static struct rzg2l_irqc_priv { void __iomem *base; + const struct irq_chip *irqchip; struct irq_fwspec fwspec[IRQC_NUM_IRQ]; raw_spinlock_t lock; struct rzg2l_irqc_reg_cache cache; @@ -138,6 +142,111 @@ static void rzg2l_irqc_eoi(struct irq_data *d) irq_chip_eoi_parent(d); } +static void rzfive_irqc_mask_irq_interrupt(struct rzg2l_irqc_priv *priv, + unsigned int hwirq) +{ + u32 bit = BIT(hwirq - IRQC_IRQ_START); + + writel_relaxed(readl_relaxed(priv->base + IMSK) | bit, priv->base + IMSK); +} + +static void rzfive_irqc_unmask_irq_interrupt(struct rzg2l_irqc_priv *priv, + unsigned int hwirq) +{ + u32 bit = BIT(hwirq - IRQC_IRQ_START); + + writel_relaxed(readl_relaxed(priv->base + IMSK) & ~bit, priv->base + IMSK); +} + +static void rzfive_irqc_mask_tint_interrupt(struct rzg2l_irqc_priv *priv, + unsigned int hwirq) +{ + u32 bit = BIT(hwirq - IRQC_TINT_START); + + writel_relaxed(readl_relaxed(priv->base + TMSK) | bit, priv->base + TMSK); +} + +static void rzfive_irqc_unmask_tint_interrupt(struct rzg2l_irqc_priv *priv, + unsigned int hwirq) +{ + u32 bit = BIT(hwirq - IRQC_TINT_START); + + writel_relaxed(readl_relaxed(priv->base + TMSK) & ~bit, priv->base + TMSK); +} + +static void rzfive_irqc_mask(struct irq_data *d) +{ + struct rzg2l_irqc_priv *priv = irq_data_to_priv(d); + unsigned int hwirq = irqd_to_hwirq(d); + + raw_spin_lock(&priv->lock); + if (hwirq >= IRQC_IRQ_START && hwirq <= IRQC_IRQ_COUNT) + rzfive_irqc_mask_irq_interrupt(priv, hwirq); + else if (hwirq >= IRQC_TINT_START && hwirq < IRQC_NUM_IRQ) + rzfive_irqc_mask_tint_interrupt(priv, hwirq); + raw_spin_unlock(&priv->lock); + irq_chip_mask_parent(d); +} + +static void rzfive_irqc_unmask(struct irq_data *d) +{ + struct rzg2l_irqc_priv *priv = irq_data_to_priv(d); + unsigned int hwirq = irqd_to_hwirq(d); + + raw_spin_lock(&priv->lock); + if (hwirq >= IRQC_IRQ_START && hwirq <= IRQC_IRQ_COUNT) + rzfive_irqc_unmask_irq_interrupt(priv, hwirq); + else if (hwirq >= IRQC_TINT_START && hwirq < IRQC_NUM_IRQ) + rzfive_irqc_unmask_tint_interrupt(priv, hwirq); + raw_spin_unlock(&priv->lock); + irq_chip_unmask_parent(d); +} + +static void rzfive_tint_irq_endisable(struct irq_data *d, bool enable) +{ + struct rzg2l_irqc_priv *priv = irq_data_to_priv(d); + unsigned int hwirq = irqd_to_hwirq(d); + + if (hwirq >= IRQC_TINT_START && hwirq < IRQC_NUM_IRQ) { + u32 offset = hwirq - IRQC_TINT_START; + u32 tssr_offset = TSSR_OFFSET(offset); + u8 tssr_index = TSSR_INDEX(offset); + u32 reg; + + raw_spin_lock(&priv->lock); + if (enable) + rzfive_irqc_unmask_tint_interrupt(priv, hwirq); + else + rzfive_irqc_mask_tint_interrupt(priv, hwirq); + reg = readl_relaxed(priv->base + TSSR(tssr_index)); + if (enable) + reg |= TIEN << TSSEL_SHIFT(tssr_offset); + else + reg &= ~(TIEN << TSSEL_SHIFT(tssr_offset)); + writel_relaxed(reg, priv->base + TSSR(tssr_index)); + raw_spin_unlock(&priv->lock); + } else { + raw_spin_lock(&priv->lock); + if (enable) + rzfive_irqc_unmask_irq_interrupt(priv, hwirq); + else + rzfive_irqc_mask_irq_interrupt(priv, hwirq); + raw_spin_unlock(&priv->lock); + } +} + +static void rzfive_irqc_irq_disable(struct irq_data *d) +{ + irq_chip_disable_parent(d); + rzfive_tint_irq_endisable(d, false); +} + +static void rzfive_irqc_irq_enable(struct irq_data *d) +{ + rzfive_tint_irq_endisable(d, true); + irq_chip_enable_parent(d); +} + static void rzg2l_tint_irq_endisable(struct irq_data *d, bool enable) { unsigned int hw_irq = irqd_to_hwirq(d); @@ -321,7 +430,7 @@ static struct syscore_ops rzg2l_irqc_syscore_ops = { .resume = rzg2l_irqc_irq_resume, }; -static const struct irq_chip irqc_chip = { +static const struct irq_chip rzg2l_irqc_chip = { .name = "rzg2l-irqc", .irq_eoi = rzg2l_irqc_eoi, .irq_mask = irq_chip_mask_parent, @@ -338,6 +447,23 @@ static const struct irq_chip irqc_chip = { IRQCHIP_SKIP_SET_WAKE, }; +static const struct irq_chip rzfive_irqc_chip = { + .name = "rzfive-irqc", + .irq_eoi = rzg2l_irqc_eoi, + .irq_mask = rzfive_irqc_mask, + .irq_unmask = rzfive_irqc_unmask, + .irq_disable = rzfive_irqc_irq_disable, + .irq_enable = rzfive_irqc_irq_enable, + .irq_get_irqchip_state = irq_chip_get_parent_state, + .irq_set_irqchip_state = irq_chip_set_parent_state, + .irq_retrigger = irq_chip_retrigger_hierarchy, + .irq_set_type = rzg2l_irqc_set_type, + .irq_set_affinity = irq_chip_set_affinity_parent, + .flags = IRQCHIP_MASK_ON_SUSPEND | + IRQCHIP_SET_TYPE_MASKED | + IRQCHIP_SKIP_SET_WAKE, +}; + static int rzg2l_irqc_alloc(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs, void *arg) { @@ -369,7 +495,7 @@ static int rzg2l_irqc_alloc(struct irq_domain *domain, unsigned int virq, if (hwirq > (IRQC_NUM_IRQ - 1)) return -EINVAL; - ret = irq_domain_set_hwirq_and_chip(domain, virq, hwirq, &irqc_chip, + ret = irq_domain_set_hwirq_and_chip(domain, virq, hwirq, priv->irqchip, (void *)(uintptr_t)tint); if (ret) return ret; @@ -401,7 +527,8 @@ static int rzg2l_irqc_parse_interrupts(struct rzg2l_irqc_priv *priv, return 0; } -static int rzg2l_irqc_init(struct device_node *node, struct device_node *parent) +static int rzg2l_irqc_common_init(struct device_node *node, struct device_node *parent, + const struct irq_chip *irq_chip) { struct irq_domain *irq_domain, *parent_domain; struct platform_device *pdev; @@ -422,6 +549,8 @@ static int rzg2l_irqc_init(struct device_node *node, struct device_node *parent) if (!rzg2l_irqc_data) return -ENOMEM; + rzg2l_irqc_data->irqchip = irq_chip; + rzg2l_irqc_data->base = devm_of_iomap(&pdev->dev, pdev->dev.of_node, 0, NULL); if (IS_ERR(rzg2l_irqc_data->base)) return PTR_ERR(rzg2l_irqc_data->base); @@ -472,8 +601,21 @@ static int rzg2l_irqc_init(struct device_node *node, struct device_node *parent) return ret; } +static int __init rzg2l_irqc_init(struct device_node *node, + struct device_node *parent) +{ + return rzg2l_irqc_common_init(node, parent, &rzg2l_irqc_chip); +} + +static int __init rzfive_irqc_init(struct device_node *node, + struct device_node *parent) +{ + return rzg2l_irqc_common_init(node, parent, &rzfive_irqc_chip); +} + IRQCHIP_PLATFORM_DRIVER_BEGIN(rzg2l_irqc) IRQCHIP_MATCH("renesas,rzg2l-irqc", rzg2l_irqc_init) +IRQCHIP_MATCH("renesas,r9a07g043f-irqc", rzfive_irqc_init) IRQCHIP_PLATFORM_DRIVER_END(rzg2l_irqc) MODULE_AUTHOR("Lad Prabhakar "); MODULE_DESCRIPTION("Renesas RZ/G2L IRQC Driver");