|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 o3 S4 A2 h& K9 q" F! `2 D
#include <linux/init.h>; r% }/ L0 g' _ @2 j& V8 G: L
#include <linux/module.h>7 s/ o+ \% R/ v
#include <linux/kernel.h>
! ?3 y$ d3 g; \#include <linux/types.h>9 W( A5 X: _$ w2 H
#include <linux/gpio.h>+ q4 r1 S# c F k+ @9 r1 n0 x j L
#include <linux/leds.h>
9 K y3 a" o. h#include <linux/platform_device.h>
) b( W7 I) F- |3 G: T- g3 _) d. p6 V
#include <asm/mach-types.h>
) F6 h! ~2 B9 i* ]#include <asm/mach/arch.h>
& q& P* X& c' v3 x#include <mach/da8xx.h>/ ~) M; [. b2 e, N
#include <mach/mux.h>" r$ z) V: _& D. g" ? l
! V# A }' A' J1 T* H2 U+ i
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# R8 J: ?) O' j$ n3 J# Z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 I W, Y/ P1 o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ k: i8 O! i3 o! S& q: ^" U
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' T+ b! c6 J: |# w
6 I$ E; s4 S+ g# P Z/* assign the tl som board LED-GPIOs*/; l; f# p: y+ R% h
static const short da850_evm_tl_user_led_pins[] = {$ U& P& [) C# a5 l+ b
/* These pins are definition at <mach/mux.h> file */( ]" }8 L5 [% ]( a0 a# b5 R. h8 `0 ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% M ^: K1 n/ d% ~$ T) `
-1; f9 y- k. ?& y: o" J
};. R4 P9 R, f: J$ w
9 I6 L4 N" t8 ^0 q* L) P* v
static struct gpio_led da850_evm_tl_leds[] = {0 ^0 ?( ]" y' o* D: h
{
6 D/ z$ {6 B* b! o .active_low = 0,
* W+ _/ c2 y [- v& Y .gpio = DA850_USER_LED0,
) _! o: g4 ~- f+ t# @- t, [ .name = "user_led0",5 n d! X3 g: a/ }% D7 i6 f
.default_trigger = "default-on",3 K$ M8 D8 @+ @+ z) d9 I- W' e
},2 H' S' Z4 y: N+ G, y( ^
{
! S. }2 m# Y5 b$ g, D+ v( _ .active_low = 0,
5 D8 j. _4 U d3 r% Q2 T) _ .gpio = DA850_USER_LED1,. X, a3 w5 A( e! ?. V' I
.name = "user_led1",3 G9 E4 ?( L8 S9 A* j. Y1 \/ M
.default_trigger = "default-on",
1 w! w1 A) e4 Q/ ? q7 y },
$ q4 E0 S" X" }# R; R {- y _/ `" g @
.active_low = 0,
7 c& @& q$ H9 J$ H+ f$ s .gpio = DA850_USER_LED2,
! w1 Z6 y- A) s& v& @ .name = "user_led2",
" k7 h$ P/ r( M( |% o1 O# m; a .default_trigger = "default-on",' G8 M3 H; }7 Q. d' i( B
},9 m7 o9 R) b% @7 D
{
. u% a1 N" `1 K5 ? .active_low = 0,
! p1 t9 x" |6 m* ~, ^- @$ s! ^# Q .gpio = DA850_USER_LED3,7 L3 e5 j$ W, _) V9 K7 A# |& N% X- z
.name = "user_led3",
" V7 D9 x2 p/ y! W .default_trigger = "default-on",
3 s/ l( w7 V9 ~1 A* [: J+ V& N },. u5 I0 H2 J: Z, n- {+ x
};
$ R: [, q" `3 L) `2 X2 @' j' {8 |+ h% z' }% R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 Y7 `. q2 G- e7 g# K. g .leds = da850_evm_tl_leds,
: `, ^. T) n& [! y0 ^* \( t; \ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; [% b1 E6 Z( j/ Q9 v};
: O4 F4 P g5 h/ @, n' p/ a
# b, l7 L5 D" o7 i' rstatic void led_dev_release(struct device *dev)
/ H, b2 f0 \2 \/ o5 y0 b3 P{
7 R6 E# m5 I8 U& W};
q( K3 J4 V& e3 I7 q: ?( o F! {; A- R+ f' h( Z
static struct platform_device da850_evm_tl_leds_device = {
( J- Y! X% Y( B) k .name = "leds-gpio",' _5 G1 \5 ~* l" A% e& C; Y
.id = 1,
5 L' j/ Z7 B3 G9 L- I .dev = {7 h" v0 Y2 S( T! ]; W& o4 K
.platform_data = &da850_evm_tl_leds_pdata,
& W3 P6 n5 U" H7 r8 a* L .release = led_dev_release,/ ? b" e- [. u( |
}6 ]9 @) V A) L4 e) J
};
, y! g8 x+ [, E% W& `# t1 g1 A% e( B' U& n. i4 m0 p
static int __init led_platform_init(void)9 [' i4 {, y- ], S4 v& I) n
{7 S* {$ n" g4 k2 O9 e! d
int ret;
. m+ F" W- m$ _. w0 n$ |, z. M) s#if 08 A( G- q5 i6 o7 Q1 W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ Z/ [3 \/ V+ b4 {: C8 S% E if (ret)
6 V/ {8 J. C4 K. o pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 g% Q, ~8 _ O2 K5 o+ O4 s. I7 i
"%d\n", ret);. O/ b \7 ^4 D P* |
#endif
6 ^3 i/ T6 l- F2 T ret = platform_device_register(&da850_evm_tl_leds_device);
6 Z+ W# c# g! {+ K z) @9 l if (ret)
! k8 d& F& S$ F6 W# | pr_warning("Could not register som GPIO expander LEDS");# i+ x6 J; z+ n" s N; p
else) a- b. C" [1 X1 L X( e+ r, r" K
printk(KERN_INFO "LED register sucessful!\n");
7 e0 Y0 E3 y* \/ I! i! J
. D2 T6 m/ h6 Q# T return ret;
# x( c! L) R/ d3 }( z! E}' | Y5 \$ X/ A: M5 K& `
3 E) h, a3 L: o& H/ s9 R; j' Cstatic void __exit led_platform_exit(void)! ]- q& D! H8 u( q6 m; s0 m Z
{/ e( Y8 W3 h. ]7 ~7 @6 ?
platform_device_unregister(&da850_evm_tl_leds_device);7 H5 D- o7 [/ b. R+ H
- x. H2 F- s+ c! i' q/ X% c printk(KERN_INFO "LED unregister!\n");
; u, |6 b! n* L( i: ]# B}
; k2 h- D+ B+ D# U# _ C" I
6 f9 x' U- G4 x2 f, Q6 `% nmodule_init(led_platform_init);
. f9 X2 V- D3 |. W! k7 V7 o. o& \module_exit(led_platform_exit);
+ N8 y7 F l3 ]9 {
: a% E: J0 a+ l% sMODULE_DESCRIPTION("Led platform driver");$ ?4 C" n4 J, y. T/ ]+ g6 K3 ^
MODULE_AUTHOR("Tronlong");- T/ q) d$ @9 P% E
MODULE_LICENSE("GPL");# _1 q3 J0 _, n
; c; w, R0 u' c3 i; z
|
|