diff options
author | Andriy Skulysh <askulysh@gmail.com> | 2006-09-27 03:20:22 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2006-09-27 03:20:22 -0400 |
commit | 3aa770e7972723f479122cf66b529017d2175289 (patch) | |
tree | f70d870381cec8034693704e346c53b311db688f /include | |
parent | ef48e8e3498605351f91f195cc9af0ef981b0dde (diff) |
sh: APM/PM support.
This adds some simple PM stubs and the basic APM interfaces,
primarily for use by hp6xx, where the existing userland
expects it.
Signed-off-by: Andriy Skulysh <askulysh@gmail.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-sh/apm.h | 46 | ||||
-rw-r--r-- | include/asm-sh/cpu-sh3/freq.h | 4 | ||||
-rw-r--r-- | include/asm-sh/hd64461.h | 7 | ||||
-rw-r--r-- | include/asm-sh/hp6xx/hp6xx.h | 53 | ||||
-rw-r--r-- | include/asm-sh/pm.h | 17 | ||||
-rw-r--r-- | include/asm-sh/system.h | 25 | ||||
-rw-r--r-- | include/asm-sh/timer.h | 2 |
7 files changed, 151 insertions, 3 deletions
diff --git a/include/asm-sh/apm.h b/include/asm-sh/apm.h new file mode 100644 index 000000000000..8b091e93651f --- /dev/null +++ b/include/asm-sh/apm.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * Copyright 2006 (c) Andriy Skulysh <askulysh@gmail.com> | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | #ifndef __ASM_SH_APM_H | ||
11 | #define __ASM_SH_APM_H | ||
12 | |||
13 | #define APM_AC_OFFLINE 0 | ||
14 | #define APM_AC_ONLINE 1 | ||
15 | #define APM_AC_BACKUP 2 | ||
16 | #define APM_AC_UNKNOWN 0xff | ||
17 | |||
18 | #define APM_BATTERY_STATUS_HIGH 0 | ||
19 | #define APM_BATTERY_STATUS_LOW 1 | ||
20 | #define APM_BATTERY_STATUS_CRITICAL 2 | ||
21 | #define APM_BATTERY_STATUS_CHARGING 3 | ||
22 | #define APM_BATTERY_STATUS_NOT_PRESENT 4 | ||
23 | #define APM_BATTERY_STATUS_UNKNOWN 0xff | ||
24 | |||
25 | #define APM_BATTERY_LIFE_UNKNOWN 0xFFFF | ||
26 | #define APM_BATTERY_LIFE_MINUTES 0x8000 | ||
27 | #define APM_BATTERY_LIFE_VALUE_MASK 0x7FFF | ||
28 | |||
29 | #define APM_BATTERY_FLAG_HIGH (1 << 0) | ||
30 | #define APM_BATTERY_FLAG_LOW (1 << 1) | ||
31 | #define APM_BATTERY_FLAG_CRITICAL (1 << 2) | ||
32 | #define APM_BATTERY_FLAG_CHARGING (1 << 3) | ||
33 | #define APM_BATTERY_FLAG_NOT_PRESENT (1 << 7) | ||
34 | #define APM_BATTERY_FLAG_UNKNOWN 0xff | ||
35 | |||
36 | #define APM_UNITS_MINS 0 | ||
37 | #define APM_UNITS_SECS 1 | ||
38 | #define APM_UNITS_UNKNOWN -1 | ||
39 | |||
40 | |||
41 | extern int (*apm_get_info)(char *buf, char **start, off_t fpos, int length); | ||
42 | extern int apm_suspended; | ||
43 | |||
44 | void apm_queue_event(apm_event_t event); | ||
45 | |||
46 | #endif | ||
diff --git a/include/asm-sh/cpu-sh3/freq.h b/include/asm-sh/cpu-sh3/freq.h index b61b6e331df0..273f3229785c 100644 --- a/include/asm-sh/cpu-sh3/freq.h +++ b/include/asm-sh/cpu-sh3/freq.h | |||
@@ -18,5 +18,9 @@ | |||
18 | #define MIN_DIVISOR_NR 0 | 18 | #define MIN_DIVISOR_NR 0 |
19 | #define MAX_DIVISOR_NR 4 | 19 | #define MAX_DIVISOR_NR 4 |
20 | 20 | ||
21 | #define FRQCR_CKOEN 0x0100 | ||
22 | #define FRQCR_PLLEN 0x0080 | ||
23 | #define FRQCR_PSTBY 0x0040 | ||
24 | |||
21 | #endif /* __ASM_CPU_SH3_FREQ_H */ | 25 | #endif /* __ASM_CPU_SH3_FREQ_H */ |
22 | 26 | ||
diff --git a/include/asm-sh/hd64461.h b/include/asm-sh/hd64461.h index 0f2e2132cc35..27e5c34e2659 100644 --- a/include/asm-sh/hd64461.h +++ b/include/asm-sh/hd64461.h | |||
@@ -40,7 +40,12 @@ | |||
40 | #define HD64461_LCDCBAR 0x11000 | 40 | #define HD64461_LCDCBAR 0x11000 |
41 | #define HD64461_LCDCLOR 0x11002 | 41 | #define HD64461_LCDCLOR 0x11002 |
42 | #define HD64461_LCDCCR 0x11004 | 42 | #define HD64461_LCDCCR 0x11004 |
43 | #define HD64461_LCDCCR_MOFF 0x80 | 43 | #define HD64461_LCDCCR_STBACK 0x0400 |
44 | #define HD64461_LCDCCR_STREQ 0x0100 | ||
45 | #define HD64461_LCDCCR_MOFF 0x0080 | ||
46 | #define HD64461_LCDCCR_REFSEL 0x0040 | ||
47 | #define HD64461_LCDCCR_EPON 0x0020 | ||
48 | #define HD64461_LCDCCR_SPON 0x0010 | ||
44 | 49 | ||
45 | #define HD64461_LDR1 0x11010 | 50 | #define HD64461_LDR1 0x11010 |
46 | #define HD64461_LDR1_DON 0x01 | 51 | #define HD64461_LDR1_DON 0x01 |
diff --git a/include/asm-sh/hp6xx/hp6xx.h b/include/asm-sh/hp6xx/hp6xx.h index a26247fd3d87..f35134c159dd 100644 --- a/include/asm-sh/hp6xx/hp6xx.h +++ b/include/asm-sh/hp6xx/hp6xx.h | |||
@@ -2,16 +2,33 @@ | |||
2 | #define __ASM_SH_HP6XX_H | 2 | #define __ASM_SH_HP6XX_H |
3 | 3 | ||
4 | /* | 4 | /* |
5 | * Copyright (C) 2003 Andriy Skulysh | 5 | * Copyright (C) 2003, 2004, 2005 Andriy Skulysh |
6 | * | ||
7 | * This file is subject to the terms and conditions of the GNU General Public | ||
8 | * License. See the file "COPYING" in the main directory of this archive | ||
9 | * for more details. | ||
10 | * | ||
6 | */ | 11 | */ |
7 | 12 | ||
8 | #define HP680_TS_IRQ IRQ3_IRQ | 13 | #define HP680_BTN_IRQ IRQ0_IRQ |
14 | #define HP680_TS_IRQ IRQ3_IRQ | ||
15 | #define HP680_HD64461_IRQ IRQ4_IRQ | ||
9 | 16 | ||
10 | #define DAC_LCD_BRIGHTNESS 0 | 17 | #define DAC_LCD_BRIGHTNESS 0 |
11 | #define DAC_SPEAKER_VOLUME 1 | 18 | #define DAC_SPEAKER_VOLUME 1 |
12 | 19 | ||
20 | #define PGDR_OPENED 0x01 | ||
21 | #define PGDR_MAIN_BATTERY_OUT 0x04 | ||
22 | #define PGDR_PLAY_BUTTON 0x08 | ||
23 | #define PGDR_REWIND_BUTTON 0x10 | ||
24 | #define PGDR_RECORD_BUTTON 0x20 | ||
25 | |||
13 | #define PHDR_TS_PEN_DOWN 0x08 | 26 | #define PHDR_TS_PEN_DOWN 0x08 |
14 | 27 | ||
28 | #define PJDR_LED_BLINK 0x02 | ||
29 | |||
30 | #define PKDR_LED_GREEN 0x10 | ||
31 | |||
15 | #define SCPDR_TS_SCAN_ENABLE 0x20 | 32 | #define SCPDR_TS_SCAN_ENABLE 0x20 |
16 | #define SCPDR_TS_SCAN_Y 0x02 | 33 | #define SCPDR_TS_SCAN_Y 0x02 |
17 | #define SCPDR_TS_SCAN_X 0x01 | 34 | #define SCPDR_TS_SCAN_X 0x01 |
@@ -21,11 +38,43 @@ | |||
21 | 38 | ||
22 | #define ADC_CHANNEL_TS_Y 1 | 39 | #define ADC_CHANNEL_TS_Y 1 |
23 | #define ADC_CHANNEL_TS_X 2 | 40 | #define ADC_CHANNEL_TS_X 2 |
41 | #define ADC_CHANNEL_BATTERY 3 | ||
42 | #define ADC_CHANNEL_BACKUP 4 | ||
43 | #define ADC_CHANNEL_CHARGE 5 | ||
24 | 44 | ||
25 | #define HD64461_GPADR_SPEAKER 0x01 | 45 | #define HD64461_GPADR_SPEAKER 0x01 |
26 | #define HD64461_GPADR_PCMCIA0 (0x02|0x08) | 46 | #define HD64461_GPADR_PCMCIA0 (0x02|0x08) |
47 | |||
27 | #define HD64461_GPBDR_LCDOFF 0x01 | 48 | #define HD64461_GPBDR_LCDOFF 0x01 |
49 | #define HD64461_GPBDR_LCD_CONTRAST_MASK 0x78 | ||
28 | #define HD64461_GPBDR_LED_RED 0x80 | 50 | #define HD64461_GPBDR_LED_RED 0x80 |
29 | 51 | ||
52 | #include <asm/hd64461.h> | ||
53 | #include <asm/io.h> | ||
54 | |||
55 | #define PJDR 0xa4000130 | ||
56 | #define PKDR 0xa4000132 | ||
57 | |||
58 | static inline void hp6xx_led_red(int on) | ||
59 | { | ||
60 | u16 v16; | ||
61 | v16 = ctrl_inw(CONFIG_HD64461_IOBASE + HD64461_GPBDR - 0x10000); | ||
62 | if (on) | ||
63 | ctrl_outw(v16 & (~HD64461_GPBDR_LED_RED), CONFIG_HD64461_IOBASE + HD64461_GPBDR - 0x10000); | ||
64 | else | ||
65 | ctrl_outw(v16 | HD64461_GPBDR_LED_RED, CONFIG_HD64461_IOBASE + HD64461_GPBDR - 0x10000); | ||
66 | } | ||
67 | |||
68 | static inline void hp6xx_led_green(int on) | ||
69 | { | ||
70 | u8 v8; | ||
71 | |||
72 | v8 = ctrl_inb(PKDR); | ||
73 | if (on) | ||
74 | ctrl_outb(v8 & (~PKDR_LED_GREEN), PKDR); | ||
75 | else | ||
76 | ctrl_outb(v8 | PKDR_LED_GREEN, PKDR); | ||
77 | } | ||
78 | |||
30 | 79 | ||
31 | #endif /* __ASM_SH_HP6XX_H */ | 80 | #endif /* __ASM_SH_HP6XX_H */ |
diff --git a/include/asm-sh/pm.h b/include/asm-sh/pm.h new file mode 100644 index 000000000000..56fdbd6b1c94 --- /dev/null +++ b/include/asm-sh/pm.h | |||
@@ -0,0 +1,17 @@ | |||
1 | /* | ||
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Copyright 2006 (c) Andriy Skulysh <askulysh@gmail.com> | ||
7 | * | ||
8 | */ | ||
9 | #ifndef __ASM_SH_PM_H | ||
10 | #define __ASM_SH_PM_H | ||
11 | |||
12 | extern u8 wakeup_start; | ||
13 | extern u8 wakeup_end; | ||
14 | |||
15 | void pm_enter(void); | ||
16 | |||
17 | #endif | ||
diff --git a/include/asm-sh/system.h b/include/asm-sh/system.h index bd7dc0554b11..477422afeb0d 100644 --- a/include/asm-sh/system.h +++ b/include/asm-sh/system.h | |||
@@ -172,6 +172,31 @@ static __inline__ void local_irq_disable(void) | |||
172 | : "memory"); | 172 | : "memory"); |
173 | } | 173 | } |
174 | 174 | ||
175 | static __inline__ void set_bl_bit(void) | ||
176 | { | ||
177 | unsigned long __dummy0, __dummy1; | ||
178 | |||
179 | __asm__ __volatile__ ("stc sr, %0\n\t" | ||
180 | "or %2, %0\n\t" | ||
181 | "and %3, %0\n\t" | ||
182 | "ldc %0, sr" | ||
183 | : "=&r" (__dummy0), "=r" (__dummy1) | ||
184 | : "r" (0x10000000), "r" (0xffffff0f) | ||
185 | : "memory"); | ||
186 | } | ||
187 | |||
188 | static __inline__ void clear_bl_bit(void) | ||
189 | { | ||
190 | unsigned long __dummy0, __dummy1; | ||
191 | |||
192 | __asm__ __volatile__ ("stc sr, %0\n\t" | ||
193 | "and %2, %0\n\t" | ||
194 | "ldc %0, sr" | ||
195 | : "=&r" (__dummy0), "=r" (__dummy1) | ||
196 | : "1" (~0x10000000) | ||
197 | : "memory"); | ||
198 | } | ||
199 | |||
175 | #define local_save_flags(x) \ | 200 | #define local_save_flags(x) \ |
176 | __asm__("stc sr, %0; and #0xf0, %0" : "=&z" (x) :/**/: "memory" ) | 201 | __asm__("stc sr, %0; and #0xf0, %0" : "=&z" (x) :/**/: "memory" ) |
177 | 202 | ||
diff --git a/include/asm-sh/timer.h b/include/asm-sh/timer.h index dd6579c0b04c..c7ab28095ba0 100644 --- a/include/asm-sh/timer.h +++ b/include/asm-sh/timer.h | |||
@@ -6,6 +6,8 @@ | |||
6 | 6 | ||
7 | struct sys_timer_ops { | 7 | struct sys_timer_ops { |
8 | int (*init)(void); | 8 | int (*init)(void); |
9 | int (*start)(void); | ||
10 | int (*stop)(void); | ||
9 | unsigned long (*get_offset)(void); | 11 | unsigned long (*get_offset)(void); |
10 | unsigned long (*get_frequency)(void); | 12 | unsigned long (*get_frequency)(void); |
11 | }; | 13 | }; |