|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( F, L" l# l: l5 o# R3 D
#include <linux/init.h>
" L$ g2 I* | ]% y#include <linux/module.h>
; T8 e, E& w* U* b1 ?#include <linux/kernel.h>; c: E# G( R& F# }$ D
#include <linux/types.h>4 f1 ]+ @0 g0 H' c7 d1 H
#include <linux/gpio.h>; R' W, B$ i2 s
#include <linux/leds.h>! b2 ~& B2 Q) k, l S K
#include <linux/platform_device.h>
$ s( _. p0 j3 L) H
" O% _ c+ c: k/ e' c4 {# z#include <asm/mach-types.h>
# e% U6 x; ~: b( @: b7 n0 s#include <asm/mach/arch.h>2 n7 X, I9 ]: g
#include <mach/da8xx.h>4 a* s' O6 U1 h g) g
#include <mach/mux.h>
3 t, n+ ~& B9 ?+ U- x$ r
# h0 \3 n4 x; g9 K#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' B6 |8 O. [: ~& ?; i; `
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
y- o! j# o, s2 q* ?; u2 a. `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) y" X% f! m2 |- F
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) [; B) l5 c. H( {2 z& |8 P) b
; P' C+ _4 R! B9 u* d' y+ Y/* assign the tl som board LED-GPIOs*/! u, l9 R8 G2 k6 X3 @8 Q
static const short da850_evm_tl_user_led_pins[] = {
. Q. [9 y$ h) B- Y# z /* These pins are definition at <mach/mux.h> file */$ v- n2 q1 u& u4 y- m4 r' k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; J6 J6 q+ |1 e0 W' f _
-1
" F% b) x0 J6 L};- ]. ^0 O% z1 G D
* N, E. W9 t( x( y- ~: ?4 s, B: a7 vstatic struct gpio_led da850_evm_tl_leds[] = {# n! ?7 U8 _- y, T/ }
{1 V$ Q3 |9 U7 _1 d d/ I
.active_low = 0,
" y0 B6 f( K# m1 k- Q .gpio = DA850_USER_LED0,3 P4 j( d2 D4 I
.name = "user_led0",
5 i( Y% r- c7 h9 i& U7 z .default_trigger = "default-on",
) ]+ ]- T3 l H% n },
4 w. p% i( O, P7 ]- ? {
8 M7 H4 m+ A, Y .active_low = 0,/ M l" T+ z# ?! f1 {5 H4 ]1 S8 [
.gpio = DA850_USER_LED1,
7 C% R3 `! b/ D; r .name = "user_led1",
) f9 m" K6 Y. u1 Z5 y% e' L. n .default_trigger = "default-on",$ H+ u/ `1 _) j5 X; Q$ t8 s
},' ~1 }% c0 u" T
{' q, m6 N2 h+ p4 A4 n) R$ d3 F. D
.active_low = 0,
8 z9 o1 [! A6 Y& ^5 C- \- M4 j .gpio = DA850_USER_LED2,
8 q5 } b& Z4 v .name = "user_led2",* P) p3 ]) X+ K8 P# c) k
.default_trigger = "default-on",; k B9 n# ^" c' G' H- {
},
" P# Y( @9 }. o: z) B. c {
& | r6 \4 f1 _' B% g .active_low = 0,
, ?6 J) E u2 c5 \; b2 U .gpio = DA850_USER_LED3,
p/ c/ {$ X% b% n1 F6 z6 K .name = "user_led3",* N- d" h, P- k( Q2 r
.default_trigger = "default-on",
! A4 F4 N2 e1 z1 P* A! t' T },$ J0 i1 ~- W/ L9 r
};( k5 L$ R1 B9 {3 }* R
! q; P1 C3 M0 E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" c" p& E3 F! c8 o+ m' T1 T3 j+ V
.leds = da850_evm_tl_leds,, n3 n$ \$ P2 M; ^
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) I9 V( E Q+ a ~};
+ f4 {3 E# m" b2 n$ m1 k* V) i5 W- r6 G
static void led_dev_release(struct device *dev)2 F, i+ K' ^( \# A! ], ~) ^
{
9 o6 t! `, W& r7 r. V3 w};& I# z/ P) H; m$ p" c
$ I$ l+ r7 t- q7 _7 bstatic struct platform_device da850_evm_tl_leds_device = {
5 I# F( ~6 l4 y$ h9 x0 ` .name = "leds-gpio",
( F4 E& e8 W! D .id = 1,
Q% t8 i' B8 b( b+ u! k. o .dev = {$ z" m' a& a& k; {
.platform_data = &da850_evm_tl_leds_pdata,' s6 M, E* Z- g+ u+ B& p
.release = led_dev_release,
& S2 ^3 w; Z% M/ \8 I }' L0 _1 Z. E# j) B
};. L: |' @. V. e+ c
- z J3 R* N1 O2 @$ Nstatic int __init led_platform_init(void)8 W, T* o& Q9 o3 ?$ g( c' F/ h
{
: f) h; d6 i: z2 {5 }, m7 | int ret;) K; @7 X. L) \; ]. L: G# M' U" O4 b
#if 0* ]4 ~* K! k4 F7 F% R6 M! K
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! W: y7 F9 S7 W; w) g) o if (ret)
9 e$ g& y, A! c' J) g6 a pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 Q, q/ \* a5 n "%d\n", ret);
' K- R3 \3 a0 A/ D; ~0 G4 x#endif
8 _- r( E8 o" M. B: k ret = platform_device_register(&da850_evm_tl_leds_device);
5 a% r" f: B9 M% r7 ?- Q+ N if (ret)
) q0 R2 r# I9 O! I1 k+ s pr_warning("Could not register som GPIO expander LEDS");5 i$ l+ f# _5 u- I
else
. U7 W+ c0 V, x5 A! e- s7 d printk(KERN_INFO "LED register sucessful!\n");" M+ L7 }+ k. n! f- N7 L
& G' i5 b. I3 `6 C
return ret;! T1 I( k) e" s# S# ^- X
}; Q. q# y; d1 ^ _
: V3 |7 s+ @0 @; z% u1 z$ O4 Wstatic void __exit led_platform_exit(void)& [, l2 h( ]% _' `
{& \" i4 L" _$ e, d# A9 u
platform_device_unregister(&da850_evm_tl_leds_device);
$ i9 E. H) K, e Y- K
3 k7 y, g' S5 v% J, F printk(KERN_INFO "LED unregister!\n");
1 j( o* q9 A9 K1 S: ~/ ^}
5 c- z" |0 r9 P, B" U4 }6 G& p$ t& h& R C+ b
module_init(led_platform_init);1 J* \' o0 @9 U- d$ s% d' z7 K/ a
module_exit(led_platform_exit);8 y8 m- B( S; Z
4 W$ |4 s' T' S6 ]) G2 TMODULE_DESCRIPTION("Led platform driver");9 ^5 y6 |7 \( e) k0 z8 q1 K5 `2 k
MODULE_AUTHOR("Tronlong");7 A! M1 R5 ?! Q5 V6 D0 D8 }
MODULE_LICENSE("GPL");
/ i3 E4 c7 v0 ]+ {, o( _0 u& h
& @9 {+ x m% P4 f* ^ t$ W9 w" e |
|