diff options
author | Tim Dijkstra <tim@famdijkstra.org> | 2007-05-13 20:16:53 +0000 |
---|---|---|
committer | Tim Dijkstra <tim@famdijkstra.org> | 2007-05-13 20:16:53 +0000 |
commit | 0829102e07e6620250ef3b4fc23ecbeb3fb7e9a9 (patch) | |
tree | a14568fe5ef70d2827a8f9be28b6a2ccfc02fd30 | |
parent | 55c654d703335d0fe56c0cfb170408602f2a0c48 (diff) | |
download | suspend-utils-0829102e07e6620250ef3b4fc23ecbeb3fb7e9a9.tar.gz |
Support for powerpc
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | s2ram-ppc.c | 109 | ||||
-rw-r--r-- | s2ram-ppc.h | 2 | ||||
-rw-r--r-- | s2ram-x86.h | 3 | ||||
-rw-r--r-- | s2ram.c | 2 | ||||
-rw-r--r-- | suspend.c | 2 |
6 files changed, 117 insertions, 5 deletions
@@ -30,6 +30,8 @@ SWSUSP_LD_FLAGS = $(LD_FLAGS) ifeq ($(ARCH), x86) S2RAM_OBJ += s2ram-x86.o dmidecode.o radeontool.o vbetool/vbetool.o S2RAM_LD_FLAGS += -lx86 -lpci -lz +else ifeq ($(ARCH), ppc) +S2RAM_OBJ += s2ram-ppc.o endif ifndef CONFIG_RESUME_DYN @@ -91,7 +93,7 @@ md5.o encrypt.o: %.o : %.c %.h md5.h $(CC) $(CC_FLAGS) -DHAVE_INTTYPES_H -DHAVE_STDINT_H -c $< -o $@ # Simple objects with header -config.o vt.o bootsplash.o splash.o splashy_funcs.o vbetool/vbetool.o: %.o : %.c %.h +config.o vt.o bootsplash.o splash.o splashy_funcs.o vbetool/vbetool.o s2ram-ppc.o: %.o : %.c %.h $(CC) $(CC_FLAGS) -c $< -o $@ # Simple object without header diff --git a/s2ram-ppc.c b/s2ram-ppc.c new file mode 100644 index 0000000..6456d56 --- /dev/null +++ b/s2ram-ppc.c @@ -0,0 +1,109 @@ +/* + * Suspend-to-RAM - PPC code + * + * Copyright 2006 Tim Dijkstra <newsuser@fa...> + * Copyright 2006 Luca Tettamanti <kronos.it@gm...> + * Distribute under GPLv2. + */ + +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdio.h> + +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/stat.h> + +#include <linux/pmu.h> + +#include "s2ram.h" + +void s2ram_add_flag(int opt, const char *arg) +{ + /* We don't take any options */ +} + +int s2ram_prepare(void) +{ + return 0; +} + +void s2ram_resume(void) +{ + /* nop */ +} + +void identify_machine(void) +{ + printf("We don't have quirks and hence no whitelist on powerpc\n"); +} + +void machine_known(void) +{ + printf("We don't have quirks and hence no whitelist on powerpc\n"); +} + +int s2ram_hacks(void) +{ + return 0; +} + +int s2ram_is_supported(void) +{ + int fd, ret = 0; + unsigned long arg = 0; + + /* PMU_IOC_CAN_SLEEP is going away, so we only say unsupported + * if PMU_IOC_CAN_SLEEP explicitly says we can't */ + fd = open("/dev/pmu", O_RDWR); + if (fd < 0) + return 0; + + ret = ioctl(fd, PMU_IOC_CAN_SLEEP, &arg); + if (!ret && arg != 1) + ret = ENOTSUP; + + close(fd); + + return 0; +} + +static int s2ram_do_pmu (void) +{ + int fd; + int ret = 0; + unsigned long arg = 0; + + fd = open("/dev/pmu", O_RDWR); + if (fd < 0) + return errno; + + ret = ioctl(fd, PMU_IOC_CAN_SLEEP, &arg); + if (!ret && arg != 1) + ret = ENOTSUP; + + if (!ret) + ret = ioctl(fd, PMU_IOC_SLEEP, 0); + + if (ret) + ret = errno; + + close(fd); + + return ret; +} + +int s2ram_do(void) +{ + int ret; + + /* If this works we're done. Else we just continue as if nothing + * happened, future kernels will work with /s/p/s. + */ + ret = s2ram_do_pmu(); + if (!ret) + return ret; + + return s2ram_generic_do(); +} diff --git a/s2ram-ppc.h b/s2ram-ppc.h new file mode 100644 index 0000000..8da3c54 --- /dev/null +++ b/s2ram-ppc.h @@ -0,0 +1,2 @@ +/* No additional options for PPC */ +#define HACKS_LONG_OPTS diff --git a/s2ram-x86.h b/s2ram-x86.h index e6c9dc1..b8ec976 100644 --- a/s2ram-x86.h +++ b/s2ram-x86.h @@ -34,5 +34,4 @@ {\ "acpi_sleep\0set the acpi_sleep parameter before suspend\n\t\t\t1=s3_bios, 2=s3_mode, 3=both",\ required_argument, NULL, 7 \ - } - + }, @@ -60,7 +60,7 @@ int main(int argc, char *argv[]) "identify\0prints a string that identifies the machine.", no_argument, NULL, 'i' }, - HACKS_LONG_OPTS, + HACKS_LONG_OPTS { NULL, 0, NULL, 0 } }; const char *optstring = "hni" "fspmrva:"; @@ -1190,7 +1190,7 @@ static inline int get_config(int argc, char *argv[]) required_argument, NULL, 's' }, #ifdef CONFIG_BOTH - HACKS_LONG_OPTS, + HACKS_LONG_OPTS #endif { NULL, 0, NULL, 0 } }; |