|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 h$ u" h( ~1 M) U2 E! u/ p#include <linux/init.h>
: \% P- _3 n! M: f' {#include <linux/module.h>
, w3 @& d- G$ z/ l5 T! k#include <linux/kernel.h>0 \4 Q7 R, U- o- J" N
#include <linux/types.h>
! H4 O& w3 [! B#include <linux/gpio.h>9 D4 `! \' h% h' k' _
#include <linux/leds.h>. K& o I+ _1 K( p6 I
#include <linux/platform_device.h>
" c# a* ]5 L4 Z' b" Q% P3 J& S+ v% p& F7 X
#include <asm/mach-types.h>
3 S' u1 a( ~- g+ w0 G H( `#include <asm/mach/arch.h>
+ v; M; [$ v! B; r+ @' g#include <mach/da8xx.h>( C O$ Z( ?3 l2 }
#include <mach/mux.h>
! F1 `" G. C A# ]; p2 z8 {* _) M
; e( U4 {: D( S8 J( F. k M r2 @) t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' l3 l; `* ` I6 g& p
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* K8 l" R. s$ I2 |, l) o" ^5 Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: U) L) @' ~ B- `0 J. l( ?#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) f1 ^' N/ g7 m {4 y' d0 N
4 J0 [# ?3 ]) o. P6 p8 F* X/ B- a9 r/* assign the tl som board LED-GPIOs*// b& b2 a% j0 b4 }
static const short da850_evm_tl_user_led_pins[] = {' t b+ i0 R) L
/* These pins are definition at <mach/mux.h> file */6 t, B5 {( P* v4 E& b1 v/ {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 P& m8 v: w% H6 F -1% U s* D" ?9 W; z: N
};
3 {7 R) n+ ?& ?8 U7 @% M5 ]) r# h9 Z
0 |- y. ]7 Q5 s, A& ]static struct gpio_led da850_evm_tl_leds[] = {
/ v$ X; p5 p. o( v1 Q {! B0 i4 W9 h; @' e F
.active_low = 0,
% X" D4 r- e" Q .gpio = DA850_USER_LED0,
& `4 `) p& L0 {$ K8 w/ S4 d .name = "user_led0",! S& ]. j8 ? U
.default_trigger = "default-on",
5 m* `/ h" h) S2 ? },; O" g) Z+ A+ }0 U. {' Z+ d. j, {2 I
{
! H3 a/ H1 [4 }4 g .active_low = 0,% u8 l3 @6 u7 A. `7 D; M5 q
.gpio = DA850_USER_LED1,
' Z, l, l5 q) C) Z6 U2 E. J .name = "user_led1",4 k/ {) O$ c' J* b/ i T8 R
.default_trigger = "default-on",) p* _% y8 K' O. Y
},$ N% ]9 J, k6 C5 r$ i# ?
{
4 a* Z) @, w" Z, ] .active_low = 0,
: o& {/ n, N. E; C- p( X- b: e$ Z .gpio = DA850_USER_LED2,
5 K; u8 M2 C' z# c" d% \ .name = "user_led2",8 q& Y _4 r y/ S
.default_trigger = "default-on",
. [6 v6 o; o$ E: p, E" ] },1 R! }. c. z. O5 e7 O
{
" \2 r4 _) N8 [5 S8 L, I .active_low = 0," U: P+ v$ v4 |+ e6 O9 s
.gpio = DA850_USER_LED3,
' t$ M5 r& k* |. O+ F .name = "user_led3",+ n/ t5 l5 h7 y) R5 x' V
.default_trigger = "default-on",0 B, O) S |. m! l; Y* ~) l
},
, T) ^3 n% k' K$ t};' \. P1 q/ K4 s# ]$ W! v5 d3 @
5 I% r; Z: \& o! j+ t& o
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# }& x7 W$ u' V) \ .leds = da850_evm_tl_leds,
5 `7 p1 B$ A, K7 V+ ~" A .num_leds = ARRAY_SIZE(da850_evm_tl_leds), B5 a; z o5 w; T2 C# X/ b5 E1 a
};% a2 \ I2 f; ^: ?9 K
+ h6 O2 H ^, }" ~0 @) cstatic void led_dev_release(struct device *dev)
$ `! F. _+ H! y9 k% }& p{! G2 X4 C9 X1 Z) G
};
3 q3 d$ _! g5 P, y- O$ s; M, A# Q6 C
static struct platform_device da850_evm_tl_leds_device = {
6 t+ f5 p3 V7 e% a$ b .name = "leds-gpio",5 N- z' r" o8 Y' d% {
.id = 1,+ ~7 l3 F5 B9 W. U' K
.dev = {
+ ^2 M: {/ {7 l! g, O0 d) B7 m .platform_data = &da850_evm_tl_leds_pdata,6 \6 l! E, E- y# ]$ d
.release = led_dev_release,
5 e3 m8 ], M, S0 C B- Y4 H }0 b4 [2 V6 s1 K+ k, M- Y! b
};' c/ U( P/ |/ }% [3 Y
: q: t3 N; w0 c1 i) s' n( @8 w4 g
static int __init led_platform_init(void)
6 {* z2 }' G: B{
4 O- h1 C. U4 m Y6 ?! C int ret;
$ ^$ ?& U2 W% j* K, z [#if 0! ~$ c$ n) b9 s0 L* l/ G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. g' y z6 ^0 h; Y4 [
if (ret)
1 U$ Z$ e x* A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! a, L% h. i! u0 {* m5 V7 e
"%d\n", ret);
) f: v, k) J, Z6 J#endif9 e" t9 v. c4 D$ K2 H4 b" `
ret = platform_device_register(&da850_evm_tl_leds_device);
- k0 O! W3 M u _ M) E if (ret)
+ w2 [7 s5 ?8 P1 F6 o2 y. @8 b pr_warning("Could not register som GPIO expander LEDS");( b' E) ^- u% f' W% T, k
else
) T+ g. ` _% v3 m$ D printk(KERN_INFO "LED register sucessful!\n");4 p" k) k8 b1 `$ S* }$ u& Q
9 w4 m3 B c* u return ret;/ @" ?; o' n' @; \# L& ~/ ?$ h/ n6 X
}
# v$ K; d8 S# D; @/ u7 _7 P2 ?) h) X0 _. X- z
static void __exit led_platform_exit(void)
( _4 ^1 s* n2 ?$ e8 o/ B0 H3 H{) T. z4 J; p" o* H$ z7 Y
platform_device_unregister(&da850_evm_tl_leds_device);
7 ?/ r8 V& w; O; O6 b7 G4 v4 U
4 W6 Z: X+ ?3 u8 [ printk(KERN_INFO "LED unregister!\n");
1 x3 q4 G. ?1 n9 ?6 }. n, }}
! C, q4 V: S4 U+ B% O/ s/ ^; _$ H6 Z2 g
module_init(led_platform_init);% M7 _6 i0 O# e0 C
module_exit(led_platform_exit);
/ C8 K. K1 V9 n) ?
' U1 D c9 m9 Z% l( a# c* tMODULE_DESCRIPTION("Led platform driver");7 ?* x1 }, u2 |/ ]% A" ~9 t
MODULE_AUTHOR("Tronlong");( K! C5 x# C1 ]7 P! c
MODULE_LICENSE("GPL");! N. C2 X3 C- T. \+ z
8 l+ @8 T- m( b4 l' c7 d$ L7 Y |
|