|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 e. b+ B; W0 C$ K2 b; E1 J#include <linux/init.h>
- C. g) Q s; n/ t9 b6 X! P#include <linux/module.h>" ^5 H( }. x% j) d
#include <linux/kernel.h>
9 B/ f* R4 r0 R: }1 b#include <linux/types.h>5 `4 h) z3 o+ K0 i; A
#include <linux/gpio.h>
- z5 f- s- K" W4 s* B" M$ d#include <linux/leds.h>
7 s& L1 c5 v( |#include <linux/platform_device.h>+ N0 z1 f5 ]$ Z G3 X2 ~
$ d! w: B5 l( O9 F% W. r Z#include <asm/mach-types.h>
: m% z: O9 V3 |5 }( o#include <asm/mach/arch.h>; W. R- r% [$ m6 q/ x) O4 ]6 y, G- v
#include <mach/da8xx.h>$ P# W( `& y' \) Z3 U# J
#include <mach/mux.h>
) V( f: w3 N# \* m1 M$ Q p6 I" n1 [/ J5 B+ E
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! \ y) n" H9 l6 X9 t; W#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! |6 @8 B: ]- h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). n! v' N$ e, ^) t7 B+ i% F
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" S. s k c2 @3 q) e/ }; ^$ P7 y7 i. }4 v9 z7 ]& n" ^; c$ @
/* assign the tl som board LED-GPIOs*/3 j6 j2 Y& \1 `6 ?' ?4 g# [
static const short da850_evm_tl_user_led_pins[] = {& _8 b" S( w" U# ~
/* These pins are definition at <mach/mux.h> file */
% N' [* c- o) Z0 _( B B+ _8 Z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; x( T/ X, j6 w/ |: {! x
-1
$ [0 h8 A% L+ a7 R' P! ?};( z- c6 w: N; O9 q% @2 `, t( P
# X1 `; t' o% j! F& t7 Y1 K$ e lstatic struct gpio_led da850_evm_tl_leds[] = {
8 T2 Z7 x. P6 }# K2 g* o2 ? {
- ^. e3 B9 [* }. {! E4 l1 Q .active_low = 0,/ k& \, \8 j5 k+ K
.gpio = DA850_USER_LED0,( T2 q7 G# X9 F% T) v$ S) o5 d. p
.name = "user_led0",5 e, q5 G0 }( j/ f" b% e$ A r0 g
.default_trigger = "default-on",0 |7 t5 Y: m/ f% _/ ~2 r# d4 E
},2 X9 C. J% j A: H) H
{
z4 C" {% @% e+ J! | .active_low = 0,
6 V0 e4 k& \8 \7 J .gpio = DA850_USER_LED1,8 s2 Z, d# Q% T' K5 S1 F
.name = "user_led1",
. R6 L* Q0 w8 J( e: _$ I3 y .default_trigger = "default-on",! y a7 ]5 S) q5 R/ Q4 A
},
& `* n! w1 w! q) B! x6 {9 i% o1 M {2 ~/ s/ P) _- Q7 w$ R. N9 r
.active_low = 0,) [& h: Q) Y# ^2 `
.gpio = DA850_USER_LED2,
0 O: g' E2 h- V .name = "user_led2",
1 ]8 D5 @) E" i2 }! Y .default_trigger = "default-on",
4 m& ^& ]: M+ c# ^* x/ ?7 M },9 F, n; f7 j: S( I9 D2 D' d, x
{ r; e+ ~4 c% O, o
.active_low = 0,
9 V! b& D# D# W) W+ y6 Y9 U .gpio = DA850_USER_LED3,
7 W# F8 \+ s- \/ S# z" @ .name = "user_led3",# E* H/ K, a9 }+ Z7 a* g! y
.default_trigger = "default-on",
8 ^: x8 S0 @# ^5 _) W" p, i# @ },
7 p9 Q0 ^( h9 Y* [};$ `0 ]! Y8 o" c( ?
. s4 n, i' q& t6 _1 hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 a2 Z( Z2 P5 n6 ~# o' ?
.leds = da850_evm_tl_leds,
4 v; k5 Y3 a1 W: I8 n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 A5 a5 ^5 b! N+ e; @$ j};
9 h, X6 d1 L) X3 K2 ^3 j; _* I/ _4 w1 J
static void led_dev_release(struct device *dev)/ M& A$ |8 i7 p8 T3 h/ \' s
{
# A: l0 p8 N$ s9 l. C};* u: L- P# S8 Q. I4 h) ]
. J4 t. l* M/ d1 l- K7 Z
static struct platform_device da850_evm_tl_leds_device = {
: V9 J" a5 ^& U( ] .name = "leds-gpio",
( k* j+ m0 z4 r+ A9 m5 C .id = 1,. l6 K: ^$ x0 |: e! [
.dev = {( K( R9 ^. Q6 I5 {
.platform_data = &da850_evm_tl_leds_pdata,( Q2 H0 f6 w1 h( l0 ^
.release = led_dev_release,
: J; z. W4 i1 O$ P }- k, d8 v" ]( C* r
};
% S! o$ D& Y' q- N* `
5 c, @& X0 T# O" \" d% ]static int __init led_platform_init(void)
2 c% l' ~4 l! {- B& p{2 Q+ R) P8 |' \, |* `: r8 O- s
int ret;
. k7 `4 J" c$ r" |) A7 l#if 0
0 L( M* P/ {8 U( W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* F- B/ ~ i* [0 N2 b
if (ret)
( k# _7 l( V8 _5 ?% Z0 g2 p4 s pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" E! M2 Y0 j1 y% g$ J
"%d\n", ret);' Q. }* j' T- V- T
#endif. F) f( P, Y4 L3 ?
ret = platform_device_register(&da850_evm_tl_leds_device);6 ^8 H6 W& k' e2 R
if (ret)
& R( N; y6 q% j3 C pr_warning("Could not register som GPIO expander LEDS");
" h) j+ f7 y+ O' N/ ~$ L: P* m4 o else/ j' b: F' C1 i
printk(KERN_INFO "LED register sucessful!\n");$ m' E D5 x( c. R r' e
6 T2 s' | m" y8 W+ ~# U$ a
return ret;4 M0 x) J2 Z) N9 n! \: R
}
, j, Y Z9 v) t& P
+ w+ ]4 O: s( v) P& B2 O1 k# hstatic void __exit led_platform_exit(void)
D) C4 m8 R6 G, W{ n. p; b$ B/ x: g( E$ g% p
platform_device_unregister(&da850_evm_tl_leds_device);
7 M$ h6 |) M6 x! @" H9 e5 A
* X; t! S9 H& ^! T printk(KERN_INFO "LED unregister!\n");
2 K M9 p- T! B) ]}3 [3 G& S* V: O3 {! T4 c
1 K: P y7 U4 c% y' K, |
module_init(led_platform_init);
. u% S$ w& o7 K! ?" _! Xmodule_exit(led_platform_exit);
; {9 E8 v4 S9 q9 a5 K9 o* e
/ R; n5 O. x% e. h' w; o! Z& y+ |' NMODULE_DESCRIPTION("Led platform driver"); ^' z0 N" T& Q+ O( g$ a8 P
MODULE_AUTHOR("Tronlong");/ Q8 k2 X7 b9 z1 d
MODULE_LICENSE("GPL");
/ q* X! }4 `# A9 m" B. S) F9 ~5 B/ |- A% Q9 z
|
|