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.c53
1 files changed, 53 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..0d4a7eceae
--- /dev/null
+++ b/firmware/target/hosted/samsungypr/gpio_ypr.c
@@ -0,0 +1,53 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0
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-target.h> /* includes common ioctl device definitions */
27#include <sys/ioctl.h>
28
29static int r0_gpio_dev = 0;
30
31void gpio_init(void)
32{
33 r0_gpio_dev = open("/dev/r0GPIO", O_RDONLY);
34 if (r0_gpio_dev < 0)
35 printf("/dev/r0GPIO open error!");
36}
37
38void gpio_close(void)
39{
40 if (r0_gpio_dev < 0)
41 close(r0_gpio_dev);
42}
43
44int gpio_control_struct(int request, R0GPIOInfo r)
45{
46 return ioctl(r0_gpio_dev, request, &r);
47}
48
49int gpio_control(int request, int num, int mode, int val)
50{
51 R0GPIOInfo r = { .num = num, .mode = mode, .val = val, };
52 return ioctl(r0_gpio_dev, request, &r);
53}