From patchwork Tue Aug 5 14:58:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Joe.C" X-Patchwork-Id: 34955 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DAE2C202A1 for ; Tue, 5 Aug 2014 15:05:55 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rp18sf4421101iec.0 for ; Tue, 05 Aug 2014 08:05:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:mime-version:cc:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=4nVoBVcKVykIflnlZP+qHDRSu9zpvh5PzGSN8k0c9oE=; b=kgPgS8slVub9HXu0NEm4JvDgDUi1kwjPPwnJdFPCDpE+X6vNiMDOgvjE8WmOltYQFp jkG+B736cN5xnNqiwlcrDyI4r1LotulmgWYBPf3Nkt8br0UkTnw8YlxjnXWjYqw5k8YU GEUJ5zq4w0xhTiptvPED1v2wMMDlHXY7DcZbLcHsW82luvIxjq1wvfu5J+Cpr2zc8okg W7z2QFFdxsD3VIWG7jKSZMkGT7mur3l6pRqlnb8+X5/oab1Ph2xmwtYOM7dQSirYKZls DlajIOgJN9z4242Vki1rAaZqniuXTveMHdeygH5y1L6ImhQPabqO5Rvxl/xIlqn2EDNa CXQg== X-Gm-Message-State: ALoCoQnCMexKNdainrNSyyiOtLJSWjOPcGhH0IG5TtwOkSnzfSNc712VVpgR+7RNtODT7JHqt+qn X-Received: by 10.182.81.161 with SMTP id b1mr2084327oby.1.1407251155389; Tue, 05 Aug 2014 08:05:55 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.89.203 with SMTP id v69ls317463qgd.6.gmail; Tue, 05 Aug 2014 08:05:55 -0700 (PDT) X-Received: by 10.52.227.72 with SMTP id ry8mr2407386vdc.64.1407251155275; Tue, 05 Aug 2014 08:05:55 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id l3si1302459ver.30.2014.08.05.08.05.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 05 Aug 2014 08:05:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id ij19so1719642vcb.39 for ; Tue, 05 Aug 2014 08:05:55 -0700 (PDT) X-Received: by 10.52.3.40 with SMTP id 8mr3655405vdz.24.1407251155167; Tue, 05 Aug 2014 08:05:55 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp396396vcb; Tue, 5 Aug 2014 08:05:54 -0700 (PDT) X-Received: by 10.68.106.194 with SMTP id gw2mr4923884pbb.85.1407251154132; Tue, 05 Aug 2014 08:05:54 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id qu6si2282627pbc.20.2014.08.05.08.05.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Aug 2014 08:05:54 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XEgI3-0007Pe-3B; Tue, 05 Aug 2014 15:04:39 +0000 Received: from [210.61.82.183] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XEgHv-0007Gy-2j for linux-arm-kernel@lists.infradead.org; Tue, 05 Aug 2014 15:04:36 +0000 X-Listener-Flag: 11101 Received: from mtkhts09.mediatek.inc [(172.21.101.70)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1795532550; Tue, 05 Aug 2014 22:58:15 +0800 Received: from mtksdtcf02.mediatek.inc (10.21.12.142) by mtkhts09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.181.6; Tue, 5 Aug 2014 22:58:13 +0800 From: Joe.C To: , Subject: [PATCH 2/3] arm: mediatek: Add support for GIC interrupt polarity extension. Date: Tue, 5 Aug 2014 22:58:09 +0800 Message-ID: <1407250690-2858-3-git-send-email-srv_yingjoe.chen@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1407250690-2858-1-git-send-email-srv_yingjoe.chen@mediatek.com> References: <1407250690-2858-1-git-send-email-srv_yingjoe.chen@mediatek.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140805_080431_551081_E22FBB8F X-CRM114-Status: GOOD ( 15.32 ) X-Spam-Score: 1.3 (+) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (1.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines Cc: yingjoe.chen@gmail.com, srv_heupstream@mediatek.com, hc.yen@mediatek.com, yh.chen@mediatek.com, olof@lixom.net, nathan.chung@mediatek.com, Matthias Brugger , eddie.huang@mediatek.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: "Joe.C" Mediatek SoCs have an interrupt polarity extension which allows to swap the polarity for given interrupts. Signed-off-by: Joe.C --- arch/arm/boot/dts/mt6589.dtsi | 7 ++++- arch/arm/mach-mediatek/Makefile | 2 +- arch/arm/mach-mediatek/common.h | 19 ++++++++++++ arch/arm/mach-mediatek/intpol.c | 61 +++++++++++++++++++++++++++++++++++++++ arch/arm/mach-mediatek/mediatek.c | 10 +++++++ 5 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 arch/arm/mach-mediatek/common.h create mode 100644 arch/arm/mach-mediatek/intpol.c diff --git a/arch/arm/boot/dts/mt6589.dtsi b/arch/arm/boot/dts/mt6589.dtsi index d0297a0..18df47f 100644 --- a/arch/arm/boot/dts/mt6589.dtsi +++ b/arch/arm/boot/dts/mt6589.dtsi @@ -76,11 +76,16 @@ timer: timer@10008000 { compatible = "mediatek,mt6577-timer"; reg = <0x10008000 0x80>; - interrupts = ; + interrupts = ; clocks = <&system_clk>, <&rtc_clk>; clock-names = "system-clk", "rtc-clk"; }; + intpol: intpol@10200100 { + compatible = "mediatek,mt6577-intpol"; + reg = <0x10200100 0x1c>; + }; + gic: interrupt-controller@10212000 { compatible = "arm,cortex-a15-gic"; interrupt-controller; diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile index 43e619f..82c39d8 100644 --- a/arch/arm/mach-mediatek/Makefile +++ b/arch/arm/mach-mediatek/Makefile @@ -1 +1 @@ -obj-$(CONFIG_ARCH_MEDIATEK) += mediatek.o +obj-$(CONFIG_ARCH_MEDIATEK) += mediatek.o intpol.o diff --git a/arch/arm/mach-mediatek/common.h b/arch/arm/mach-mediatek/common.h new file mode 100644 index 0000000..8f2bbeb --- /dev/null +++ b/arch/arm/mach-mediatek/common.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2014 Mediatek Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + */ +#ifndef __MEDIATEK_COMMON_H__ +#define __MEDIATEK_COMMON_H__ + +extern char init_intpol(void); + +#endif /* __MEDIATEK_COMMON_H__ */ diff --git a/arch/arm/mach-mediatek/intpol.c b/arch/arm/mach-mediatek/intpol.c new file mode 100644 index 0000000..65ccc7c --- /dev/null +++ b/arch/arm/mach-mediatek/intpol.c @@ -0,0 +1,61 @@ +/* + * This file contains common code that is intended to be used across + * boards so that it's not replicated. + * + * Copyright (C) 2014 Mediatek Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ +#include +#include +#include +#include + +#define GIC_HW_IRQ_BASE 32 +#define INT_POL_INDEX(a) ((a) - GIC_HW_IRQ_BASE) + +static void __iomem *int_pol_base; + +static int mtk_int_pol_set_type(struct irq_data *d, unsigned int type) +{ + unsigned int irq = d->hwirq; + u32 offset, reg_index, value; + + offset = INT_POL_INDEX(irq) & 0x1F; + reg_index = INT_POL_INDEX(irq) >> 5; + + /* This arch extension was called with irq_controller_lock held, + so the read-modify-write will be atomic */ + value = readl(int_pol_base + reg_index * 4); + if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_EDGE_FALLING) + value |= (1 << offset); + else + value &= ~(1 << offset); + writel(value, int_pol_base + reg_index * 4); + + return 0; +} + +void init_intpol(void) +{ + struct device_node *node; + + node = of_find_compatible_node(NULL, NULL, "mediatek,mt6577-intpol"); + if (!node) + return; + + int_pol_base = of_io_request_and_map(node, 0, "intpol"); + if (IS_ERR(int_pol_base)) { + pr_warn("Can't get resource\n"); + return; + } + + gic_arch_extn.irq_set_type = mtk_int_pol_set_type; +} diff --git a/arch/arm/mach-mediatek/mediatek.c b/arch/arm/mach-mediatek/mediatek.c index 48051a2..aa10c70 100644 --- a/arch/arm/mach-mediatek/mediatek.c +++ b/arch/arm/mach-mediatek/mediatek.c @@ -16,6 +16,15 @@ */ #include #include +#include + +#include "common.h" + +static void __init mediatek_init_irq(void) +{ + init_intpol(); + irqchip_init(); +} static const char * const mediatek_board_dt_compat[] = { "mediatek,mt6589", @@ -26,4 +35,5 @@ static const char * const mediatek_board_dt_compat[] = { DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)") .dt_compat = mediatek_board_dt_compat, + .init_irq = mediatek_init_irq, MACHINE_END