|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, @- h7 Y/ q- @9 C# M5 d! k0 a; [$ H#include <linux/init.h>3 m' w9 j+ L/ {3 F0 p
#include <linux/module.h># _ N: P c! f# n
#include <linux/kernel.h>
+ ]- {: K+ N" H; \% m#include <linux/types.h> Q) X9 a* L" ?4 A2 {* k6 Q
#include <linux/gpio.h>
7 y) A7 b/ D6 {5 x( w#include <linux/leds.h>
6 P% c$ T' m; n1 |; d#include <linux/platform_device.h>9 m: }5 S/ }- n9 X8 Z( C& i
$ k" U P$ D/ \) T! u#include <asm/mach-types.h> H" O% u* }$ [, ?
#include <asm/mach/arch.h>, Y1 O/ S: k" T1 d7 \3 k0 G( x
#include <mach/da8xx.h>
( p2 ~. w3 N" W, q9 [; T y! [#include <mach/mux.h>6 c* H+ C- }/ W4 ~0 n) h; E
9 n [1 _% Z( |3 u: J0 E' s6 A- e7 i#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 ~9 J+ Q7 d& {) G4 _7 \#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 T- H+ J! j7 A* M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): I& c( M' r7 O/ I B* Z. F* ?1 ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
p e, B8 q8 F1 v3 G' f0 }( n# \! P$ j7 w& U2 U0 t% t
/* assign the tl som board LED-GPIOs*/
f8 M( ~8 c8 z; R- P' b# Q4 _4 ?static const short da850_evm_tl_user_led_pins[] = {! k( k1 ~( D4 h( ^; J
/* These pins are definition at <mach/mux.h> file *// V' j; k; Y9 b/ c" L9 M, h
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# ]! @ V1 \; @, G L! V( q7 e' A -1
% K+ `4 x1 C. I5 |+ @};
+ H: E7 P7 o3 a# |7 ?
2 q$ S1 i _' R- N: Qstatic struct gpio_led da850_evm_tl_leds[] = {
* o, k! r; V1 d P, F {9 a1 r3 W" U6 r
.active_low = 0,& M+ G, ^2 P6 ~- m9 ~2 A8 e
.gpio = DA850_USER_LED0,% Q) M# w3 j9 L+ M4 Q8 p; |4 J/ E
.name = "user_led0",5 z, s; ?( c3 X* v# q
.default_trigger = "default-on",) f4 c* v9 q' q9 y, b' K. m7 h5 B
},
6 I5 O9 ?0 n j, N( m {" X/ X$ W7 E+ G* O1 Z3 v
.active_low = 0,- ?! U! {7 t9 W" p
.gpio = DA850_USER_LED1,
" q' h3 @' {+ _9 |! D- \ .name = "user_led1",1 b9 T1 \5 O1 F2 j7 }
.default_trigger = "default-on",7 a2 t/ Y$ S8 N# R( y! D5 E
},
7 N" X* @- o7 Y. w4 l+ m {& m( N8 |3 W/ r9 W( ~' d
.active_low = 0,% H: q0 O/ Q, t( p( t9 S
.gpio = DA850_USER_LED2,
% v' m6 r2 J* | .name = "user_led2",: z* a8 B3 N3 \1 _- x0 M( s
.default_trigger = "default-on",( q; g* H' p/ ^7 W3 s; Y* u
},) O8 j. H' O" o$ ?4 C
{
* [! T, I, Z9 f2 @* h y .active_low = 0,' Q/ ^4 H& T1 ~( a- Y' {; Z
.gpio = DA850_USER_LED3,
3 Q" M# Z. Q/ g, R. L4 W i0 B .name = "user_led3",; D& n/ L3 f+ ~8 q% E
.default_trigger = "default-on",( i7 O- I& C# } d5 H6 s b
},) A+ L. o& B) ?, {5 M i3 c
};$ t+ n; p: L+ d2 P z7 j
8 m% q% O+ x4 [9 c: ~& h2 u6 Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ j2 B x* a* d) X, b .leds = da850_evm_tl_leds,
" N. k8 K- w8 F3 e2 R# W* h! } .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ |9 s# a3 k0 g1 B# L};
% k' ~8 G- q" x( D
2 o6 Y; V. x0 Ustatic void led_dev_release(struct device *dev)
; B5 ^, w& m# ^7 h" ]{
+ J- h' \ G _: T};, G* u4 B& u7 U) B
- C" [! x. @- Q3 S# i9 j. R# ustatic struct platform_device da850_evm_tl_leds_device = {6 Z. b w* F# W! [
.name = "leds-gpio",
{7 k: q4 H! E# e: o .id = 1,
. r) Y$ n: S0 m4 R7 p .dev = {" X9 D/ g6 r2 u" C- H ~
.platform_data = &da850_evm_tl_leds_pdata,
+ b Q8 e/ y9 |6 ^$ \$ u; \ .release = led_dev_release,
& ]8 J) Z6 { L* k, K$ r3 o4 Q9 I }( }: o( r3 y, |
};% v/ Z" N! {4 C% I' |* o
/ R8 |5 k8 _: n# K* b7 m
static int __init led_platform_init(void)8 W3 T& D/ s) {0 }
{
0 t4 z; F, E( Y1 v int ret;
/ Q: J; l; V: W5 }% l- t- |#if 0! ]" G; a# a @) |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# h7 M5 l) P7 ^3 S. \) b
if (ret), }* S7 g" j9 a! ]7 C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 m5 d. u% @$ `# p% o5 Q9 C
"%d\n", ret);
/ g4 ^1 a: `/ E4 K; E' j9 y#endif& Q$ P7 U4 Z( x3 I8 U( P
ret = platform_device_register(&da850_evm_tl_leds_device);
: n0 `! q' M, d9 \6 y if (ret)# m8 _9 x8 O1 d* b
pr_warning("Could not register som GPIO expander LEDS");
; {5 [ j. L/ `# } else0 [) V6 G6 G( f) z; N% z
printk(KERN_INFO "LED register sucessful!\n");
% Y6 e" U% ~2 n2 X
; _. o4 d+ V7 B g* _% x0 u return ret;
+ } R8 M3 q y d) w3 i$ o}# A, r8 B9 ?' x7 }. [: h
- y" Z* u: W. h/ |$ v$ F; X
static void __exit led_platform_exit(void)
2 ?( Q$ Z. e3 _9 }{1 |4 I# A' d" d* }1 O$ X$ M7 t8 D# k
platform_device_unregister(&da850_evm_tl_leds_device);- x' a4 G8 \6 @. ]- b$ I7 s7 x J7 l
1 l/ X8 _% S+ ]4 P. x4 R
printk(KERN_INFO "LED unregister!\n");
* P* ^+ s2 V, ]$ O: ?( I9 e}' G4 S4 ?1 Z3 D8 V
! x1 A6 F; Z' V. i/ @% j
module_init(led_platform_init);9 l$ i+ L0 m; z1 N
module_exit(led_platform_exit);
@' B# b" U1 B1 I4 G6 R; d" K) t: v. g
MODULE_DESCRIPTION("Led platform driver");8 v o7 E/ x; U! ]5 {/ ?
MODULE_AUTHOR("Tronlong");# C7 i6 d# O6 v, R
MODULE_LICENSE("GPL");
& B& [/ B+ M" T
7 s. @* H* g1 H' V9 G2 f3 d |
|