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: 13852 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2B10F23E27 for ; Mon, 7 Jan 2013 01:27:48 +0000 (UTC) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by fiordland.canonical.com (Postfix) with ESMTP id BE93FA18827 for ; Mon, 7 Jan 2013 01:27:47 +0000 (UTC) Received: by mail-vc0-f176.google.com with SMTP id fo13so18441188vcb.7 for ; Sun, 06 Jan 2013 17:27:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=vAeqnmAmP79uc+paQPXdXwuQEajQorjIc4voYmsNNCw=; b=IEp6aRWo4id22C/jP6A5VVpsP6NpffRgnbsnahuWiCahUdo63nDAdcwEiKlcC4TaXw /wsGV7UNbHrO1xaL9bbRXyZz2OuSaLU6M0zUFg3yzWMzJPbuEdI+iprXZRU9rJy+NFya Xo0/Yw+bVryNld9rvsXzCNjjwg9kZZFs6oCtDObzBz4Qn2MvBWoYaTIbiRdBQmI+ZNqv 7pLLDcSABQwDtTh+4CVveMN0AjWpdfxzcZnQCzCxk+fXxJ8LWMDWGyswe4mFML5SAMXi eikqPhJNHjSWjm1fl/gyyKvIJ66/DqiQa8aifJskdCxKQUOpAdlLZZAtLNUIs27zd4SL YS8Q== X-Received: by 10.58.196.196 with SMTP id io4mr84017348vec.22.1357522067247; Sun, 06 Jan 2013 17:27:47 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp41238veb; Sun, 6 Jan 2013 17:27:46 -0800 (PST) X-Received: by 10.68.248.74 with SMTP id yk10mr183182388pbc.86.1357522065949; Sun, 06 Jan 2013 17:27:45 -0800 (PST) Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com [209.85.220.53]) by mx.google.com with ESMTPS id b9si57938751pax.107.2013.01.06.17.27.45 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 06 Jan 2013 17:27:45 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.53 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.220.53; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.53 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by mail-pa0-f53.google.com with SMTP id hz1so10327490pad.12 for ; Sun, 06 Jan 2013 17:27:45 -0800 (PST) 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 Cc: Russell King , Jason Wessel , John Stultz , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com 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: ALoCoQkisHGOYgD4DBZvvnj0L/D0E+w2jg/Kzhdmd22CfCYqu38KinEsMGtwVIm7mBbEK3M2T/a1 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);