comparison loadtools/old/gtapower.c @ 577:62a91abc0300

loadtools: no-longer-working stuff moved into old subdir
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 02 Feb 2020 21:18:37 +0000
parents loadtools/gtapower.c@e7502631a0f9
children
comparison
equal deleted inserted replaced
576:34d544c0f639 577:62a91abc0300
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 }