xref: /netbsd-src/sys/arch/powerpc/include/ibm4xx/cpu.h (revision 695ec7bba4e9b5bc280f47d0c4d4cf4dc1ce36eb)
1*695ec7bbSryo /*	$NetBSD: cpu.h,v 1.27 2021/11/02 11:21:24 ryo Exp $	*/
2a3833eb1Seeh 
3a3833eb1Seeh /*
4a3833eb1Seeh  * Copyright 2002 Wasabi Systems, Inc.
5a3833eb1Seeh  * All rights reserved.
6a3833eb1Seeh  *
7a3833eb1Seeh  * Written by Eduardo Horvath for Wasabi Systems, Inc.
8a3833eb1Seeh  *
9a3833eb1Seeh  * Redistribution and use in source and binary forms, with or without
10a3833eb1Seeh  * modification, are permitted provided that the following conditions
11a3833eb1Seeh  * are met:
12a3833eb1Seeh  * 1. Redistributions of source code must retain the above copyright
13a3833eb1Seeh  *    notice, this list of conditions and the following disclaimer.
14a3833eb1Seeh  * 2. Redistributions in binary form must reproduce the above copyright
15a3833eb1Seeh  *    notice, this list of conditions and the following disclaimer in the
16a3833eb1Seeh  *    documentation and/or other materials provided with the distribution.
17a3833eb1Seeh  * 3. All advertising materials mentioning features or use of this software
18a3833eb1Seeh  *    must display the following acknowledgement:
19a3833eb1Seeh  *      This product includes software developed for the NetBSD Project by
20a3833eb1Seeh  *      Wasabi Systems, Inc.
21a3833eb1Seeh  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22a3833eb1Seeh  *    or promote products derived from this software without specific prior
23a3833eb1Seeh  *    written permission.
24a3833eb1Seeh  *
25a3833eb1Seeh  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26a3833eb1Seeh  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27a3833eb1Seeh  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28a3833eb1Seeh  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
29a3833eb1Seeh  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30a3833eb1Seeh  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31a3833eb1Seeh  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32a3833eb1Seeh  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33a3833eb1Seeh  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34a3833eb1Seeh  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35a3833eb1Seeh  * POSSIBILITY OF SUCH DAMAGE.
36a3833eb1Seeh  */
37a3833eb1Seeh 
38a3833eb1Seeh #ifndef	_IBM4XX_CPU_H_
39a3833eb1Seeh #define	_IBM4XX_CPU_H_
40a3833eb1Seeh 
41b1b36fc1Ssimonb #ifdef _KERNEL_OPT
42b1b36fc1Ssimonb #include "opt_param.h"
43b1b36fc1Ssimonb #endif
44b1b36fc1Ssimonb 
4510c6a9d2Smatt #include <powerpc/psl.h>
46b8ea2c8cSmatt #include <powerpc/spr.h>
47b8ea2c8cSmatt #include <powerpc/ibm4xx/spr.h>
48b8ea2c8cSmatt #include <powerpc/ibm4xx/dcr4xx.h>
49b8ea2c8cSmatt 
50a3833eb1Seeh #if defined(_KERNEL)
51dba36e03Smatt struct exc_info {
52dba36e03Smatt 	vaddr_t exc_vector;
53dba36e03Smatt 	const uint32_t *exc_addr;
54dba36e03Smatt 	uintptr_t exc_size;
55dba36e03Smatt };
56dba36e03Smatt 
5749c3c144Sshige #include <sys/param.h>
5849c3c144Sshige #include <sys/device.h>
59fb44a857Sthorpej #include <prop/proplib.h>
6049c3c144Sshige 
6149c3c144Sshige /* export from ibm4xx/autoconf.c */
62036ca983Smatt extern void (*md_device_register)(device_t dev, void *aux);
6349c3c144Sshige 
6495b24072Sshige /* export from ibm4xx/machdep.c */
6502cdf4d2Sdsl extern void (*md_consinit)(void);
6602cdf4d2Sdsl extern void (*md_cpu_startup)(void);
6795b24072Sshige 
6895b24072Sshige /* export from ibm4xx/ibm40x_machdep.c */
6995b24072Sshige extern void ibm40x_memsize_init(u_int, u_int);
7095b24072Sshige 
7195b24072Sshige /* export from ibm4xx/ibm4xx_machdep.c */
72dba36e03Smatt extern void ibm4xx_init(vaddr_t, vaddr_t, void (*)(void));
7395b24072Sshige extern void ibm4xx_cpu_startup(const char *);
7495b24072Sshige extern void ibm4xx_dumpsys(void);
7595b24072Sshige extern void ibm4xx_install_extint(void (*)(void));
7695b24072Sshige 
7749c3c144Sshige /* export from ibm4xx/ibm4xx_autoconf.c */
7836cc5934Srin extern void ibm4xx_device_register(device_t, void *, int);
7949c3c144Sshige 
809704ef24Sshige /* export from ibm4xx/clock.c */
8195b24072Sshige extern void calc_delayconst(void);
829704ef24Sshige 
839704ef24Sshige /* export from ibm4xx/4xx_locore.S */
84b8ea2c8cSmatt extern void ppc4xx_reset(void) __dead;
8595b24072Sshige 
86dba36e03Smatt extern void intr_init(void);
87dba36e03Smatt 
88b8ea2c8cSmatt /*
89b8ea2c8cSmatt  * DCR (Device Control Register) access. These have to be
90b8ea2c8cSmatt  * macros because register address is encoded as immediate
91b8ea2c8cSmatt  * operand.
92b8ea2c8cSmatt  */
93*695ec7bbSryo static __inline __always_inline void
mtdcr(const int reg,uint32_t val)94*695ec7bbSryo mtdcr(const int reg, uint32_t val)
95b8ea2c8cSmatt {
96b8ea2c8cSmatt 	__asm volatile("mtdcr %0,%1" : : "K"(reg), "r"(val));
97b8ea2c8cSmatt }
98b8ea2c8cSmatt 
99*695ec7bbSryo static __inline __always_inline uint32_t
mfdcr(const int reg)100*695ec7bbSryo mfdcr(const int reg)
101b8ea2c8cSmatt {
102b8ea2c8cSmatt 	uint32_t val;
103b8ea2c8cSmatt 
104b8ea2c8cSmatt 	__asm volatile("mfdcr %0,%1" : "=r"(val) : "K"(reg));
105b8ea2c8cSmatt 	return val;
106b8ea2c8cSmatt }
107b8ea2c8cSmatt 
10887fd18f8Schristos static __inline void
mtcpr(int reg,uint32_t val)109b8ea2c8cSmatt mtcpr(int reg, uint32_t val)
110b8ea2c8cSmatt {
111b8ea2c8cSmatt 	mtdcr(DCR_CPR0_CFGADDR, reg);
112b8ea2c8cSmatt 	mtdcr(DCR_CPR0_CFGDATA, val);
113b8ea2c8cSmatt }
114b8ea2c8cSmatt 
11587fd18f8Schristos static __inline uint32_t
mfcpr(int reg)116b8ea2c8cSmatt mfcpr(int reg)
117b8ea2c8cSmatt {
118b8ea2c8cSmatt 	mtdcr(DCR_CPR0_CFGADDR, reg);
119b8ea2c8cSmatt 	return mfdcr(DCR_CPR0_CFGDATA);
120b8ea2c8cSmatt }
121b8ea2c8cSmatt 
122b8ea2c8cSmatt static void inline
mtsdr(int reg,uint32_t val)123b8ea2c8cSmatt mtsdr(int reg, uint32_t val)
124b8ea2c8cSmatt {
125b8ea2c8cSmatt 	mtdcr(DCR_SDR0_CFGADDR, reg);
126b8ea2c8cSmatt 	mtdcr(DCR_SDR0_CFGDATA, val);
127b8ea2c8cSmatt }
128b8ea2c8cSmatt 
12987fd18f8Schristos static __inline uint32_t
mfsdr(int reg)130b8ea2c8cSmatt mfsdr(int reg)
131b8ea2c8cSmatt {
132b8ea2c8cSmatt 	mtdcr(DCR_SDR0_CFGADDR, reg);
133b8ea2c8cSmatt 	return mfdcr(DCR_SDR0_CFGDATA);
134b8ea2c8cSmatt }
135dba36e03Smatt 
136dba36e03Smatt #include <powerpc/pic/picvar.h>
137dba36e03Smatt 
138dba36e03Smatt extern struct pic_ops pic_uic403;
139dba36e03Smatt extern struct pic_ops pic_uic0;
140dba36e03Smatt extern struct pic_ops pic_uic1;
141dba36e03Smatt extern struct pic_ops pic_uic2;
142234c45d0Smatt 
143234c45d0Smatt extern paddr_t msgbuf_paddr;
144234c45d0Smatt extern vaddr_t msgbuf_vaddr;
145234c45d0Smatt extern char msgbuf[MSGBUFSIZE];
146a3833eb1Seeh #endif /* _KERNEL */
147a3833eb1Seeh 
148fb44a857Sthorpej /* Board info dictionary */
149fb44a857Sthorpej extern prop_dictionary_t board_properties;
150ce880a59Sshige extern void board_info_init(void);
151ce880a59Sshige 
152a3833eb1Seeh #endif	/* _IBM4XX_CPU_H_ */
153