|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( k/ U. q# p8 \; V#include <linux/init.h>5 C% k# S5 o8 n$ h' h8 z8 z
#include <linux/module.h>0 S' ] s# M s7 D
#include <linux/kernel.h>
1 q7 X8 q/ @6 ^% J& x2 B. x0 q# U#include <linux/types.h>! Z; v0 a! Y* ~4 I% R
#include <linux/gpio.h>! A1 z" D; G0 t1 M9 x% E
#include <linux/leds.h>
6 `+ v. T$ ~9 R0 @! P2 Q#include <linux/platform_device.h>
: y$ T& l1 D. X: ?. R
' N! O' x; Y3 D#include <asm/mach-types.h>
1 s8 N* M. P u4 }2 V: X#include <asm/mach/arch.h>
, a$ f! T* ?& y* ?* Q" u! B: \1 c#include <mach/da8xx.h>
6 ]- [% I% u/ V4 _; ^#include <mach/mux.h>: d/ s& ^5 n2 Y
( A0 ?% L! N. A1 A0 Y( n#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. _5 w" c3 t" `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" X: B! `2 c; ^4 |
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- n7 v: }1 u: Y9 n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 t# f, `$ W9 h; S: x v2 y( r0 {) q- k6 O F3 o
/* assign the tl som board LED-GPIOs*/
: l; U; [6 m1 F7 `3 V: }' X( } sstatic const short da850_evm_tl_user_led_pins[] = {1 h; J& _5 I, A2 [
/* These pins are definition at <mach/mux.h> file */) Y6 V& p: ^5 g8 x3 a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 \# G2 n- c3 L/ v- i) Y -19 c) h* F2 R$ x& y# e0 C
};# h- s1 R2 R% [$ M3 ?1 A
$ {$ t. W k* O7 S) S9 A7 O* ]2 dstatic struct gpio_led da850_evm_tl_leds[] = {
2 b* g# @; f% C8 V {
9 {% g3 ?5 |7 [ .active_low = 0,: l* B Y- F! o" x' |) O
.gpio = DA850_USER_LED0,
' q7 y/ T7 t0 l .name = "user_led0",. N- A- x8 E4 _7 B6 {
.default_trigger = "default-on",
( k5 w* H) X' k; g# ?3 t! ? },
! S% R. Q [: D {9 d! C& \8 a, p& ~. d* T5 U
.active_low = 0,; \ Y7 R+ K: r6 a. W( o
.gpio = DA850_USER_LED1,
2 [. L: O' V& H' E3 c .name = "user_led1",
5 v/ S: v4 q( t* o$ Z .default_trigger = "default-on",
6 w6 `6 V: G5 w5 K$ ?; @+ Y) ~ e },# \/ g: D2 M W: C7 h4 Z/ _
{$ x; }6 \) C; M
.active_low = 0,1 L4 A" x: f8 X$ v
.gpio = DA850_USER_LED2,
7 N% c7 V8 r- G3 y .name = "user_led2",
) e/ a4 O# Z. x6 e, {+ I .default_trigger = "default-on",0 {' D6 T, \/ q7 ?/ X
},8 I+ y; y1 X: Q* V* J& }% q
{
+ u7 X( |$ e: i: O/ M: p .active_low = 0,
7 ?: _- N/ b/ O& Q0 i4 g .gpio = DA850_USER_LED3,$ m# P+ _9 ]0 \ x. I6 z& }+ b
.name = "user_led3",
! s5 I' U+ i% v' M. I1 R o .default_trigger = "default-on",$ \0 k: x. [' D b
},7 V8 V( P4 W& E
};2 q- ~4 _6 I j
- s5 w N# P2 }/ ~: _2 K& estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. u v: R7 R% `- y. D% j5 T9 k
.leds = da850_evm_tl_leds,
, O" E5 ?) J. Q, f .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) D* Z7 `3 _) \6 l' H( w0 }& m9 _
};' X, ^8 K; N( d- i$ A4 {; H; S7 P
0 o# c7 L5 q* U3 B/ S: lstatic void led_dev_release(struct device *dev)9 Z# h/ L' I+ t- i
{
' \+ D5 W1 Q+ X};
3 z. f: |) W% ]6 z! E8 o2 q* i- K1 v2 i9 L# _3 |
static struct platform_device da850_evm_tl_leds_device = {
0 k; O8 W1 T, Q- V p: c+ w .name = "leds-gpio",
) e" l! A3 U" T8 p# D5 ? .id = 1,
; v! J0 @- U* U3 s5 e: e9 y/ c' y .dev = {5 }/ p; S: ^, ]
.platform_data = &da850_evm_tl_leds_pdata,
# ^' P/ x' Z1 b. y2 u' j8 C .release = led_dev_release,
( m6 F# s$ r# g2 E% | }0 X' c& G8 G& d& a% F- D+ o) Q# }: i
};
5 ]/ S! O' m8 z2 i2 L7 W
3 @5 Z P$ j' U9 mstatic int __init led_platform_init(void)
% | Q: ~3 {- j9 g{
7 L, x$ s5 K; [2 F* Z int ret;
7 I6 Q$ Y8 m0 ^, A( c#if 0/ L: L% w: R/ O" U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 {7 m$ D2 ]" d3 a0 @ if (ret): w# T; } M/ E
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- A: ^$ j# v! f8 Q8 ^* `
"%d\n", ret);* M3 h6 B+ u9 N
#endif
# M' A5 T T+ b1 k ret = platform_device_register(&da850_evm_tl_leds_device);
) p/ k A8 b% R% F if (ret)
9 f+ f1 G0 I: ` pr_warning("Could not register som GPIO expander LEDS");
0 U6 l% b8 n: g- e6 \8 W$ V- X else1 L2 l ?2 Q; t. }
printk(KERN_INFO "LED register sucessful!\n");+ l2 ]4 }+ }; V! i6 T. D
! A+ @9 O4 B$ h! D0 w, W) U return ret; p7 R7 F3 _( S7 h
}0 t( _% |+ b; r3 r1 s* a
8 i$ l3 @4 V; m! _) a C6 ~9 j: S# Mstatic void __exit led_platform_exit(void)# w. S% p& _- p" G& b) s0 x
{
7 |1 s P8 h6 t3 ?; g/ o0 t platform_device_unregister(&da850_evm_tl_leds_device);
) V+ R! k @, |, d$ j5 ?, s
# j; |- n5 O, M+ k2 D1 {0 r9 F" ^ printk(KERN_INFO "LED unregister!\n");
R$ _9 F5 E0 h3 M2 L/ I! g}1 x7 z! a* [( [6 F+ x
) K, ?% p+ M7 U* A' [ r
module_init(led_platform_init);' ?: T( n( ]& M
module_exit(led_platform_exit);
' G. R- B3 d1 f) _3 z8 [4 E$ `5 Y m* @2 z& ^: y2 b
MODULE_DESCRIPTION("Led platform driver");# V* n. m3 f6 {( i( g0 X
MODULE_AUTHOR("Tronlong");1 ~8 _# k H4 t1 q" F$ k
MODULE_LICENSE("GPL");8 |3 B4 c* P5 [
+ N. e2 X* c$ `: h |
|