5 * Copyright (C) 2007-2012 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 #define CONNMAN_API_SUBJECT_TO_CHANGE
30 #include <connman/plugin.h>
31 #include <connman/device.h>
32 #include <connman/log.h>
34 static struct connman_device *hh2serial_device;
36 static int set_reg(char *key, char *value)
40 reg_file = fopen(key, "w");
44 fprintf(reg_file, "%s", value);
49 static int hh2serial_probe(struct connman_device *device)
54 static void hh2serial_remove(struct connman_device *device)
58 static int hh2serial_enable(struct connman_device *device)
62 set_reg("/sys/class/gpio/expo_rt", "85");
63 set_reg("/sys/class/gpio/gpio85/direction", "out");
64 set_reg("/sys/class/gpio/gpio85/value", "1");
69 static int hh2serial_disable(struct connman_device *device)
73 set_reg("/sys/class/gpio/expo_rt", "85");
74 set_reg("/sys/class/gpio/gpio85/direction", "out");
75 set_reg("/sys/class/gpio/gpio85/value", "0");
80 static struct connman_device_driver hh2serial_device_driver = {
81 .name = "hh2serial GPS",
82 .type = CONNMAN_DEVICE_TYPE_GPS,
83 .enable = hh2serial_enable,
84 .disable = hh2serial_disable,
85 .probe = hh2serial_probe,
86 .remove = hh2serial_remove,
89 static int hh2serial_init(void)
93 err = connman_device_driver_register(&hh2serial_device_driver);
97 hh2serial_device = connman_device_create("hh2serial_gps",
98 CONNMAN_DEVICE_TYPE_GPS);
99 if (!hh2serial_device) {
100 connman_device_driver_unregister(&hh2serial_device_driver);
104 err = connman_device_register(hh2serial_device);
106 connman_device_unref(hh2serial_device);
113 static void hh2serial_exit(void)
115 if (hh2serial_device) {
116 connman_device_unregister(hh2serial_device);
117 connman_device_unref(hh2serial_device);
120 connman_device_driver_unregister(&hh2serial_device_driver);
123 CONNMAN_PLUGIN_DEFINE(hh2serial_gps, "hh2serial GPS", VERSION,
124 CONNMAN_PLUGIN_PRIORITY_LOW, hh2serial_init, hh2serial_exit)