Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/arm/mv/mvvar.h
39507 views
1
/*-
2
* SPDX-License-Identifier: BSD-2-Clause
3
*
4
* Copyright (c) 2002, 2003 Wasabi Systems, Inc.
5
* All rights reserved.
6
*
7
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
8
*
9
* Redistribution and use in source and binary forms, with or without
10
* modification, are permitted provided that the following conditions
11
* are met:
12
* 1. Redistributions of source code must retain the above copyright
13
* notice, this list of conditions and the following disclaimer.
14
* 2. Redistributions in binary form must reproduce the above copyright
15
* notice, this list of conditions and the following disclaimer in the
16
* documentation and/or other materials provided with the distribution.
17
* 3. All advertising materials mentioning features or use of this software
18
* must display the following acknowledgement:
19
* This product includes software developed for the NetBSD Project by
20
* Wasabi Systems, Inc.
21
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
22
* or promote products derived from this software without specific prior
23
* written permission.
24
*
25
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
* POSSIBILITY OF SUCH DAMAGE.
36
*
37
* from: FreeBSD: //depot/projects/arm/src/sys/arm/xscale/pxa2x0/pxa2x0var.h, rev 1
38
*/
39
40
#ifndef _MVVAR_H_
41
#define _MVVAR_H_
42
43
#include <sys/rman.h>
44
#include <machine/bus.h>
45
#include <vm/vm.h>
46
#include <vm/pmap.h>
47
48
#include <dev/ofw/openfirm.h>
49
50
#define MV_TYPE_PCI 0
51
#define MV_TYPE_PCIE 1
52
53
#define MV_MODE_ENDPOINT 0
54
#define MV_MODE_ROOT 1
55
56
enum soc_family{
57
MV_SOC_ARMADA_38X = 0x00,
58
MV_SOC_ARMADA_XP = 0x01,
59
MV_SOC_UNSUPPORTED = 0xff,
60
};
61
62
struct gpio_config {
63
int gc_gpio; /* GPIO number */
64
uint32_t gc_flags; /* GPIO flags */
65
int gc_output; /* GPIO output value */
66
};
67
68
struct decode_win {
69
int target; /* Mbus unit ID */
70
int attr; /* Attributes of the target interface */
71
vm_paddr_t base; /* Physical base addr */
72
uint32_t size;
73
vm_paddr_t remap;
74
};
75
76
extern const struct gpio_config mv_gpio_config[];
77
extern const struct decode_win *cpu_wins;
78
extern const struct decode_win *idma_wins;
79
extern const struct decode_win *xor_wins;
80
extern int idma_wins_no;
81
extern int xor_wins_no;
82
83
extern vm_paddr_t fdt_immr_pa;
84
extern vm_offset_t fdt_immr_va;
85
86
int soc_decode_win(void);
87
void soc_id(uint32_t *dev, uint32_t *rev);
88
void soc_dump_decode_win(void);
89
void soc_power_ctrl_set(uint32_t mask);
90
91
int decode_win_cpu_set(int target, int attr, vm_paddr_t base, uint32_t size,
92
vm_paddr_t remap);
93
int decode_win_overlap(int, int, const struct decode_win *);
94
int win_cpu_can_remap(int);
95
void decode_win_pcie_setup(u_long);
96
97
void ddr_disable(int i);
98
int ddr_is_active(int i);
99
uint32_t ddr_base(int i);
100
uint32_t ddr_size(int i);
101
uint32_t ddr_attr(int i);
102
103
uint32_t get_tclk(void);
104
uint32_t get_cpu_freq(void);
105
uint32_t read_cpu_ctrl(uint32_t);
106
void write_cpu_ctrl(uint32_t, uint32_t);
107
108
uint32_t read_cpu_mp_clocks(uint32_t reg);
109
void write_cpu_mp_clocks(uint32_t reg, uint32_t val);
110
uint32_t read_cpu_misc(uint32_t reg);
111
void write_cpu_misc(uint32_t reg, uint32_t val);
112
113
int mv_pcib_bar_win_set(device_t dev, uint32_t base, uint32_t size,
114
uint32_t remap, int winno, int busno);
115
int mv_pcib_cpu_win_remap(device_t dev, uint32_t remap, uint32_t size);
116
117
void mv_mask_endpoint_irq(uintptr_t nb, int unit);
118
void mv_unmask_endpoint_irq(uintptr_t nb, int unit);
119
120
int mv_drbl_get_next_irq(int dir, int unit);
121
void mv_drbl_mask_all(int unit);
122
void mv_drbl_mask_irq(uint32_t irq, int dir, int unit);
123
void mv_drbl_unmask_irq(uint32_t irq, int dir, int unit);
124
void mv_drbl_set_mask(uint32_t val, int dir, int unit);
125
uint32_t mv_drbl_get_mask(int dir, int unit);
126
void mv_drbl_set_cause(uint32_t val, int dir, int unit);
127
uint32_t mv_drbl_get_cause(int dir, int unit);
128
void mv_drbl_set_msg(uint32_t val, int mnr, int dir, int unit);
129
uint32_t mv_drbl_get_msg(int mnr, int dir, int unit);
130
131
int mv_msi_data(int irq, uint64_t *addr, uint32_t *data);
132
133
struct devmap_entry;
134
135
int mv_pci_devmap(phandle_t, struct devmap_entry *, vm_offset_t,
136
vm_offset_t);
137
int fdt_localbus_devmap(phandle_t, struct devmap_entry *, int, int *);
138
enum soc_family mv_check_soc_family(void);
139
140
int mv_fdt_is_type(phandle_t, const char *);
141
int mv_fdt_pm(phandle_t);
142
143
uint32_t get_tclk_armadaxp(void);
144
uint32_t get_tclk_armada38x(void);
145
uint32_t get_cpu_freq_armadaxp(void);
146
uint32_t get_cpu_freq_armada38x(void);
147
#endif /* _MVVAR_H_ */
148
149