|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# T# W, D: Q) _$ R& R
#include <linux/init.h>$ J1 `% n8 c# i$ r6 _
#include <linux/module.h>9 m: k+ f" ^' j$ F
#include <linux/kernel.h>
7 i2 {/ }% `" w& r/ J" s/ D8 o#include <linux/types.h>- H: V0 T$ z8 A: m
#include <linux/gpio.h>/ t/ p" y- e. M/ T
#include <linux/leds.h>; i+ T9 ]8 o; U
#include <linux/platform_device.h>
$ o: e/ i- j1 I, s7 B5 C, w4 ?) _
) A7 Y6 b C! Z& o9 p( O! h#include <asm/mach-types.h>$ U9 K( z8 x6 Q. j9 Y6 q- F
#include <asm/mach/arch.h>
6 r( a! {' m/ U#include <mach/da8xx.h>& Z* B( J0 V! k5 P/ b. t
#include <mach/mux.h>
9 X& d1 D: @' z, ^
6 ~0 T \$ O8 g1 B* t& W$ _+ X8 w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- m. _& }$ w, w9 d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ I, S( Q! W5 _! D+ V. J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" D# S: ^6 B0 E/ N& P6 X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ O5 C6 Y% M, ~
9 R, s4 f. ] e& \1 w
/* assign the tl som board LED-GPIOs*/
c" g' m$ Y7 _& Astatic const short da850_evm_tl_user_led_pins[] = {
8 e* M8 ?3 q: c W' h. O: }' ` /* These pins are definition at <mach/mux.h> file */
. J5 p) m* o5 e4 v0 e- S6 o DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 ^7 D: X% s0 n5 @
-1
1 m* k7 h m! j7 b4 s. f( _7 @}; }3 ~! w! c3 g0 e5 Y1 y) D
2 t1 b3 A- h, M* O8 k& `% ^/ G- rstatic struct gpio_led da850_evm_tl_leds[] = {
: V. [! V- J/ f) }1 I {
1 H9 d) |2 U6 n* c% O, P- W% \" ^ .active_low = 0,
9 n% G! S( T) R+ t" x .gpio = DA850_USER_LED0,
, d1 @0 @9 t8 X6 p .name = "user_led0",
0 ^0 ?0 x; H& G8 s .default_trigger = "default-on",
" M% Q9 z# B$ r9 R6 }8 C6 s* }1 Z },. |6 X; F9 `7 J. _8 b
{* R7 Y6 H+ \5 ~+ P. Y/ }/ \( I
.active_low = 0,
3 R* u) F7 o- \5 V .gpio = DA850_USER_LED1,9 S1 V. S- s' y+ q) i+ X
.name = "user_led1", b: e: x3 S _$ X, \
.default_trigger = "default-on",5 _1 k4 O6 T9 w5 P R N- w* o
},
8 y( u2 m* W: L0 C0 `+ @/ }% Z/ n {( R I& Q7 M x4 f
.active_low = 0,( _, C7 l; c7 s; N F
.gpio = DA850_USER_LED2,0 f% P* }* H4 i3 J/ m9 Z9 u4 a- i
.name = "user_led2",
! n( S/ x5 _4 z+ F8 c" ~ .default_trigger = "default-on",- g+ d3 X8 k# i0 N
},9 Q( J6 }4 U3 C1 e Q
{0 w9 l1 L! o! f6 W6 a4 l. r1 e
.active_low = 0,
. f. \$ C) n6 T: n .gpio = DA850_USER_LED3,3 K. [. G- w* } f0 j+ a' N
.name = "user_led3",9 u/ y! `8 F. y% q/ y3 S: e
.default_trigger = "default-on",
# R: G" A: D4 D4 c, d/ [" L },* C1 U! ]/ T' _8 x; y* e; `
};
& p. K# w6 M( A7 d1 ]" Q/ k" _4 b j& \1 S- Z6 o
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 \0 I; P, B8 z" {, R
.leds = da850_evm_tl_leds,4 z" J8 d9 l9 Y5 N
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ X5 w5 v+ A+ W9 ~6 s. T};
( ]( l5 {6 _, ?, W. o& ~$ J6 W' P" Q9 m
static void led_dev_release(struct device *dev)3 V, Q+ R% \: q0 e+ E; U
{1 q1 W5 R/ j; E+ Q' v1 m8 F
};8 \- }0 @6 m/ {7 l9 {; v
( Z" a5 s6 T Pstatic struct platform_device da850_evm_tl_leds_device = {" S# L0 w2 N- n' `
.name = "leds-gpio",
2 j5 S. n; b' F .id = 1,( E* K& u8 }( ?& s( @# u7 i
.dev = {- S% }3 `& {+ r0 f, A! L
.platform_data = &da850_evm_tl_leds_pdata,/ `1 n3 T) I5 ]2 j- a. I& i2 w
.release = led_dev_release,
; B5 S* o& t" o- o. x; B% s }
" D1 T. c$ d5 k' [};
' i9 M6 f% t# ]+ J! G$ G& t& @7 S# P# W( p! ^) k
static int __init led_platform_init(void), r5 `, e/ W: v7 I- z# i
{
2 C9 t* ?2 G' n3 k; a4 l) p) K! P1 q int ret;
+ n+ z. `0 Q% ~& o2 l#if 0/ k4 l9 d0 w6 U( ^5 o
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 k) w2 D0 ]! b& G2 V if (ret)
7 g6 d) w- ]! M1 | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 a( V5 X' |9 k8 y
"%d\n", ret);
4 | o! x+ b) U: B#endif! d1 r" w' \: L5 H9 K# h% V, S# Q
ret = platform_device_register(&da850_evm_tl_leds_device);) l' |$ r; D' ?, l6 E; p l
if (ret)
8 w4 i6 \6 u% e- C' r' Q3 N; ` pr_warning("Could not register som GPIO expander LEDS");1 @9 k1 h, T2 d: |) s6 n( k) A
else
& i% a, p6 H- K& m2 l* h) @! H+ @7 X printk(KERN_INFO "LED register sucessful!\n");
$ M) D2 w3 u7 J- ]( q
, R9 k6 F+ V5 J+ ` return ret;3 z7 c/ S1 K! G& \
}
& E) Z2 ?, P! N0 A1 J3 a, [) f6 X# |8 J" L1 G$ X! s, f/ L
static void __exit led_platform_exit(void), \( E2 @( Z" s9 q* t% R
{# u4 _ f) `& R
platform_device_unregister(&da850_evm_tl_leds_device);
3 B( ]& R% O( K1 f5 [
; i1 s. L. {, f. Z+ T% C7 Q' Z printk(KERN_INFO "LED unregister!\n");7 q- f3 G2 [ P0 N
}
; @" K% h) k7 t1 i# k6 U
L1 Y6 L) q9 g, u/ m- ^module_init(led_platform_init);
5 x E* R9 S0 I, x" J) Cmodule_exit(led_platform_exit);
( m; t! w/ w3 h% |: Z, A0 e$ U
7 w1 Z+ Q! o6 O/ B/ }8 TMODULE_DESCRIPTION("Led platform driver");5 n4 `" m6 E, J) y
MODULE_AUTHOR("Tronlong");
* l- q7 T% q0 k5 M6 n$ UMODULE_LICENSE("GPL");# j; ^+ y* _/ w/ d6 z, C! ?* J
# |; n- S1 o& ~& | |
|