Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4596510imu; Tue, 29 Jan 2019 04:25:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN6RKu0dB+A5S9wLBlEMG+KRZqLYBw2+O8UbwKj/qvxzWSW4qGPtwi+WidfzY0sB06OFRTWK X-Received: by 2002:a17:902:925:: with SMTP id 34mr24853948plm.14.1548764706659; Tue, 29 Jan 2019 04:25:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548764706; cv=none; d=google.com; s=arc-20160816; b=GzN3934HFKNox7ED84VTDl6OXjMDWlIJjaRdumtAEXJXCj/FNkNAtSWz/gEKm7L/t9 oquISk/Zwa4eMsFuDYGm02RApg/GUhwScsMAAoq8K/nEiK7rynVqU/33nahYrVRgTPrm p0zJJmMbxipXEbRNPvSKnX3d8gf18MSOFAYuWVlrZUiHLmjVNYk6f/W4rPlJO3zoQV3D Xd53yR8sBCF1Jw6tjgXoJPqC7Sw6sYi3B/zwIEMrWWRV40hEGvuEZn7BsPLteSq04NSD laMnaHkWDw5RhHNeeXQ2q0qrtt199lFuAp7X7TDZ7+zbVY4DZeizFXT/f1DgUdPfIf4A ox1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=U7tuGbBnjjd8bHix299Zd0KrUr/ti8hZI6HPSRBEv24=; b=e/me6catthGhaEU5fRrrHWW4EouyBJpq/8NbaGAbtj1XmT1d3vDF08TstJ5iDWDuw+ Sq7aSK72S52ZsvLRNMfhlSexyqPfHyzZ1FKd3ro0+WQDa8KfPtx1M7BNI6mOxt/zqk7n 2xC0ALkhPpMpvP8qcF/SdS9CshfkswcgCwLYeMd2MgTSDnkPZdLp6nT7JJ+7deicIto9 vSlS37oVPMC5IPDfQf1KrZke07WukAy+6br6SWlRCwTEEH0Cv5qgfAWEbHPOPrB2A/is gkfqLnmAZzX7tRKl1Y9nsDLt25ElfSJNeDocLhiQ8/icAj9NlQlrVHO4yqSY5m39zt4y uO3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=alDQ55Gb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l94si11771199plb.416.2019.01.29.04.24.48; Tue, 29 Jan 2019 04:25:06 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=alDQ55Gb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728456AbfA2MYn (ORCPT + 99 others); Tue, 29 Jan 2019 07:24:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:35624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727593AbfA2MYn (ORCPT ); Tue, 29 Jan 2019 07:24:43 -0500 Received: from localhost.localdomain (unknown [60.186.218.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 854CC20870; Tue, 29 Jan 2019 12:24:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548764681; bh=amGcodM5pva2Vl5Km6rOy46w672v1fLarHy2uMMkMSs=; h=From:To:Cc:Subject:Date:From; b=alDQ55GbSZhrjF2aX85dznWbZCqPA5HCmGuMDPtJgoauZhW9ncoyxLMdrn7krBuks mF15pmsdUJQUUHCGZcaMcxyKoH9ERbGuI1bCGeVjojGpPje4aauGZ+TM2j+AovtmWM ddqnWzutPPhlM0y+3qCC98JM7kZ/x6snXav6JbBE= From: guoren@kernel.org To: arnd@arndb.de, robh+dt@kernel.org, marc.zyngier@arm.com Cc: linux-kernel@vger.kernel.org, guoren@kernel.org, linux-arch@vger.kernel.org, Guo Ren Subject: [PATCH 01/10] irqchip/csky: Support csky,dh7k SOC intc driver Date: Tue, 29 Jan 2019 20:24:20 +0800 Message-Id: <1548764669-16656-1-git-send-email-guoren@kernel.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guo Ren C-SKY dh7k SOC use simple APB interrupt controller and most of driver's implementation codes could be reused in csky-apb-intc.c. So merge them together. Signed-off-by: Guo Ren --- drivers/irqchip/irq-csky-apb-intc.c | 95 +++++++++++++++++++++++++++++++++---- 1 file changed, 85 insertions(+), 10 deletions(-) diff --git a/drivers/irqchip/irq-csky-apb-intc.c b/drivers/irqchip/irq-csky-apb-intc.c index 5a2ec43..fcc5444 100644 --- a/drivers/irqchip/irq-csky-apb-intc.c +++ b/drivers/irqchip/irq-csky-apb-intc.c @@ -12,6 +12,7 @@ #include #include #include +#include #define INTC_IRQS 64 @@ -31,6 +32,17 @@ #define GX_INTC_NMASK63_32 0x54 #define GX_INTC_SOURCE 0x60 +#define DH_INTC_CLR 0x10 +#define DH_INTC_INIT 0x34 +#define DH_INTC_NMASK31_00 0x08 +#define DH_INTC_NMASK63_32 0x68 +#define DH_INTC_SOURCE31_00 0x14 +#define DH_INTC_SOURCE63_32 0x6c +#define DH_INTC_EDGE31_00 0x00 +#define DH_INTC_EDGE63_32 0x60 +#define DH_INTC_POLL31_00 0x04 +#define DH_INTC_POLL63_32 0x64 + static void __iomem *reg_base; static struct irq_domain *root_domain; @@ -58,15 +70,21 @@ static void irq_ck_mask_set_bit(struct irq_data *d) } static void __init ck_set_gc(struct device_node *node, void __iomem *reg_base, - u32 mask_reg, u32 irq_base) + u32 en_off, u32 mask_off, u32 irq_base) { struct irq_chip_generic *gc; gc = irq_get_domain_generic_chip(root_domain, irq_base); gc->reg_base = reg_base; - gc->chip_types[0].regs.mask = mask_reg; - gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit; - gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit; + if (en_off) { + gc->chip_types[0].regs.mask = en_off; + gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit; + gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit; + } else if (mask_off) { + gc->chip_types[0].regs.mask = mask_off; + gc->chip_types[0].chip.irq_mask = irq_gc_mask_set_bit; + gc->chip_types[0].chip.irq_unmask = irq_gc_mask_clr_bit; + } if (of_find_property(node, "csky,support-pulse-signal", NULL)) gc->chip_types[0].chip.irq_unmask = irq_ck_mask_set_bit; @@ -183,8 +201,8 @@ gx_intc_init(struct device_node *node, struct device_node *parent) setup_irq_channel(0x03020100, reg_base + GX_INTC_SOURCE); - ck_set_gc(node, reg_base, GX_INTC_NEN31_00, 0); - ck_set_gc(node, reg_base, GX_INTC_NEN63_32, 32); + ck_set_gc(node, reg_base, GX_INTC_NEN31_00, 0, 0); + ck_set_gc(node, reg_base, GX_INTC_NEN63_32, 0, 32); set_handle_irq(gx_irq_handler); @@ -192,6 +210,63 @@ gx_intc_init(struct device_node *node, struct device_node *parent) } IRQCHIP_DECLARE(csky_gx6605s_intc, "csky,gx6605s-intc", gx_intc_init); +static void dh_irq_handler(struct pt_regs *regs) +{ + u32 tmp; + unsigned long vector = (mfcr("psr") >> 16) & 0xff; + + tmp = readl(reg_base + DH_INTC_CLR); + tmp |= BIT(2); + writel(tmp, reg_base + DH_INTC_CLR); + + handle_domain_irq(root_domain, vector - 32, regs); +} + +extern void csky_irq(void); + +static int __init +dh_intc_init(struct device_node *node, struct device_node *parent) +{ + int ret, i; + + ret = ck_intc_init_comm(node, parent); + if (ret) + return ret; + + /* set default mode */ + writel(0xffffffff, reg_base + DH_INTC_EDGE31_00); + writel(0xffffffff, reg_base + DH_INTC_EDGE63_32); + writel(0xffffffff, reg_base + DH_INTC_POLL31_00); + writel(0xffffffff, reg_base + DH_INTC_POLL63_32); + + writel(BIT(1) | BIT(6), reg_base + DH_INTC_INIT); + + /* Setup 0-31 channel slots */ + for (i = 0; i < INTC_IRQS/2; i += 4) + writel(build_channel_val(i, 0x03020100) + 0x40404040, + reg_base + DH_INTC_SOURCE31_00 + i); + + /* Setup 32-63 channel slots */ + for (i = 0; i < INTC_IRQS/2; i += 4) + writel(build_channel_val(i, 0x03020100) + 0x40404040, + reg_base + DH_INTC_SOURCE63_32 + i); + + /* mask all interrrupts */ + writel(0xffffffff, reg_base + DH_INTC_NMASK31_00); + writel(0xffffffff, reg_base + DH_INTC_NMASK63_32); + + ck_set_gc(node, reg_base, 0, DH_INTC_NMASK31_00, 0); + ck_set_gc(node, reg_base, 0, DH_INTC_NMASK63_32, 32); + + for (i = 32; i < 128; i++) + VEC_INIT(i, csky_irq); + + set_handle_irq(dh_irq_handler); + + return 0; +} +IRQCHIP_DECLARE(csky_dh7k_intc, "csky,dh7k-intc", dh_intc_init); + /* * C-SKY simple 64 irqs interrupt controller, dual-together could support 128 * irqs. @@ -243,8 +318,8 @@ ck_intc_init(struct device_node *node, struct device_node *parent) /* Enable irq intc */ writel(BIT(31), reg_base + CK_INTC_ICR); - ck_set_gc(node, reg_base, CK_INTC_NEN31_00, 0); - ck_set_gc(node, reg_base, CK_INTC_NEN63_32, 32); + ck_set_gc(node, reg_base, CK_INTC_NEN31_00, 0, 0); + ck_set_gc(node, reg_base, CK_INTC_NEN63_32, 0, 32); setup_irq_channel(0x00010203, reg_base + CK_INTC_SOURCE); @@ -270,8 +345,8 @@ ck_dual_intc_init(struct device_node *node, struct device_node *parent) writel(0, reg_base + CK_INTC_NEN31_00 + CK_INTC_DUAL_BASE); writel(0, reg_base + CK_INTC_NEN63_32 + CK_INTC_DUAL_BASE); - ck_set_gc(node, reg_base + CK_INTC_DUAL_BASE, CK_INTC_NEN31_00, 64); - ck_set_gc(node, reg_base + CK_INTC_DUAL_BASE, CK_INTC_NEN63_32, 96); + ck_set_gc(node, reg_base + CK_INTC_DUAL_BASE, CK_INTC_NEN31_00, 0, 64); + ck_set_gc(node, reg_base + CK_INTC_DUAL_BASE, CK_INTC_NEN63_32, 0, 96); setup_irq_channel(0x00010203, reg_base + CK_INTC_SOURCE + CK_INTC_DUAL_BASE); -- 2.7.4