FreeCalypso > hg > freecalypso-sw
comparison loadtools/gtapower.c @ 84:ccc5161848c7
loadtools: support building for GTA0x AP
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 20 Aug 2013 04:51:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
83:ebe258a85813 | 84:ccc5161848c7 |
---|---|
1 /* | |
2 * This module is included only when loadtools are being built to run on the | |
3 * GTA0x application processor (AP). It provides automated modem power | |
4 * control, i.e., coordinates modem power control with loadtools operations | |
5 * for convenience. | |
6 */ | |
7 | |
8 #include <sys/types.h> | |
9 #include <sys/file.h> | |
10 #include <stdio.h> | |
11 #include <stdlib.h> | |
12 #include <unistd.h> | |
13 | |
14 /* | |
15 * Check this pathname: it is correct for the kernel version I'm using | |
16 * on my test GTA02, but it differs for some other kernel versions. | |
17 */ | |
18 static char modem_powerctl_pathname[] = | |
19 "/sys/bus/platform/devices/gta02-pm-gsm.0/power_on"; | |
20 | |
21 void | |
22 set_gta_modem_power_ctrl(boolval) | |
23 { | |
24 char strbuf[16]; | |
25 int len, fd; | |
26 | |
27 len = sprintf(strbuf, "%d\n", boolval); | |
28 fd = open(modem_powerctl_pathname, O_WRONLY); | |
29 if (fd < 0) { | |
30 perror(modem_powerctl_pathname); | |
31 exit(1); | |
32 } | |
33 write(fd, strbuf, len); | |
34 close(fd); | |
35 } | |
36 | |
37 void | |
38 fork_gta_modem_poweron() | |
39 { | |
40 int i; | |
41 | |
42 i = fork(); | |
43 if (i < 0) { | |
44 perror("fork"); | |
45 exit(1); | |
46 } | |
47 if (i) | |
48 return; | |
49 printf("Toggling %s\n", modem_powerctl_pathname); | |
50 set_gta_modem_power_ctrl(0); | |
51 usleep(350000); | |
52 set_gta_modem_power_ctrl(1); | |
53 exit(0); | |
54 } |