|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% {+ `7 W/ @% i- d: h#include <linux/init.h>
+ [( l- u5 o1 q. a* m, Q#include <linux/module.h>
0 \" }' \3 O% @% P# A: E* j$ N0 H#include <linux/kernel.h>2 r! |0 y* r. L/ {* ]* w
#include <linux/types.h>
* }3 k, t# k" ^# S$ R: u6 ?#include <linux/gpio.h>+ I2 W8 Z' y4 ]( L+ C' {+ w: R. m
#include <linux/leds.h>1 b! h: M, a H% v* Y
#include <linux/platform_device.h>% p* n9 O) O8 \. C! j# A) s+ r8 B
5 e3 s3 b. Q M5 h! K
#include <asm/mach-types.h>1 ~7 q7 d: c4 F+ Q( I. \; ]
#include <asm/mach/arch.h>
J% A5 F6 c- Q3 n#include <mach/da8xx.h>
8 z! C( i9 ^9 V) _! t8 y! |$ D. o#include <mach/mux.h>9 l$ J9 J: g9 a b
0 I0 r8 w) e; m' M N
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 T4 f- H( V5 @, I e# P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# T5 C& T2 t# I. q$ C7 s R7 P#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 t5 A8 y4 W* r" {/ V7 C5 J4 x" v#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 u/ k p5 k& x' o, f0 ^9 @
3 L$ h5 x+ }. K" g. i1 t4 p; ]/* assign the tl som board LED-GPIOs*/ g. ?' P( @, [# G
static const short da850_evm_tl_user_led_pins[] = {: L& M( y3 B, P" O8 g, ~: H& F
/* These pins are definition at <mach/mux.h> file */! o5 Y( r, @: P3 d* K: p* @* Q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 o7 [9 n. q, ]8 L% q" k+ O- T) | -1
" R# t9 _6 y- w};! Z: `6 N" K( J, [* Z; t
7 u( H! P* S/ z& j/ ]9 z3 G
static struct gpio_led da850_evm_tl_leds[] = {" J# o' [0 X; D, p# f7 `& I8 Q# j/ b
{
0 T& l A! A# H5 B .active_low = 0,/ j5 z9 X. I* Q3 e+ p: W2 t
.gpio = DA850_USER_LED0,# C ]% z" |8 R! p; \. c
.name = "user_led0",5 s# R& @, @& P5 X$ E0 [3 @) i# E3 N
.default_trigger = "default-on",& L ]6 @( Z+ y8 z ]! a/ d4 q: I5 ]
},
8 N$ X* }, |) `0 w, A3 D7 [4 a9 f { j5 {1 G, j/ t, h' U! n' T
.active_low = 0,
) e5 A& g$ C6 E+ _: N9 B3 O( r/ K) s- U .gpio = DA850_USER_LED1,% f% f5 F Q, |% N0 k% j
.name = "user_led1",
0 M/ O0 h. l G2 [/ \ .default_trigger = "default-on",
o( D; s4 ?& l0 M+ G },4 A9 D B3 j7 f# I: e" H7 _2 ]# o
{0 Q! ` @0 O3 l h0 O* K' z( t
.active_low = 0,
' R5 `5 f% `% W$ V7 B .gpio = DA850_USER_LED2,
; t y a. Q6 L3 y; d! W .name = "user_led2",
4 q* G$ H- Z; t .default_trigger = "default-on",
! J) C1 |5 z8 p6 D9 s9 `- q( \ },: X/ n! x% w2 u8 |. T ]
{1 j0 l- Q6 [ M: \1 H8 Q! U4 @- Q- T
.active_low = 0,
; D R. l6 Q, D6 l1 ` .gpio = DA850_USER_LED3,
" N% ~# s1 f* E .name = "user_led3",
6 E, L$ n( x7 `3 s) |, g* ^ .default_trigger = "default-on",
; @% r, f H% K },
' Z( D/ d3 X! ^% M7 b( k};
g2 r& v* a I# l8 s7 p* B, t" y5 H5 c# I. k2 o% P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ I& f' t% F0 a1 ~
.leds = da850_evm_tl_leds,) V8 ]/ @; Z! F( e
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 `1 O ~- a, [* U1 f};; Z; m) |$ U& Y: N+ ]( j; W
! S0 R# o$ i8 X& G6 ^
static void led_dev_release(struct device *dev)* x, n+ r# E: Z9 a- k) ]
{4 N* P: k+ L5 B- d' j) A" f
};
4 D- O1 A0 r0 m+ w7 o- I+ K) G. u* p) q6 k# E* ]' o7 y) q) h' R' }
static struct platform_device da850_evm_tl_leds_device = {
4 l0 ~- R8 c& Y- ~ .name = "leds-gpio",$ }' y4 C6 m2 O, ~# e
.id = 1,
- m" }3 y- K! f+ F$ w5 o .dev = {
! l+ R! O8 m3 e1 G; [ .platform_data = &da850_evm_tl_leds_pdata,: w- @8 t6 p& V: J" o. ]
.release = led_dev_release,
& @6 t x8 l5 X3 c' T8 q r }* e% A3 P `( O6 V1 w7 J) t
};4 Q7 A, k+ F, P
6 G8 w; V% J0 l) m3 ]% ~static int __init led_platform_init(void)
/ |, L; ?8 m) P) p) B{
2 E, t) b) H0 J: e# b! U/ N int ret;' K- C4 o+ `: n. Z
#if 07 S; V) r, M0 J+ y" R3 l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 w% R2 F& D- _# S
if (ret) F. {0 f, \4 W" V# W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 }" R6 W2 m; A: D: W
"%d\n", ret);
3 X: ]# m" L, c) y$ B#endif
" q6 X, Y, q3 s$ v6 R: z ret = platform_device_register(&da850_evm_tl_leds_device);
. M' \, J% v+ m3 y5 U if (ret)
% ~0 w) ^8 y3 K% `7 a$ h3 z ]. B pr_warning("Could not register som GPIO expander LEDS");
9 W3 @6 V1 \) [4 D* X. Y6 q: Q2 l else7 n& W% E- n' W) g( V V6 f. q7 A
printk(KERN_INFO "LED register sucessful!\n");8 g* ]) c* B! r9 S- P& [
9 p& P c c6 N( d
return ret;
4 `! d# b- P4 i" b9 s. ~}
2 s/ W n! A& [ C! R2 Z# @* S; ^7 w
static void __exit led_platform_exit(void)8 f" l; l9 R; @( k: }, j& S
{
' \# Z" N5 ~9 f2 n- C7 ^- Z platform_device_unregister(&da850_evm_tl_leds_device);
( V6 ~( L! N# W7 s! X: O. M& {
" `3 R3 y8 I6 ?+ V8 r printk(KERN_INFO "LED unregister!\n");
- B1 i; A' z3 Q$ e}9 u5 ?8 s" H) o+ Q$ s
& x; K+ T0 k* V" I' l) m. Pmodule_init(led_platform_init);6 @) @* w1 u* m# Z( i
module_exit(led_platform_exit);
. F4 K$ p3 s" q- X6 e2 |+ M; E, ]; _" f* \
MODULE_DESCRIPTION("Led platform driver");& W. F: W! Z4 P% A$ k
MODULE_AUTHOR("Tronlong");- n/ U3 T, d( Q; g5 S }
MODULE_LICENSE("GPL"); `) a9 y. T3 M: T5 l/ ]$ e
) a. d+ W! g+ |$ e/ w |
|