Skip to content

Commit dd1386d

Browse files
committed
Merge tag 'xtensa-20230905' of https://github.com/jcmvbkbc/linux-xtensa
Pull xtensa updates from Max Filippov: - enable MTD XIP support - fix base address of the xtensa perf module in newer hardware * tag 'xtensa-20230905' of https://github.com/jcmvbkbc/linux-xtensa: xtensa: add XIP-aware MTD support xtensa: PMU: fix base address for the newer hardware
2 parents 78a0668 + 03ce34c commit dd1386d

File tree

7 files changed

+56
-5
lines changed

7 files changed

+56
-5
lines changed

arch/xtensa/Kconfig

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ config ARCH_HAS_ILOG2_U32
7171
config ARCH_HAS_ILOG2_U64
7272
def_bool n
7373

74+
config ARCH_MTD_XIP
75+
def_bool y
76+
7477
config NO_IOPORT_MAP
7578
def_bool n
7679

arch/xtensa/include/asm/core.h

+9
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,13 @@
5252
#define XTENSA_STACK_ALIGNMENT 16
5353
#endif
5454

55+
#ifndef XCHAL_HW_MIN_VERSION
56+
#if defined(XCHAL_HW_MIN_VERSION_MAJOR) && defined(XCHAL_HW_MIN_VERSION_MINOR)
57+
#define XCHAL_HW_MIN_VERSION (XCHAL_HW_MIN_VERSION_MAJOR * 100 + \
58+
XCHAL_HW_MIN_VERSION_MINOR)
59+
#else
60+
#define XCHAL_HW_MIN_VERSION 0
61+
#endif
62+
#endif
63+
5564
#endif

arch/xtensa/include/asm/mtd-xip.h

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
3+
#ifndef _ASM_MTD_XIP_H
4+
#define _ASM_MTD_XIP_H
5+
6+
#include <asm/processor.h>
7+
8+
#define xip_irqpending() (xtensa_get_sr(interrupt) & xtensa_get_sr(intenable))
9+
#define xip_currtime() (xtensa_get_sr(ccount))
10+
#define xip_elapsed_since(x) ((xtensa_get_sr(ccount) - (x)) / 1000) /* should work up to 1GHz */
11+
#define xip_cpu_idle() do { asm volatile ("waiti 0"); } while (0)
12+
13+
#endif /* _ASM_MTD_XIP_H */
14+

arch/xtensa/include/asm/sections.h

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ extern char _SecondaryResetVector_text_start[];
3434
extern char _SecondaryResetVector_text_end[];
3535
#endif
3636
#ifdef CONFIG_XIP_KERNEL
37+
#ifdef CONFIG_VECTORS_ADDR
38+
extern char _xip_text_start[];
39+
extern char _xip_text_end[];
40+
#endif
3741
extern char _xip_start[];
3842
extern char _xip_end[];
3943
#endif

arch/xtensa/kernel/perf_event.c

+13-4
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,26 @@
1313
#include <linux/perf_event.h>
1414
#include <linux/platform_device.h>
1515

16+
#include <asm/core.h>
1617
#include <asm/processor.h>
1718
#include <asm/stacktrace.h>
1819

20+
#define XTENSA_HWVERSION_RG_2015_0 260000
21+
22+
#if XCHAL_HW_MIN_VERSION >= XTENSA_HWVERSION_RG_2015_0
23+
#define XTENSA_PMU_ERI_BASE 0x00101000
24+
#else
25+
#define XTENSA_PMU_ERI_BASE 0x00001000
26+
#endif
27+
1928
/* Global control/status for all perf counters */
20-
#define XTENSA_PMU_PMG 0x1000
29+
#define XTENSA_PMU_PMG XTENSA_PMU_ERI_BASE
2130
/* Perf counter values */
22-
#define XTENSA_PMU_PM(i) (0x1080 + (i) * 4)
31+
#define XTENSA_PMU_PM(i) (XTENSA_PMU_ERI_BASE + 0x80 + (i) * 4)
2332
/* Perf counter control registers */
24-
#define XTENSA_PMU_PMCTRL(i) (0x1100 + (i) * 4)
33+
#define XTENSA_PMU_PMCTRL(i) (XTENSA_PMU_ERI_BASE + 0x100 + (i) * 4)
2534
/* Perf counter status registers */
26-
#define XTENSA_PMU_PMSTAT(i) (0x1180 + (i) * 4)
35+
#define XTENSA_PMU_PMSTAT(i) (XTENSA_PMU_ERI_BASE + 0x180 + (i) * 4)
2736

2837
#define XTENSA_PMU_PMG_PMEN 0x1
2938

arch/xtensa/kernel/setup.c

+3
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,9 @@ void __init setup_arch(char **cmdline_p)
311311

312312
mem_reserve(__pa(_stext), __pa(_end));
313313
#ifdef CONFIG_XIP_KERNEL
314+
#ifdef CONFIG_VECTORS_ADDR
315+
mem_reserve(__pa(_xip_text_start), __pa(_xip_text_end));
316+
#endif
314317
mem_reserve(__pa(_xip_start), __pa(_xip_end));
315318
#endif
316319

arch/xtensa/kernel/vmlinux.lds.S

+10-1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ SECTIONS
118118
SECTION_VECTOR2 (.DoubleExceptionVector.text, DOUBLEEXC_VECTOR_VADDR)
119119

120120
*(.exception.text)
121+
*(.xiptext)
121122
#endif
122123

123124
IRQENTRY_TEXT
@@ -201,6 +202,9 @@ SECTIONS
201202
.DebugInterruptVector.text);
202203
RELOCATE_ENTRY(_exception_text,
203204
.exception.text);
205+
#ifdef CONFIG_XIP_KERNEL
206+
RELOCATE_ENTRY(_xip_text, .xiptext);
207+
#endif
204208
#endif
205209
#ifdef CONFIG_XIP_KERNEL
206210
RELOCATE_ENTRY(_xip_data, .data);
@@ -319,7 +323,12 @@ SECTIONS
319323
LAST)
320324
#undef LAST
321325
#define LAST .exception.text
322-
326+
SECTION_VECTOR4 (_xip_text,
327+
.xiptext,
328+
,
329+
LAST)
330+
#undef LAST
331+
#define LAST .xiptext
323332
#endif
324333
. = (LOADADDR(LAST) + SIZEOF(LAST) + 3) & ~ 3;
325334

0 commit comments

Comments
 (0)