|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( s$ H T: G5 g
#include <linux/init.h>4 _2 X0 a/ y8 M+ A
#include <linux/module.h>- ?% y; M6 z0 p" V$ z1 `* U9 v
#include <linux/kernel.h>
1 ~; y* s9 h9 Q/ _+ |#include <linux/types.h>
/ R! w4 R' t G& X j- O5 r+ g#include <linux/gpio.h>
3 P4 w* H$ j0 G* I4 `#include <linux/leds.h>2 M, |( j* X- ^! t
#include <linux/platform_device.h># U$ e1 G8 u1 `) C' a
( h5 S! M6 U, V8 I$ I
#include <asm/mach-types.h># a8 ^! n0 O/ `0 B$ s
#include <asm/mach/arch.h>
8 F& [- |& {2 b. y#include <mach/da8xx.h>
" L+ v, T& j. C# V. p#include <mach/mux.h>( N" ]) v. I, U/ P. l
4 c* U% J& r' N7 t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' x, v- }1 p0 [' ^3 Z/ F8 \9 X+ o. ?#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; d! F7 I, y2 n$ k; f6 a7 W$ q3 P#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 s( h' }0 v. {$ k2 L7 X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ m& [/ d$ @/ i! B9 j
0 T& C. G" u& K! z
/* assign the tl som board LED-GPIOs*/
2 a9 D8 j. U V0 A3 J7 s) h' Astatic const short da850_evm_tl_user_led_pins[] = {8 P6 j# x" x$ T* z9 N8 U
/* These pins are definition at <mach/mux.h> file */4 @6 T4 m$ N9 Z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
V: T2 s0 h5 }& ~$ V5 f -1' e9 S5 ^+ j5 R# m2 R
};) C; Y! V( C/ `. c# ]/ A
h7 s s+ [$ L
static struct gpio_led da850_evm_tl_leds[] = {
1 a3 Z. A" @8 G( Q, w- { {( O/ z' X7 x9 x2 [
.active_low = 0,
3 {" h9 I% X( \0 {! f .gpio = DA850_USER_LED0,, Q9 K9 s+ P1 F' E' D* x/ b/ }) r
.name = "user_led0",! K0 j& t8 c5 w' w' Z; ]- a
.default_trigger = "default-on",
" r, {" a6 e7 K% w9 X( w },, k# u ^: N- c! M2 e/ _" C7 \# V4 |
{/ Q$ L$ ~% H/ S7 r: ?
.active_low = 0,2 [# u/ P" o' a! L$ M
.gpio = DA850_USER_LED1,
+ V& t6 d' v/ W& D* c. _; N* a! o9 i .name = "user_led1",- O+ l8 v. |( _8 [
.default_trigger = "default-on",$ \/ D q+ \5 e
},
; \' a& j* b. b6 p4 J1 y {
, r# `8 x- P- y5 A J! z) m$ v" N. d$ ? .active_low = 0,4 H& G. f! k# g
.gpio = DA850_USER_LED2,
; Q9 s- R; W, C$ ? .name = "user_led2",
5 Y" f. t/ s2 ?& ] .default_trigger = "default-on",7 _9 q* ~) f8 Y7 F0 b# ~
},' }$ z( ?1 h/ G; i# H
{# f' X& |8 E7 [% R- M7 I/ Q
.active_low = 0,% \, \5 y5 V( R
.gpio = DA850_USER_LED3,
0 _. G: L$ {( N* C9 X0 c" N .name = "user_led3",
" B; l' O ]! I/ R .default_trigger = "default-on",+ X E3 s# Y$ V0 j- Q7 H$ g
},# c( `/ ?- E. S6 Q1 w% K0 a
};
! E0 B& ^( T [) e: Q4 T6 \5 I
+ f; N7 q/ _$ E' n" D' X' Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" p1 H: p4 o4 ^1 x( M$ s9 B
.leds = da850_evm_tl_leds,
- w3 g- Y- e) q% _3 Y3 A .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ @; H2 O6 Y6 S5 Y4 s) g};
/ j4 `3 C! q* ]' F2 m) c. W! V \0 Y$ x5 d, d' p3 t3 S
static void led_dev_release(struct device *dev)/ a3 k+ e! G/ _% A
{$ J: c* t5 @2 p; @
};3 @3 a/ s2 }+ u9 s% C2 O4 X0 n
" n) Z$ m5 ]/ E/ ^7 {! A
static struct platform_device da850_evm_tl_leds_device = {0 ^! r! ^# C8 A+ T* |/ N Z! S! f
.name = "leds-gpio",
0 H$ ~( j) o9 q& g .id = 1,- {, f. z+ |1 M3 c. L$ T
.dev = {
: C) @5 ?1 E0 \5 _% P! C .platform_data = &da850_evm_tl_leds_pdata,
6 ` }9 T. T" A4 _6 X. ^6 Y, { .release = led_dev_release,
% w8 S7 `3 g$ e }
' u/ b- P( g. N( e};
' i# r+ S3 |+ L" P9 I2 N! \5 w
8 Z/ Z8 }# H8 S' estatic int __init led_platform_init(void)
1 W/ O# o* M/ g) k1 o; G4 W7 Q{
5 o: }' v2 U% Y. L/ ? int ret;! j( N: q- ~- }6 U' o
#if 0) Y: w" j# b8 V, {( U h) e
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ O2 Y- N4 u1 y* e% B6 S- \
if (ret)6 G1 t3 A5 s; x+ z3 v/ J! N# E% u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' w8 T3 s& d3 P+ T& i m: N
"%d\n", ret);3 l- b6 \' i8 N# U( z) i( Y2 p
#endif
# q# N/ a) e6 {: j I, m8 D ret = platform_device_register(&da850_evm_tl_leds_device);
% i" G! w+ h6 ^2 f( p* J. n) w if (ret)
( o+ v, G# Y2 c: @5 \ pr_warning("Could not register som GPIO expander LEDS");% I1 H* d. v. X$ Y- @. \1 G# d y
else
' N5 ?% u$ h2 R. J- Q& w& ^+ | printk(KERN_INFO "LED register sucessful!\n");% ~; T/ z3 @9 w2 m& F* }; C: Y
8 W) m( B9 {! _+ I3 c J return ret;
; U k# y/ {& }- J4 Q. O i# ~}0 T6 V) [3 B6 z! B2 g
7 y8 l' S8 Q; K
static void __exit led_platform_exit(void)
% m5 ~' p" T& b: B( o z- h1 j{9 m7 L" F& }2 H8 g! d' a5 f* O6 Q
platform_device_unregister(&da850_evm_tl_leds_device);. U; j; e% p% K, m0 L% t' `
) K, w8 h& N Z' O printk(KERN_INFO "LED unregister!\n");: ]- J9 ]6 }4 T: b) L
}
! y1 o3 u1 \2 X5 D5 _2 `
! E7 G: d2 s9 R0 A8 M# nmodule_init(led_platform_init);& ]$ \5 t2 a9 d9 c; I
module_exit(led_platform_exit);6 _+ C- L3 P W
! S9 g) [: S8 p. X, ]5 Z7 ^
MODULE_DESCRIPTION("Led platform driver");! l6 y$ r, Q: H2 \9 n( C
MODULE_AUTHOR("Tronlong");7 x+ c/ _) }3 u* W3 t
MODULE_LICENSE("GPL");! y2 t5 {6 `6 B' S
. q7 ] k8 l6 P. j: L |
|