|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! v& ?, c0 A1 j4 }4 G8 N#include <linux/init.h>( ]; w; x, W9 t$ p3 [5 b
#include <linux/module.h>) a! a4 g0 b0 _: x1 F
#include <linux/kernel.h>" e% [+ k/ R1 R8 [' Z: o
#include <linux/types.h>) A% P8 ]+ x3 Z+ z' D+ y4 P4 D; J
#include <linux/gpio.h>
& o$ I3 O" c1 `, [: m1 F3 e h+ m' ?#include <linux/leds.h>( [6 u4 R& k; O" t1 Y g
#include <linux/platform_device.h> O1 N" r, T* }0 C
9 m% I* x) I4 k) E. {" p D: ~#include <asm/mach-types.h>2 s2 z* P8 p' ^! A& h0 M& Z
#include <asm/mach/arch.h>
; o% h& y* m# }& _& J#include <mach/da8xx.h>
) W H: t2 ^6 f! {+ u# p#include <mach/mux.h>
6 P& z- S. `6 G' m4 e" K) w
1 B: ^7 F1 @0 M6 _- r) C. H" u#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 q/ w; v6 g( R* A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) r. _! N" ^2 |* M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 L: E+ f3 j. @: L/ J1 i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, h, J8 r9 i3 q0 ~" V& F8 u$ a4 T& o9 G4 X% @ _
/* assign the tl som board LED-GPIOs*/
% R& ~/ O7 i( M# Y# q- h, s$ G, Istatic const short da850_evm_tl_user_led_pins[] = {
1 P+ j8 J" K8 i: d# Q0 A: S /* These pins are definition at <mach/mux.h> file */
. C: {! o+ k+ l5 q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 C( q5 A2 t3 o) {8 L
-1
0 o/ g% h- c, n7 }& |( _" }! I' u};! O I+ ]2 g/ |& V* q* R
R2 _5 U7 ]6 h/ x' Fstatic struct gpio_led da850_evm_tl_leds[] = {$ Z3 G& z6 n& b, I. d+ ]/ G9 D# r
{
& Y7 x3 k5 U) W, {; G .active_low = 0,
5 d3 i6 c3 }; F6 r' [! f8 B .gpio = DA850_USER_LED0,
! Z5 W; {; {# e- f .name = "user_led0",
* E: l0 m/ a/ ? .default_trigger = "default-on",) Q U# b2 k( p
},
9 I6 w" k Y& D l1 y! E {
- O9 q2 x P) w. Z5 T .active_low = 0,
( u9 T9 Y( _/ O& X .gpio = DA850_USER_LED1,
2 X* l% Q! n4 l* a; s6 x3 _ .name = "user_led1",2 f N4 ?) R2 `; ~' E( t+ ?
.default_trigger = "default-on",1 o. [' i, m" F& |+ Y- Y, Q
},
& M8 V9 Z8 T& B9 A, Q' _4 ` {' v5 J9 j) M# @/ ?
.active_low = 0,3 _( v- C1 X, ?/ v6 p
.gpio = DA850_USER_LED2,
2 k, q# {+ c3 |% A @9 T4 I .name = "user_led2",( \* Z0 `! W0 d. V) }# C M
.default_trigger = "default-on",, g. W3 k) r, y: h
},
2 f6 y# a) e9 s w1 i U" Z% D {5 x! k+ G" M* t! n% I$ g: Y7 z$ E
.active_low = 0,& z9 p- @1 l7 Q5 q2 e
.gpio = DA850_USER_LED3,
6 Z" k% m6 z6 b8 P+ ?5 Z .name = "user_led3",
! k' ~0 D7 w* s6 j0 S: Z .default_trigger = "default-on",8 a2 m2 n' \* P
},9 l+ H, L5 a: o# [0 n: u
};1 I4 w3 r( y% a, O) f0 U
2 g5 Y2 `- _: o% z1 K4 jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# X1 i! r4 r a8 C; G9 K .leds = da850_evm_tl_leds,& t$ z& _: I9 c; i
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: f% H+ G5 V1 J# p};) Z. b- i8 ~* k f/ ^" y/ x
8 ?5 b9 Q0 l5 nstatic void led_dev_release(struct device *dev)
( i2 I: R+ J% b{" f# [2 j9 n3 g& ~+ C: b. L
};; `8 B3 Q3 s4 ~5 N4 u
9 K. [) c R/ X+ N$ \4 c
static struct platform_device da850_evm_tl_leds_device = {
4 @/ L( ?9 }- Y7 ? @' ~ .name = "leds-gpio",
4 _7 d4 \( d6 \* ^) V .id = 1,8 m0 X( D+ {! A; O2 w/ K6 ]
.dev = {
" G+ S0 e/ {3 L/ N5 ` .platform_data = &da850_evm_tl_leds_pdata,8 V; [ g' E. z* W7 a
.release = led_dev_release,2 W- `9 S* ]4 ^* [ \$ Z" g6 e
}
! p# \) l7 B: V* i- x& @ J: h# w};
( W Q/ S6 e% a# {: f1 c& d9 b g: @( s; y3 e9 y
static int __init led_platform_init(void)9 ^+ f3 t, E% P) @4 J4 ]2 d
{! j5 P, O- V1 Q% n; a4 |+ h5 m
int ret;8 Y: g, g3 o( H- p- X
#if 0+ ?& r% U1 L; g. s" W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 |4 j; e5 z% |9 G/ D+ C6 O
if (ret)8 U9 d3 H7 \8 F1 j9 G$ L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ e! B6 u" j7 v "%d\n", ret);4 k2 }3 W0 F( d$ U* |' R
#endif
+ \' Q4 N( q& E ret = platform_device_register(&da850_evm_tl_leds_device);
: `/ s. e8 ?) ~9 u q if (ret)6 B, o2 O& \; N2 E7 w' j6 f0 w9 R
pr_warning("Could not register som GPIO expander LEDS");5 {6 I# y* s$ c( ?6 I
else& ]7 B3 B, C/ N6 x- ~
printk(KERN_INFO "LED register sucessful!\n");- k8 \2 ^4 L/ e& W3 ]+ c
4 o' B; Y: d( N0 s! n/ g2 ~0 O
return ret;
; _1 t- ^0 w& t) B, W# Q}
/ F: ]3 @, c5 j8 {- o- q( W3 C# V& O+ O) _$ ^
static void __exit led_platform_exit(void)5 b$ b' d* h- a# v' r ^! F
{
6 }; t: }1 b( c) k+ m& O platform_device_unregister(&da850_evm_tl_leds_device);
6 S/ e% M2 G$ M# j* n9 e; X0 i* t" x3 N; ]- a9 d) ?
printk(KERN_INFO "LED unregister!\n");
0 N- O1 f! G+ [; D; c: a0 s8 h}
. z! @: o( ?2 L
% L0 n1 z6 F$ A" V/ Jmodule_init(led_platform_init);
* o4 y7 ^8 ?) E, w$ M& Umodule_exit(led_platform_exit); w/ s" W' c( S- {5 N4 @/ h7 a! }
# Y; x+ ~5 w& ?. t) I s% w' f
MODULE_DESCRIPTION("Led platform driver");
2 E( b* P4 \- c. M: rMODULE_AUTHOR("Tronlong");
3 n. Q, A* t$ Y' w) ?MODULE_LICENSE("GPL");
1 [" X# \, D% F0 [- e0 J5 C; R8 I. _9 C- M
|
|