summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/samsungypr/gpio-ypr.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/hosted/samsungypr/gpio-ypr.c')
-rw-r--r--firmware/target/hosted/samsungypr/gpio-ypr.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/firmware/target/hosted/samsungypr/gpio-ypr.c b/firmware/target/hosted/samsungypr/gpio-ypr.c
new file mode 100644
index 0000000000..e5abc4cdc9
--- /dev/null
+++ b/firmware/target/hosted/samsungypr/gpio-ypr.c
@@ -0,0 +1,48 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Module wrapper for GPIO, using kernel module of Samsung YP-R0/YP-R1
10 *
11 * Copyright (c) 2011 Lorenzo Miori
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ****************************************************************************/
22
23#include <stdio.h>
24#include <unistd.h>
25#include <fcntl.h>
26#include <gpio-ypr.h> /* includes common ioctl device definitions */
27#include <sys/ioctl.h>
28
29static int gpio_dev = 0;
30
31void gpio_init(void)
32{
33 gpio_dev = open(GPIO_DEVICE, O_RDONLY);
34 if (gpio_dev < 0)
35 printf("GPIO device open error!");
36}
37
38void gpio_close(void)
39{
40 if (gpio_dev >= 0)
41 close(gpio_dev);
42}
43
44int gpio_control(int request, int num, int mode, int val)
45{
46 struct gpio_info r = { .num = num, .mode = mode, .val = val, };
47 return ioctl(gpio_dev, request, &r);
48}