|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; B2 l2 }/ o* A
#include <linux/init.h>
( e( C; B( z* }#include <linux/module.h>
, U Q: t; g* U6 P) B$ z2 h+ ~#include <linux/kernel.h>, C+ E9 u. X1 H5 [7 C- O
#include <linux/types.h>
! Y! q1 s2 H9 f. A9 {0 N#include <linux/gpio.h>3 w# o3 h# [4 E# P! r! }7 p( C
#include <linux/leds.h>4 r$ w2 a t8 S, K3 `
#include <linux/platform_device.h>: k1 J6 r# Z( a- B6 M
/ c' _# c; b* M4 e$ ]. H#include <asm/mach-types.h>
9 D4 K$ h3 e; c* \3 A, V2 T W#include <asm/mach/arch.h>
5 J% [1 B, q7 n, b5 x# |#include <mach/da8xx.h>/ f5 r6 {3 r1 ~( ~+ D" K' R+ {
#include <mach/mux.h>
+ \8 j8 y4 H7 `3 o' X$ u1 C8 d. J$ U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# J/ b4 T+ n0 u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ A& M5 v6 A# [5 t2 d7 B, E#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 [2 A" ?: t( x& F1 X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& U% u& @# X ?$ S K
( E) U1 C& K y$ C. y
/* assign the tl som board LED-GPIOs*/
x& @0 p5 D) \! F+ S# k5 Y- O: astatic const short da850_evm_tl_user_led_pins[] = {* B; p+ `8 U# ?
/* These pins are definition at <mach/mux.h> file */
9 ^1 q6 G5 D6 f6 \( N DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 N4 }2 \# s6 j+ V8 I( Q0 }
-19 t4 m6 v$ J# }& J, }/ y2 W
};# s5 o# Q* T8 H1 m3 \0 g0 C
3 H* |2 k4 e! x
static struct gpio_led da850_evm_tl_leds[] = {; y: r1 [6 T$ t
{
% ^6 c% ?5 a$ o! ^9 c4 Y .active_low = 0,! N! O' T8 x2 z& L% u" S6 F* O
.gpio = DA850_USER_LED0,0 c5 ~: H0 h, E1 w8 P$ c( I
.name = "user_led0",
4 i! Y5 o( |/ o1 M .default_trigger = "default-on",+ O' j- n0 R, T; Z4 B+ Q
},
3 N3 k7 s# \% j, _/ L5 @7 q {# K9 X4 B; N* O
.active_low = 0," Y4 w M7 c3 o+ {, U, _# R" Z* f: j
.gpio = DA850_USER_LED1,7 i- ], f" G; o( V* H1 w% L0 |
.name = "user_led1",
2 Q2 R: b1 M8 n6 S I# y3 J .default_trigger = "default-on", l0 }8 [$ e% k% Q
},3 |$ y7 M. b! k! @3 J
{
. ? R$ h2 f8 ?9 d- R: M$ ? .active_low = 0,8 O5 Q" u* O' S$ E! t+ G
.gpio = DA850_USER_LED2,% C) S3 ?: U. |& g' j/ B4 |
.name = "user_led2",3 \+ P- I& m7 n2 G0 t7 r
.default_trigger = "default-on",6 P% h. ?/ [/ m3 W# Y
},
- W0 _; V* u/ h# f: { {* d" m* v; K& U' ~4 p) Z0 X# a
.active_low = 0,/ g# w4 j- F3 @/ v1 L. C
.gpio = DA850_USER_LED3,
5 S. B# Z$ k' q9 }: O' c$ }; X .name = "user_led3",
6 U) y1 n. w& v1 E! w6 b .default_trigger = "default-on",
" a$ g5 o: ^7 M! S" [# I3 Y },
& r Q o/ o* ^0 i$ i2 E/ c4 b};( x0 R9 f; Y5 i3 g0 h& ^# S! H" D
8 e; R7 B( h0 E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 s: t% x: v; {' J6 W .leds = da850_evm_tl_leds,
$ U& H: \, o3 i4 p& B* _ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: d' h+ v$ X* ^( j4 K1 m};
& [8 v( W5 a7 I" |' N! z& H$ d2 h& f7 p# p
static void led_dev_release(struct device *dev)
N3 l( P N" s H; {{: a! H4 ~4 [3 ?6 n4 g4 v
};
8 [2 n2 c* m+ E: T9 u4 ~0 F; y7 u. l3 W
3 M; L* p! d8 x5 s4 T- m! c8 O6 V/ Ostatic struct platform_device da850_evm_tl_leds_device = {9 j3 V7 n1 [* v; m
.name = "leds-gpio",
/ h8 A6 t; w1 c! }- J$ R$ y .id = 1,8 ^, B, |$ {1 x/ h( \
.dev = {3 M* j+ \. D/ n
.platform_data = &da850_evm_tl_leds_pdata,( H# A$ ?7 ]+ z/ x/ t
.release = led_dev_release,
) u; Z6 f/ v% L) n }! B1 @& r3 _8 d: q
}; v0 z G" F; _! W3 [
& }6 C8 h0 U* Q# Rstatic int __init led_platform_init(void)/ ~- ?3 m& |7 s# C3 H) r$ }, R
{
3 @5 g2 k/ Z$ v" X. [ int ret;
! h. A/ Z7 V; G L#if 0
3 z2 x& b3 s' w# f2 R; C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& |4 e$ q# G% b6 l
if (ret)( U% P( M0 Q% {. Z! E; j
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ z, S$ [, D1 R' D% c
"%d\n", ret);( Y, o. Y" C$ U+ k l$ G8 m) o. ]/ N
#endif( T P; R. s4 C1 a4 y. g' T1 H
ret = platform_device_register(&da850_evm_tl_leds_device);1 B4 s h+ H# j4 r$ W# Y
if (ret)
) L) a( d4 m" ~2 U pr_warning("Could not register som GPIO expander LEDS");) S4 U1 G* s/ ^9 @" A- I7 M2 Q- q6 D' X
else6 m# P4 W. y5 e, n8 W, L# c8 N
printk(KERN_INFO "LED register sucessful!\n");! L/ ~1 L# q& ]
6 y6 x3 r$ d- n7 b7 z3 e, L P* ~9 s return ret;" F# Z5 L$ q; b6 _
}' M+ h" {8 m2 f
* k" e) _+ B5 s y1 q' @: o5 O! rstatic void __exit led_platform_exit(void)! ?. P( I7 \0 x8 _* _: N1 h
{
5 G4 V) Y/ ?- |4 D. V ~% k5 K+ B platform_device_unregister(&da850_evm_tl_leds_device);
5 E7 E$ A7 f% x* z$ c$ u
) f9 a5 v V3 V9 w F printk(KERN_INFO "LED unregister!\n");
+ m8 g- ~7 ]6 S# y3 A1 X0 Y}7 o+ q( q M7 T! _ @& F5 K
: y4 y0 U0 r; d
module_init(led_platform_init);
( Z8 D8 D6 W" T9 [4 N3 b: Omodule_exit(led_platform_exit);
5 c, `' l8 }$ Y! p4 r1 ^8 O
. Q6 Z! h$ ^; |- K) N4 pMODULE_DESCRIPTION("Led platform driver");/ \$ a# |* `* d5 ~9 V; a
MODULE_AUTHOR("Tronlong");
: d2 J6 x: y2 A( l$ l% U! CMODULE_LICENSE("GPL");
5 d) r/ o( @% {* k6 r
( g' c# l# U3 b# w( g |
|