xref: /openbsd-src/sys/arch/loongson/include/autoconf.h (revision 77e35563a4c16e39b4b3a3bf8bdfcf7309c73848)
1*77e35563Svisa /*	$OpenBSD: autoconf.h,v 1.17 2017/05/21 13:00:53 visa Exp $ */
24c7dc0caSmiod 
34c7dc0caSmiod /*
44c7dc0caSmiod  * Copyright (c) 2001-2003 Opsycon AB  (www.opsycon.se / www.opsycon.com)
54c7dc0caSmiod  *
64c7dc0caSmiod  * Redistribution and use in source and binary forms, with or without
74c7dc0caSmiod  * modification, are permitted provided that the following conditions
84c7dc0caSmiod  * are met:
94c7dc0caSmiod  * 1. Redistributions of source code must retain the above copyright
104c7dc0caSmiod  *    notice, this list of conditions and the following disclaimer.
114c7dc0caSmiod  * 2. Redistributions in binary form must reproduce the above copyright
124c7dc0caSmiod  *    notice, this list of conditions and the following disclaimer in the
134c7dc0caSmiod  *    documentation and/or other materials provided with the distribution.
144c7dc0caSmiod  *
154c7dc0caSmiod  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
164c7dc0caSmiod  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
174c7dc0caSmiod  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
184c7dc0caSmiod  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
194c7dc0caSmiod  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
204c7dc0caSmiod  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
214c7dc0caSmiod  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
224c7dc0caSmiod  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
234c7dc0caSmiod  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
244c7dc0caSmiod  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
254c7dc0caSmiod  * SUCH DAMAGE.
264c7dc0caSmiod  *
274c7dc0caSmiod  */
284c7dc0caSmiod 
294c7dc0caSmiod /*
304c7dc0caSmiod  * Definitions used by autoconfiguration.
314c7dc0caSmiod  */
324c7dc0caSmiod 
334c7dc0caSmiod #ifndef _MACHINE_AUTOCONF_H_
344c7dc0caSmiod #define _MACHINE_AUTOCONF_H_
354c7dc0caSmiod 
364c7dc0caSmiod #include <machine/bus.h>
374c7dc0caSmiod 
38e1844cd9Smiod struct bonito_config;
39565153a0Svisa struct htb_config;
40d57a735dSmiod struct mips_isa_chipset;
41e1844cd9Smiod 
424c7dc0caSmiod /*
4351b07be5Smiod  * List of legacy I/O ranges.
444c7dc0caSmiod  */
4551b07be5Smiod struct legacy_io_range {
4651b07be5Smiod 	bus_addr_t	start;
4751b07be5Smiod 	bus_size_t	end;	/* inclusive */
484c7dc0caSmiod };
494c7dc0caSmiod 
5051b07be5Smiod /*
5151b07be5Smiod  * Per platform information.
5251b07be5Smiod  */
5351b07be5Smiod struct platform {
5451b07be5Smiod 	int				 system_type;
55e07ee38fSmiod #define	LOONGSON_2E		0x0000	/* Generic Loongson 2E system */
56e07ee38fSmiod #define	LOONGSON_YEELOONG	0x0001	/* Lemote Yeeloong */
57e07ee38fSmiod #define	LOONGSON_GDIUM		0x0002	/* EMTEC Gdium Liberty */
58e07ee38fSmiod #define	LOONGSON_FULOONG	0x0003	/* Lemote Fuloong */
59e07ee38fSmiod #define	LOONGSON_LYNLOONG	0x0004	/* Lemote Lynloong */
60e07ee38fSmiod #define	LOONGSON_EBT700		0x0005	/* eBenton EBT700 */
616f377552Smiod #define	LOONGSON_3A		0x0066	/* Loongson 2Gq or 3A based system */
62e07ee38fSmiod 
6351b07be5Smiod 	char				*vendor;
6451b07be5Smiod 	char				*product;
6551b07be5Smiod 
6651b07be5Smiod 	const struct bonito_config	*bonito_config;
67565153a0Svisa 	const struct htb_config		*htb_config;
68d57a735dSmiod 	struct mips_isa_chipset		*isa_chipset;
6951b07be5Smiod 	const struct legacy_io_range	*legacy_io_ranges;
7051b07be5Smiod 
718a850467Smiod 	void				(*setup)(void);
72f9a4f028Smiod 	void				(*device_register)(struct device *,
73f9a4f028Smiod 					    void *);
74f9a4f028Smiod 
7551b07be5Smiod 	void				(*powerdown)(void);
768a850467Smiod 	void				(*reset)(void);
77bec266e2Spirofti 	int				(*suspend)(void);
78bec266e2Spirofti 	int				(*resume)(void);
7939de0dfdSvisa 
8039de0dfdSvisa #ifdef MULTIPROCESSOR
8139de0dfdSvisa 	void				(*config_secondary_cpus)(
8239de0dfdSvisa 					    struct device *, cfprint_t);
8339de0dfdSvisa 	void				(*boot_secondary_cpu)(
8439de0dfdSvisa 					    struct cpu_info *);
8539de0dfdSvisa 	int				(*ipi_establish)(int (*)(void *),
8639de0dfdSvisa 					    cpuid_t);
8739de0dfdSvisa 	void				(*ipi_set)(cpuid_t);
8839de0dfdSvisa 	void				(*ipi_clear)(cpuid_t);
8939de0dfdSvisa #endif /* MULTIPROCESSOR */
9051b07be5Smiod };
9151b07be5Smiod 
923485d230Svisa #define LOONGSON_MAXCPUS	16
933485d230Svisa 
9451b07be5Smiod extern const struct platform *sys_platform;
95*77e35563Svisa extern void *loongson_videobios;
963485d230Svisa extern uint loongson_cpumask;
97d57a735dSmiod extern uint loongson_ver;
983485d230Svisa extern int nnodes;
994c7dc0caSmiod 
100e8637625Svisa #ifdef MULTIPROCESSOR
101e8637625Svisa extern uint64_t cpu_spinup_a0;
102e8637625Svisa extern uint64_t cpu_spinup_sp;
103e8637625Svisa #endif
104e8637625Svisa 
1054c7dc0caSmiod struct mainbus_attach_args {
1064c7dc0caSmiod 	const char	*maa_name;
1074c7dc0caSmiod };
1084c7dc0caSmiod 
109f9a4f028Smiod extern struct device *bootdv;
110f9a4f028Smiod extern char bootdev[];
111f9a4f028Smiod extern enum devclass bootdev_class;
112f9a4f028Smiod 
11303052511Smiod extern bus_space_tag_t early_mem_t;
11403052511Smiod extern bus_space_tag_t early_io_t;
11503052511Smiod 
11680500071Svisa #define	REGVAL8(x)	*((volatile uint8_t *)PHYS_TO_XKPHYS((x), CCA_NC))
11780500071Svisa #define	REGVAL32(x)	*((volatile uint32_t *)PHYS_TO_XKPHYS((x), CCA_NC))
11880500071Svisa #define	REGVAL64(x)	*((volatile uint64_t *)PHYS_TO_XKPHYS((x), CCA_NC))
11980500071Svisa 
12080500071Svisa #define	REGVAL(x)	REGVAL32(x)
12180500071Svisa 
122c301e791Smiod #include <mips64/autoconf.h>
123c301e791Smiod 
1244c7dc0caSmiod #endif /* _MACHINE_AUTOCONF_H_ */
125