|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 h+ W8 l# C1 D. U4 c#include <linux/init.h>' N h. a, Y, {5 o
#include <linux/module.h>
! ~$ l9 P) d+ D3 W( I c#include <linux/kernel.h>
! H3 N$ `' l/ H4 a2 B#include <linux/types.h>
# i6 s/ f- d! [+ t$ T8 b#include <linux/gpio.h>$ D* t0 Y; ^; n% d8 V
#include <linux/leds.h>1 e1 i1 a9 k/ T9 r8 U' K! G8 k
#include <linux/platform_device.h>
; c+ v% b& |1 X
5 m5 T* ]& g& d M: ~! f#include <asm/mach-types.h>
! l; |2 \' n* Q) Y3 B+ s3 z#include <asm/mach/arch.h>
2 X* t j+ N e2 J#include <mach/da8xx.h>) \* x8 V- y8 d
#include <mach/mux.h>
& V/ Y* O7 _3 I9 b. c3 ?8 Q3 g4 ~8 t) X! D1 I; N+ Z1 Z( B( _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 I1 f( C" k X
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 P; p% h1 u* T/ Q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, o7 r# s7 o& C _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): ^5 r H( ?) V/ O/ {8 k; v6 c1 f* G
; \; H( C, N2 b A
/* assign the tl som board LED-GPIOs*/. A' z! z1 I1 Z, r& ^
static const short da850_evm_tl_user_led_pins[] = {
1 @0 y7 `6 Q- M+ e1 H /* These pins are definition at <mach/mux.h> file */
1 X: m6 `* e- o1 V) d3 M) _9 G DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* p1 I! Z0 p) O# {; f" K$ `5 V
-1# w1 d7 i7 {# ?* H C7 z9 x- D
};
7 r4 a5 e7 D' J( Q" P$ v
$ q3 o# U& A' V/ \2 V( U! dstatic struct gpio_led da850_evm_tl_leds[] = {/ ?' Y" u I( u) z, b! W- v7 S; ]
{- E( Q, u) B* p" ^; _
.active_low = 0, e2 J$ u: p H- N, n% u" }( B& p* }
.gpio = DA850_USER_LED0,
& T* K3 p+ E4 \7 w: N+ z! x .name = "user_led0",! I( S1 S$ M% Z7 K# A
.default_trigger = "default-on",
q. ~! W8 i' J8 f4 t },2 u" {* s3 I3 r6 Q; X
{/ M, S5 d$ {' w6 S$ g! S4 c& ?3 l9 _5 F
.active_low = 0,
f' ?: g2 @: g! s* w% a! E f .gpio = DA850_USER_LED1,
' V9 ~! t `( o; A6 g .name = "user_led1",
! B: t8 b: O+ o# }0 g& d1 Z$ J .default_trigger = "default-on",
a2 }4 `; s0 r6 @2 s },. M% x3 L# f0 N! q2 h& `0 @$ M
{2 v3 U' {7 L" b) M" l$ L3 `
.active_low = 0,
5 o1 i( [' O- T7 A8 U .gpio = DA850_USER_LED2,+ p6 U+ d5 A% l9 L
.name = "user_led2",
! P( N7 r+ }, r .default_trigger = "default-on",% H$ Q! Z$ i3 r
}, c* j, \0 o) F9 V% }# r' C
{. S' G7 V, b: h- F2 o5 n
.active_low = 0,
1 M @* `$ g' L8 v' y( s6 d .gpio = DA850_USER_LED3,
, w, S0 U8 ~ X. ]- t1 H .name = "user_led3",
, u; h" ?* W8 L5 [, ?, Q% ~ .default_trigger = "default-on",# o! C$ G0 o+ ]3 w0 i
},3 G4 L1 _/ e @5 M8 n! r! b P& o
};& j8 j; F$ _3 R7 }5 M3 K1 W2 B" _- x
7 }; d/ J) T0 q9 S% Q# Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
W4 s$ k& _, B! S2 x0 I0 X! b; J .leds = da850_evm_tl_leds,
* @: \1 ~: D0 M+ { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ e; C+ I& R& G9 W" G @};
6 @: {( A) ~! K! V/ ?6 L( j; e$ h! C. y e/ ~& E% V
static void led_dev_release(struct device *dev)- {( {8 k/ d% R
{. ~+ Z' [' q4 Z; C7 e3 K3 }. p
};
' i) }, i4 @8 @+ `* K! u
# ^- e# H3 j3 R* h, y9 Mstatic struct platform_device da850_evm_tl_leds_device = {# y( o6 W; z' g6 G" j3 o* E
.name = "leds-gpio",
+ g% R% S4 d: }! J4 \9 A .id = 1,
) T! ]7 B* ~9 K0 H5 u8 k .dev = {6 o2 W ]2 b' X, J' _
.platform_data = &da850_evm_tl_leds_pdata,
S. t Y3 p0 Z7 b& }" a1 z .release = led_dev_release,
4 m, t! Y3 h) f5 B3 \ }
; a5 b* w7 O1 W x/ ?$ M$ p};
# e4 ~- J; w! N- B, u. Q
6 S* z+ N5 T3 ^) j. L8 b+ {' Mstatic int __init led_platform_init(void)
4 k2 l( O- g: Q% W6 y% P8 R{% {. q( t+ b' O d' {
int ret;
9 \8 d8 @. {) P* ~#if 0- F9 M" Z. K7 }1 w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" u) E& V) ~3 {2 q- I' K" k1 c# { if (ret)
1 c. z: J- O5 L& e8 ?& v- l pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 m7 R: n A6 E
"%d\n", ret);2 Z. v1 T! ?" h* C/ k+ _* f
#endif
5 H! Z$ y4 Q7 V& B& D ret = platform_device_register(&da850_evm_tl_leds_device);
! J) t( S/ U/ s if (ret)
$ D- Y5 K0 m3 q- w; w/ l pr_warning("Could not register som GPIO expander LEDS");
9 w. c; \2 b- l* s; v3 y- |) l else5 x9 b X: V {+ B
printk(KERN_INFO "LED register sucessful!\n");" H/ S3 c' v9 q, ]
9 O+ D5 o4 Q9 ~" M' ~
return ret;
% j T$ L/ S3 Y, j; ?' B}. l( O7 \+ ?; K, c
% d* V. z% U* N4 |9 P) T$ nstatic void __exit led_platform_exit(void)
" `$ e4 ]7 K8 O; R# q) l; v{
1 q4 I9 F6 o1 W/ m! T platform_device_unregister(&da850_evm_tl_leds_device);: c# z* q9 R+ P; m4 ~2 R
?* E* e9 Y8 J" J. x
printk(KERN_INFO "LED unregister!\n");
* L( t! g0 E4 I' u' g}# q' h% \1 ^) P8 }' c9 d
y% z7 ^, \* H I0 g% r
module_init(led_platform_init);
9 R" V2 Q9 M- smodule_exit(led_platform_exit);
9 @; E: \* l% R" _' U3 J( E! P ]. f- ^( ~6 O
MODULE_DESCRIPTION("Led platform driver");: e m. }* T" U4 m% D$ h* @
MODULE_AUTHOR("Tronlong");- }6 g+ x4 q# D
MODULE_LICENSE("GPL");, n& l+ G0 k) n4 z
" ?! l; |1 ]- C2 B( x |
|