|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( s' n7 [* e2 Q& _+ y# M8 G. }#include <linux/init.h>
. q- w3 o- L; w# Z+ V7 H#include <linux/module.h>2 W4 v5 ?- R# P; H0 j
#include <linux/kernel.h>
' a1 ~+ I2 N/ @& }$ M#include <linux/types.h>; J. c! i7 {0 p2 x" I* h
#include <linux/gpio.h>4 a. h n/ d" \9 E7 q3 F9 f7 W
#include <linux/leds.h>9 y/ \# w% E0 p7 @
#include <linux/platform_device.h>1 G! e* j0 N/ i! V
1 [. A/ k9 n9 P2 S4 F8 `4 o" n1 N( @#include <asm/mach-types.h>
$ M( k6 n0 D5 r o7 o#include <asm/mach/arch.h>
3 |/ }/ X& L1 o7 x" z$ g+ U5 _& |#include <mach/da8xx.h>0 ]/ p" i5 G; w* w* A! h% I
#include <mach/mux.h>
1 v& h$ @0 q& p" |" t2 K
( t5 O) O; ~, }, J$ c) g: b, [& O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( m" q7 a" P) W/ G. N: N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* z0 s, G; g' L9 h0 B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' r2 ^& n! P. y! }1 [& o M0 z3 P#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; l! J' {4 Y- }; L b) { @! q* e* f y# Q5 ^
/* assign the tl som board LED-GPIOs*/
0 b7 ~3 }2 P+ [1 r& tstatic const short da850_evm_tl_user_led_pins[] = {
* q9 y: U, e% {* y /* These pins are definition at <mach/mux.h> file */1 @$ L' ?6 C0 X: ]; X+ _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 U0 C/ D$ D' ^4 r) d
-1- t' y! ?7 }4 [% Y5 k; e4 h- V5 y
};
. F( Y5 D5 f) N
" h: P5 c% ~3 x7 w" N' K8 sstatic struct gpio_led da850_evm_tl_leds[] = {
$ _! F* J; T6 y {$ @4 A% g& b% i2 X, E, A" J
.active_low = 0,
& ^6 e3 Z" }( B" y .gpio = DA850_USER_LED0,8 |) D# h3 h: K1 [ }+ r
.name = "user_led0",! d, ?4 ^9 [5 g" x% a
.default_trigger = "default-on",# [ }$ }0 C4 V: h$ S
},, ^3 R" g% @$ D5 d: a
{ j9 u7 r4 s5 O) s5 h" _
.active_low = 0,
/ X; U" a6 X) @3 a/ q) H .gpio = DA850_USER_LED1,; C0 t) H4 F3 A, d
.name = "user_led1",1 K" j) P8 L$ r x
.default_trigger = "default-on",, k+ T8 \2 ~: c
},
" t7 m( y& \ e {+ a, f2 ?2 A) M% E& ~9 n
.active_low = 0,5 R! ^6 j' c- U6 e" C# z
.gpio = DA850_USER_LED2,4 B7 D' \! b. v* ]
.name = "user_led2",
1 G, g" {$ S& x2 W6 H .default_trigger = "default-on",
/ u9 E p t& E },
" Z' O6 D# e$ C1 _9 d y m {% N; y& E, e5 G, @
.active_low = 0,( @9 z9 W- s7 R- a, B6 X; e
.gpio = DA850_USER_LED3,( }* R4 m0 S V# D
.name = "user_led3",( Q' ~2 H* U8 d9 G
.default_trigger = "default-on",
, p8 y# Z5 m' L/ Y9 Y },) ?8 G: V7 O6 g+ d! X. X
};
& k7 S. ^/ C9 C" W% w( ^; @5 t
& ^: `; [5 T% V: M# x$ H* \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% A3 L G" z9 C6 \& q! H .leds = da850_evm_tl_leds,% X R1 {0 F. v+ G% D2 Z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; l* Y( p- U2 D& m1 t0 Y( u};
# g" z2 g4 G$ m Z3 R; T ?+ |4 Q% x% ]2 r! n. d+ j
static void led_dev_release(struct device *dev)+ _* ~( I6 d% E8 A" S7 \; S
{9 k" `2 @5 D1 T$ A- n
};
9 T% ?: |8 N! n: y& t$ S
; Q% H" |; Y( |# U& p- I6 ?static struct platform_device da850_evm_tl_leds_device = {
% q/ c, a6 e) t: N$ x/ m .name = "leds-gpio",# V, C& x- z% E, O& r3 ?
.id = 1,
( X1 v$ b) x" ]0 f; y .dev = {
& X6 G% I! X3 H. v/ _ .platform_data = &da850_evm_tl_leds_pdata,
' p) M$ j- h1 G l; D# S. C. ^ .release = led_dev_release,+ y9 y. C; j$ y: s( K/ m5 N
}
x+ S7 i$ s& h" A/ _) I};
9 m& |. g; [) h, I& w
8 O+ J2 v) X) ]" n5 [static int __init led_platform_init(void)
) S5 t3 z7 z. C1 p$ X: v8 x{
: u {# P+ k3 k: _6 R2 H. _7 L int ret;
/ U# [2 \' h0 @9 ]#if 0
: y5 I2 V2 s+ d4 U% W2 L: @$ _ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ R W$ F' P$ A' Z- T" f) u
if (ret)
) p3 o! P G9 f2 S, @6 h pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ C; ^0 y5 g& d' ^: V: q, b "%d\n", ret);
" {+ z4 x/ k) N0 X' C; S#endif" f) J M% A, S) I6 }& j' O
ret = platform_device_register(&da850_evm_tl_leds_device);0 A2 Z1 m; t7 e
if (ret)/ q0 {5 F) W' h8 j( L, Q9 w
pr_warning("Could not register som GPIO expander LEDS");
; U* ]2 k, v# [* r5 @ else
1 U4 v2 J7 ?) o+ G) h9 C8 c ] printk(KERN_INFO "LED register sucessful!\n");
& j9 K+ [( i' Z7 t* J* J% s( A8 m9 t) F
return ret;, p/ h5 X! f5 T. r
}
3 d7 l( k" Y! ?7 P( v* B4 V, Y8 L1 c7 t% d E5 i" n: y5 x
static void __exit led_platform_exit(void)
, r3 x3 p% Y. q- O& F: l$ \# Q+ G{2 y6 u) y2 {6 Y1 g3 ~
platform_device_unregister(&da850_evm_tl_leds_device);( S& S$ A1 u& J" h( D3 H
) r- ^7 ]& o, Z4 X
printk(KERN_INFO "LED unregister!\n");
# V7 ^9 z% G3 b9 \' G8 p- @6 E1 N5 ^" C}; t- C( M8 x) `; B9 `3 p
' ^3 ~5 @; V: ?0 S& umodule_init(led_platform_init);4 n ~' P8 y- }4 Z
module_exit(led_platform_exit);
) o$ J7 G8 O: s' T/ Q0 Q; w# M
- o# }, r6 `4 @% c9 k" VMODULE_DESCRIPTION("Led platform driver");/ Q, k# ]0 \! ] \8 q8 f1 ?( l
MODULE_AUTHOR("Tronlong"); q0 U: m) |5 q4 z
MODULE_LICENSE("GPL");, f- U! a3 b- r! _& I6 Y" b
0 g9 \; _2 k$ g7 d4 I9 o8 r5 h
|
|