|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# _% j t# v- B* t2 Y9 g#include <linux/init.h>7 N$ u9 ~ C P+ _& {* S+ Q
#include <linux/module.h>
5 w+ T' |5 V4 R& N#include <linux/kernel.h>
+ ]2 A: P- u! S3 g0 y#include <linux/types.h>. }+ X2 B$ {* r) _# U
#include <linux/gpio.h>
% f k9 R5 d/ M* Z9 B* u#include <linux/leds.h>- i# L1 T& g$ w% A5 @$ d4 g
#include <linux/platform_device.h>
5 S; M. k- O4 f3 v* v. E: P% n3 H
#include <asm/mach-types.h>; Q& M0 I5 o; u3 E
#include <asm/mach/arch.h>( D/ z* f$ h6 V8 U$ Y; U4 b! M$ |
#include <mach/da8xx.h>$ |" Y( V( |$ |& H! N% ]1 @ ~
#include <mach/mux.h>$ w9 w @ j9 v
. L7 E+ O, r6 f2 g, U1 a! W+ A#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 T, R+ K2 `, i3 m* g: [. R- l
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; Z% a E* F# f, s3 d+ R( A#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 t& ]4 \+ N+ l#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& j, q1 u2 R2 A8 Y. X
5 C0 J( Y, i3 e+ r/ B! H1 @/* assign the tl som board LED-GPIOs*/* l1 C) K% f4 c% _2 f
static const short da850_evm_tl_user_led_pins[] = {0 _' Z* \9 g0 h o* s
/* These pins are definition at <mach/mux.h> file */5 Y+ _/ j# _" p# n) f. x3 k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, V& J2 H. o& t* X/ }3 o) h& h
-1
! |' B! ^/ I% {4 [( F& v0 w* L};: \9 e5 v3 _6 p* w" p# E* Y
# R# S' R$ t" l* F! u6 _2 M4 { Istatic struct gpio_led da850_evm_tl_leds[] = {2 c4 E9 f2 A) h3 E$ b
{
1 J% F9 t1 y! o .active_low = 0,9 R" Y/ j; A8 y- w/ \, t4 o
.gpio = DA850_USER_LED0,5 }3 ~' s, ?. j/ Y4 {- R
.name = "user_led0",# S' C! h6 V/ s# e8 c3 C& E$ K, W
.default_trigger = "default-on", m' w' Q& C2 ?6 k9 v. ?8 G
},
7 V) t( V/ U4 k7 n# E! z {' |. N- j* E0 @4 v2 t1 x
.active_low = 0,1 b* g# C& D* p* U6 R+ y3 x
.gpio = DA850_USER_LED1,4 S9 v, s& y* M& c% z
.name = "user_led1",
8 H: w( Y: G- f Z& d! n r .default_trigger = "default-on",8 E5 L) U* M4 F0 v) s4 g# f
},
$ P# g, K. k; j& R {. E2 [5 o7 [+ J8 d' _
.active_low = 0,+ W! ? z& a/ c0 ^6 n4 I2 r
.gpio = DA850_USER_LED2,7 }% O# k$ |7 n5 H* T
.name = "user_led2",+ r% D) n, g6 T+ Z
.default_trigger = "default-on",0 m3 q0 k3 x+ S
},
" N% ^, n. u: z$ w( n {5 e. a, \+ ^- L% ~: C# F
.active_low = 0,# m; `# h- J% \( Y" Q$ D3 `( M
.gpio = DA850_USER_LED3,( U$ ~, G+ n* d# `
.name = "user_led3",
+ X7 N* \( y$ O6 l3 W* a .default_trigger = "default-on",$ Q' c! o; f$ k
},
' L3 `8 Z {* Z3 Z! {, H. B};
) n3 p5 t7 D0 L+ \" A5 T$ d" b" D: ^8 e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 ?2 {1 |' B# ^. h1 _/ C% S9 w
.leds = da850_evm_tl_leds,% t. \4 X. M- J" e8 w& V7 b7 Q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' T1 R O! s6 f% R8 }4 g2 ^% D: w' S
};
2 @4 g7 y0 j+ Y9 p
2 [% ?- Z. c% c5 c+ n- l. m3 zstatic void led_dev_release(struct device *dev)
2 H: I: o: ~0 J5 U{
! m# y# v5 k/ _3 z) B# B$ @% r( n& l};
# i- @3 l) e- }, X, N$ x
( B& r/ ^1 p* B4 Bstatic struct platform_device da850_evm_tl_leds_device = {
' w9 ~: \) `4 {. ] .name = "leds-gpio"," \3 g! I3 y0 R6 W
.id = 1,* c- K2 c: p' g! m
.dev = {, F$ u4 G3 M' M- \; @
.platform_data = &da850_evm_tl_leds_pdata,6 x/ k6 u2 p- a% Y/ @
.release = led_dev_release,# x" U; J6 T2 b4 D0 b& E
}7 o! W7 r& w, g
};! w1 S6 Z4 ?- S8 b! j6 C, J
# ?4 x3 Q' d% ?static int __init led_platform_init(void)
_& s% p& C8 p+ o2 U{
4 P9 j: o8 k) c int ret;
$ }4 \8 C7 i+ Q: |" Z5 i# ~9 k7 G#if 0$ p' V1 J: L5 Z1 o3 v, ]1 I0 V
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ I9 |: ^8 G( m7 Q0 O p
if (ret)
" Y7 ^7 N' X" M% s5 W pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- |4 T$ U: S5 b% ~5 | "%d\n", ret);8 X* P7 ~1 i/ ^8 r d( M8 m5 ~
#endif
8 ^" \, x% C+ D( v: } ret = platform_device_register(&da850_evm_tl_leds_device);
: J: t" c4 ]9 N) X' e1 B$ r if (ret)0 O3 G' ~! d. N$ t$ P- V
pr_warning("Could not register som GPIO expander LEDS");6 G1 f+ {" U2 ~8 D( `5 m% u4 K
else/ s! M3 H' g6 x' ~2 p6 ]
printk(KERN_INFO "LED register sucessful!\n");3 p! P( s- q! g' O; j% a8 }. B ^
1 G- q0 a! Y5 J) I% t* o8 r2 r
return ret;
/ l5 F6 d) A( i4 g}
1 l) B; I, q$ ~; i
- o# T1 V# _9 K U$ `' Vstatic void __exit led_platform_exit(void)
. A7 M) G, R! t{; J8 A8 p1 t; l7 p6 }6 _" f6 z
platform_device_unregister(&da850_evm_tl_leds_device);/ @! A. S1 Y0 T: I$ Z
% M8 y$ N% L, ~7 O" Z8 I* i printk(KERN_INFO "LED unregister!\n");
( X" j$ g, X; S C0 @8 P, Z}+ P& y; [) L5 ^0 ~) m6 g6 F7 ^7 _8 b
. A. L/ k. U% l$ d5 f
module_init(led_platform_init);8 E, O1 n! d7 z$ h9 o! ]1 J; q6 V
module_exit(led_platform_exit);
# n- B% b+ p/ z" I9 t) ?3 l7 E3 p, n- m0 d U
MODULE_DESCRIPTION("Led platform driver");5 z% d) J& @# R% Z# v
MODULE_AUTHOR("Tronlong");- E: d) T! \$ ^! J; Z
MODULE_LICENSE("GPL");
! c- y4 |# w! _ y2 X4 E
! l1 b* ^) v) Q( k* | |
|