|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 {9 s: L( f( F( ?$ _, N5 J3 y6 e$ x#include <linux/init.h>& a, `0 M. ^4 N
#include <linux/module.h>
( ?4 J% A2 j* s7 }. \; S" \2 z3 D#include <linux/kernel.h>
$ P! H8 D/ _4 k* J0 d, @#include <linux/types.h>5 L" V- g/ A" t
#include <linux/gpio.h>, V! E# R, k' H1 m, v! {
#include <linux/leds.h>7 e, h8 P8 I5 k2 ]+ p x; b/ J
#include <linux/platform_device.h>
: t( v1 N. P0 Q1 u" o( N. o
$ O& C, q" U9 Q- d; K#include <asm/mach-types.h>
" s$ N/ Q, a9 q* r+ f4 U/ l#include <asm/mach/arch.h>
" f$ ~: I: Y" ~. e5 q# L, o8 `#include <mach/da8xx.h># w ^* _) N, N% G4 r* e; w1 P
#include <mach/mux.h>" b1 T0 s% C8 n8 V1 p( l, x
0 M2 U" Y0 o2 J0 h$ y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ y8 B/ A4 H3 x2 f& w3 B: L#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# F3 _0 r# h/ V9 T, D0 ]
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* u. H F C2 l) O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% h4 F( T0 I' x3 ~9 v% `3 S. ?7 {/ E; v) w j1 B' K
/* assign the tl som board LED-GPIOs*/
/ g6 s& e% G/ qstatic const short da850_evm_tl_user_led_pins[] = {
2 s, V6 i) n7 A3 } /* These pins are definition at <mach/mux.h> file */& U+ G8 A! Z) z1 T7 A
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 i* q$ Z9 u" M3 ^/ l" W -1
/ V- f# l0 w; V1 f. p};
- Q; d) V, u1 L( N0 G5 g. {
8 U+ t9 w! }2 g- s9 Cstatic struct gpio_led da850_evm_tl_leds[] = {# N0 ]" v5 p0 q
{ {4 [, \% S4 Q; G) l# Q: }6 P: g$ T
.active_low = 0,
, H& o l* i5 j# a. d+ a- [( [5 s .gpio = DA850_USER_LED0,
8 M! B7 H' ~' ?; e, M( F2 n .name = "user_led0",
1 t) q6 R8 X) F6 n" y: D .default_trigger = "default-on",
; f# M- X/ J7 c6 w5 j },5 S8 Z" |7 S7 u
{: ?5 U6 a+ n9 m" _; {1 \# d8 d
.active_low = 0,
# s5 r! T2 \* v3 B .gpio = DA850_USER_LED1,# D- U4 C# V& d
.name = "user_led1",
7 o6 Z* F/ w) y) Z .default_trigger = "default-on",. G6 g/ E V2 D- Y: ~, E9 j# V! S
},7 G2 C7 h4 X; J6 R) @$ T6 ?- u
{
& q! h, R+ K/ ^9 S+ y, p .active_low = 0,
! x [. F4 H9 F. R$ `. {0 M) C .gpio = DA850_USER_LED2,0 s- [; [6 ?! Q: ^2 Q5 `
.name = "user_led2", I) i/ ~9 G& o( d, ]0 k
.default_trigger = "default-on",
^+ G8 h; c2 @% T: \" y },
2 A) F5 ]3 z$ c8 N. W: G {" W, B8 A, Q4 C! f
.active_low = 0,
, o3 k$ C4 z) S .gpio = DA850_USER_LED3,
; q$ R# u3 X. M4 j .name = "user_led3",7 v+ U- }2 n7 h5 C5 \* l
.default_trigger = "default-on",
; R8 Y9 q: [5 {! K( u },
/ V T& C; l" H9 v: R2 D: r};
: l- X, Q, L! p+ D/ h C( N
) Y' r+ ?4 Q& v1 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ _; v6 w8 h0 J. O' h) W$ \% t8 }
.leds = da850_evm_tl_leds,( f7 M j& E s) j( j s# Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, j# j& Y$ W7 w1 Q/ n! _};
* d7 o0 t: J4 W; w; g3 r4 b' k ~: r% O$ u5 J* D
static void led_dev_release(struct device *dev)8 A2 Q' N- ^1 }) O8 F" X- G) j
{
) E' ~# F( W7 J. J; z2 H. q9 o};- X2 W% x' }% x8 [, {
; x6 |* K- I' M% y
static struct platform_device da850_evm_tl_leds_device = {
/ k+ K9 s H+ D( o! r. M3 r .name = "leds-gpio",
( w# o, V% {9 T' K .id = 1,/ F0 q9 `. v5 ` r T* f& P
.dev = {
5 b/ G' y& M/ D .platform_data = &da850_evm_tl_leds_pdata,
3 @& D" Y5 ]; ~: C" n- N; i- k+ D) U .release = led_dev_release,
9 |- h, Y n5 r" A& l; r }
5 n) n1 `1 p+ O: ?; l};
6 o" @/ D' O" S+ P N3 m, r
) [1 {* v, N6 y9 ?# @% Ostatic int __init led_platform_init(void)) r; s P0 C% L# p
{. f' \6 H* @! G; a/ P7 L8 V7 G8 S
int ret;' M' ]/ {0 n3 ]" [) `% W
#if 0
Y& a* F+ _/ p6 p ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. x' J$ _3 j1 i4 j& B if (ret)
6 Q* y( A/ y4 V" S8 B2 m pr_warning("da850_evm_tl_leds_init : User LED mux failed :", W+ R- q0 Z1 a! b4 O' o
"%d\n", ret);% H' E) S0 Y" [, D4 m+ `* t
#endif' c' g. L6 D+ D* g/ l
ret = platform_device_register(&da850_evm_tl_leds_device);
" D W1 x& S: J) \ if (ret)
1 U. U+ _" o9 Z" h; U" ]2 g' S pr_warning("Could not register som GPIO expander LEDS");: W4 D- t g0 H8 M
else: y Y, ]' L: k2 ^6 f8 l7 S
printk(KERN_INFO "LED register sucessful!\n");
3 J/ G3 j8 G0 c# Z3 P1 G, m Y7 \7 x# D/ L
return ret;1 e0 N2 W! D Z* B8 R
}
& K* R! @, {( H$ u( n$ {
7 r7 o$ C# m1 Q+ C( d9 astatic void __exit led_platform_exit(void)
) q5 [1 ^ k9 l1 D+ R{: T( i4 d! p/ A9 V3 q
platform_device_unregister(&da850_evm_tl_leds_device);
. s' C; ]* m: e3 f9 I" J- [5 A8 I
) l/ K- f; f' j4 t, z4 ~ printk(KERN_INFO "LED unregister!\n");
5 R$ ]3 F9 k. z: H1 ` Q}
" B5 s) M" z! n" R4 ?! z) t
- a7 @! w6 H+ s0 L D* B4 K Tmodule_init(led_platform_init);5 ]0 [6 P# S; V3 G5 A
module_exit(led_platform_exit);$ A7 }7 J( ~. ^1 s- R
& H+ q' e/ U+ zMODULE_DESCRIPTION("Led platform driver");
- \' P v6 v& r& M9 @( D/ VMODULE_AUTHOR("Tronlong");6 V+ P2 ?- i! v
MODULE_LICENSE("GPL");
# d- j" L! k* e7 Z! U* W% m3 C
5 v; `0 V4 P$ d5 z$ S: Y' d9 |4 P6 B |
|