1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/*
* Copyright (C) 2010 Samsung Electronics Co. Ltd. All Rights Reserved.
* Author: Rom Lemarchand <rlemarchand@sta.samsung.com>
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/init.h>
#include <linux/gpio.h>
#include <linux/earlysuspend.h>
#include <asm/mach-types.h>
#include "herring.h"
static int led_gpios[] = { 2, 3, 6, 7 };
static void herring_touchkey_led_onoff(int onoff)
{
int i;
for (i = 0; i < ARRAY_SIZE(led_gpios); i++)
gpio_direction_output(S5PV210_GPJ3(led_gpios[i]), !!onoff);
}
static void herring_touchkey_led_early_suspend(struct early_suspend *h)
{
herring_touchkey_led_onoff(0);
}
static void herring_touchkey_led_late_resume(struct early_suspend *h)
{
herring_touchkey_led_onoff(1);
}
static struct early_suspend early_suspend = {
.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1,
.suspend = herring_touchkey_led_early_suspend,
.resume = herring_touchkey_led_late_resume,
};
static int __init herring_init_touchkey_led(void)
{
int i;
int ret = 0;
if (!machine_is_herring() || !herring_is_tft_dev())
return 0;
for (i = 0; i < ARRAY_SIZE(led_gpios); i++) {
ret = gpio_request(S5PV210_GPJ3(led_gpios[i]), "touchkey led");
if (ret) {
pr_err("Failed to request touchkey led gpio %d\n", i);
goto err_req;
}
s3c_gpio_setpull(S5PV210_GPJ3(led_gpios[i]),
S3C_GPIO_PULL_NONE);
}
herring_touchkey_led_onoff(1);
register_early_suspend(&early_suspend);
return 0;
err_req:
while (--i >= 0)
gpio_free(S5PV210_GPJ3(led_gpios[i]));
return ret;
}
device_initcall(herring_init_touchkey_led);
|