2012-01-03 21:15:27 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
2013-09-10 20:48:34 +00:00
|
|
|
* Module wrapper for GPIO, using kernel module of Samsung YP-R0/YP-R1
|
2012-01-03 21:15:27 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 2011 Lorenzo Miori
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
2013-12-28 18:00:57 +00:00
|
|
|
#include <gpio-ypr.h> /* includes common ioctl device definitions */
|
2012-01-03 21:15:27 +00:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
2013-09-10 20:48:34 +00:00
|
|
|
static int gpio_dev = 0;
|
2012-01-03 21:15:27 +00:00
|
|
|
|
|
|
|
void gpio_init(void)
|
|
|
|
{
|
2013-09-10 20:48:34 +00:00
|
|
|
gpio_dev = open(GPIO_DEVICE, O_RDONLY);
|
|
|
|
if (gpio_dev < 0)
|
|
|
|
printf("GPIO device open error!");
|
2012-01-03 21:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void gpio_close(void)
|
|
|
|
{
|
2013-09-10 20:48:34 +00:00
|
|
|
if (gpio_dev >= 0)
|
|
|
|
close(gpio_dev);
|
2012-01-03 21:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int gpio_control(int request, int num, int mode, int val)
|
|
|
|
{
|
2013-03-06 09:11:12 +00:00
|
|
|
struct gpio_info r = { .num = num, .mode = mode, .val = val, };
|
2013-09-10 20:48:34 +00:00
|
|
|
return ioctl(gpio_dev, request, &r);
|
2012-01-08 01:43:16 +00:00
|
|
|
}
|