Received: by 10.223.164.202 with SMTP id h10csp1594187wrb; Mon, 27 Nov 2017 05:01:00 -0800 (PST) X-Google-Smtp-Source: AGs4zMaPEgB8D7jsQl8F4+CH1Y3KLxCM0LRh1O08yMPWi4Ld3Z0wkYphtPV/lp7FeXN7lFnwwpYi X-Received: by 10.101.90.71 with SMTP id z7mr30332216pgs.14.1511787660598; Mon, 27 Nov 2017 05:01:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511787660; cv=none; d=google.com; s=arc-20160816; b=YLrTmCtcF6KvrNoUp971Lml7nwGn4tqXwDBQ/Hc1iRr1yFjFV9d2ZLwIMZWGCEBbZ5 UcCTGIu4VV9mdHhcVg2o7DhEftXujo0D4w1GuMlnpoRcyg09PK6j7wMcndA3PnwT+ymH Z+/ZL8v7RVqesE43TohfOf4NuvaxJvRDApBz05uP3V1iV50gh8bHFQnPnWCmLPehdAkv GTOumqAVytmRo8Kb3yrZZzdV2eOhRutnR44H3V7+qdjD7wdrnlHNxeRJ9O7omhAJoiOd TAaMOkndg5+Ai3tSnHE3TiSgnwdmLtw637RyeiaZwLfjihmxKD+NM2dVu/gPOkH/Hk6j bFnw== 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:dkim-signature :arc-authentication-results; bh=4Yn7U1RcIxzaAIH26p3bEYBlwu5QCWiM/rFfqp5SSrk=; b=Qc8tVEYhwYsIW+JEJNoFspbEfCh7R2/6tOec4NxI0xF9NQFWpoHsc1iTLW07vDdn1f i599rvEWUZ3HdtFGL7fpg6Ut+cfcjOl3Qp4jL3JTF+AZmE+zV1+wKJdNfPltoZFoKgb8 AALaat8PudTb72CrJPaueLmIZn2BfDhTInbUvWuaL4O/n2D+j/7MKG3nGj0eD8A8iTiy gmSRARXVTU5JAnLYgjHFsEl8t3s7ZwzHT3QS+O6d+uR8fWCWZzETy91PFFR9JZJ/t6Gl mY2PZw/jjeJe9vuWWNxEAP2H+Gs515SlBAk7yEdKAhBmCQLM8Nf23WRS7WogdK4Or42M z5Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gAHUAfAC; 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=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 75si25454557pfz.240.2017.11.27.05.00.48; Mon, 27 Nov 2017 05:01:00 -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=@gmail.com header.s=20161025 header.b=gAHUAfAC; 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=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752881AbdK0M7V (ORCPT + 77 others); Mon, 27 Nov 2017 07:59:21 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33772 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752314AbdK0My7 (ORCPT ); Mon, 27 Nov 2017 07:54:59 -0500 Received: by mail-pg0-f68.google.com with SMTP id s75so18660902pgs.0; Mon, 27 Nov 2017 04:54:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=4Yn7U1RcIxzaAIH26p3bEYBlwu5QCWiM/rFfqp5SSrk=; b=gAHUAfAC9wXXczsk4o/531dcLfosWvwNahQRB1QyPuJjLXTaAPiP4dVCqsYY4OrFhY AK+DD4xlXUlwRQRh3FbTA901YGjHx/W+JXW4JgGQ9wgoQH3Oa8LZvnjNEga2sScMaP5U 2B7Pwq3/Kvp4CzyD/ED105XIyJ+EFXM3AsyO/uiVj00otnv3den9Tb4MIrGdJUzhLq5d IyWyfUha/1iV/Y1ME/sp91oLfDs1YNMBOgTImwi+xzXMZk3Nb0/Ch//QlAmpgsBfh+58 e1B2RVlBsOsfi1ESIYuKs1X80lzwRHgkG4MeYbI8x+6TD3PJZB8A39w8d5tDa9KruCu7 4Oyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=4Yn7U1RcIxzaAIH26p3bEYBlwu5QCWiM/rFfqp5SSrk=; b=Dva+VnMgA8RToXx1SmfiVbBZS+aitrQ99JiFak8fAVvz9HhzeNSg5+ddeDF3jrrrJA GyjaB+nvVt8sk1WsFxUsE2FVVmg9+r3qDwR9+PTETU2cuuqeLlBMTwRayq6kRAo4iD9v JTiVERfjGRlcO+85JuZooZ06otJPSXKGBjSYeY5sz6APl7s5sbvY3zu6DV7FbXrVTtdJ Ljs2vb1XTm5Ng53ID1WrQS80GPiswHfb4CZDEYmsmveJJQ89tg9AF1N3rHINz6+PeQ5f VSz67sL3G8LQuZTO9EtpZeTYNTSCZLu0R/XQbJPfNJ4FFqtr9HceBeuJMMH3OljTH/Sx VDpA== X-Gm-Message-State: AJaThX5IWAjbpDxLoD+f6FhjaESjFd/dsGPYBr+py19zRyMmt80GjwFz MRaKxISZFE8o1opTmRUSHe4qLpjE X-Received: by 10.101.67.140 with SMTP id m12mr35793713pgp.51.1511787298633; Mon, 27 Nov 2017 04:54:58 -0800 (PST) Received: from app09.andestech.com ([118.163.51.199]) by smtp.gmail.com with ESMTPSA id w64sm55225459pfj.62.2017.11.27.04.54.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Nov 2017 04:54:57 -0800 (PST) From: Greentime Hu To: greentime@andestech.com, linux-kernel@vger.kernel.org, arnd@arndb.de, linux-arch@vger.kernel.org, tglx@linutronix.de, jason@lakedaemon.net, marc.zyngier@arm.com, robh+dt@kernel.org, netdev@vger.kernel.org, deanbo422@gmail.com, devicetree@vger.kernel.org, viro@zeniv.linux.org.uk, dhowells@redhat.com, will.deacon@arm.com, daniel.lezcano@linaro.org, linux-serial@vger.kernel.org Cc: green.hu@gmail.com, Rick Chen Subject: [PATCH v2 27/35] irqchip: Andestech Internal Vector Interrupt Controller driver Date: Mon, 27 Nov 2017 20:28:14 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 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 From: Greentime Hu This patch adds the Andestech Internal Vector Interrupt Controller driver. You can find the spec here. Ch4.9 of AndeStar SPA V3 Manual. http://www.andestech.com/product.php?cls=9 Signed-off-by: Rick Chen Signed-off-by: Greentime Hu --- drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-ativic32.c | 119 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 drivers/irqchip/irq-ativic32.c diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index b842dfd..201ca9f 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -80,3 +80,4 @@ obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o irq-aspeed-i2c-ic.o obj-$(CONFIG_STM32_EXTI) += irq-stm32-exti.o obj-$(CONFIG_QCOM_IRQ_COMBINER) += qcom-irq-combiner.o obj-$(CONFIG_IRQ_UNIPHIER_AIDET) += irq-uniphier-aidet.o +obj-$(CONFIG_NDS32) += irq-ativic32.o diff --git a/drivers/irqchip/irq-ativic32.c b/drivers/irqchip/irq-ativic32.c new file mode 100644 index 0000000..c4d6f86 --- /dev/null +++ b/drivers/irqchip/irq-ativic32.c @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2005-2017 Andes Technology Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static void ativic32_ack_irq(struct irq_data *data) +{ + __nds32__mtsr_dsb(1 << data->hwirq, NDS32_SR_INT_PEND2); +} + +static void ativic32_mask_irq(struct irq_data *data) +{ + unsigned long int_mask2 = __nds32__mfsr(NDS32_SR_INT_MASK2); + __nds32__mtsr_dsb(int_mask2 & (~(1 << data->hwirq)), NDS32_SR_INT_MASK2); +} + +static void ativic32_mask_ack_irq(struct irq_data *data) +{ + unsigned long int_mask2 = __nds32__mfsr(NDS32_SR_INT_MASK2); + __nds32__mtsr_dsb(int_mask2 & (~(1 << data->hwirq)), NDS32_SR_INT_MASK2); + __nds32__mtsr_dsb((1 << data->hwirq), NDS32_SR_INT_PEND2); + +} + +static void ativic32_unmask_irq(struct irq_data *data) +{ + unsigned long int_mask2 = __nds32__mfsr(NDS32_SR_INT_MASK2); + __nds32__mtsr_dsb(int_mask2 | (1 << data->hwirq), NDS32_SR_INT_MASK2); +} + +static struct irq_chip ativic32_chip = { + .name = "ativic32", + .irq_ack = ativic32_ack_irq, + .irq_mask = ativic32_mask_irq, + .irq_mask_ack = ativic32_mask_ack_irq, + .irq_unmask = ativic32_unmask_irq, +}; + +static unsigned int __initdata nivic_map[6] = { 6, 2, 10, 16, 24, 32 }; + +static struct irq_domain *root_domain; +static int ativic32_irq_domain_map(struct irq_domain *id, unsigned int virq, + irq_hw_number_t hw) +{ + + unsigned long int_trigger_type; + int_trigger_type = __nds32__mfsr(NDS32_SR_INT_TRIGGER); + if (int_trigger_type & (1 << hw)) + irq_set_chip_and_handler(virq, &ativic32_chip, handle_edge_irq); + else + irq_set_chip_and_handler(virq, &ativic32_chip, handle_level_irq); + + return 0; +} + +static struct irq_domain_ops ativic32_ops = { + .map = ativic32_irq_domain_map, + .xlate = irq_domain_xlate_onecell +}; + +static int get_intr_src(void) +{ + return ((__nds32__mfsr(NDS32_SR_ITYPE)&ITYPE_mskVECTOR) >> ITYPE_offVECTOR) + - NDS32_VECTOR_offINTERRUPT; +} + +asmlinkage void asm_do_IRQ(struct pt_regs *regs) +{ + int hwirq = get_intr_src(); + handle_domain_irq(root_domain, hwirq, regs); +} + +int __init ativic32_init_irq(struct device_node *node, struct device_node *parent) +{ + unsigned long int_vec_base, nivic; + + if (WARN(parent, "non-root ativic32 are not supported")) + return -EINVAL; + + int_vec_base = __nds32__mfsr(NDS32_SR_IVB); + + if (((int_vec_base & IVB_mskIVIC_VER) >> IVB_offIVIC_VER) == 0) + panic("Unable to use atcivic32 for this cpu.\n"); + + nivic = (int_vec_base & IVB_mskNIVIC) >> IVB_offNIVIC; + if (nivic >= (sizeof nivic_map / sizeof nivic_map[0])) + panic("The number of input for ativic32 is not supported.\n"); + + nivic = nivic_map[nivic]; + + root_domain = irq_domain_add_linear(node, nivic, + &ativic32_ops, NULL); + + if (!root_domain) + panic("%s: unable to create IRQ domain\n", node->full_name); + + return 0; +} +IRQCHIP_DECLARE(ativic32, "andestech,ativic32", ativic32_init_irq); -- 1.7.9.5 From 1585461774371780593@xxx Thu Nov 30 03:56:13 +0000 2017 X-GM-THRID: 1585461774371780593 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread