Linux Kernel
3.7.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
drivers
staging
nvec
nvec_paz00.c
Go to the documentation of this file.
1
/*
2
* nvec_paz00: OEM specific driver for Compal PAZ00 based devices
3
*
4
* Copyright (C) 2011 The AC100 Kernel Team <
[email protected]
>
5
*
6
* Authors: Ilya Petrov <
[email protected]
>
7
*
8
* This file is subject to the terms and conditions of the GNU General Public
9
* License. See the file "COPYING" in the main directory of this archive
10
* for more details.
11
*
12
*/
13
14
#include <linux/module.h>
15
#include <
linux/err.h
>
16
#include <linux/slab.h>
17
#include <
linux/leds.h
>
18
#include <
linux/platform_device.h
>
19
#include "
nvec.h
"
20
21
#define to_nvec_led(led_cdev) \
22
container_of(led_cdev, struct nvec_led, cdev)
23
24
#define NVEC_LED_REQ {'\x0d', '\x10', '\x45', '\x10', '\x00'}
25
26
#define NVEC_LED_MAX 8
27
28
struct
nvec_led
{
29
struct
led_classdev
cdev
;
30
struct
nvec_chip
*
nvec
;
31
};
32
33
static
void
nvec_led_brightness_set(
struct
led_classdev
*led_cdev,
34
enum
led_brightness
value
)
35
{
36
struct
nvec_led
*
led
=
to_nvec_led
(led_cdev);
37
unsigned
char
buf
[] =
NVEC_LED_REQ
;
38
buf[4] =
value
;
39
40
nvec_write_async
(led->
nvec
, buf,
sizeof
(buf));
41
42
led->
cdev
.brightness =
value
;
43
44
}
45
46
static
int
__devinit
nvec_paz00_probe(
struct
platform_device
*pdev)
47
{
48
struct
nvec_chip
*nvec =
dev_get_drvdata
(pdev->
dev
.parent);
49
struct
nvec_led
*
led
;
50
int
ret
= 0;
51
52
led =
devm_kzalloc
(&pdev->
dev
,
sizeof
(*led),
GFP_KERNEL
);
53
if
(led ==
NULL
)
54
return
-
ENOMEM
;
55
56
led->
cdev
.max_brightness =
NVEC_LED_MAX
;
57
58
led->
cdev
.brightness_set = nvec_led_brightness_set;
59
led->
cdev
.name =
"paz00-led"
;
60
led->
cdev
.flags |=
LED_CORE_SUSPENDRESUME
;
61
led->
nvec
=
nvec
;
62
63
platform_set_drvdata(pdev, led);
64
65
ret =
led_classdev_register
(&pdev->
dev
, &led->
cdev
);
66
if
(ret < 0)
67
return
ret
;
68
69
/* to expose the default value to userspace */
70
led->
cdev
.brightness = 0;
71
72
return
0;
73
}
74
75
static
int
__devexit
nvec_paz00_remove(
struct
platform_device
*pdev)
76
{
77
struct
nvec_led
*led = platform_get_drvdata(pdev);
78
79
led_classdev_unregister
(&led->
cdev
);
80
81
return
0;
82
}
83
84
static
struct
platform_driver
nvec_paz00_driver = {
85
.probe = nvec_paz00_probe,
86
.remove =
__devexit_p
(nvec_paz00_remove),
87
.driver = {
88
.name =
"nvec-paz00"
,
89
.owner =
THIS_MODULE
,
90
},
91
};
92
93
module_platform_driver
(nvec_paz00_driver);
94
95
MODULE_AUTHOR
(
"Ilya Petrov <
[email protected]
>"
);
96
MODULE_DESCRIPTION
(
"Tegra NVEC PAZ00 driver"
);
97
MODULE_LICENSE
(
"GPL"
);
98
MODULE_ALIAS
(
"platform:nvec-paz00"
);
Generated on Thu Jan 10 2013 14:29:47 for Linux Kernel by
1.8.2