|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% a" o# q4 b2 R: ], W4 \; u#include <linux/init.h>
, _7 J8 l' G9 u+ h: _#include <linux/module.h>
9 M( H/ |7 r9 O* d3 H J#include <linux/kernel.h>
3 d2 B( o* O' I, Y# ^: n* G#include <linux/types.h>, f7 @# ]% j& W+ A- ?
#include <linux/gpio.h>
4 l: X" I$ A6 j: y: g: j) q! w#include <linux/leds.h>
0 g+ g/ }6 Q; q4 x#include <linux/platform_device.h>) T9 M; i; C; |. q" p+ {# R( i' u; t
6 v0 n2 w/ B8 ~; m#include <asm/mach-types.h>; @: k- a) v8 \" E' B
#include <asm/mach/arch.h>
! k. g$ L* F& W#include <mach/da8xx.h>8 F8 c7 Z' ~9 B4 f6 I& i( C1 j
#include <mach/mux.h>
& f! k9 o- w( ?3 j" U" v$ q# }$ h
0 v% J" Z+ L" s" U7 n: W8 C# x#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 c% N7 w/ W! l3 O1 S1 _$ a: @' ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" O6 w. \; Y" `' D6 M0 j
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 d( n ]" C, v' m2 |#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 _+ C( w& `7 p* U O7 k
/ {* e: E2 d) l/* assign the tl som board LED-GPIOs*/
7 X. Q3 p2 v) g" q b3 C! W' E& fstatic const short da850_evm_tl_user_led_pins[] = {
4 Q, b* G7 f0 Y7 J /* These pins are definition at <mach/mux.h> file */
9 ?* y) {$ l0 S; m DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 X. y% u) X! t -1
8 J- L* l/ T) e. U; p& E7 X' Q1 H7 p};% N/ x6 j0 p: t* q
; n( I% E) z7 q% N- X, S6 `& c' ]
static struct gpio_led da850_evm_tl_leds[] = {( G: ]' t/ ~5 ]8 a/ \2 d
{; A, y Y1 q4 F% }+ _/ v* q
.active_low = 0,3 D$ z% f% @% L& Z6 \4 q
.gpio = DA850_USER_LED0,1 E# y8 ^- }5 T
.name = "user_led0",
H! _$ H% f# r3 X% e& J6 @" i# T+ Z .default_trigger = "default-on",
, ?2 N+ I5 A$ n b# G5 C },& z( ?% m2 l. o
{8 T& d$ j9 s2 |& Q) `( j: B% U
.active_low = 0,5 j5 \6 N3 v5 b* d# K" ^9 r# }* |
.gpio = DA850_USER_LED1,
' b/ Z! C7 }% w/ m$ W .name = "user_led1",
2 o5 K7 w3 @/ ^% W .default_trigger = "default-on",8 q- d. j# K5 n9 M( }6 e2 _
},% @3 I9 D. i* Y% ?: D/ F* ~
{, p/ j$ o7 n+ ^ Z# J% z4 X' `1 ?) ~
.active_low = 0,
, U2 y5 P. n' L6 Z+ i .gpio = DA850_USER_LED2,5 {% s1 }) O/ A4 u- O3 t% k
.name = "user_led2",
8 v, h9 t+ t; ~& t7 I3 P .default_trigger = "default-on",
! D* f+ c7 g( R5 i },
, m8 S7 a9 S7 I8 o! X8 Z8 { S {
u) b4 g( {) w& P# i2 S6 E) C( S/ M+ h .active_low = 0,
+ G- s, \( C' Q" B0 ] .gpio = DA850_USER_LED3,* _, @% _7 ? h3 G9 f4 X1 ?; H5 X% q
.name = "user_led3",; N8 H) ]2 n5 k6 t5 g+ D
.default_trigger = "default-on",/ d q" U! ], j
},* `1 P; q1 b# G1 e: M F% s! V
};6 o% a1 a$ N2 `+ }0 X
9 B' O3 c/ ]9 W k' W8 Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 B1 y* F1 j" h; q* G .leds = da850_evm_tl_leds,
! c* q2 u8 T: C9 d% @+ ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 j. p( x9 g6 f# {5 c! a2 q6 P};( }: o# G; ^" A/ n- V8 s7 c
, T! d% Z( Q- H9 bstatic void led_dev_release(struct device *dev)# j( [. N7 I' A5 }) X. z/ C
{
0 G \3 I% N9 r0 S/ u# y};( a$ k0 M* R# v7 w F3 v) F
$ A' G, k( |' V' p% B. I$ h. _static struct platform_device da850_evm_tl_leds_device = {
: T; F* a$ p9 m( I+ U3 p- Y6 ]: L .name = "leds-gpio",6 d: W6 i3 j( j. o' C% i) e: U
.id = 1,/ `/ g- m }/ g# Y
.dev = {2 {( F, f5 {/ H* V" I/ m, M" n
.platform_data = &da850_evm_tl_leds_pdata,3 @" } o- O* W3 C) K5 S
.release = led_dev_release,, O. w2 {! J7 z$ y/ L7 o
}4 m; q# B0 \: G% L3 y5 f
};7 I1 h! k2 l7 S6 ^0 e1 B
7 R2 P7 q O! sstatic int __init led_platform_init(void) s/ D& d: K. u8 h5 V1 d8 r# a. D
{
: z P9 U( x! e int ret;8 `/ y- G+ Y; F+ Y; j$ w* H
#if 03 o6 q( k& R. q/ L c4 k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 [" r6 u% u2 e( ~ h" T8 O
if (ret)+ \9 {9 s7 a2 y9 a9 g! T2 u- ]
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( X3 p F: ]6 g3 x, G! s4 W
"%d\n", ret);
% V) E! ~' d- v0 H#endif- J! y# b/ y; K5 Y# i+ p
ret = platform_device_register(&da850_evm_tl_leds_device);
! ]" q8 N2 m# T1 L* H5 P if (ret)
, l; B" q( l( s+ d+ Y9 M+ ? pr_warning("Could not register som GPIO expander LEDS");/ p7 U: v+ s+ X7 f
else
8 \! h' l" s- y' S4 \ printk(KERN_INFO "LED register sucessful!\n");
$ y, H2 k) s# n6 p: ?# p$ F3 Q& n2 x' {
return ret;
2 P: L- ~ k# K+ x% |1 e, K* ~}
2 B. c9 \5 d! p3 q: ~
- B" X; b' V, @2 [, Mstatic void __exit led_platform_exit(void)5 ^1 `" u7 ]: K
{1 t2 y/ N6 ?, x+ i. Y, `
platform_device_unregister(&da850_evm_tl_leds_device);
/ F& e6 j; r7 h( d% L7 o
" x1 B6 w* g' B/ Y6 ]4 ` printk(KERN_INFO "LED unregister!\n");7 R* {* T% {2 `5 [ v4 R
}; Q2 L$ v( |! K8 J; Z
9 [+ {& Y5 c+ x. E. ?
module_init(led_platform_init);, _, K, i ^. K+ U9 d1 ~2 W$ m
module_exit(led_platform_exit);1 H6 q) z% `) ?1 B: o! B7 i
8 e& J% D/ i2 y. w) N0 _* qMODULE_DESCRIPTION("Led platform driver");
, Y3 F, `! A' sMODULE_AUTHOR("Tronlong");5 j0 u! P, t/ x( u9 P6 Q/ E
MODULE_LICENSE("GPL");
# H. n# O$ {/ e+ O$ Q9 A- U: a- u
" X+ z; c/ m- p0 E n( m4 p |
|