|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! v; _ h! j8 h0 M* K+ S#include <linux/init.h>
: R [6 u/ \3 {2 J0 {9 T, a#include <linux/module.h>2 i9 w: y* U e4 O+ S& D
#include <linux/kernel.h>" \0 N- x$ e+ T5 I# D: C" l
#include <linux/types.h>
/ b) g; U+ k3 X#include <linux/gpio.h># Z1 s7 n7 o1 n0 ?0 i$ c' a
#include <linux/leds.h>
G) R# \! k' L+ A X#include <linux/platform_device.h>
2 T' V4 R8 v2 `8 l0 y
# u, x$ v5 @7 u, `#include <asm/mach-types.h>% L; m' l8 {2 ^- E7 m7 }# Y, h
#include <asm/mach/arch.h>; V7 \. R' t i3 I1 O$ k5 R
#include <mach/da8xx.h>
4 @: s, b L+ H6 t$ s2 H#include <mach/mux.h>/ v# Z* D9 S; j f# B* M
! U4 T8 b9 I6 a7 Q' t" [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& l x- x( @4 t! k% L#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& A& `( {* U. ^5 P8 {: Y% T W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 A1 z: ], g# O# M#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); A+ t" r- l8 `/ d9 y! n2 e
5 }& f+ M% l! x- a( w/* assign the tl som board LED-GPIOs*/
; i$ |) d l2 {# o. \ n0 g) ]& `# Astatic const short da850_evm_tl_user_led_pins[] = {* |& G4 I e: T; J- I$ |+ L" X
/* These pins are definition at <mach/mux.h> file */4 g% V' }2 o' v) C5 r/ I
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 X* X" G' |: w' z1 W k -1
+ _ \& [% q$ M$ C};- [7 o7 ^1 f4 t K, f4 c" G1 q
S3 X3 v. Z/ q b5 [. x; Dstatic struct gpio_led da850_evm_tl_leds[] = {
8 x k0 T4 g) Z7 _6 M$ L {' Q( W* I; @4 n6 N
.active_low = 0,+ C+ V! S0 U7 A
.gpio = DA850_USER_LED0,
) A+ p( c& [1 \( ~/ A( O .name = "user_led0",
3 N) B0 T4 ^4 a0 i8 n .default_trigger = "default-on",
* } P7 {4 y% [+ X },0 s3 ? I6 h& @
{( Q% k' R3 F; ~2 Q5 h) v7 i$ D) c
.active_low = 0,7 O2 `7 O( ?6 Y8 \
.gpio = DA850_USER_LED1,# l; n5 o2 g: y& W
.name = "user_led1",
3 G% N2 A$ \# s .default_trigger = "default-on",7 `; i1 J* ^- m1 }
},
; ]) J* m& l/ ^6 t& `" { {
9 M# p v$ C' y& A5 i, `* e8 g/ | .active_low = 0,
+ E& G9 ?2 t* n c! E6 @ .gpio = DA850_USER_LED2,
/ T, o- N. s, f9 \6 y .name = "user_led2",# o5 w3 ?8 N" \$ @( l
.default_trigger = "default-on",
% ]( u# f1 k8 e2 f& N% V },1 [$ F& e3 t- y! L
{, L& ^ q: I# K o& Q4 `. [
.active_low = 0,0 {# q+ F! Z* N* X
.gpio = DA850_USER_LED3,
: b& U: H: ~' `: p& d" y5 L; _ .name = "user_led3",% G; r6 ^" e# y# z2 W' e
.default_trigger = "default-on",$ _" D" `$ H7 `( Q# Q
},( V1 g: x! g5 {( c* `; ?9 o
};
+ ]( h3 V2 r, Q* ~ a! \
; {1 X0 b- I; r" P; \1 h2 ]0 x( lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; {8 ?1 u* w1 H .leds = da850_evm_tl_leds,* e8 n; F2 Y; w6 x9 `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& z& @$ ?& F1 K3 p9 {, [6 P
};$ H" k9 |7 L3 m, x( w6 f4 D- k% R
4 U8 ~& }; x: f6 p1 Qstatic void led_dev_release(struct device *dev)% [4 i9 Q# d- K- `0 q
{
|. ^" U7 z5 V+ T! J$ W3 J7 O};
2 \) l' n* _1 Y( L+ p$ R: I! n& e/ e2 A
static struct platform_device da850_evm_tl_leds_device = {! N! V a& b& k7 n# |/ m4 W
.name = "leds-gpio",
: b2 f! T+ M) Y6 Z8 e. u; p# b .id = 1,
" k0 @- U6 g3 X .dev = {
% p' V5 i. I' {# j! |, f, N+ @ .platform_data = &da850_evm_tl_leds_pdata,0 L; @: R: P$ \5 C
.release = led_dev_release,
Y# J0 |/ @8 x; T }
8 o; R6 d# j" F+ g, q9 m};6 V0 R* h; r3 T q }( n! b
7 k+ ~ q& f+ P4 c& W. {3 `/ N/ n
static int __init led_platform_init(void)
: N. }% K" {& M$ O& Y/ h1 X( l{
' _5 H# ?$ Y( b: ]8 {9 P0 i int ret;! S+ Z; B0 o; k& R9 [6 ?
#if 06 v8 K E! J! S! r/ k% X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ V+ x. Q3 X2 p0 E if (ret)
/ @1 m5 e' ^3 F' k0 O8 H3 ~( n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 U6 {& N$ {' U+ s0 f& e "%d\n", ret);
' Y9 t+ w; `, ^! C#endif( Y( j' b$ V# S5 V
ret = platform_device_register(&da850_evm_tl_leds_device);' z) T1 V+ A$ t4 x
if (ret)
4 W! h. E2 T: d pr_warning("Could not register som GPIO expander LEDS");$ O4 j5 b0 K. ^# _" o5 j& p
else
8 @; `" [6 f B& v3 }+ _+ W printk(KERN_INFO "LED register sucessful!\n");( F7 B- \/ r2 X. ]3 c) {+ I
+ j, ?+ Y4 V* e# v* r( y+ ] l
return ret;
) I" T- f# e* U}6 \9 n; \& } ?: y
8 i3 H! \, s9 B- ?; W4 x" x. u9 q
static void __exit led_platform_exit(void)" k8 s; m' C* b; p
{2 c% Q3 j/ p/ S: G% ]5 |1 E, g
platform_device_unregister(&da850_evm_tl_leds_device);
# z" R6 D2 F& ?7 F2 c( R, K) c7 t- Q6 t7 R2 D. ^0 k9 M1 X
printk(KERN_INFO "LED unregister!\n");
6 b! e* Y7 |! ~( H3 f( \8 j}0 ?2 Y- z7 r, {' y! Z: t
( c6 g& S- j- k8 V1 T/ [0 Kmodule_init(led_platform_init);/ v* u5 c2 _3 `
module_exit(led_platform_exit);8 _5 i) k. ]: C. Q
9 G) r/ h- P- e/ ^$ U( f' ` h- BMODULE_DESCRIPTION("Led platform driver");$ T q0 _$ s: L; l$ B
MODULE_AUTHOR("Tronlong");
" ]7 l6 l" x4 F/ OMODULE_LICENSE("GPL");
: ^7 m' _8 f. V5 M
1 i$ m& A6 w3 j5 i/ J- N |
|