xref: /freebsd/sys/arm/freescale/imx/imx6_pl310.c (revision 6ef6ba9950260f42b47499d17874d00ca9290955)
1 /*-
2  * Copyright (c) 2012 Olivier Houchard.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #include <sys/cdefs.h>
27 __FBSDID("$FreeBSD$");
28 
29 /*
30  * The machine-dependent part of the arm/pl310 driver for imx6 SoCs.
31  */
32 
33 #include <sys/types.h>
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/bus.h>
37 #include <sys/rman.h>
38 #include <sys/lock.h>
39 #include <sys/mutex.h>
40 
41 #include <machine/bus.h>
42 #include <machine/pl310.h>
43 
44 void
45 platform_pl310_init(struct pl310_softc *sc)
46 {
47 	uint32_t aux, prefetch;
48 
49 	aux = pl310_read4(sc, PL310_AUX_CTRL);
50 	prefetch = pl310_read4(sc, PL310_PREFETCH_CTRL);
51 
52 	if (bootverbose) {
53 		device_printf(sc->sc_dev, "Early BRESP response: %s\n",
54 			(aux & AUX_CTRL_EARLY_BRESP) ? "enabled" : "disabled");
55 		device_printf(sc->sc_dev, "Instruction prefetch: %s\n",
56 			(aux & AUX_CTRL_INSTR_PREFETCH) ? "enabled" : "disabled");
57 		device_printf(sc->sc_dev, "Data prefetch: %s\n",
58 			(aux & AUX_CTRL_DATA_PREFETCH) ? "enabled" : "disabled");
59 		device_printf(sc->sc_dev, "Non-secure interrupt control: %s\n",
60 			(aux & AUX_CTRL_NS_INT_CTRL) ? "enabled" : "disabled");
61 		device_printf(sc->sc_dev, "Non-secure lockdown: %s\n",
62 			(aux & AUX_CTRL_NS_LOCKDOWN) ? "enabled" : "disabled");
63 		device_printf(sc->sc_dev, "Share override: %s\n",
64 			(aux & AUX_CTRL_SHARE_OVERRIDE) ? "enabled" : "disabled");
65 
66 		device_printf(sc->sc_dev, "Double linefil: %s\n",
67 			(prefetch & PREFETCH_CTRL_DL) ? "enabled" : "disabled");
68 		device_printf(sc->sc_dev, "Instruction prefetch: %s\n",
69 			(prefetch & PREFETCH_CTRL_INSTR_PREFETCH) ? "enabled" : "disabled");
70 		device_printf(sc->sc_dev, "Data prefetch: %s\n",
71 			(prefetch & PREFETCH_CTRL_DATA_PREFETCH) ? "enabled" : "disabled");
72 		device_printf(sc->sc_dev, "Double linefill on WRAP request: %s\n",
73 			(prefetch & PREFETCH_CTRL_DL_ON_WRAP) ? "enabled" : "disabled");
74 		device_printf(sc->sc_dev, "Prefetch drop: %s\n",
75 			(prefetch & PREFETCH_CTRL_PREFETCH_DROP) ? "enabled" : "disabled");
76 		device_printf(sc->sc_dev, "Incr double Linefill: %s\n",
77 			(prefetch & PREFETCH_CTRL_INCR_DL) ? "enabled" : "disabled");
78 		device_printf(sc->sc_dev, "Not same ID on exclusive sequence: %s\n",
79 			(prefetch & PREFETCH_CTRL_NOTSAMEID) ? "enabled" : "disabled");
80 		device_printf(sc->sc_dev, "Prefetch offset: %d\n",
81 			(prefetch & PREFETCH_CTRL_OFFSET_MASK));
82 	}
83 }
84 
85 void
86 platform_pl310_write_ctrl(struct pl310_softc *sc, uint32_t val)
87 {
88 
89 	pl310_write4(sc, PL310_CTRL, val);
90 }
91 
92 void
93 platform_pl310_write_debug(struct pl310_softc *sc, uint32_t val)
94 {
95 
96 	pl310_write4(sc, PL310_DEBUG_CTRL, val);
97 }
98 
99