|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 _. O: Q" e2 m& X0 T#include <linux/init.h>5 z$ I9 c" W7 L- ?( c1 C
#include <linux/module.h>- h& ?# V' ?) G- ~
#include <linux/kernel.h>3 m+ c& Z5 h+ L* ?
#include <linux/types.h>
2 q: Y2 ?" M8 O% V1 c1 u" o- q#include <linux/gpio.h>
0 @' T: L# b6 a1 f! x) B2 L* h#include <linux/leds.h>1 R2 |! f+ R m; `4 W3 U
#include <linux/platform_device.h>3 {+ i5 B$ }% M5 e- \# o" e
' S+ k; U% _4 f6 I4 O/ B' |
#include <asm/mach-types.h>" f7 N7 {: D) k# {
#include <asm/mach/arch.h>
" A+ h0 u( a3 V- V2 I5 u#include <mach/da8xx.h>
. `" Z: _8 }! j#include <mach/mux.h>, T. t( q# v* @4 a+ d4 e
7 l' c4 d# n/ n2 r
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ n T- |; G* J3 \, b#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ c# ~/ I3 c* P( i
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ K4 i/ |' u- i+ H#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- X W" f6 @5 L" y' H
4 o+ h: s6 o( t G% O ~$ W/* assign the tl som board LED-GPIOs*/. _! W b# q( _
static const short da850_evm_tl_user_led_pins[] = {6 s0 m" C& L# \% y% g4 i+ J
/* These pins are definition at <mach/mux.h> file */
9 f! P+ k! N8 b" @+ P! G* R DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ q& u7 C2 p% d& _- r
-1' [. Q' B' L( c: G5 K( N. ?/ C
};
+ n( ^0 J+ {9 k0 k* i- F9 c9 `/ Q! r
static struct gpio_led da850_evm_tl_leds[] = {8 ]6 |( G% i& U( G3 Q6 V" h5 y
{0 n* V, _! b: _9 W. Q
.active_low = 0,& ]# B7 G# t# ^4 g0 I
.gpio = DA850_USER_LED0,
" M& s# d# R) E/ ^ .name = "user_led0",
9 l( ^% W* E4 p7 e* u0 I .default_trigger = "default-on",
# W, W5 Z6 ], ^/ O* |) y; c8 |6 s },4 n4 p, W' s- d! h
{
Z% \! ~5 o! M2 q, R, o .active_low = 0,
7 ^6 h% m A6 g: t1 v; d .gpio = DA850_USER_LED1,& Y' f1 \0 Y( w* w( a
.name = "user_led1",& B, O, h9 B5 s# ]. Y
.default_trigger = "default-on", ^$ ~) |& E% X( L
},
6 U9 M( f8 `- t! n# I. F { m7 a& v) F; y4 p3 J
.active_low = 0,
' c& r1 a7 q" j3 Y4 f6 F5 P .gpio = DA850_USER_LED2,- ~/ \ T% h, {
.name = "user_led2",
* N( k( K4 c3 @! s* v% } .default_trigger = "default-on",
( R9 @( p/ y0 X* a" m },
2 Y) w- H/ b8 a _ {. q8 z1 L' b6 d3 k, {. |
.active_low = 0, E/ L; d1 F8 W9 D3 c; I( e1 n
.gpio = DA850_USER_LED3,# b& j1 r# b2 w9 A7 j: Q
.name = "user_led3",' N. H. |* h; y, k+ Y
.default_trigger = "default-on",
" ?7 }! l* i. I/ _3 u( d/ Y },
6 ]6 P2 b9 y2 h4 n* R8 T0 S+ M- _};
2 j* w2 l+ a! N/ j" W9 e9 D/ c. n
2 r! q% B1 R" Z' _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 F4 T7 Z" r0 S& h6 O( m) j% k
.leds = da850_evm_tl_leds,
# t% V3 r1 `$ ? ?5 A7 ~9 J- B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 C; g* q) O6 s* S3 l' ~
};/ |4 O' U2 k. v
) R5 n# { o: B! ?+ m0 Kstatic void led_dev_release(struct device *dev)
' W. ^9 N& Z9 z) x1 ~1 v{) `. @' I2 a" {' R) S0 u( K
}; k) t l9 I- B' {9 L9 I
9 R+ S9 \0 `* Q5 kstatic struct platform_device da850_evm_tl_leds_device = {* B% ?( T. z& U4 T' U, c* q* e
.name = "leds-gpio",
. M1 r' `/ x- w .id = 1,
! |7 y* F% ^: H7 Y( r% t, { .dev = {
; U8 z+ i2 ~+ S- g .platform_data = &da850_evm_tl_leds_pdata,
* E/ I9 ?; |- P- U7 n! w4 j& B .release = led_dev_release,
8 u3 Q4 m/ [0 w |* t$ S A }* Y- R' m* t" i5 m5 j# r' w
};& }' x2 K/ V" y5 X- `4 S* r! E
0 M/ \3 s* Q) V" }1 ostatic int __init led_platform_init(void)6 n' t5 h5 `# A: c n, d! E
{
$ f" M, s8 E! l9 m$ O: g int ret;# X( c g% r6 }# K8 o& G5 Z, C8 B
#if 0
1 b( {4 x1 j4 u; B G/ x5 q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, q! w; b: G; j Y4 l; G) Q if (ret)
6 _/ f- |6 A! @, x3 t" V0 y: H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 t- B- [- V8 b! t& ^: C
"%d\n", ret);
& N2 Y2 c9 H; r9 r& b#endif
+ b, u" T' R# M( {8 e% P" [- y1 p ret = platform_device_register(&da850_evm_tl_leds_device);8 S0 E4 e" i2 q( y; }# w6 p
if (ret)
& r- {# c! V0 g' j$ W pr_warning("Could not register som GPIO expander LEDS");
* a8 [" K. e: Z& J! ? else, w+ o. D7 |, [+ z
printk(KERN_INFO "LED register sucessful!\n");
% f8 l( n2 L% ]# W* _, t+ r& p6 d0 z7 @5 J
return ret;/ c1 K+ v6 _9 j: o* l9 A) m
}
. m, b+ z; N1 ]3 ? @
4 W7 G, w; _2 M; ^5 astatic void __exit led_platform_exit(void)
3 W6 R6 Q. t2 _: d9 [" g, U{
+ z2 r2 Z6 S ~- ?) z, w( U platform_device_unregister(&da850_evm_tl_leds_device);- M, W! s3 B1 x9 I7 r5 {
2 u% u6 M. y" B# E1 u
printk(KERN_INFO "LED unregister!\n");
% e0 P- ? _6 ]! S}
5 `$ z0 @" @9 G4 _6 ^: U8 h5 F! \9 ?4 Y7 E
module_init(led_platform_init);
7 @: }5 G. X( a9 y! H$ `) P+ cmodule_exit(led_platform_exit);1 Y/ M" q! C0 r
; N- \2 S! l8 V2 }" U2 C6 ]
MODULE_DESCRIPTION("Led platform driver");' \; W# `8 `0 Y/ h4 n; A
MODULE_AUTHOR("Tronlong");
5 H7 _, N0 E( v& }7 i. rMODULE_LICENSE("GPL");
1 V5 h( e9 B3 K- o
, S8 f$ C7 Y Z) l2 w |
|