|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 _& G! F1 `9 u$ q+ ]#include <linux/init.h>
) y$ U+ T- b( e4 ]#include <linux/module.h>% `! \3 \) _) }) A
#include <linux/kernel.h>
* ?0 l* @8 p; h# u( ]! p; m( v#include <linux/types.h>
0 d9 h$ n: F7 `/ b# C* M* V#include <linux/gpio.h>
, \$ ^( ]; u$ r8 x( w. E+ F7 Z" O#include <linux/leds.h> E/ ?7 j' f! S5 a: e; M' X
#include <linux/platform_device.h>
4 g& A. Y* L1 X. a$ e7 u$ D! s
+ T" P' b& W; z+ V7 k3 X5 {! ^#include <asm/mach-types.h>
/ d0 j- a: @( Z) ~#include <asm/mach/arch.h>' t$ i' h1 Q- \1 ]' I0 h
#include <mach/da8xx.h>2 m/ E9 ]! j- N1 m
#include <mach/mux.h>- _' F: Q) E% X' e, g
" ^: S; A/ z( q! z' _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! b/ M0 ?; ?/ l& s
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; J7 L2 G3 | }6 t2 ]#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# f' E8 q) e7 {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 V) h* u* N* j0 z" H! l3 W0 k
( M8 n6 n' ?/ }" h
/* assign the tl som board LED-GPIOs*/. x( {+ E% O4 u, @+ W2 w
static const short da850_evm_tl_user_led_pins[] = {
$ ?0 i* Z1 {& q$ U8 L /* These pins are definition at <mach/mux.h> file */
9 \7 G4 s. S8 j DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& m) F- V8 d- O# h4 z
-1
8 N w( [; w; M6 Y};+ f6 ]# T- y3 n0 D
+ b9 N' N2 Z/ @( |. l+ n7 s8 Wstatic struct gpio_led da850_evm_tl_leds[] = {7 {$ t, t+ M" K$ E9 O9 k: g
{# e @- { j2 t+ s+ U9 K- S1 r
.active_low = 0,
- j. X6 }# q, J .gpio = DA850_USER_LED0,
2 `' Z$ H9 S9 k( L4 B6 V/ o .name = "user_led0",
, v8 l: p @7 N. i: j: x9 ] .default_trigger = "default-on",, _; j( ], g& i3 V6 `; C+ p
},
% x6 O9 G" F0 b3 U9 D. ?, t, Z {6 {( P* n, j: A& m' P# \6 p
.active_low = 0,
1 R ?; K# Q5 F: W, L .gpio = DA850_USER_LED1,6 X( I; K$ \& X5 A' s
.name = "user_led1",
' {* k. S# x, `+ M! L2 _$ Q2 Z S .default_trigger = "default-on",
$ a+ u. b a- N },
u1 O8 p9 a" s {$ v3 {) a8 S( S& m
.active_low = 0,
3 p+ V' o0 J# H5 g; d .gpio = DA850_USER_LED2,; |) E/ l1 ^6 g
.name = "user_led2",
( b. H2 s7 D$ W: _) F) ?* E .default_trigger = "default-on",
' p( T8 ^0 k& X( b. Q8 R! {# y },6 f9 ]2 ` _- d4 ?3 g: F0 r
{
' z2 }- V2 g1 s5 ^% o' g1 E .active_low = 0,' v. s I/ G! R! F( k4 P% b+ p
.gpio = DA850_USER_LED3,0 B* x! [( _9 }4 r; {/ H: `
.name = "user_led3",
& W! w a ^& s* T. g .default_trigger = "default-on",
1 a* W* T+ ?7 @8 U: ` D2 c0 \0 z },
# ?8 P& ]* ]4 E};
7 U' R6 I: U) O8 x2 Z1 K6 k) g, P( e1 x0 n( D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; c; s/ ~( Q0 P D. I% }& j .leds = da850_evm_tl_leds,) ^- P- |0 s* F3 [5 b
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' q9 w5 ~+ z8 h};' ?" |( ~/ v# r, }4 y, h/ R# S
/ G7 E1 z7 e( C, l" r
static void led_dev_release(struct device *dev)
& q! ?, S* M6 g{/ D( N9 @$ ^" G, L/ [! ]1 c
};( a2 i8 C! v# ~3 U! A- w- k
, \8 B) A) \/ q0 G6 Istatic struct platform_device da850_evm_tl_leds_device = {. N" O3 m6 l: D0 c# \
.name = "leds-gpio",
" A1 x# h8 E! {; C0 b6 ~& ^# f" o .id = 1,
' W9 J9 g& E8 \+ a9 x! W .dev = {* n" \: d' \5 l
.platform_data = &da850_evm_tl_leds_pdata,
8 X7 r5 |3 A6 Q) D .release = led_dev_release,! G. P2 f6 X; |$ l: w
}
, H* \) N6 v& M7 i7 A$ v5 V0 i};. E1 y/ [- b% y% v8 a
9 w. i$ X! s' L! e! @static int __init led_platform_init(void); G5 ~& x. a. y! y, A4 x
{" m& \1 ?8 v' U$ Q* k
int ret;
0 B4 M# L' t% I5 C9 ~" D#if 0' t) t8 l: S( \( R( v
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: L( l% E4 N: p1 i if (ret)
3 q# ?/ q( n* ` pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% U, `% ~/ A- H8 k V6 d" e
"%d\n", ret);$ m* p [, K- Y& o
#endif4 d4 a6 j8 K5 X+ p, f. m/ I4 E' b
ret = platform_device_register(&da850_evm_tl_leds_device);& Z) x% q8 _+ n0 f/ N) X5 R! `( |
if (ret)0 r) I$ h* P0 A/ j8 J3 T N& G; B
pr_warning("Could not register som GPIO expander LEDS");+ L7 s) r1 W9 Q/ @2 V5 e
else7 d3 s% H' Y. M9 r: N) c6 |2 d
printk(KERN_INFO "LED register sucessful!\n");" ]) z, m. c7 \5 ]6 O) |
) O( N, F7 @0 p5 {/ D, B8 ]
return ret;3 `' O$ C5 q9 u1 ^! m
}! y; P0 c: K/ }! g+ R+ `
( f8 N. d1 p! h6 A' _& u4 b) \static void __exit led_platform_exit(void)! J: G# r$ e9 x6 V
{
$ A! H/ g/ b0 C0 R( X, f platform_device_unregister(&da850_evm_tl_leds_device);( V- U+ f; t6 t
0 x* k# {! ^1 g) B" ~% Q printk(KERN_INFO "LED unregister!\n");1 f) i j7 L" ~& a9 t3 s, B) a
}! n) N2 h3 v! x/ j! F. J
. b+ O% C, E: |: G2 e9 v9 I
module_init(led_platform_init);8 [( T4 {7 I: N* P
module_exit(led_platform_exit);
8 q3 G5 e2 h% Q1 c2 O* n
4 `* _* d/ b$ p, H) C, t$ NMODULE_DESCRIPTION("Led platform driver");5 F8 c9 T1 A! I; D! I2 T
MODULE_AUTHOR("Tronlong");
- e# H2 B; V; I/ l, C; h, ^+ z j$ m5 T9 BMODULE_LICENSE("GPL");
/ _2 D2 e/ s+ q" J. ?0 g9 S0 o. d5 |( N( W
|
|