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