1/*
2 **************************************************************************
3 * Copyright (c) 2013, 2015 The Linux Foundation. All rights reserved.
4 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all copies.
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
13 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 **************************************************************************
15 */
16
17/**
18 * nss_regs.h
19 *	NSS register definitions.
20 */
21
22#ifndef __NSS_REGS_H
23#define __NSS_REGS_H
24
25#include <linux/types.h>
26#include <asm/io.h>
27
28/*
29 * CSM register offsets
30 */
31#define NSS_REGS_CORE_ID_OFFSET			0x0000
32#define NSS_REGS_RESET_CTRL_OFFSET		0x0004
33#define NSS_REGS_CORE_BAR_OFFSET		0x0008
34#define NSS_REGS_CORE_AMC_OFFSET		0x000c
35#define NSS_REGS_CORE_BOOT_ADDR_OFFSET		0x0010
36#define NSS_REGS_C2C_INTR_STATUS_OFFSET		0x0014
37#define NSS_REGS_C2C_INTR_SET_OFFSET		0x0018
38#define NSS_REGS_C2C_INTR_CLR_OFFSET		0x001c
39#define NSS_REGS_N2H_INTR_STATUS_OFFSET		0x0020
40#define NSS_REGS_N2H_INTR_SET_OFFSET		0x0024
41#define NSS_REGS_N2H_INTR_CLR_OFFSET		0x0028
42#define NSS_REGS_N2H_INTR_MASK_OFFSET		0x002c
43#define NSS_REGS_N2H_INTR_MASK_SET_OFFSET	0x0030
44#define NSS_REGS_N2H_INTR_MASK_CLR_OFFSET	0x0034
45#define NSS_REGS_CORE_INT_STAT0_TYPE_OFFSET	0x0038
46#define NSS_REGS_CORE_INT_STAT1_TYPE_OFFSET	0x003c
47#define NSS_REGS_CORE_INT_STAT2_TYPE_OFFSET	0x0040
48#define NSS_REGS_CORE_INT_STAT3_TYPE_OFFSET	0x0044
49#define NSS_REGS_CORE_IFETCH_RANGE_OFFSET	0x0048
50
51/*
52 * FPB register offsets
53 */
54#define NSS_REGS_FPB_CSR_CFG_OFFSET		0x0004
55
56/*
57 * Defines for N2H interrupts
58 *
59 * It is required to have 2 COREDUMP_COMPLETE interrupts because
60 * both NSS cores may generate interrupt simultaneously
61 */
62#define NSS_REGS_N2H_INTR_STATUS_EMPTY_BUFFER_QUEUE	(1 << 0)
63#define NSS_REGS_N2H_INTR_STATUS_DATA_COMMAND_QUEUE	(1 << 1)
64#define NSS_REGS_N2H_INTR_STATUS_DATA_QUEUE_1	    	(1 << 2)
65#define NSS_REGS_N2H_INTR_STATUS_EMPTY_BUFFERS_SOS	(1 << 10)
66#define NSS_REGS_N2H_INTR_STATUS_TX_UNBLOCKED		(1 << 11)
67#define NSS_REGS_N2H_INTR_STATUS_COREDUMP_COMPLETE_1	(1 << 13)
68#define NSS_REGS_N2H_INTR_STATUS_COREDUMP_COMPLETE_0	(1 << 14)
69
70/*
71 * Defines for H2N interrupts
72 */
73#define NSS_REGS_H2N_INTR_STATUS_EMPTY_BUFFER_QUEUE	(1 << 0)
74#define NSS_REGS_H2N_INTR_STATUS_DATA_COMMAND_QUEUE	(1 << 1)
75#define NSS_REGS_H2N_INTR_STATUS_RESET			(1 << 10)	/** Unused */
76#define NSS_REGS_H2N_INTR_STATUS_TX_UNBLOCKED		(1 << 11)
77#define NSS_REGS_H2N_INTR_STATUS_TRIGGER_COREDUMP	(1 << 15)
78
79/*
80 * clock source for NSS cores
81 */
82enum nss_regs_clk_src_select {
83	NSS_REGS_CLK_SRC_DEFAULT,
84	NSS_REGS_CLK_SRC_ALTERNATE
85};
86
87/*
88 * nss_read_32()
89 *	Read NSS register
90 */
91static inline uint32_t nss_read_32(uint32_t addr, uint32_t offs)
92{
93	return readl((void *)(addr + offs));
94}
95
96/*
97 * nss_write_32()
98 *	Write NSS register
99 */
100static inline void nss_write_32(uint32_t addr, uint32_t offs, uint32_t val)
101{
102	writel(val, (void *)(addr + offs));
103}
104
105#endif /* __NSS_REGS_H */
106