~funderscore blog cgit wiki get in touch
aboutsummaryrefslogtreecommitdiff
blob: 960381f987a1672bb6f0c9f577181220ea312f47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) 2020 Marvell International Ltd.
 *
 * This file provides support for the processor local scratch memory.
 * Scratch memory is byte addressable - all addresses are byte addresses.
 */

#ifndef __CVMX_SCRATCH_H__
#define __CVMX_SCRATCH_H__

/* Note: This define must be a long, not a long long in order to compile
	without warnings for both 32bit and 64bit. */
#define CVMX_SCRATCH_BASE (-32768l) /* 0xffffffffffff8000 */

/* Scratch line for LMTST/LMTDMA on Octeon3 models */
#ifdef CVMX_CAVIUM_OCTEON3
#define CVMX_PKO_LMTLINE 2ull
#endif

/**
 * Reads an 8 bit value from the processor local scratchpad memory.
 *
 * @param address byte address to read from
 *
 * Return: value read
 */
static inline u8 cvmx_scratch_read8(u64 address)
{
	return *CASTPTR(volatile u8, CVMX_SCRATCH_BASE + address);
}

/**
 * Reads a 16 bit value from the processor local scratchpad memory.
 *
 * @param address byte address to read from
 *
 * Return: value read
 */
static inline u16 cvmx_scratch_read16(u64 address)
{
	return *CASTPTR(volatile u16, CVMX_SCRATCH_BASE + address);
}

/**
 * Reads a 32 bit value from the processor local scratchpad memory.
 *
 * @param address byte address to read from
 *
 * Return: value read
 */
static inline u32 cvmx_scratch_read32(u64 address)
{
	return *CASTPTR(volatile u32, CVMX_SCRATCH_BASE + address);
}

/**
 * Reads a 64 bit value from the processor local scratchpad memory.
 *
 * @param address byte address to read from
 *
 * Return: value read
 */
static inline u64 cvmx_scratch_read64(u64 address)
{
	return *CASTPTR(volatile u64, CVMX_SCRATCH_BASE + address);
}

/**
 * Writes an 8 bit value to the processor local scratchpad memory.
 *
 * @param address byte address to write to
 * @param value   value to write
 */
static inline void cvmx_scratch_write8(u64 address, u64 value)
{
	*CASTPTR(volatile u8, CVMX_SCRATCH_BASE + address) = (u8)value;
}

/**
 * Writes a 32 bit value to the processor local scratchpad memory.
 *
 * @param address byte address to write to
 * @param value   value to write
 */
static inline void cvmx_scratch_write16(u64 address, u64 value)
{
	*CASTPTR(volatile u16, CVMX_SCRATCH_BASE + address) = (u16)value;
}

/**
 * Writes a 16 bit value to the processor local scratchpad memory.
 *
 * @param address byte address to write to
 * @param value   value to write
 */
static inline void cvmx_scratch_write32(u64 address, u64 value)
{
	*CASTPTR(volatile u32, CVMX_SCRATCH_BASE + address) = (u32)value;
}

/**
 * Writes a 64 bit value to the processor local scratchpad memory.
 *
 * @param address byte address to write to
 * @param value   value to write
 */
static inline void cvmx_scratch_write64(u64 address, u64 value)
{
	*CASTPTR(volatile u64, CVMX_SCRATCH_BASE + address) = value;
}

#endif /* __CVMX_SCRATCH_H__ */