|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ p. E1 ^" Y0 Q#include <linux/init.h>- K' W! ?" K: K& r
#include <linux/module.h>
# i+ j/ ^8 [. q8 p# U; e#include <linux/kernel.h>) w7 L' v% H5 X" p0 [
#include <linux/types.h>
0 ^8 |& ~( r; E7 \" j9 P/ f#include <linux/gpio.h>- l# l g) L8 ?/ _& o' t3 k
#include <linux/leds.h>( ] B% y. X! S G9 `- H
#include <linux/platform_device.h>0 Y+ F1 o- V/ c( S' N& B a
, t2 L+ C. j* s
#include <asm/mach-types.h>
( K& O! ~( Q: ]. W. `6 P#include <asm/mach/arch.h>
+ f; E$ ~. K! @) m#include <mach/da8xx.h>7 R" A: a! o: _( q- f% A( G
#include <mach/mux.h>
( j1 k, c0 E8 d/ {( y* l) E6 F
% Z' t& e$ j0 K! N! X7 S1 [9 o6 Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& g' e' ^; f0 |* O) k1 Z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 }1 c2 H8 i4 F/ E( \/ E; }#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% Q7 n" B% y1 g+ N) D/ G8 X& c; e/ ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' S1 k* A. h! Q( C$ [ u9 A( j: D5 J" H
/* assign the tl som board LED-GPIOs*/
: P4 t- X) l# m. @1 W, S" c; A Wstatic const short da850_evm_tl_user_led_pins[] = {4 m! @. {8 ^0 E6 R/ R. d: d
/* These pins are definition at <mach/mux.h> file *// y* \4 Z% }8 N& t8 k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' l" V# _; T" k( N" j# f -18 G. N/ ~: v6 f+ e2 ?* _
};
/ S4 I. j% j1 ~+ A$ X1 w6 p$ Y7 V% \2 R
static struct gpio_led da850_evm_tl_leds[] = {
. I( j" K" o1 l1 f8 a {/ H7 K) h' l' a2 I2 Q
.active_low = 0,
& x6 S+ L; E1 i- B; p8 q R .gpio = DA850_USER_LED0,
( w" _9 @, z" P .name = "user_led0",' \/ a: ?# w3 ^( m) o; u3 ?
.default_trigger = "default-on",; ^* V1 e/ ^$ m$ G8 E
},
@( S; i% \" |1 W {
- k ~" i) m! @- I" @ .active_low = 0,
+ Z" a' B$ \( h .gpio = DA850_USER_LED1, ?0 Y3 e6 Y" m8 @6 W8 ]* W
.name = "user_led1", C. \2 P) E) O- K1 H) p! i6 A
.default_trigger = "default-on",* U j" x& ^6 C9 r' z; q' }( Y
},
/ B. S K+ S6 n2 J7 g {! _3 |7 n$ ~6 @# l: b' |
.active_low = 0,9 u6 D) q+ f5 m$ U
.gpio = DA850_USER_LED2,8 O" J6 D; o4 b x" x4 r ~- N
.name = "user_led2",9 Q, v$ X R* u+ K0 V
.default_trigger = "default-on",' X8 S7 x1 Y, F( i
},
, }7 c) y4 S7 s, W- i/ V! S3 _ {
( E7 p- G6 ]- X: v .active_low = 0,
x: O3 _* c, @5 n% U .gpio = DA850_USER_LED3,# J8 B1 S0 w; Y0 o5 @; _
.name = "user_led3",
- e; a% ~6 ?& @/ _ .default_trigger = "default-on",4 L, J1 F, {* i
},/ C& j: m1 F0 o) v5 G& |- v
};
4 R2 s6 g9 w0 p% v( @" A! ]7 a. f5 }9 z* h/ u
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 T6 _1 Y0 W1 g5 O, X1 u$ K6 E- M9 P
.leds = da850_evm_tl_leds,
7 D3 L! [ s# ?# e/ v+ T: ?" Z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. C) C) p$ m, |' f0 Q! I) p5 D
};
B F" `6 y1 V% H
- \% A4 \& j7 kstatic void led_dev_release(struct device *dev)# |5 K6 `5 U* [
{& ^- ?) _8 z) o9 R; A7 M/ i. G
};+ t6 e' `- `8 g; R r" l* p" v
7 i) X1 k% z6 F0 F5 Ostatic struct platform_device da850_evm_tl_leds_device = {
{& w" _3 ^0 [4 _ @; A0 z9 m .name = "leds-gpio",+ _- Y. j1 R# E
.id = 1,% @. f3 Z0 B9 {/ v2 J0 x
.dev = {: V/ }, m0 k9 B$ C' b
.platform_data = &da850_evm_tl_leds_pdata,
0 A, X5 Q: n F4 b .release = led_dev_release,
# G) u$ ]# d0 d( Q% r ~" S }
; ?2 i J$ q6 E' ]6 ^, b};
& E% r- Y4 G& ~9 Q
+ W w0 n: L$ Y" N+ l/ W$ C! istatic int __init led_platform_init(void)
* a- a- S! W3 `0 {1 B8 _3 C, h8 I5 |{
1 J* _( @' W; }, ~# p7 p int ret;7 U/ L- b/ h2 a( ^, S) r2 k: X
#if 0
, X" \4 T: x6 f) t3 S1 X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 W* A! @1 p+ a- a0 h if (ret)( H* o( U7 C( h3 l5 G! k$ @! G+ {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# g2 o$ p2 N q4 B+ ~+ K4 z
"%d\n", ret);/ X$ v- z- E( w, ~
#endif
0 J7 z+ M9 H/ s* |( U5 A ret = platform_device_register(&da850_evm_tl_leds_device);
; U( A8 O+ V9 b. V1 j if (ret)
' G! b% G! E8 O pr_warning("Could not register som GPIO expander LEDS");6 i# ~ ~8 G* ~
else1 a* d8 f1 ?5 g9 v
printk(KERN_INFO "LED register sucessful!\n");0 i m3 |9 Z+ U+ w& h$ q
# e% S1 J6 y6 P4 O/ { return ret;
# h3 n* [ q( M O3 M}
, F3 a5 _! l9 W: D- D* j4 E1 J, F8 Y+ E' w- W1 |
static void __exit led_platform_exit(void)
+ e8 ?' }( B5 N/ c- D* \5 h{0 X5 g: B' R. c* c! p( ^
platform_device_unregister(&da850_evm_tl_leds_device);
+ R1 v) z" y j: {! q9 O) w. B
printk(KERN_INFO "LED unregister!\n");
& Z& _5 q# ~( `( t}
' c6 x4 a) ?) I, Q
: R9 Z6 [( B/ ^% @; bmodule_init(led_platform_init);$ {1 r% G4 X/ O4 e0 ~4 W! p& k
module_exit(led_platform_exit);
1 K/ @ R5 A: l; P1 i' p, g1 c+ r% C2 v6 @% ~
MODULE_DESCRIPTION("Led platform driver");
! l$ U( o# [5 E3 A5 f0 I3 W ?3 o# FMODULE_AUTHOR("Tronlong");
3 v* z$ e1 n0 `" q$ w$ S" @9 KMODULE_LICENSE("GPL");
" r& z& B( ~2 k6 [
* V1 b9 A' A: k a% \1 F |
|