|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 |9 u% J" o6 p0 U( @9 m#include <linux/init.h>
4 f# e; g! `. i/ l2 u; [#include <linux/module.h>
# ]9 d; t1 p$ L$ e#include <linux/kernel.h>
( j; F. x$ l* I0 J5 p#include <linux/types.h>4 h3 k- }( E- x! D9 ]; i5 V
#include <linux/gpio.h>
8 }3 q% h$ r/ N# k |#include <linux/leds.h>
$ _0 l3 b4 |9 _% F8 i#include <linux/platform_device.h>) Y$ B0 E5 p+ L$ ^) ~# w* _. s
& Q5 f5 t1 A7 Z# F3 \5 z) r/ u0 Z#include <asm/mach-types.h>
6 V$ U1 \+ |/ s7 z: @$ j4 e9 K#include <asm/mach/arch.h>
# a4 G: P% P4 p. ^/ p0 b% S#include <mach/da8xx.h>
7 \* b0 x: U2 I% ~#include <mach/mux.h>+ |( e& N# W' s$ O/ [! e
9 x* u0 q: W8 y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* ?& l, A% v" p3 y/ M; T#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& t) i9 k5 f" h; A+ U: s A3 F#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! G$ s1 f/ d% c& {0 U! `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' V! y% O% m# b0 Q7 X
( q5 F& p y$ \" X0 B' D/* assign the tl som board LED-GPIOs*/0 j3 j9 t8 S3 o
static const short da850_evm_tl_user_led_pins[] = {
. g: g b: G1 L8 L6 D# l" m8 {4 r /* These pins are definition at <mach/mux.h> file */( j. U3 d1 L. n1 n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 [" K% q7 A/ U
-1
1 l: F, a/ U( ~};) T s( X& A* i& f
/ T+ n- b. F: A |5 u; Z
static struct gpio_led da850_evm_tl_leds[] = {
! B: o; G( M: V7 {: g+ T- y {
- n- {, n- F2 @' d6 g" c) z9 ]# ? .active_low = 0,
4 I5 y: N, j4 v5 t( _) z .gpio = DA850_USER_LED0,+ N; K! L1 [9 J9 R. O0 s5 R F
.name = "user_led0",8 f7 P7 l/ i; N9 [4 N. p& v- P
.default_trigger = "default-on",$ v' Y6 P7 ?! B7 W
},4 `; v& }* j4 x# A+ P+ b8 M" O
{. R( `% M7 q! q" [& S; n
.active_low = 0, O3 f8 I* t( c. U" ]; U; p
.gpio = DA850_USER_LED1,
$ n: U+ U( o! S5 a .name = "user_led1",
# g9 h8 d p4 i" ?: }0 W1 Z; B8 [ .default_trigger = "default-on",
T4 e U6 N3 h, I1 z6 P },3 ~! h" C$ W7 U5 j/ r/ k. d4 e o' `
{; X8 l. C; K$ f% `- {! t
.active_low = 0,
& j8 r* b1 T( c# `, d- r .gpio = DA850_USER_LED2,
/ O" q& o* ^: ?# i .name = "user_led2",
- C. L6 K' o; i% T8 u2 f2 f! J .default_trigger = "default-on",
- f& ?7 I1 Q4 G3 v3 ? },, `4 Z' i# q6 f* {3 E
{* n+ m" @$ _; S4 \* m! s4 F
.active_low = 0,
* c Z, N |& g& n K* L; p5 M y .gpio = DA850_USER_LED3,+ V6 ^$ K; g7 R
.name = "user_led3",0 g1 r9 ~9 [: H) H. `
.default_trigger = "default-on",
( G) j9 N/ M+ A, O) b" U },
$ R0 E/ ]! q8 G; |};. `# r# p, u2 t8 L4 k
! P! j+ `$ K7 v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 w6 {$ o( c8 H9 H
.leds = da850_evm_tl_leds,& O& N. G" A# c' D' e
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* p" {3 _. f9 r/ j' _/ r};
. R# y% c2 {8 M8 }7 N+ `6 z5 ]7 S, x! Z, e' v& d8 [2 S
static void led_dev_release(struct device *dev)% k2 r; u. O0 y) L
{, m$ i) v- ~. H0 j6 c. D, t( G4 i
};
% y2 P+ y9 m! c9 M% L0 Z1 I8 {. m( P ]2 P. O8 T7 S( ~
static struct platform_device da850_evm_tl_leds_device = {8 ?% N5 I; C, ?' W D
.name = "leds-gpio",
- i" [1 ?" w1 `" e6 K# l .id = 1,4 e! a8 j) h9 F+ v" I8 U
.dev = {
; l. r. x! m1 V' o2 r .platform_data = &da850_evm_tl_leds_pdata,; M4 P0 p4 ~/ ?; g9 o% x& [
.release = led_dev_release,( t/ Z% n' }; u% j
}
& Q7 N) E; L6 }( y0 R* F% Q( n9 f! ^};
' }' Q2 J t: c7 U8 D. h5 I6 M
$ I8 o. M2 h; h6 W% @static int __init led_platform_init(void)' B9 {3 V+ Y& t* c3 t+ c" N
{
5 @2 `5 `0 n* Z# h int ret;
1 V8 { z/ X' W+ @1 C5 s% y' g#if 0
5 |# r2 k8 G7 J) E$ @" J ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 {0 q( v+ l: M7 L; G' v0 I if (ret)1 s& U9 ^1 s7 z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ i7 [3 z3 f% N% o0 t. |3 p" { "%d\n", ret);
5 `, g; f9 E7 @: x! l#endif8 q" I, N3 O& E$ K d
ret = platform_device_register(&da850_evm_tl_leds_device);
. ~- K; W3 i4 p5 Z. y6 d5 u4 Y0 j0 V if (ret)7 L) N, @8 F( m3 Y$ \ D
pr_warning("Could not register som GPIO expander LEDS");
7 |" d/ N( I9 c7 [ else3 M0 n6 [1 s6 ?5 U
printk(KERN_INFO "LED register sucessful!\n");
( z1 H" k! [: G% M! v8 U! T: n9 W6 A# u8 M; a4 Q
return ret;
! P/ v8 p& {& B/ c}
9 L& m) K5 N0 e. u+ X& k2 O+ p4 n0 Y; T) A. U
static void __exit led_platform_exit(void)" V8 s. i3 |# m N* g- _9 y
{5 S, G* ]; p& Y3 Z$ Y
platform_device_unregister(&da850_evm_tl_leds_device);$ v- G: ^7 \8 ~( ?# P: n
3 i1 f" m$ S! |1 R% ^
printk(KERN_INFO "LED unregister!\n");* p) r* n$ a1 N
}
8 _- B% E8 u. D+ z2 n2 B, s* y
% g$ [0 u" h( m, Lmodule_init(led_platform_init);
8 B2 R5 N+ ?2 Y6 N b: `" Fmodule_exit(led_platform_exit);
' |. _* b b& v& y+ k9 `9 ~ Q
! ]- z6 U1 v8 n$ G; fMODULE_DESCRIPTION("Led platform driver");
6 n4 Z5 M% y/ k4 S4 U8 c( _- [MODULE_AUTHOR("Tronlong");2 X; m$ ~/ s6 c k* Z
MODULE_LICENSE("GPL");
, A7 ]3 E0 Y. a* N- O% M; @. \6 s+ `3 I. Q' [
|
|