|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- D: ?0 u7 R) H' D0 C2 n1 u3 p
#include <linux/init.h>
6 }/ z- K! Q/ B; v' o#include <linux/module.h>1 Q o! A, M, A, o
#include <linux/kernel.h>
& x3 y8 G- v! H0 ?2 h f#include <linux/types.h>
; `/ e' v- V' ?7 `#include <linux/gpio.h>) u; r3 ]: L6 W) ~
#include <linux/leds.h>; q5 x$ M/ ^/ M. S5 h) Q) w: B
#include <linux/platform_device.h>
3 S% O, g8 b) O1 k8 h* H1 T. C, x
8 z0 ]: l( t; Q. o; }#include <asm/mach-types.h>
9 h3 [& E4 g+ u6 c n#include <asm/mach/arch.h>5 K; S- N! J* [$ m/ H
#include <mach/da8xx.h>
9 k' r9 [* T6 o3 U#include <mach/mux.h>
" ?& `. {, t X& c
8 q% x, G9 l) `5 t- W+ H#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; ~0 b, \" L* X; q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 o. ]9 c' i9 E# ]) G0 H9 K
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& r3 F0 {' s1 t; R: c6 N7 \
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) n# }: w) @& L) R3 b, w' N
/ N0 t) ^$ q# x8 ?+ ]% Y$ t
/* assign the tl som board LED-GPIOs*/3 ~. K; c; N- b9 S: ^
static const short da850_evm_tl_user_led_pins[] = {( t% l; `0 x; ^
/* These pins are definition at <mach/mux.h> file */
7 U x4 x, s) v! ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! ?4 U* N% k& N/ d' Q
-1
' O3 s L, P1 c. P};0 p: d8 K) {& N% T( ~
9 X* b1 a( h a9 hstatic struct gpio_led da850_evm_tl_leds[] = {
- I! `8 G) @- t* _ {2 o; F f9 g2 Y7 i* ?( ?- F, |
.active_low = 0,' \1 t) B! q2 n5 F; V, X
.gpio = DA850_USER_LED0,
7 k+ V( |$ J, l, o .name = "user_led0",2 ]; J# D( g/ @
.default_trigger = "default-on",5 G. t+ [5 |3 E+ ^ v4 D
},, a# A! }1 ~/ T8 x
{
) N* Q: f% K0 A' Q .active_low = 0,
/ ?/ N3 ~! P$ ? u .gpio = DA850_USER_LED1,( T, i) r" }7 y, ~ [; B4 O1 m: S- ?4 v
.name = "user_led1", U/ r6 M6 ~) f) J% u6 Q" ^
.default_trigger = "default-on",
* `* i! q# L7 U) \" [2 X },
. _8 h5 b' o; u$ Y% ?9 q7 N {( k8 o" W5 `% E5 H' l
.active_low = 0,' x' B5 l1 N5 y: a. H
.gpio = DA850_USER_LED2,
b/ O& | R. q. H ~3 G3 B& H .name = "user_led2",
# R- [" P2 y& ~ .default_trigger = "default-on",1 j5 G, J! a/ ?# s0 C4 i
},
" c) a/ A' M$ s! C {; P" J8 P9 p5 J3 Q) V: Q
.active_low = 0,
3 z) h D; _9 O& z& @7 o5 ?$ K .gpio = DA850_USER_LED3,
6 ?+ l7 E$ h6 l* h' M: h .name = "user_led3",
) z+ J9 L/ v* Q d% J7 v6 a .default_trigger = "default-on",
, ^6 A V; f _$ ]4 Q+ X },2 ?$ S2 h- Y4 p: [
};$ b; O- r# s8 \
2 |& t6 s" L. V& \9 G, B5 v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ y5 s- G+ j& e$ x( P
.leds = da850_evm_tl_leds,! Z7 h0 V2 q4 [8 W' d0 p4 j- t4 T. \
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 x. n) x5 F! E' }/ T! Y};
$ r' E5 A& v1 _ L
4 p5 h( P1 g5 ?9 t1 Zstatic void led_dev_release(struct device *dev)
* @+ t8 f! ^" d$ K: k( z* B{
' Q5 j0 `3 P7 [( g3 x4 }2 F};/ b) O6 g; j6 t4 x# `8 s
7 l4 w- c( Y8 w/ u5 X: [ S/ U$ L( N
static struct platform_device da850_evm_tl_leds_device = {
2 G B- x# x& Z5 w/ v; t .name = "leds-gpio",
$ F+ J4 a* u% T& K# P .id = 1,3 D' f3 x- \5 {1 `2 f
.dev = {
0 P3 ]6 w! E: e. V8 }+ w, G .platform_data = &da850_evm_tl_leds_pdata,4 r: `: |5 d( x% J; A A s4 x+ u" k- T% r
.release = led_dev_release,7 }- U8 h1 ^# D% y; V: d5 R3 E
}0 q$ U; P9 a% ?3 ~/ m
};
! e* y. L+ Z" b+ {. V; n
{( _! m( g( a$ Y* Zstatic int __init led_platform_init(void)2 ~, v2 E6 U$ }" |
{3 d! n4 b7 G0 k( g5 k
int ret;
) R* ?& y$ f. K- U9 `/ a#if 0
+ h: w q8 ^1 s8 p ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 W- Z0 n" s& G4 k% V1 r! J if (ret)' V* I j2 B' }) a8 S$ X' C1 M$ U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ q/ ]. I- c9 s2 R5 F0 _
"%d\n", ret);7 |- S0 m: M3 a" z" f
#endif
7 E. f2 @1 B2 x. S: p* a ret = platform_device_register(&da850_evm_tl_leds_device);4 q9 U1 y, B8 K+ W" v9 u
if (ret)
* G! w- ]* H; y. Y pr_warning("Could not register som GPIO expander LEDS");
6 m: f \. f" { a% R* G+ V else' ~! l$ t2 }* R* w4 Z4 \/ R
printk(KERN_INFO "LED register sucessful!\n");
. _" J5 t$ L" u4 R) c0 E( e( U% k# L# p" g
return ret;+ f# o% L( v+ a: Y% D5 D$ p1 t
}# y- U, a; L: T! \% X$ o5 [1 ?* C
( D4 W2 N# L1 P! g6 ?/ M
static void __exit led_platform_exit(void)
% i7 e8 `4 i* a# p{
|: n4 s+ Z5 o; ]2 N3 O platform_device_unregister(&da850_evm_tl_leds_device);
2 X! S! L: g* }) B, h% V4 }( e2 q$ ^" y) Q
printk(KERN_INFO "LED unregister!\n");8 `0 I0 @! \) I! Y6 Y" F- [9 d! B
}
. n$ r! C" p$ z4 O6 o
% @# S# Y1 p( v) H" z% mmodule_init(led_platform_init);
' t; T8 J* z6 }- z1 C3 omodule_exit(led_platform_exit);
' }1 F6 H5 m( i& q0 b
4 h; o0 b! O. ]MODULE_DESCRIPTION("Led platform driver");6 n+ |5 s' J8 l! o
MODULE_AUTHOR("Tronlong");
. V# K" F$ @8 L1 {& F; e2 b( o$ ]- mMODULE_LICENSE("GPL");
* S9 z7 I5 U) b
$ @: E7 V! \1 P( c# O2 V |
|