|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 e. c7 D. z5 n7 O, L
#include <linux/init.h>7 Z4 g) f0 q7 c/ M* O
#include <linux/module.h>
3 C% }7 ^0 H0 R+ T& ^/ X#include <linux/kernel.h>' F' \7 X$ g; m% a& M/ }
#include <linux/types.h>) T: P7 U) ]) n! V# I2 w
#include <linux/gpio.h>
" Q" L9 b1 r `6 t9 _0 R8 C* B#include <linux/leds.h>
; c9 b% D; P* E( p#include <linux/platform_device.h>
: M+ `6 P9 _/ r# H+ c& N7 a( ~6 ~
( t5 B& f5 Z( q% H# r#include <asm/mach-types.h>
5 ?5 n' g" ^1 _6 i; c/ d#include <asm/mach/arch.h>
* o6 P8 ~2 k! C; R#include <mach/da8xx.h>
" p6 k# l5 S6 w0 Q+ j8 U/ ~5 @#include <mach/mux.h>! e3 A$ b0 E1 S Y8 w" i
: g! u0 \- l& p' ]( A0 v4 s9 p& ]#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 M$ P% M: g' `/ _8 I9 I# S: ^#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 }+ B- F6 ~. F2 O. g5 x8 l# ?#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 d+ G" v& n, f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 [- d1 Y, w% j3 J5 P8 h8 z
4 e7 n3 W. C9 X) U/* assign the tl som board LED-GPIOs*/
3 J0 C" ^9 f# Sstatic const short da850_evm_tl_user_led_pins[] = {3 v y. N7 g% Y/ ^
/* These pins are definition at <mach/mux.h> file */$ {& J- F0 f2 [' O' F0 }/ q8 z5 g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. Y+ Y6 w9 S+ H9 d/ j
-1, u/ V% P9 V" J+ n% p) @, ~
};
% z4 e ~6 V6 r5 v4 Z) [8 W- b* a2 d9 l" h. s) I5 e/ E
static struct gpio_led da850_evm_tl_leds[] = {
2 Z: @0 Q) ]1 d- m& C {3 ~3 @0 M3 q% j6 z
.active_low = 0,
. u" H G# g9 n" _8 L* G .gpio = DA850_USER_LED0,1 a# A$ c8 `2 X6 Q
.name = "user_led0",
8 ~3 H8 |: P# { |4 L .default_trigger = "default-on",
0 n: B; F3 X" D# H& X- l },2 l3 I& ?3 U& m/ {3 R7 h {/ M
{
4 X% \ ^ j' @1 n2 M9 r5 H .active_low = 0,8 G' J+ ]* C' O' a3 ^9 h9 m2 a- o
.gpio = DA850_USER_LED1,0 H* k- C. e" c! d- h& q
.name = "user_led1",
, g: Y" Z1 X, x* K; h3 F* o .default_trigger = "default-on",
2 z$ i- e% K1 @) t% d },7 I0 F6 S: [1 w: }' z3 j( _
{/ U4 U2 G9 J1 G* ~' ^7 ~
.active_low = 0, s. R8 m4 @1 n
.gpio = DA850_USER_LED2,
, g' o! E# o( C+ U; ^7 H .name = "user_led2",3 M8 p% g' _ @. ]7 B
.default_trigger = "default-on",8 x! Z& }7 t; x/ {3 Z, @4 W1 @7 X$ \
},
+ U9 M: L8 D1 R; d' t6 Y {
9 U$ Y4 f1 `5 w, w n2 K .active_low = 0,
/ P0 F: G3 k$ G! i4 A! D" W f1 Q( f .gpio = DA850_USER_LED3,8 C5 }: u* l- k& d, X6 B4 u
.name = "user_led3",7 b% H8 }+ C& c6 [. e
.default_trigger = "default-on",3 d- K: @4 {0 a5 A% Z/ G: N* P5 W
},
q* F9 p+ Y6 O, Z4 Y4 [};
/ ]+ `" y. T5 ^' ?/ g" B: W# }5 d+ s( `" s( r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 P0 P* J+ b( f# s" o0 J5 v8 g$ L
.leds = da850_evm_tl_leds,
n, [1 Z$ _' ?4 h9 g/ n9 V .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% ]4 C; b5 s- N ^, u8 d};
7 a6 r* _% Y9 \! \$ a6 s1 u) L8 K# {+ e: E
static void led_dev_release(struct device *dev)( p0 f: K; i1 o8 | Q
{
4 S$ y" j- P5 P# L# c};" A' ]3 E/ d8 h
* s3 F, v3 h% f3 b8 ]
static struct platform_device da850_evm_tl_leds_device = {( Z' x! t0 r! Z- _
.name = "leds-gpio",
' Y* q6 T* i7 a; z .id = 1,4 v* f1 \0 _) W8 g, I- y
.dev = {3 Z/ z1 S, ?' o
.platform_data = &da850_evm_tl_leds_pdata,4 W! G( ?9 v. M, D! Z% Z
.release = led_dev_release,; g N% o$ j9 W; z7 {* C
}: q. S/ h* ~6 ~, G7 ?
};
7 f; t5 n6 W/ }, i5 w) ]5 g
) L! m$ M; l: `2 r. M: n. d) a! W istatic int __init led_platform_init(void): @; M/ O: U F. O& v$ @
{" i* k9 z/ G( w, U; M0 N m
int ret;! r, n$ y, n$ z. Y% ?
#if 0" i0 Y; |/ I( @6 ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); E8 ?6 D* o5 Y0 n* m+ |
if (ret)
# E" I9 w8 s" ?4 [& c pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# }6 N2 |/ B; B! z/ t5 V
"%d\n", ret);
6 q* V0 u- h2 y2 |# r; u& A. U#endif7 J' M8 R4 n1 t# m: s; x, W
ret = platform_device_register(&da850_evm_tl_leds_device);' B. w8 C: u q$ r! @7 M; d
if (ret)+ |5 H3 X5 O" X% U# S3 [
pr_warning("Could not register som GPIO expander LEDS");1 c) I' l* ^0 \3 R7 z
else
+ M" q) o8 [$ x* X printk(KERN_INFO "LED register sucessful!\n");$ ~) M; {$ @: k# j* Z( O/ W
9 M1 I8 t) K B' Y- T/ Y return ret;
8 k5 W/ I" v5 y1 {& ^/ U}
8 b) `/ m1 m4 s: ]% B3 _) r5 i6 e
static void __exit led_platform_exit(void)
, m3 X; |, j. a5 ^{3 q- v9 P2 g1 x: y( A* P
platform_device_unregister(&da850_evm_tl_leds_device);
/ O+ a2 I& a& W* i1 K+ z) X
# q0 F% w8 L( V printk(KERN_INFO "LED unregister!\n");
8 j2 S+ N( \# ^, B}
% {( \% `3 _ _1 [8 j% M
# {( [3 `2 F# L1 B( |6 i' h' mmodule_init(led_platform_init);
# O8 _( R5 Q8 r7 o8 Tmodule_exit(led_platform_exit);& M+ C1 \8 l: L6 j; S
: T" z& P. |$ t, ]6 o
MODULE_DESCRIPTION("Led platform driver");
; X; y- x) R e$ uMODULE_AUTHOR("Tronlong");
* M2 u- r. t O9 }MODULE_LICENSE("GPL");
1 u' d1 a! a; d; B7 D7 r* k4 m, F9 H' ^2 ^
" I# H+ c) T. T# i B* }! j8 r* `) W |
|