xref: /netbsd-src/sys/arch/arm/marvell/mvsocvar.h (revision 7d0ac4467565b841a7bc4dbb6b1acb8fec22b511)
1 /*	$NetBSD: mvsocvar.h,v 1.13 2021/08/30 00:04:30 rin Exp $	*/
2 /*
3  * Copyright (c) 2007, 2010 KIYOHARA Takashi
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef _MVSOCVAR_H_
29 #define _MVSOCVAR_H_
30 
31 #include <sys/bus.h>
32 
33 struct mvsoc_softc {
34         device_t sc_dev;
35 
36 	bus_addr_t sc_addr;
37 	bus_space_tag_t sc_iot;
38 	bus_space_handle_t sc_ioh;
39 	bus_dma_tag_t sc_dmat;
40 };
41 
42 typedef int (*mvsoc_irq_handler_t)(void *);
43 
44 extern uint32_t mvPclk, mvSysclk, mvTclk;
45 extern vaddr_t mlmb_base;
46 extern int nwindow, nremap;
47 extern int gpp_npins, gpp_irqbase;
48 extern struct bus_space mvsoc_bs_tag;
49 extern struct arm32_bus_dma_tag mvsoc_bus_dma_tag;
50 
51 #define read_mlmbreg(o)		\
52     le32toh(*(volatile uint32_t *)(mlmb_base + (o)))
53 #define write_mlmbreg(o, v)	\
54     (*(volatile uint32_t *)(mlmb_base + (o)) = htole32(v))
55 
56 void mvsoc_bootstrap(bus_addr_t);
57 uint16_t mvsoc_model(void);
58 uint8_t mvsoc_rev(void);
59 void *mvsoc_bridge_intr_establish(int, int, int (*)(void *), void *);
60 
61 #include <dev/marvell/marvellvar.h>
62 
63 enum mvsoc_tags {
64 	MVSOC_TAG_INTERNALREG  = MARVELL_TAG_MAX,
65 
66 	ORION_TAG_PEX0_MEM,
67 	ORION_TAG_PEX0_IO,
68 	ORION_TAG_PEX1_MEM,
69 	ORION_TAG_PEX1_IO,
70 	ORION_TAG_PCI_MEM,
71 	ORION_TAG_PCI_IO,
72 	ORION_TAG_DEVICE_CS0,
73 	ORION_TAG_DEVICE_CS1,
74 	ORION_TAG_DEVICE_CS2,
75 	ORION_TAG_FLASH_CS,
76 	ORION_TAG_DEVICE_BOOTCS,
77 	ORION_TAG_CRYPT,
78 
79 	KIRKWOOD_TAG_PEX_MEM,
80 	KIRKWOOD_TAG_PEX_IO,
81 	KIRKWOOD_TAG_PEX1_MEM,
82 	KIRKWOOD_TAG_PEX1_IO,
83 	KIRKWOOD_TAG_NAND,
84 	KIRKWOOD_TAG_SPI,
85 	KIRKWOOD_TAG_BOOTROM,
86 	KIRKWOOD_TAG_CRYPT,
87 
88 	MV78XX0_TAG_DEVICE_CS0,
89 	MV78XX0_TAG_DEVICE_CS1,
90 	MV78XX0_TAG_DEVICE_CS2,
91 	MV78XX0_TAG_DEVICE_CS3,
92 	MV78XX0_TAG_DEVICE_BOOTCS,
93 	MV78XX0_TAG_SPI,
94 	MV78XX0_TAG_PEX0_MEM,
95 	MV78XX0_TAG_PEX01_MEM,
96 	MV78XX0_TAG_PEX02_MEM,
97 	MV78XX0_TAG_PEX03_MEM,
98 	MV78XX0_TAG_PEX0_IO,
99 	MV78XX0_TAG_PEX01_IO,
100 	MV78XX0_TAG_PEX02_IO,
101 	MV78XX0_TAG_PEX03_IO,
102 	MV78XX0_TAG_PEX1_MEM,
103 	MV78XX0_TAG_PEX11_MEM,
104 	MV78XX0_TAG_PEX12_MEM,
105 	MV78XX0_TAG_PEX13_MEM,
106 	MV78XX0_TAG_PEX1_IO,
107 	MV78XX0_TAG_PEX11_IO,
108 	MV78XX0_TAG_PEX12_IO,
109 	MV78XX0_TAG_PEX13_IO,
110 	MV78XX0_TAG_CRYPT,
111 
112 	DOVE_TAG_PEX0_MEM,
113 	DOVE_TAG_PEX0_IO,
114 	DOVE_TAG_PEX1_MEM,
115 	DOVE_TAG_PEX1_IO,
116 	DOVE_TAG_CRYPT,
117 	DOVE_TAG_SPI0,
118 	DOVE_TAG_SPI1,
119 	DOVE_TAG_BOOTROM,
120 	DOVE_TAG_NAND,
121 	DOVE_TAG_PMU,
122 
123 	ARMADAXP_TAG_PEX00_MEM,
124 	ARMADAXP_TAG_PEX00_IO,
125 	ARMADAXP_TAG_PEX01_MEM,
126 	ARMADAXP_TAG_PEX01_IO,
127 	ARMADAXP_TAG_PEX02_MEM,
128 	ARMADAXP_TAG_PEX02_IO,
129 	ARMADAXP_TAG_PEX03_MEM,
130 	ARMADAXP_TAG_PEX03_IO,
131 	ARMADAXP_TAG_PEX10_MEM,
132 	ARMADAXP_TAG_PEX10_IO,
133 	ARMADAXP_TAG_PEX11_MEM,
134 	ARMADAXP_TAG_PEX11_IO,
135 	ARMADAXP_TAG_PEX12_MEM,
136 	ARMADAXP_TAG_PEX12_IO,
137 	ARMADAXP_TAG_PEX13_MEM,
138 	ARMADAXP_TAG_PEX13_IO,
139 	ARMADAXP_TAG_PEX2_MEM,
140 	ARMADAXP_TAG_PEX2_IO,
141 	ARMADAXP_TAG_PEX3_MEM,
142 	ARMADAXP_TAG_PEX3_IO,
143 	ARMADAXP_TAG_CRYPT0,
144 	ARMADAXP_TAG_CRYPT1,
145 };
146 int mvsoc_target(int, uint32_t *, uint32_t *, uint32_t *, uint32_t *);
147 int mvsoc_target_dump(struct mvsoc_softc *);
148 int mvsoc_attr_dump(struct mvsoc_softc *, uint32_t, uint32_t);
149 
150 extern void (*mvsoc_intr_init)(void);
151 extern int (*mvsoc_clkgating)(struct marvell_attach_args *);
152 
153 void orion_bootstrap(vaddr_t);
154 void kirkwood_bootstrap(vaddr_t);
155 void mv78xx0_bootstrap(vaddr_t);
156 void dove_bootstrap(vaddr_t);
157 void armadaxp_bootstrap(vaddr_t, bus_addr_t);
158 
159 #endif	/* _MVSOCVAR_H_ */
160