From patchwork Fri May 10 00:10:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 16812 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f71.google.com (mail-qe0-f71.google.com [209.85.128.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5A2B025E04 for ; Fri, 10 May 2013 00:11:51 +0000 (UTC) Received: by mail-qe0-f71.google.com with SMTP id 1sf4593864qec.10 for ; Thu, 09 May 2013 17:11:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=8kjDfLsUUkSjaXAIMaDMBKxsBwS/3tKe8LfW/4RTnPQ=; b=C4e/nXHMmHkcZeRvlBSgLgmp1FYl65GGUWNqnicYf3vQyu/NuPE2+pOmYAV+mOkkfW 3kSGCkEBRhEYhUJqjtUM0A6eyz+KKxNiY6lxVuBlxozt4i1xNrSfJ48L4xeyPWWj6EWA P+hmhA7FpHykYFKmzwKHj+wkwETDPZ/mvfnrk6WinfAld2a4QroAp4gtL9Bt534s4348 Pvk/snpbL0hH9Tt3MYR/pM85Gi8YZorqasJbEOBMTGtT8XQ9mzC8wPdFD13qm5mg6Tzv 5a1g9pCkbyxd4N57mWteXbJu05yS1PXwFP80RRVu0H+Aj19bAUMzPIR1gDu8FHvl1iEA PpVw== X-Received: by 10.236.36.44 with SMTP id v32mr7478231yha.33.1368144686969; Thu, 09 May 2013 17:11:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.5.10 with SMTP id o10ls1665009qeo.69.gmail; Thu, 09 May 2013 17:11:26 -0700 (PDT) X-Received: by 10.52.240.211 with SMTP id wc19mr8175462vdc.12.1368144686752; Thu, 09 May 2013 17:11:26 -0700 (PDT) Received: from mail-vb0-x235.google.com (mail-vb0-x235.google.com [2607:f8b0:400c:c02::235]) by mx.google.com with ESMTPS id wy7si182006vec.4.2013.05.09.17.11.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 May 2013 17:11:26 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::235 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::235; Received: by mail-vb0-f53.google.com with SMTP id i3so2993627vbh.26 for ; Thu, 09 May 2013 17:11:26 -0700 (PDT) X-Received: by 10.52.69.109 with SMTP id d13mr8138467vdu.75.1368144686607; Thu, 09 May 2013 17:11:26 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.170.105 with SMTP id al9csp17524vec; Thu, 9 May 2013 17:11:25 -0700 (PDT) X-Received: by 10.68.103.194 with SMTP id fy2mr424407pbb.158.1368144685429; Thu, 09 May 2013 17:11:25 -0700 (PDT) Received: from mail-pd0-f173.google.com (mail-pd0-f173.google.com [209.85.192.173]) by mx.google.com with ESMTPS id dj6si225334pad.163.2013.05.09.17.11.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 May 2013 17:11:25 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.173 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.192.173; Received: by mail-pd0-f173.google.com with SMTP id v10so2370835pde.32 for ; Thu, 09 May 2013 17:11:24 -0700 (PDT) X-Received: by 10.66.146.74 with SMTP id ta10mr15163893pab.60.1368144684727; Thu, 09 May 2013 17:11:24 -0700 (PDT) Received: from localhost.localdomain (c-24-21-54-107.hsd1.or.comcast.net. [24.21.54.107]) by mx.google.com with ESMTPSA id aa8sm355657pad.14.2013.05.09.17.11.23 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 May 2013 17:11:23 -0700 (PDT) From: John Stultz To: linux-kernel@vger.kernel.org Cc: Anton Vorontsov , Russell King , Nicolas Pitre , Arnd Bergmann , Jason Wessel , Andrew Morton , linux-arm-kernel@lists.infradead.org, kernel-team@android.com, John Stultz Subject: [PATCH 3/3] ARM: versatile: Make able to use UART ports for KGDB FIQ debugger Date: Thu, 9 May 2013 17:10:51 -0700 Message-Id: <1368144651-11250-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1368144651-11250-1-git-send-email-john.stultz@linaro.org> References: <1368144651-11250-1-git-send-email-john.stultz@linaro.org> X-Gm-Message-State: ALoCoQktvvOduI4CKrvCb7/x8yQ1W6VOMlYyS6QP88kOiw5Z2j3rzCSRnrM2oOIq/ea5cQF5FWTv X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::235 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Anton Vorontsov 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. Cc: Anton Vorontsov Cc: Russell King Cc: Nicolas Pitre Cc: Arnd Bergmann Cc: Jason Wessel Cc: Andrew Morton Cc: linux-arm-kernel@lists.infradead.org Cc: kernel-team@android.com Signed-off-by: Anton Vorontsov Signed-off-by: John Stultz --- 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 66a9076..9909af3 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -364,6 +364,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);