|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ q2 y5 T( \6 Z7 @, H, ^8 E, y#include <linux/init.h>4 r v& P! q0 k" {6 E* W5 E
#include <linux/module.h>+ j7 F1 H7 G) _$ Q& D) x
#include <linux/kernel.h>
: r* ~# P1 t9 i9 Q#include <linux/types.h>6 K) c& O! H: l" @8 b1 A
#include <linux/gpio.h>. J9 o& _8 |3 {" D7 |# g
#include <linux/leds.h>
+ f+ A% T/ x; p#include <linux/platform_device.h>7 N* R3 ~. C& |9 H
3 W0 r# V. ^4 K. j8 t
#include <asm/mach-types.h>- i; Y( g1 w; ^" G* X; U" m
#include <asm/mach/arch.h>
. z$ l+ [; q) q! B: W#include <mach/da8xx.h>
. T+ n( O( J4 P- u2 P#include <mach/mux.h>: ?/ S+ z7 A5 w1 U/ ] z# l, l6 B
; P4 c5 D( n3 f' A1 [
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 N; J" }) g, I' V6 m: A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 m: z) u7 ^3 p1 r: M# f/ [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 A3 h# ^) ~/ C1 L) Z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- x1 X; S+ ?0 f$ e8 w
; y0 o3 P- [0 [- C/* assign the tl som board LED-GPIOs*// N+ _& \1 T# h5 h0 d
static const short da850_evm_tl_user_led_pins[] = {
/ U2 Y- {5 c# Y" [/ m* s /* These pins are definition at <mach/mux.h> file */0 A$ N1 |$ c& S/ i6 T! k+ X) n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, Y- q) l) X' x; r- q. W& j" q
-1
2 s) C) d0 d- N) S6 i) U5 ~/ X2 u};
4 h7 U8 ]* f8 ~" }0 @! j8 y+ M
( x) r$ c. }4 `& i% ]& [& ^+ Astatic struct gpio_led da850_evm_tl_leds[] = {' x( r" l# f- s0 u* N$ C
{
7 F! ^, n9 u) i, m4 r, a .active_low = 0,
& A* ^8 Q$ S" Q% P4 _ .gpio = DA850_USER_LED0,: A" Y% y" ?9 A* g- c" @; K7 N/ B5 t
.name = "user_led0",+ |1 Q; [8 {5 r; h) K% D
.default_trigger = "default-on",5 `- l- g7 K& C8 X" {( M" b
},
% S5 y0 Y* g6 D, B4 p j- l {# ]% X" e) Y5 q
.active_low = 0,
- Q( e% Q) M- m! U .gpio = DA850_USER_LED1,4 l- A& Y, A' [! n* |, Q
.name = "user_led1",
$ E) ]0 G9 g. B, N; A% F2 W .default_trigger = "default-on",% U# T6 M# }$ h
},+ ?( s/ Q1 F1 a3 l
{
1 j$ a7 N% z9 \9 ~ .active_low = 0,9 F9 Y8 d5 ^4 X6 N
.gpio = DA850_USER_LED2,
' n# O, R/ e( j7 H* \4 z1 I2 U7 E .name = "user_led2",1 o6 l0 C, h' |8 B+ W) d
.default_trigger = "default-on",( @; o8 v8 S/ t& |! h3 o
},# |. w# _0 \4 F+ q, @9 F. L
{
8 H" p/ K8 i- Q( B3 x1 P! w" ]2 l# J4 R .active_low = 0," \/ r9 @( E* t. u/ K) Q6 g: X
.gpio = DA850_USER_LED3,
$ ?' u7 k$ B# \( n .name = "user_led3",
+ T& Z& o* x4 U/ I0 w/ Q .default_trigger = "default-on",
3 Q, t* n/ s8 f+ `- ` },
! y, {- i1 \& s6 d' k};, @, b4 U5 z2 K, J' h/ }4 P
2 X5 ]' J6 ?4 J& h P7 z0 J. Zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ J( v, `# |" r/ d6 E( J# d& U .leds = da850_evm_tl_leds,/ F. K. f: ?$ M2 {( v
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ h7 P; x7 M- Z% B; l; j};7 Z$ O0 G; U! R' I P6 L
. P+ ]9 F4 r0 t$ o. u A/ f7 W
static void led_dev_release(struct device *dev)( B; q$ `6 Z1 R5 s5 x2 ]
{
& }( m2 v2 b) [, w/ N6 p8 R8 E. ~};
0 r% ^; I$ V2 }, u& J
4 R0 h* @% e' g Z7 [& tstatic struct platform_device da850_evm_tl_leds_device = {
% a& p% U# u, o# L .name = "leds-gpio", y* ]% w/ f6 w* L
.id = 1,# s1 s* d) M0 X( v4 r
.dev = {9 l2 d! ~3 }1 M+ V
.platform_data = &da850_evm_tl_leds_pdata,
/ v/ \# F% f9 L* ? .release = led_dev_release,
: u2 h! d. c* D, ~/ R }
4 v3 L6 d- o, V};4 ^3 x) A7 s6 j5 X2 {2 _
* M f. c; B# G9 [- y+ T
static int __init led_platform_init(void)4 C% `- E! ?4 G$ w; Q8 T2 N
{' w/ J U$ O% s( ^+ D" ~1 X
int ret;
+ d8 r) z. j4 L7 C8 i0 N4 C#if 0/ h$ z4 h6 u' a
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 I: _% C; B* m1 c8 o* s) g3 H
if (ret)1 A$ Y) `" s- {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 ?5 I2 l' _' h1 {/ L "%d\n", ret);
, r( G' Q6 {' V/ m0 H5 b#endif
% F: o" B( M( C& p7 R3 L ret = platform_device_register(&da850_evm_tl_leds_device);
4 ~, k5 s0 C3 b6 H. Z if (ret)$ |" u, p& m, U; Q: R
pr_warning("Could not register som GPIO expander LEDS");+ A+ P. d1 q/ I! _
else3 E# U7 f; {+ v. x& R$ P
printk(KERN_INFO "LED register sucessful!\n");
7 L R5 Z/ r1 Q h5 o$ f8 w0 Y- O+ W( a( ^6 @
return ret;
, [6 y* |/ ?; K}8 J7 S& `6 c n
) m0 m: k, t+ }( b2 sstatic void __exit led_platform_exit(void)* I- x- h g* m" E
{0 j: U4 Y" R; r E% x
platform_device_unregister(&da850_evm_tl_leds_device);
6 w( g3 {( D8 r' a0 _6 d1 l: b) ?% l f& T
printk(KERN_INFO "LED unregister!\n");; M# [% A u' Z9 {& `5 z
}9 G! X7 @9 P2 g+ Z6 B" r
* x5 C6 l% J7 ?) r) }module_init(led_platform_init);8 R) S& B" A9 \. \0 M) _. P& L
module_exit(led_platform_exit);) R1 l9 B3 r4 ?& T0 `9 R- z O
E% k7 I. x. ]0 o. P% p1 R" f5 @
MODULE_DESCRIPTION("Led platform driver");
( T' \ a/ q3 m. s' |- x: d$ jMODULE_AUTHOR("Tronlong");
# v$ f) m2 C; WMODULE_LICENSE("GPL");8 U3 \) j& R3 A) m
5 o) y% u) h M1 d7 u |
|