|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& a% |5 R$ [: N7 }; \) J
#include <linux/init.h>$ k, U7 f2 h% o, t! |
#include <linux/module.h>
0 v$ r! j) R6 Y6 a* ^9 \$ u/ Q#include <linux/kernel.h>
5 \0 Y# G+ h# ^5 X9 S9 u#include <linux/types.h>( p0 u7 y3 {$ B- C
#include <linux/gpio.h> o' b3 D/ a" N& ~( T* w8 f
#include <linux/leds.h>* }* @& X2 S. k K
#include <linux/platform_device.h>5 v% o7 t7 H: `# B
( w0 T7 p0 {- \ z# G- K$ s6 g, g5 b#include <asm/mach-types.h>
8 U$ A( m" o; ?6 {1 B#include <asm/mach/arch.h>
, a* u R/ u, X, z; e; M#include <mach/da8xx.h>
" _. ^* Z# [% D3 T4 y4 x' f. t#include <mach/mux.h>6 x" Y0 l' _ V9 C& o7 S
% q w/ V6 N% `9 e, ?& ~6 D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 W. K$ @5 N6 T2 \( |0 J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), E3 |; w4 A) r, ]; B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) I% C J+ G. U8 v: p1 \* c
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ X" ]" a6 I9 {: y# T
/ F( R) j! T0 R/ q
/* assign the tl som board LED-GPIOs*/
0 \' A; ]9 W- d! a" _, P; l; H% Jstatic const short da850_evm_tl_user_led_pins[] = {, d; E( [0 h, ^) H1 p8 q5 m
/* These pins are definition at <mach/mux.h> file */
* x" e, h# k2 D, J3 h7 F! G$ v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 T6 W3 C$ K/ N4 F -1
9 \2 i$ I5 [3 O};
4 Q% m8 F3 I" c9 u/ s2 T$ M: m/ n% u- X$ H' G1 {$ H
static struct gpio_led da850_evm_tl_leds[] = {
1 \& l2 s) ^" | {
0 F n: G) d" u .active_low = 0,
9 y+ W' s4 \! o2 ^8 A6 Y .gpio = DA850_USER_LED0, D7 g7 o0 t7 X d/ c
.name = "user_led0",
- s7 x2 j+ j8 C( F: T" z8 a .default_trigger = "default-on",! r- t6 M1 u+ S7 u
},0 Q$ I& G( N* B
{
9 b- i* K" m8 d8 t8 H .active_low = 0,8 `* S2 l& v+ Q; K8 k, J% g
.gpio = DA850_USER_LED1,6 E- V% C+ j/ r( G6 }) {+ j
.name = "user_led1",2 f" E/ i9 k& A7 {& E& s9 A
.default_trigger = "default-on",' G# t' c7 R' |; H
},* U) h$ S0 ^8 e1 t3 [" M z5 M" b
{
8 f f: ^: @! P .active_low = 0,
2 |5 s# A( T |3 w- Y( \) n+ ?4 F .gpio = DA850_USER_LED2,
+ |( U. T' O" M: a' x1 p: m .name = "user_led2",
- ]9 g6 H# F+ G3 S: ~ .default_trigger = "default-on", M P: x; j& }6 c1 @/ h, n) q2 g( |
},
' `! o9 u- w+ p; o b: F! ^ {
7 i; u; I* X; T1 s- S$ Z4 j$ H .active_low = 0,
0 b8 Q1 E* J9 t" ~ .gpio = DA850_USER_LED3,
$ j) f2 i. R6 Q6 r# t4 O3 O .name = "user_led3",0 U% E0 X# t# E% b& ]4 q" K
.default_trigger = "default-on",8 _5 v5 ?9 n" q
},/ I$ Z% u' K: j+ y8 \ \
};
# B q! p9 t- p1 p! ~" W6 x4 j7 y8 i5 n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- h* m! v2 @6 d, _- m
.leds = da850_evm_tl_leds,( W0 U w/ ]' Z5 Q* V) Q7 ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! o9 X( e; B6 Y5 M& m};
2 o Y- _) `7 k; N, V5 P8 a0 Q4 n' b9 e- m
static void led_dev_release(struct device *dev)
W r; q& W# R{% G3 B/ F0 F( c4 U9 b9 b
};
3 W3 P$ N1 D( K( Y$ S: ^" v" ^! s) r
* X2 O; l7 t B/ fstatic struct platform_device da850_evm_tl_leds_device = {
, g7 d( Y. [1 L9 `% g x% I .name = "leds-gpio",2 J) [, w8 H1 D% J5 e+ f
.id = 1,3 [% ?5 m9 J" v5 R: k8 U1 p
.dev = {
4 d) n* p3 H) z- N .platform_data = &da850_evm_tl_leds_pdata,- P. e# V! j" C- R& x7 E& ^
.release = led_dev_release,
( e6 E, d4 B. W; m$ p/ b9 m: ` }( T0 J2 g1 j1 u! g+ W9 w5 ^$ J
};1 P; W9 ?' l8 z1 n& b
- B1 l9 d2 U e$ n: ?static int __init led_platform_init(void)
9 h* ]1 s" ?4 @0 e" h R9 V" E9 H{
7 N1 D0 X% Z7 N. T2 X! ?) B, A z int ret;" Z: Q& R5 ?2 T7 H3 Q+ c( y4 y
#if 0# L8 P$ q3 R$ ~3 w; ^
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 }# c4 s# X5 s9 U- j( k/ J if (ret)
7 V, n9 M$ S$ ?" I& E c pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ U: ^( d+ E- o/ J# x0 p, F
"%d\n", ret);" M8 ^& R$ q F8 J# Y6 ?1 y/ t
#endif) J4 s% y( |, U! T; A/ E* H" ~( O
ret = platform_device_register(&da850_evm_tl_leds_device);
- M1 H [# N/ C if (ret)1 |9 \+ r7 i! B9 |" Q: a1 \
pr_warning("Could not register som GPIO expander LEDS");1 g' x1 L9 r. P' N8 I5 E q
else. j& V& y9 r$ @+ F: ?
printk(KERN_INFO "LED register sucessful!\n");
# @$ l+ T4 s( k2 h/ w* c; h7 P5 T
9 I5 I# P. Y" P7 P return ret;
- S' ?6 t8 i3 Q}6 O2 P; |& `. S, a& t2 r
' ^, `- R2 \0 W- d% P0 c% A& s, W
static void __exit led_platform_exit(void)+ Z ?* ~0 i ]; i2 i4 V) u# t3 p
{
: g, e% U& o' K, {4 | platform_device_unregister(&da850_evm_tl_leds_device);4 _8 R5 m" }) T2 [
: m. f: s( u3 p, s" P8 s printk(KERN_INFO "LED unregister!\n");" `4 d# p3 k7 B" c$ ^3 y: g' {
}* {; Y& _$ ~- F$ L8 D
* w, D! D( ^* _3 A' Q" Smodule_init(led_platform_init);4 b2 y/ V& o) ?# i/ m
module_exit(led_platform_exit);
! |! S/ o& b+ t
) A/ Z! t! a0 s/ X7 c. mMODULE_DESCRIPTION("Led platform driver");
, |# n e& a" G: r* Q; WMODULE_AUTHOR("Tronlong");3 ?- D1 B' w' _1 k2 |/ c
MODULE_LICENSE("GPL");) G* `) T* O1 V. ^; v& s7 E( z
: a9 l0 F8 K! H6 n# ?3 O4 v9 z |
|