aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJames Hogan <james.hogan@imgtec.com>2012-09-21 12:38:15 -0400
committerJames Hogan <james.hogan@imgtec.com>2013-03-02 15:09:56 -0500
commitae85ac71b7433fa974759109c4380c620258f07f (patch)
tree066915c6c1f0f830c35ff12f4a84e233b6fd15da /arch
parent690998b629a554d8004d3129a42176afafce9fae (diff)
metag: Add JTAG Debug Adapter (DA) support
Add basic JTAG Debug Adapter (DA) support so that drivers which communicate with the DA can detect whether one is actually present (otherwise the target will halt indefinitely). This allows the metag_da TTY driver and imgdafs filesystem driver to be built, updates defconfigs, and sets up the metag_da console early if it's configured in. Signed-off-by: James Hogan <james.hogan@imgtec.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/metag/Kconfig12
-rw-r--r--arch/metag/configs/meta1_defconfig3
-rw-r--r--arch/metag/configs/meta2_defconfig3
-rw-r--r--arch/metag/configs/meta2_smp_defconfig3
-rw-r--r--arch/metag/include/asm/da.h43
-rw-r--r--arch/metag/kernel/Makefile1
-rw-r--r--arch/metag/kernel/da.c23
-rw-r--r--arch/metag/kernel/setup.c15
8 files changed, 103 insertions, 0 deletions
diff --git a/arch/metag/Kconfig b/arch/metag/Kconfig
index f6846ad5d3a8..30adc7875daa 100644
--- a/arch/metag/Kconfig
+++ b/arch/metag/Kconfig
@@ -214,6 +214,18 @@ config METAG_PERFCOUNTER_IRQS
214 When disabled, Performance Counters information will be collected 214 When disabled, Performance Counters information will be collected
215 based on Timer Interrupt. 215 based on Timer Interrupt.
216 216
217config METAG_DA
218 bool "DA support"
219 help
220 Say Y if you plan to use a DA debug adapter with Linux. The presence
221 of the DA will be detected automatically at boot, so it is safe to say
222 Y to this option even when booting without a DA.
223
224 This enables support for services provided by DA JTAG debug adapters,
225 such as:
226 - communication over DA channels (such as the console driver).
227 - use of the DA filesystem.
228
217menu "Boot options" 229menu "Boot options"
218 230
219config METAG_BUILTIN_DTB 231config METAG_BUILTIN_DTB
diff --git a/arch/metag/configs/meta1_defconfig b/arch/metag/configs/meta1_defconfig
index 837c235ab67a..ad663ca53208 100644
--- a/arch/metag/configs/meta1_defconfig
+++ b/arch/metag/configs/meta1_defconfig
@@ -14,6 +14,7 @@ CONFIG_PARTITION_ADVANCED=y
14# CONFIG_IOSCHED_CFQ is not set 14# CONFIG_IOSCHED_CFQ is not set
15CONFIG_FLATMEM_MANUAL=y 15CONFIG_FLATMEM_MANUAL=y
16CONFIG_META12_FPGA=y 16CONFIG_META12_FPGA=y
17CONFIG_METAG_DA=y
17CONFIG_HZ_100=y 18CONFIG_HZ_100=y
18CONFIG_DEVTMPFS=y 19CONFIG_DEVTMPFS=y
19CONFIG_DEVTMPFS_MOUNT=y 20CONFIG_DEVTMPFS_MOUNT=y
@@ -27,6 +28,8 @@ CONFIG_BLK_DEV_RAM_SIZE=16384
27# CONFIG_SERIO is not set 28# CONFIG_SERIO is not set
28# CONFIG_VT is not set 29# CONFIG_VT is not set
29# CONFIG_LEGACY_PTYS is not set 30# CONFIG_LEGACY_PTYS is not set
31CONFIG_DA_TTY=y
32CONFIG_DA_CONSOLE=y
30# CONFIG_DEVKMEM is not set 33# CONFIG_DEVKMEM is not set
31# CONFIG_HW_RANDOM is not set 34# CONFIG_HW_RANDOM is not set
32# CONFIG_HWMON is not set 35# CONFIG_HWMON is not set
diff --git a/arch/metag/configs/meta2_defconfig b/arch/metag/configs/meta2_defconfig
index e5bada83dd76..47922e9306af 100644
--- a/arch/metag/configs/meta2_defconfig
+++ b/arch/metag/configs/meta2_defconfig
@@ -16,6 +16,7 @@ CONFIG_PARTITION_ADVANCED=y
16CONFIG_METAG_L2C=y 16CONFIG_METAG_L2C=y
17CONFIG_FLATMEM_MANUAL=y 17CONFIG_FLATMEM_MANUAL=y
18CONFIG_METAG_HALT_ON_PANIC=y 18CONFIG_METAG_HALT_ON_PANIC=y
19CONFIG_METAG_DA=y
19CONFIG_HZ_100=y 20CONFIG_HZ_100=y
20CONFIG_DEVTMPFS=y 21CONFIG_DEVTMPFS=y
21# CONFIG_STANDALONE is not set 22# CONFIG_STANDALONE is not set
@@ -28,6 +29,8 @@ CONFIG_BLK_DEV_RAM_SIZE=16384
28# CONFIG_SERIO is not set 29# CONFIG_SERIO is not set
29# CONFIG_VT is not set 30# CONFIG_VT is not set
30# CONFIG_LEGACY_PTYS is not set 31# CONFIG_LEGACY_PTYS is not set
32CONFIG_DA_TTY=y
33CONFIG_DA_CONSOLE=y
31# CONFIG_DEVKMEM is not set 34# CONFIG_DEVKMEM is not set
32# CONFIG_HW_RANDOM is not set 35# CONFIG_HW_RANDOM is not set
33# CONFIG_HWMON is not set 36# CONFIG_HWMON is not set
diff --git a/arch/metag/configs/meta2_smp_defconfig b/arch/metag/configs/meta2_smp_defconfig
index 41983a20db72..f5082505872d 100644
--- a/arch/metag/configs/meta2_smp_defconfig
+++ b/arch/metag/configs/meta2_smp_defconfig
@@ -17,6 +17,7 @@ CONFIG_METAG_L2C=y
17CONFIG_FLATMEM_MANUAL=y 17CONFIG_FLATMEM_MANUAL=y
18CONFIG_METAG_HALT_ON_PANIC=y 18CONFIG_METAG_HALT_ON_PANIC=y
19CONFIG_SMP=y 19CONFIG_SMP=y
20CONFIG_METAG_DA=y
20CONFIG_HZ_100=y 21CONFIG_HZ_100=y
21CONFIG_DEVTMPFS=y 22CONFIG_DEVTMPFS=y
22# CONFIG_STANDALONE is not set 23# CONFIG_STANDALONE is not set
@@ -29,6 +30,8 @@ CONFIG_BLK_DEV_RAM_SIZE=16384
29# CONFIG_SERIO is not set 30# CONFIG_SERIO is not set
30# CONFIG_VT is not set 31# CONFIG_VT is not set
31# CONFIG_LEGACY_PTYS is not set 32# CONFIG_LEGACY_PTYS is not set
33CONFIG_DA_TTY=y
34CONFIG_DA_CONSOLE=y
32# CONFIG_DEVKMEM is not set 35# CONFIG_DEVKMEM is not set
33# CONFIG_HW_RANDOM is not set 36# CONFIG_HW_RANDOM is not set
34# CONFIG_HWMON is not set 37# CONFIG_HWMON is not set
diff --git a/arch/metag/include/asm/da.h b/arch/metag/include/asm/da.h
new file mode 100644
index 000000000000..81bd5212fb03
--- /dev/null
+++ b/arch/metag/include/asm/da.h
@@ -0,0 +1,43 @@
1/*
2 * Meta DA JTAG debugger control.
3 *
4 * Copyright 2012 Imagination Technologies Ltd.
5 */
6
7#ifndef _METAG_DA_H_
8#define _METAG_DA_H_
9
10#ifdef CONFIG_METAG_DA
11
12#include <linux/init.h>
13#include <linux/types.h>
14
15extern bool _metag_da_present;
16
17/**
18 * metag_da_enabled() - Find whether a DA is currently enabled.
19 *
20 * Returns: true if a DA was detected, false if not.
21 */
22static inline bool metag_da_enabled(void)
23{
24 return _metag_da_present;
25}
26
27/**
28 * metag_da_probe() - Try and detect a connected DA.
29 *
30 * This is used at start up to detect whether a DA is active.
31 *
32 * Returns: 0 on detection, -err otherwise.
33 */
34int __init metag_da_probe(void);
35
36#else /* !CONFIG_METAG_DA */
37
38#define metag_da_enabled() false
39#define metag_da_probe() do {} while (0)
40
41#endif
42
43#endif /* _METAG_DA_H_ */
diff --git a/arch/metag/kernel/Makefile b/arch/metag/kernel/Makefile
index a5e4ba6fd20a..d7675f4a5df8 100644
--- a/arch/metag/kernel/Makefile
+++ b/arch/metag/kernel/Makefile
@@ -28,6 +28,7 @@ obj-y += user_gateway.o
28obj-$(CONFIG_PERF_EVENTS) += perf/ 28obj-$(CONFIG_PERF_EVENTS) += perf/
29 29
30obj-$(CONFIG_METAG_COREMEM) += coremem.o 30obj-$(CONFIG_METAG_COREMEM) += coremem.o
31obj-$(CONFIG_METAG_DA) += da.o
31obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o 32obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o
32obj-$(CONFIG_FUNCTION_TRACER) += ftrace_stub.o 33obj-$(CONFIG_FUNCTION_TRACER) += ftrace_stub.o
33obj-$(CONFIG_MODULES) += metag_ksyms.o 34obj-$(CONFIG_MODULES) += metag_ksyms.o
diff --git a/arch/metag/kernel/da.c b/arch/metag/kernel/da.c
new file mode 100644
index 000000000000..52aabb658fde
--- /dev/null
+++ b/arch/metag/kernel/da.c
@@ -0,0 +1,23 @@
1/*
2 * Meta DA JTAG debugger control.
3 *
4 * Copyright 2012 Imagination Technologies Ltd.
5 */
6
7
8#include <linux/io.h>
9#include <linux/kernel.h>
10#include <asm/da.h>
11#include <asm/metag_mem.h>
12
13bool _metag_da_present;
14
15int __init metag_da_probe(void)
16{
17 _metag_da_present = (metag_in32(T0VECINT_BHALT) == 1);
18 if (_metag_da_present)
19 pr_info("DA present\n");
20 else
21 pr_info("DA not present\n");
22 return 0;
23}
diff --git a/arch/metag/kernel/setup.c b/arch/metag/kernel/setup.c
index 74e2c1f812a5..89f9cdc389e8 100644
--- a/arch/metag/kernel/setup.c
+++ b/arch/metag/kernel/setup.c
@@ -37,6 +37,7 @@
37#include <asm/hwthread.h> 37#include <asm/hwthread.h>
38#include <asm/mmzone.h> 38#include <asm/mmzone.h>
39#include <asm/l2cache.h> 39#include <asm/l2cache.h>
40#include <asm/da.h>
40#include <asm/prom.h> 41#include <asm/prom.h>
41#include <asm/mach/arch.h> 42#include <asm/mach/arch.h>
42#include <asm/core_reg.h> 43#include <asm/core_reg.h>
@@ -60,6 +61,11 @@ extern char _heap_start[];
60extern u32 __dtb_start[]; 61extern u32 __dtb_start[];
61#endif 62#endif
62 63
64#ifdef CONFIG_DA_CONSOLE
65/* Our early channel based console driver */
66extern struct console dash_console;
67#endif
68
63struct machine_desc *machine_desc __initdata; 69struct machine_desc *machine_desc __initdata;
64 70
65/* 71/*
@@ -180,6 +186,15 @@ void __init setup_arch(char **cmdline_p)
180 186
181 metag_cache_probe(); 187 metag_cache_probe();
182 188
189 metag_da_probe();
190#ifdef CONFIG_DA_CONSOLE
191 if (metag_da_enabled()) {
192 /* An early channel based console driver */
193 register_console(&dash_console);
194 add_preferred_console("ttyDA", 1, NULL);
195 }
196#endif
197
183 /* try interpreting the argument as a device tree */ 198 /* try interpreting the argument as a device tree */
184 machine_desc = setup_machine_fdt(original_cmd_line); 199 machine_desc = setup_machine_fdt(original_cmd_line);
185 /* if it doesn't look like a device tree it must be a command line */ 200 /* if it doesn't look like a device tree it must be a command line */