From patchwork Mon Jan 7 01:23:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 1938351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id EB702DF2A2 for ; Mon, 7 Jan 2013 01:30:33 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Ts1VZ-0006X9-SY; Mon, 07 Jan 2013 01:28:09 +0000 Received: from mail-da0-f47.google.com ([209.85.210.47]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Ts1VD-0006QT-5N for linux-arm-kernel@lists.infradead.org; Mon, 07 Jan 2013 01:27:52 +0000 Received: by mail-da0-f47.google.com with SMTP id s35so8383613dak.34 for ; Sun, 06 Jan 2013 17:27:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=vAeqnmAmP79uc+paQPXdXwuQEajQorjIc4voYmsNNCw=; b=RmQBxQmE+tJOMzySt96+iC05wqRdi4N1/v2wUwlQn+fcDWZsiwyodhyMhUHitv1UEs E3yP1g5Y/gexv9xbfFpO77nBwiFlct4N/SkhPOtF3/69osXLclOZ/RlzOgmVr36O2/Xc fw0frob9Nh/bDzaOHUGkEiiOJzQMvcDK6v7wHytQVjE0SKDNuKUwJOR80LiSxr9NG9Im WbjWe8Lrzt1r39oq69WDSpUPZ4X22kAPQqb4Zpf0yKo+PI/7t93nGfPA215UdscJPKWh iulHfQA9dmOzByh/pzdC9IEBMYTgdL6ZTe99EK5m4NX5BvNg7T2WnNby9j/HWCbG4ARp kEEQ== X-Received: by 10.69.0.199 with SMTP id ba7mr165873537pbd.165.1357522065581; Sun, 06 Jan 2013 17:27:45 -0800 (PST) Received: from localhost (ip-64-134-225-38.public.wayport.net. [64.134.225.38]) by mx.google.com with ESMTPS id vo8sm36611902pbc.16.2013.01.06.17.27.43 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 06 Jan 2013 17:27:44 -0800 (PST) From: Anton Vorontsov To: Andrew Morton Subject: [PATCH 3/3] ARM: versatile: Make able to use UART ports for KGDB FIQ debugger Date: Sun, 6 Jan 2013 17:23:51 -0800 Message-Id: <1357521831-6053-3-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.8.0.2 In-Reply-To: <20130107012242.GA31052@lizard.mcd01528.sjc.wayport.net> References: <20130107012242.GA31052@lizard.mcd01528.sjc.wayport.net> X-Gm-Message-State: ALoCoQkL0dWm2Gwcb5KinUOgM62LZMSIvyXn8SV/wndTwOM/xS0boCF/QOhzJrwboNan0tT9kMJv X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130106_202747_496254_2C4A98C9 X-CRM114-Status: GOOD ( 16.06 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.210.47 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linaro-kernel@lists.linaro.org, Russell King , patches@linaro.org, linux-kernel@vger.kernel.org, John Stultz , Jason Wessel , kernel-team@android.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org If enabled, kernel will able to enter KGDB upon serial line activity on UART ports. Note that even with this patch and CONFIG_KGDB_FIQ is enabled, you still need to pass kgdb_fiq.enable=1 kernel command line option, otherwise UART will behave in a normal way. By default UART0 is used, but this can be changed via kgdb_fiq.uart_num kernel command line option. Signed-off-by: Anton Vorontsov --- arch/arm/Kconfig | 1 + arch/arm/mach-versatile/Makefile | 1 + arch/arm/mach-versatile/kgdb_fiq.c | 55 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 arch/arm/mach-versatile/kgdb_fiq.c diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index bde27c1..8fea25d 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -338,6 +338,7 @@ config ARCH_VERSATILE select PLAT_VERSATILE_CLCD select PLAT_VERSATILE_CLOCK select VERSATILE_FPGA_IRQ + select ARCH_MIGHT_HAVE_KGDB_FIQ help This enables support for ARM Ltd Versatile board. diff --git a/arch/arm/mach-versatile/Makefile b/arch/arm/mach-versatile/Makefile index 81fa3fe..bfd761f 100644 --- a/arch/arm/mach-versatile/Makefile +++ b/arch/arm/mach-versatile/Makefile @@ -7,3 +7,4 @@ obj-$(CONFIG_ARCH_VERSATILE_PB) += versatile_pb.o obj-$(CONFIG_MACH_VERSATILE_AB) += versatile_ab.o obj-$(CONFIG_MACH_VERSATILE_DT) += versatile_dt.o obj-$(CONFIG_PCI) += pci.o +obj-$(CONFIG_KGDB_FIQ) += kgdb_fiq.o diff --git a/arch/arm/mach-versatile/kgdb_fiq.c b/arch/arm/mach-versatile/kgdb_fiq.c new file mode 100644 index 0000000..dd92e40 --- /dev/null +++ b/arch/arm/mach-versatile/kgdb_fiq.c @@ -0,0 +1,55 @@ +/* + * KGDB FIQ board support + * + * Copyright 2012 Linaro Ltd. + * Anton Vorontsov + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include + +static void *kgdb_irq_base; + +static int kgdb_irq; +module_param_named(uart_num, kgdb_irq, int, 0600); +MODULE_PARM_DESC(uart_num, "UART port to use for KGDB FIQ"); + +static void kgdb_fiq_select(bool on) +{ + void __iomem *sel = kgdb_irq_base + VIC_INT_SELECT; + u32 msk = 1 << kgdb_irq; + u32 val; + + pr_debug("rerouting VIC vector %d to %s\n", kgdb_irq, + on ? "FIQ" : "IRQ"); + + val = readl(sel); + val &= ~msk; + if (on) + val |= msk; + writel(val, sel); +} + +static bool kgdb_is_fiq_rised(void) +{ + return readl(kgdb_irq_base + VIC_FIQ_STATUS) & (1 << kgdb_irq); +} + +static int __init kgdb_fiq_init(void) +{ + kgdb_irq_base = __io_address(VERSATILE_VIC_BASE); + kgdb_irq += INT_UARTINT0; + WARN_ON(kgdb_irq > INT_UARTINT2); + + return kgdb_register_fiq(kgdb_fiq_select, kgdb_is_fiq_rised); +} +console_initcall(kgdb_fiq_init);