xref: /openbsd/sys/arch/macppc/macppc/ofw_machdep.h (revision dcf4ae46)
1 /*	$OpenBSD: ofw_machdep.h,v 1.10 2020/04/02 19:27:51 gkoehler Exp $	*/
2 
3 /*
4  * Copyright (c) 2002, Miodrag Vallat.
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
16  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  */
28 
29 #include <machine/cpu.h>
30 #include <machine/psl.h>
31 
32 extern int cons_backlight_available;
33 
34 void ofwconprobe(void);
35 
36 struct rasops_info;
37 void ofwconsswitch(struct rasops_info *);
38 
39 /*
40  * For some reason, setting the brightness under 0x29 from OF switches the
41  * backlight off, and it won't be switched on again until you set the
42  * brightness above 0x33.  All hail hysteresis! -- miod
43  */
44 #define	MIN_BRIGHTNESS		0x34
45 #define	MAX_BRIGHTNESS		0xff
46 #define	STEP_BRIGHTNESS		8
47 #define	DEFAULT_BRIGHTNESS	0x80
48 extern int cons_brightness;
49 
50 void of_setbacklight(int);
51 void of_setbrightness(int);
52 void of_setcolors(const uint8_t *, unsigned int, unsigned int);
53 
54 void OF_quiesce(void);
55 
56 static inline uint32_t
ofw_msr(void)57 ofw_msr(void)
58 {
59 	uint32_t s = ppc_mfmsr();
60 
61 	ppc_mtmsr(s & ~(PSL_EE|PSL_RI)); /* turn off interrupts */
62 	return s;
63 }
64