|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ A1 `- z" }* L: D/ K% \#include <linux/init.h>
+ u/ R! w( Z; E4 {/ o+ r#include <linux/module.h>
' d7 z7 I1 ]* n, f% l, p5 c* l% Q#include <linux/kernel.h>5 Y) k! @2 w6 R
#include <linux/types.h>+ y+ A. y/ Y1 Y: G+ v) m4 O
#include <linux/gpio.h>
! `* w* x% `( f [/ W#include <linux/leds.h>" |) t7 _# q: t) \2 M7 E
#include <linux/platform_device.h>" h; Y1 z ~( _$ m
1 l, g+ o. y% u( F7 d( k
#include <asm/mach-types.h>
2 ]$ k2 r9 ^7 Y0 {* C, u/ N#include <asm/mach/arch.h>8 ^3 r+ Y1 y V" Y
#include <mach/da8xx.h>
z/ u0 r/ v) o5 K0 {+ g#include <mach/mux.h>/ r% Y6 s% Y# v: Y
. D3 J! L& K' ^* b7 G# [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, o( ~# ]& A: i# k: u, |#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 N$ i6 V. y2 g6 g3 J#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 ?* a5 e- r$ q) U5 z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ B1 G2 `7 q+ s( d
- @# Z& k2 N& X" r \$ h+ t9 O/* assign the tl som board LED-GPIOs*/ b; G% j0 w4 S
static const short da850_evm_tl_user_led_pins[] = {
6 k9 L @# E: w7 E /* These pins are definition at <mach/mux.h> file */! H' p, \9 d7 h( a1 B* j% J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, A- K* [ c% u1 y& b4 Q
-12 F% D+ r: C5 V2 L3 ?
};
* \/ \% X5 ~9 ?5 z- {
0 s( O$ F# m5 A! z# f. c& f# P1 qstatic struct gpio_led da850_evm_tl_leds[] = {0 S2 y# I/ M- }. E4 a$ {
{
5 R* N# S" i$ W' Q8 o! h% ?6 V .active_low = 0,
) g' m7 v* g8 T .gpio = DA850_USER_LED0,
$ L3 R7 H2 ^( ^: L7 b% r .name = "user_led0",9 u: x, P, [/ I8 ~6 b2 I; j& w. X
.default_trigger = "default-on",8 F. H `+ E! K [# `
},) ~- u; ?3 X; U+ O A$ U `+ H
{
" w4 f: a2 p' m% ?! w D. m .active_low = 0,
, G( K$ S' f1 J9 L .gpio = DA850_USER_LED1,9 w% C, w' L/ x: }
.name = "user_led1",
6 X5 r& `6 S! |1 f6 C .default_trigger = "default-on",' ]% x3 ~9 E" [) k4 N/ I
},* E. r* z( w3 j. ~ n
{
, V+ {3 E: L7 b; z! F4 Z .active_low = 0,% w% ?1 W; @5 |( x
.gpio = DA850_USER_LED2,( K- F! M3 o z: y
.name = "user_led2",9 k8 Y: P+ X: k, o' I5 |3 p- ~: @
.default_trigger = "default-on",, k, `4 B: K# x9 n# A
},2 Y. c& Q P4 o. y4 B9 b
{
, f. S* t. ?7 `. }! }7 R* K$ C .active_low = 0,
7 [( @( ]1 J9 p& M- c5 U .gpio = DA850_USER_LED3,
5 m) |3 g% |3 B .name = "user_led3",
; Q! C4 p( Z9 |5 U* P. c .default_trigger = "default-on",
3 g, U% ^4 w: Z, W },4 W0 z. i( F% Z; j$ ^7 O
};5 M' _! R5 V8 c4 k
* n3 `/ l3 Z$ J# y! u8 J0 b, b
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 y2 Y2 ?6 A5 n+ L R t3 r a .leds = da850_evm_tl_leds,% r( C- t2 A* w7 N' B, T! ~: ^
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),! c$ n8 P' o5 J3 f
};
/ J6 o; L4 f, v( |; _$ u5 X
3 e- h0 L/ c8 g( X& S) Ustatic void led_dev_release(struct device *dev)
' Y% Q i7 f- s{
' P! ?) U( x- C* k};7 |" E$ x. i7 ?
# V4 [" B& m/ l# Y2 \- B% K" Y/ Q
static struct platform_device da850_evm_tl_leds_device = {
! g' }: B5 U) U5 m$ Z .name = "leds-gpio",: h: f: N6 Q: @, O) V# c, i
.id = 1,
2 X7 A% X/ H% ^) H, M .dev = {+ Q+ O3 ?6 {2 t6 G+ v1 ^: e9 C
.platform_data = &da850_evm_tl_leds_pdata,
! U: X1 P" K1 z' o+ Z+ q; F .release = led_dev_release,
2 Y- T1 \1 a1 j2 e. s. b6 } }$ e0 s' N: I3 m8 J5 ^6 L$ G. L
};' H( o0 Q8 {2 h" B5 B
! e8 C) o- }* w1 D* {
static int __init led_platform_init(void)
) ~% z8 ]# b/ Z7 w' s% [* L{
9 G& u( o) l4 t2 X0 m/ N int ret;. H8 B* J. r1 U" g b0 s4 P8 \; F
#if 08 b) N- P* ]/ y' r- r
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ L0 j& Y1 S, N9 v2 w. C
if (ret)* f- d+ P: L4 ]4 K5 m. ]3 S1 _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( \+ m9 _% n K. Y3 U9 Q/ R! y
"%d\n", ret);9 \5 W/ l" V1 \4 b- @4 I; H" I: g9 D/ E
#endif/ H) O1 g& m* _
ret = platform_device_register(&da850_evm_tl_leds_device);+ S4 @1 Y' d% f3 u/ z
if (ret)9 F- H( [) E; p; C8 x
pr_warning("Could not register som GPIO expander LEDS");% F3 Z9 Y; g) }7 G q3 u* n/ l$ q
else" }* Z5 R) k% ^! _
printk(KERN_INFO "LED register sucessful!\n");
9 T+ A3 V- B$ z& I" h7 X% w) A3 ]% g" ]+ V* W( i8 H$ X
return ret;
1 u0 S% _1 F d" I A) w3 S. ]5 _}
* e: V7 e0 i& K1 k& O
9 [) b$ J6 x5 Q# {6 ^& N8 ^static void __exit led_platform_exit(void)
2 l0 i) q/ w* r2 t7 G# Y{. f9 I% r' ?$ Y% C' E) W4 C0 U
platform_device_unregister(&da850_evm_tl_leds_device);
2 r% z# k3 J/ m Y
; r( J& W, j [ printk(KERN_INFO "LED unregister!\n");
: [; D. H" E' N4 P}' j3 C: A8 j% f9 O2 s4 x& N/ e( L
2 p, J! U! {" P4 imodule_init(led_platform_init);
4 c+ p# u, ^% p! amodule_exit(led_platform_exit);
: E" y. T5 r& @0 S8 T6 w
: x4 }( F3 Q/ C) h. lMODULE_DESCRIPTION("Led platform driver");
/ H9 e# w. l$ j! j5 ?' {MODULE_AUTHOR("Tronlong");3 a* S7 s+ d2 g* n; i
MODULE_LICENSE("GPL");
- M6 o0 S5 C4 F% t4 Z& C' V& a8 p" c g
|
|