|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
k, O* Z; S; C: d+ C, B#include <linux/init.h>
7 w9 m+ d5 J: u/ I# m#include <linux/module.h>
7 i" n4 O6 W. r" m" W, t' G#include <linux/kernel.h>
3 y7 j% T5 @; F! u1 i#include <linux/types.h>5 j2 b! o+ R8 l- ? K
#include <linux/gpio.h>
& f4 J9 Y& X, Y/ n+ o3 {: N* V#include <linux/leds.h>
- M d+ @+ S% y2 u$ j- b#include <linux/platform_device.h>6 f+ K) s# F: k9 \
$ o) C3 J( F% W; S8 [5 X#include <asm/mach-types.h>% ]- t) e$ N. u. {
#include <asm/mach/arch.h>
5 w) M& p# m( b* _. Q#include <mach/da8xx.h>
. n! Q* ^& `; `* |3 x7 ~" {#include <mach/mux.h>2 t! }) H' ~+ C6 l& Z) J
& G4 e- g E1 Q) n% Z5 M Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 e0 w# ]6 z- R6 [( B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ {6 ?) C. g' a( `5 _/ a. ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! R1 e. v; j' g. U4 o( {( A7 B) f
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 _: }* d- [ L1 d9 g1 Q# W2 ^ }4 Y
/* assign the tl som board LED-GPIOs*/
( z/ A+ X! B7 R6 j2 |% |static const short da850_evm_tl_user_led_pins[] = {6 t7 p: i. \ u
/* These pins are definition at <mach/mux.h> file */' s& @; Q) X7 q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# _7 N6 K! b8 g/ C' M. s
-1. U6 v0 y% K, g" F9 q. {0 _$ ^
};
* [( c* p. m7 o6 J2 t/ S
) k& D+ ?4 Z, R6 Cstatic struct gpio_led da850_evm_tl_leds[] = {9 z3 u; t! D* w: n; K! J
{
% J, b$ i; i9 { .active_low = 0,
' O6 s+ U0 v+ E# M' i4 K .gpio = DA850_USER_LED0,( Y, E7 u; F. R" ]* n" [
.name = "user_led0",
% K+ }* O- Y) p1 d2 }. m .default_trigger = "default-on",
' E3 n C3 G: Q, q },
/ \# Y3 z* E; Q; h! z3 |* J9 v' ^ {6 F E' S4 A% @; b6 _
.active_low = 0,
3 z; [0 S1 m) q; u+ c1 t6 P! O .gpio = DA850_USER_LED1,, O5 x- A1 \6 l/ D4 p* G
.name = "user_led1",9 _" o. n; M4 ?0 v
.default_trigger = "default-on",$ t1 X' d& l2 W2 _* p6 c4 y3 J
},( M( l$ V6 P. Y2 d' |
{
u, H* B7 O* l) B# D .active_low = 0,! f2 q( \" F- a4 c+ O% n
.gpio = DA850_USER_LED2,( U1 B6 K! c y/ N6 @
.name = "user_led2",
3 u3 }6 U, F/ P; g k7 q .default_trigger = "default-on",
# J. S8 [7 ^ O$ i2 m. @2 G( N+ N },
% E" @9 n. m8 Y* O7 j {
; l" T/ {1 y" Q# u/ L* r) q7 [ .active_low = 0,% W; a( a" X$ y: a5 k2 k
.gpio = DA850_USER_LED3,
- y! J5 Q1 e+ i .name = "user_led3",
% I* t4 P E) ]0 X .default_trigger = "default-on",
6 v( @; e* h6 V8 x- Z4 ~ },+ }0 N' Z) x% ?! k [
};4 S" w" T' \: L( h
4 I. j# N% I# H6 _8 K
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ T" d1 X% x8 W+ z4 K6 `4 v
.leds = da850_evm_tl_leds,
2 w, w7 g( ^$ d- A1 [ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 P" A: M9 D) @0 b% u$ n8 x S};
2 d; ]3 w, _$ ~. V; @+ {/ j( v5 s: M* o
static void led_dev_release(struct device *dev)( b, }% l9 g+ K% x
{0 u- k# Q1 p3 w! a' B
};" R# D4 N* D) P0 Y/ W
5 U; `+ o* ?: n6 O* G/ A
static struct platform_device da850_evm_tl_leds_device = { ^( e b: S# J! `. e8 @* |
.name = "leds-gpio",/ d5 L8 b3 k, @
.id = 1,
* f. w8 B* \( @" q .dev = {( w5 m, u, y( r
.platform_data = &da850_evm_tl_leds_pdata,
6 f" P1 N7 f, N2 Q( U .release = led_dev_release,8 H2 ?! h8 a# F( }
}
, R0 l1 {$ w, A, d0 q};
* u1 ^7 R+ {3 k7 u _7 W$ r9 ^* Q( C4 W7 Z- B7 {7 v# a
static int __init led_platform_init(void)
$ a( l; R8 B. T; A{
% ~9 X9 q6 C. a6 M3 P% r q6 ^ int ret;
) e1 T/ `. u: n D6 }: P! X6 M$ O: G& m#if 0( n5 M$ b! I( [2 C5 U9 j" l. Y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, ?% `: U2 M. L7 q$ z4 |, D4 M: {
if (ret)
; P1 \+ `* c* L/ S( @" L8 E/ B pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 S5 t& M3 V$ f: Y
"%d\n", ret);) J) A7 L i! a* x6 z# w- }; N
#endif
+ [5 w/ p. @/ H; R6 R$ p ret = platform_device_register(&da850_evm_tl_leds_device);
( c: p$ d, Z: ] if (ret)5 k0 r# h/ O* t5 f8 e
pr_warning("Could not register som GPIO expander LEDS");
( w" d$ }( W( t; i else( b; o7 k# h' F. I7 z
printk(KERN_INFO "LED register sucessful!\n");
- r5 z2 h% \$ _/ @) [
& ?) @8 h% s) _9 j* L return ret;) [) ?& O' S L0 x6 V
}
- e' @2 ~# t9 \# G8 T9 q9 H' e- g9 p3 ]7 m* V- U: W
static void __exit led_platform_exit(void)
4 O! n- }$ N- R$ `* }5 r{
0 o N8 c* q: E' T# Y platform_device_unregister(&da850_evm_tl_leds_device);! W9 P4 y; x0 ?
/ ^* `& Y" L2 E' T9 F6 u7 M& V printk(KERN_INFO "LED unregister!\n");# I! ^. L" k3 O9 Q
}8 K7 ~% Z: r6 J/ J! B! x' r
& E$ {1 P! L p, M \
module_init(led_platform_init);, S" p' V* H7 Z+ k, `# Z
module_exit(led_platform_exit);5 |9 N( t( \6 _- q0 K2 ^
2 u8 T! L& ]" v6 W( C6 zMODULE_DESCRIPTION("Led platform driver");
& n& J3 h7 n4 P# J* lMODULE_AUTHOR("Tronlong");9 d( d2 d, B$ d
MODULE_LICENSE("GPL");. M9 V2 U4 X l+ x9 l( \% V7 Z
! e: P. r5 v2 }* [/ j. Q( k
|
|