diff options
author | Lorenzo Miori <memorys60@gmail.com> | 2013-02-23 16:59:49 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2013-03-06 00:21:22 +0100 |
commit | 60592165ca998875e4bc46c4396c5a123a7e9dbb (patch) | |
tree | 60b53e6b733fd49bef249761789e97a4bedbef03 /firmware/target/hosted/samsungypr/gpio_ypr.c | |
parent | 3e4be68f8b596cf3467f993dc9a210a3d901ca1c (diff) | |
download | rockbox-60592165ca998875e4bc46c4396c5a123a7e9dbb.tar.gz rockbox-60592165ca998875e4bc46c4396c5a123a7e9dbb.zip |
Samsung YP-R0 hosted target code refactoring
As per title this patch aims at splitting common target
code and specific target code in a better way to
support future ports within the same environment
(e.g. Samsung YP-R1 where the Linux and the SoC
are the same, with differences in hardware devices
handling)
Change-Id: I67b4918c46403b184d3d8f42ab5aae7d01037fd0
Reviewed-on: http://gerrit.rockbox.org/409
Reviewed-by: Thomas Martitz <kugel@rockbox.org>
Tested-by: Thomas Martitz <kugel@rockbox.org>
Diffstat (limited to 'firmware/target/hosted/samsungypr/gpio_ypr.c')
-rw-r--r-- | firmware/target/hosted/samsungypr/gpio_ypr.c | 53 |
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 | |||
29 | static int r0_gpio_dev = 0; | ||
30 | |||
31 | void 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 | |||
38 | void gpio_close(void) | ||
39 | { | ||
40 | if (r0_gpio_dev < 0) | ||
41 | close(r0_gpio_dev); | ||
42 | } | ||
43 | |||
44 | int gpio_control_struct(int request, R0GPIOInfo r) | ||
45 | { | ||
46 | return ioctl(r0_gpio_dev, request, &r); | ||
47 | } | ||
48 | |||
49 | int 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 | } | ||