|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; a z D' x: H5 Y- G#include <linux/init.h>6 U( G% [5 v/ Y" N: R# k( e% M% M9 W7 `
#include <linux/module.h>" N/ V' R& ?1 {! U
#include <linux/kernel.h>
6 b6 o6 X; ~/ w#include <linux/types.h>9 P3 v+ @" m8 N* n. w- @
#include <linux/gpio.h>2 d$ D2 {" U' \5 J }* ]
#include <linux/leds.h>; K( n, v7 A( c( s8 b/ x
#include <linux/platform_device.h>
7 y" m3 S# D, Q& O' l) m7 H: `5 c* s0 n3 g0 d' ]$ Y; Z. f( ^4 K
#include <asm/mach-types.h>
& |7 z- z( G% }#include <asm/mach/arch.h># y; Q# R( x1 i* ~( x4 m: g
#include <mach/da8xx.h>
$ {7 N5 Y% \9 t+ J2 \$ i6 J#include <mach/mux.h>
0 @8 P2 f+ w0 m) [7 W0 W$ d R* h& @, d+ G& L1 j. U$ _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 H% j+ O V n, D, m9 }#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 m5 Q2 L* j1 B7 i#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ g D( `" ~$ b2 g2 M: F1 q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 G4 ?& o, `5 f/ C* {' F; r' S+ \4 p" x
/* assign the tl som board LED-GPIOs*/2 E# F7 o! t. G' j) ?
static const short da850_evm_tl_user_led_pins[] = {
) [9 {/ G2 @" b0 u5 ~4 m8 M /* These pins are definition at <mach/mux.h> file */
" h! f8 Z u; m% R! J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& A0 m1 @2 ?" q Z7 d) l' W
-1
3 R8 z( E5 R5 g* r};3 G1 J, R( ^2 X [& R
5 k+ q. ]" g8 _, Y( |. F2 {static struct gpio_led da850_evm_tl_leds[] = {+ Y( S. s+ }' |! B- s7 M
{
; V5 j% `; Z1 c& d .active_low = 0,4 m/ P1 X2 x2 U w2 r% [
.gpio = DA850_USER_LED0,8 d8 e! m8 l: H! J" [) n R
.name = "user_led0",8 |) G5 @( h( _7 b, V
.default_trigger = "default-on",' x) k# T6 F4 Y$ L6 P9 O
},
/ H9 C6 \0 S0 _) @( x {
5 P1 L8 q5 r5 N; g+ e .active_low = 0,
7 b. d5 U2 t- j4 c' S! i+ s .gpio = DA850_USER_LED1,2 W7 V' _# d8 K+ P4 Y! ~
.name = "user_led1",
, k# N& L u8 L+ \" Q .default_trigger = "default-on",
3 H" S7 U" t" J. s: b }," j4 `+ \% M. c4 ^# q6 g! i+ k
{. V3 e: }0 V# w) v; b
.active_low = 0,
. C7 s- @" ?/ ~& c .gpio = DA850_USER_LED2,
+ U$ x6 y7 u3 V# F# r) N0 T .name = "user_led2",
3 R% b3 H0 G! l& R" E- b .default_trigger = "default-on",$ {' c6 v- b1 S
},
: o7 u* g+ B# o; e" q$ u$ U# Y) z. Y% v {) ? f" ]( _7 d7 J+ d
.active_low = 0,2 t; ? ~0 O* }
.gpio = DA850_USER_LED3,' u: p% H/ l6 r% r& c( e) M0 L& y. ?
.name = "user_led3",
; p3 L1 z5 b3 U6 r' d* b .default_trigger = "default-on",
m0 u' q# i8 t* V },' K( \/ D$ b- x5 I& ^( ^6 e
};
6 L- M) b) {9 ~& X, {1 f3 B# I' g; T! O: a0 L# ]4 p$ i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { x. a g; l) T4 s$ M
.leds = da850_evm_tl_leds,
; w. @: K) y' E .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ i8 C) l/ c7 g5 O# } y
};
+ A1 q# w) X# U. P6 Y# v% u& V3 @3 b* X
static void led_dev_release(struct device *dev)' B- I+ c5 a, ]# Q G, J
{: t+ S% b" d1 L# ^
};
/ N1 x1 H7 v$ i, V5 [' o: ?( |' o) W( X) d" t
static struct platform_device da850_evm_tl_leds_device = {
2 P8 l! D: X) W* Z$ F .name = "leds-gpio",+ L2 |# N9 l; q& `
.id = 1,& Z* S8 m. x: _( T5 K. e7 E7 Y
.dev = {
8 |* ]9 @9 G: B* i2 w d .platform_data = &da850_evm_tl_leds_pdata,( b0 E: l1 C3 G: c7 Q
.release = led_dev_release,# m% T$ V) ?6 ]8 R6 t6 D+ O
}
; |1 P3 m9 x3 C6 o; U/ K2 b- D};! K$ x. S% W+ T# j0 h
1 ?! d, G8 e9 K2 h) Z% ^& h
static int __init led_platform_init(void)
8 P( [4 w1 u% u4 J" C2 b{- ?7 {& ?+ a$ K/ R
int ret;! ^9 _2 Q1 S9 R. D
#if 0
2 [: y: a! Q2 W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, B- g& W- o" O G. D' \
if (ret)) i7 n1 c. J" H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ F0 A( D4 H6 }; D' j* B/ {5 r
"%d\n", ret);
" R( S3 |- \! s" b& s- L0 q g* r#endif
! q/ S U4 a* e; C0 Y ret = platform_device_register(&da850_evm_tl_leds_device);
7 a; x5 a( `# G1 y& d+ G; Q) d' p) u if (ret)' p. P/ K3 Y% {7 W' e, d5 _
pr_warning("Could not register som GPIO expander LEDS");
5 @5 W1 P" f5 l1 x, ^ else
! }$ c$ J2 S( M% b6 C2 w/ a5 g printk(KERN_INFO "LED register sucessful!\n");
+ ~) T9 \- q+ F; ?! `8 C1 v6 _- u/ `- l2 r z2 Q
return ret;
; {& o$ i' s! Y$ K9 N}; H; t$ |8 j8 v# z( ^
" o Y4 h( `/ S- q: O
static void __exit led_platform_exit(void)' `5 y4 s* i, m! i) K! _
{# M- A% n% i! x6 h0 q9 _9 J2 X9 d
platform_device_unregister(&da850_evm_tl_leds_device);- c+ j( @$ }+ y5 y) X' `, H7 O
/ z2 m! u. D. Y/ l printk(KERN_INFO "LED unregister!\n");0 O3 a3 u& {( F+ E5 J
}
7 D% q5 a% ]7 ]# c( z0 F" s
% ?( A6 h8 z- n" r3 w& ^module_init(led_platform_init);
# Z6 X2 e7 u$ d9 |# }6 X. \module_exit(led_platform_exit);. R; v6 Q4 `; t4 H8 @
4 _9 l) j0 q% [. B) i z/ h9 U0 e6 nMODULE_DESCRIPTION("Led platform driver");: h" d( ^3 W/ a% M
MODULE_AUTHOR("Tronlong");7 D4 W, F% Z7 m5 u {
MODULE_LICENSE("GPL");$ _6 `- g2 v8 q( m" Y
# a; k. D( F( m8 d- t X, Z( ? |
|