Received: by 10.213.65.68 with SMTP id h4csp1060881imn; Sun, 18 Mar 2018 12:58:33 -0700 (PDT) X-Google-Smtp-Source: AG47ELsKo+YbkvsUNA8egBpUR75xrFW1zBys2OYtLIBo6Lzg20Oe08sNeiTFpCMUrIrH7nPyiZ9F X-Received: by 10.98.31.155 with SMTP id l27mr8113395pfj.176.1521403113428; Sun, 18 Mar 2018 12:58:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521403113; cv=none; d=google.com; s=arc-20160816; b=aKh4qvN/FcJ7ArVDdmsyDFs+h+fD0ZzMmMZCAJiotPgx6AoVUPCCMAUl3JT069PXTl WBS/XH3hBxqIdx0VO7NKWAbiqZMfsrqkYTAw2WiW96M8GXLfwuGkb9af61sv2zPHesqn vHT6cWxEK31kTMvLL4pN5z6ZCp9vF2rtABoPc5tUEKiXB9T1YQ/lYrhTKIu4XyhnEr5v 30T9aVPp2ThxxSRhyYzAvwyWJKw9AS2STrqzwVmCO7XqEnWkKZDvrL4MgAtX8yYH5hOB koKbcF9Y5sLpPqV792N6GN0Kp9snCkrcc8kEHCkJsb6Z4m4OMRYaIkHQtWh3tcfOeO5G IH3A== 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:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=0kP1QKgslN8+mLqhT0oVsobLf0/lNfxSZ+GOM6GrJAw=; b=GrYmwdJAt6K/A5qCi2k0hlg0AoAUrVdJTpxokPncrY38bxP0EGnLlJs+bGPscrB6Js 9OMenyTQEa+nKg5BZS4RJBr0cYcL1MwH6qVHdK+BMLHaAnBa/djbuOvB0OAg8dYISzz3 2f/nWDYE7WgBNnv0s8m/sQqEC9BvZfWGwJ1eYTZ49JwNrStWgAmKuglyb37CPVgJr1vd AxqMiN9gKw7R/ZhTkg8EeMHxi8fNu/yRvtrdvE3MvXSUWYJh6cTpANhPrTEgd5QBedn7 xTFmeeFV7PwizgrJm2+UhhC0Rn3n6uZQ96xXHOQl023BGrz/Q7SWp/bM56vKrokXYJZR OkDg== 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 32-v6si10601838plg.555.2018.03.18.12.58.19; Sun, 18 Mar 2018 12:58:33 -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 S1754750AbeCRT4k (ORCPT + 99 others); Sun, 18 Mar 2018 15:56:40 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:39251 "EHLO smtp2200-217.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754508AbeCRTwg (ORCPT ); Sun, 18 Mar 2018 15:52:36 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.02444225|-1;CH=green;FP=0|0|0|0|0|-1|-1|-1;HT=e01e01542;MF=ren_guo@c-sky.com;NM=1;PH=DS;RN=11;RT=11;SR=0;TI=SMTPD_---.BMC-7mw_1521402716; Received: from localhost(mailfrom:ren_guo@c-sky.com fp:183.159.50.56) by smtp.aliyun-inc.com(10.147.43.230); Mon, 19 Mar 2018 03:51:56 +0800 From: Guo Ren To: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, daniel.lezcano@linaro.org, jason@lakedaemon.net, arnd@arndb.de Cc: c-sky_gcc_upstream@c-sky.com, gnu-csky@mentor.com, thomas.petazzoni@bootlin.com, wbx@uclibc-ng.org, Guo Ren Subject: [PATCH 06/19] csky: IRQ handling Date: Mon, 19 Mar 2018 03:51:28 +0800 Message-Id: <28baa2d92e5c3145afdff68ca784075afbb64d88.1521399976.git.ren_guo@c-sky.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Guo Ren --- arch/csky/include/asm/irq.h | 12 +++++++++ arch/csky/include/asm/irqflags.h | 55 ++++++++++++++++++++++++++++++++++++++++ arch/csky/kernel/irq.c | 41 ++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 arch/csky/include/asm/irq.h create mode 100644 arch/csky/include/asm/irqflags.h create mode 100644 arch/csky/kernel/irq.c diff --git a/arch/csky/include/asm/irq.h b/arch/csky/include/asm/irq.h new file mode 100644 index 0000000..f68e868 --- /dev/null +++ b/arch/csky/include/asm/irq.h @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. +#ifndef __ASM_CSKY_IRQ_H +#define __ASM_CSKY_IRQ_H + +#define NR_IRQS CONFIG_CSKY_NR_IRQS + +#include + +extern unsigned int (*csky_get_auto_irqno) (void); + +#endif /* __ASM_CSKY_IRQ_H */ diff --git a/arch/csky/include/asm/irqflags.h b/arch/csky/include/asm/irqflags.h new file mode 100644 index 0000000..ac8035a --- /dev/null +++ b/arch/csky/include/asm/irqflags.h @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. +#ifndef __ASM_CSKY_IRQFLAGS_H +#define __ASM_CSKY_IRQFLAGS_H + +static inline unsigned long arch_local_irq_save(void) +{ + unsigned long flags; + asm volatile( + "mfcr %0, psr \n" + "psrclr ie \n" + :"=r"(flags)); + return flags; +} +#define arch_local_irq_save arch_local_irq_save + +static inline void arch_local_irq_enable(void) +{ + asm volatile("psrset ee, ie\n"); +} +#define arch_local_irq_enable arch_local_irq_enable + +static inline void arch_local_irq_disable(void) +{ + asm volatile("psrclr ie\n"); +} +#define arch_local_irq_disable arch_local_irq_disable + +static inline unsigned long arch_local_save_flags(void) +{ + unsigned long flags; + asm volatile("mfcr %0, psr\n":"=r"(flags)); + return flags; +} +#define arch_local_save_flags arch_local_save_flags + +static inline void arch_local_irq_restore(unsigned long flags) +{ + asm volatile( + "mtcr %0, psr \n" + ::"r" (flags) + :"memory" + ); +} +#define arch_local_irq_restore arch_local_irq_restore + +static inline int arch_irqs_disabled_flags(unsigned long flags) +{ + return !(flags & (1<<6)); +} +#define arch_irqs_disabled_flags arch_irqs_disabled_flags + +#include + +#endif /* __ASM_CSKY_IRQFLAGS_H */ diff --git a/arch/csky/kernel/irq.c b/arch/csky/kernel/irq.c new file mode 100644 index 0000000..0cdb4fe --- /dev/null +++ b/arch/csky/kernel/irq.c @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. +#include +#include +#include +#include + +unsigned int (*csky_get_auto_irqno) (void) = NULL; + +void csky_do_IRQ(int irq, struct pt_regs *regs) +{ + struct pt_regs *old_regs = set_irq_regs(regs); + + irq_enter(); + generic_handle_irq(irq); + irq_exit(); + + set_irq_regs(old_regs); +} + +asmlinkage void csky_do_auto_IRQ(struct pt_regs *regs) +{ + unsigned long irq, psr; + + asm volatile("mfcr %0, psr":"=r"(psr)); + + irq = (psr >> 16) & 0xff; + + if (irq == 10) + irq = csky_get_auto_irqno(); + else + irq -= 32; + + csky_do_IRQ(irq, regs); +} + +void __init init_IRQ(void) +{ + irqchip_init(); +} + -- 2.7.4