|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; k; e: c9 v4 Q/ w1 U$ ]
#include <linux/init.h>, X7 Y) E8 z/ N# H
#include <linux/module.h>
8 ?, _ d7 H, r) ~, T* Y#include <linux/kernel.h>
8 o8 K& n0 H2 r& s; B#include <linux/types.h>. x1 f/ C2 G& e
#include <linux/gpio.h>& t" i# W/ a! e% B
#include <linux/leds.h>) D- x& M/ ]6 [* s
#include <linux/platform_device.h>. [9 n! g* e+ h* E
* }$ R" l$ Y) Z7 k#include <asm/mach-types.h>
; {4 d- I9 @. V1 a5 d& t$ f#include <asm/mach/arch.h>& H% k* M" u6 U; C$ W& R ]
#include <mach/da8xx.h>. ?4 ]: t0 a0 z0 V% C/ R
#include <mach/mux.h># `( ^! R4 Q: f- S8 o2 Z
, l% T6 w C- D* ]8 c. H
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% k0 z: q' U7 i- X7 Y3 J/ ]8 c& E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 u0 N1 v, r4 m" R/ L/ i" p#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( T2 c0 F j: t: i1 I# |#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 a7 j" c1 V/ W- x* _& ^4 k
0 B& T' n. r6 U& X, w
/* assign the tl som board LED-GPIOs*/
( g6 {: ]/ r" M5 z* bstatic const short da850_evm_tl_user_led_pins[] = {& }/ h$ H7 B' c$ u Y/ ~6 w; r9 v9 K
/* These pins are definition at <mach/mux.h> file */: Y% J" Q% a$ Q. ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! d' i- J3 L; ^ -1
; U5 Q8 U1 \+ ]* e7 P7 o};: u& J" e- ]+ U6 ]0 z" f' [2 P
- D) |& N5 K9 @2 ?$ x1 Zstatic struct gpio_led da850_evm_tl_leds[] = {
( O2 w& J8 g; b1 E! {7 B {+ i: o3 ~# v0 h! |' Z% |
.active_low = 0,$ u. c2 f, L& E0 l
.gpio = DA850_USER_LED0,( r4 U4 q% B2 |
.name = "user_led0",
8 D& d6 Z7 W. e! U- n .default_trigger = "default-on",( m3 y: T) L2 v+ c
},2 h! U5 f- v2 b4 f p5 f5 T8 M
{& {8 k% N6 G+ z2 i# U5 |: [
.active_low = 0,4 W& e) {# H0 w
.gpio = DA850_USER_LED1,: B% g+ Z- Y9 T
.name = "user_led1",
, R% a) s' l; N) F .default_trigger = "default-on",
, R" s; ?' O, E+ c. S5 h# g- C/ R },
1 E' F! D" b, w; D6 h' K {
5 V0 B2 r3 F1 X* l$ ? .active_low = 0,4 C- |% l$ j# v* L* j' ^9 L8 Y
.gpio = DA850_USER_LED2,
1 Q P9 R6 h3 d5 G+ v* b .name = "user_led2",6 S* Y: }& ~( o% i
.default_trigger = "default-on",: d1 |: i6 N" P P8 i3 J6 f
},- k( ?7 x. F% U2 ?" G8 A1 G
{
$ p8 W0 \+ N g# H1 y .active_low = 0,( X, }( m& R( a9 d$ f* k9 f
.gpio = DA850_USER_LED3,! {$ ~2 ?/ C& H0 J1 L I( w' C5 R
.name = "user_led3",
9 R2 f/ U1 p9 w' i .default_trigger = "default-on",
; k1 H. R" l9 S- \" r },
: i7 r$ T/ e# C2 ], x! W& w};& M9 ]/ v9 N, ^0 W, ^. _
c }$ R4 c* a# G. z* ?% ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) y J6 z8 |- r7 z .leds = da850_evm_tl_leds,4 `5 i9 `7 Q5 F7 v0 j4 A" Z- z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 H# @* J3 b2 N};
# }9 N7 }$ y7 E" g3 S6 ~3 |% p1 {
% r0 g; \* n3 J& s3 q2 Istatic void led_dev_release(struct device *dev), _1 v! h6 l6 ~
{) y' T" ^' V' D- g" J3 c; A
};
8 o$ @5 }8 ?8 E( Y$ Z- h5 q5 G6 X' N/ t8 P4 w" R
static struct platform_device da850_evm_tl_leds_device = {. S* D' e0 a+ y3 n3 U! s# H$ K, H
.name = "leds-gpio",& T5 n; R. n) F: |' b
.id = 1,( e+ d1 W$ y. Y8 @: B! w
.dev = {5 y- c# G4 I P
.platform_data = &da850_evm_tl_leds_pdata,5 Q( X& B. b. c) ?$ O1 L. U
.release = led_dev_release,- m8 ?- d0 H0 [) H+ f" t$ ]
}* w, E) F- c; X9 U R3 M( P
};* e* e- P# H) E7 a
1 P5 Z. O1 t. q; h, a) X
static int __init led_platform_init(void)
; \* R% E- x1 b. N, g{
3 _: |/ r& h9 D. m$ s5 m0 \ int ret;5 }2 a, r9 i) u7 I m* x% }
#if 0
/ E' h& v" l. p% l ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 q8 m1 T) ]& n3 h b if (ret)7 E4 w" s; G2 i) _/ b
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ {& e' a6 w( z& E "%d\n", ret);
4 t7 S6 k2 w5 A8 A+ F8 a; ]$ v#endif' j5 @' P! G% m& K
ret = platform_device_register(&da850_evm_tl_leds_device);
- q& l) r! ~9 J9 y9 k5 e5 C if (ret)
) D( H' U5 K* V, {/ r pr_warning("Could not register som GPIO expander LEDS");
h4 p) Q9 j y' G _* w else
* d( |+ h' ]. v1 } printk(KERN_INFO "LED register sucessful!\n");/ U( J6 W+ O" E& g
6 B8 y% `# J/ b* L1 D" u return ret;( c) l) s) N! Z0 D6 W$ |& X
}! S, D8 v. U5 B6 O7 @3 s0 d
4 X- F, c7 u# F' J Estatic void __exit led_platform_exit(void)
0 z2 M2 V) y' {. v6 p{
! N" ~; S2 c- g0 A, ? platform_device_unregister(&da850_evm_tl_leds_device);" m! P' L" y: r1 Q" } U' |
6 Z; i! P: z* |; V) @# d7 x7 L6 ~
printk(KERN_INFO "LED unregister!\n");3 I/ Z f6 u6 \5 D$ ]5 q
}
- E; q3 Y" K! V& d+ u% l# \% O$ ^' I: G# U' V0 T1 B4 _" W
module_init(led_platform_init);
3 X" `4 |3 s3 `9 I0 G9 ]6 gmodule_exit(led_platform_exit);, h0 K/ P" u- s% b3 o
0 K: l/ r Z. @# K7 ZMODULE_DESCRIPTION("Led platform driver");; g2 ?$ r; [: O7 v9 @
MODULE_AUTHOR("Tronlong");
( K- T. `* L5 \8 oMODULE_LICENSE("GPL");$ ?5 h* w) m3 }, V
( X X9 m5 i, R( n5 ?5 V2 i
|
|