|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 y/ y0 p8 \6 v3 C( B* d! \, E#include <linux/init.h>0 X$ ?1 z) i. q; r1 F3 V5 w
#include <linux/module.h>% z8 U& S( m4 f) b; P0 d+ R8 t" t
#include <linux/kernel.h>
/ Q# R, L/ h/ V' o#include <linux/types.h>
* P( a: }6 T8 `- A+ g2 R% d: R#include <linux/gpio.h>
1 i6 }/ B. _; h8 [#include <linux/leds.h>
; o1 d' M( C& Z& K$ U2 p; q" ^/ ~0 @#include <linux/platform_device.h>
4 G) F- d. s7 |% U2 Y2 }' {: V H' k5 `8 b8 w) C
#include <asm/mach-types.h>
4 i' @) R& f" t5 v#include <asm/mach/arch.h>
: I" I- v' r3 B9 y#include <mach/da8xx.h>9 Z+ r- c3 d* P6 H
#include <mach/mux.h>
6 c0 ]$ A4 M* _* I- W& ^* _ o3 g% w% d2 W3 z+ l/ c
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 \- K4 F4 R* g8 s$ f, D+ C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) a8 V+ \8 u4 n$ q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- ]- a2 i8 y: G7 W4 p5 D. ?' U
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 x- B7 @- t% C5 N
3 p5 r: |$ f l/* assign the tl som board LED-GPIOs*/( t/ n/ }. d9 Q7 C2 W
static const short da850_evm_tl_user_led_pins[] = {) j# { [( _& J: h3 `; C
/* These pins are definition at <mach/mux.h> file */
# _3 m G# o- U; z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) A" l0 Z/ m# c" d" n
-1
6 U- j$ t0 v2 e};& n% b9 a7 s$ Z0 d) I" [$ S
0 _2 D! B+ ?0 K; |5 v* P: E* Cstatic struct gpio_led da850_evm_tl_leds[] = {5 c# g. Y/ l8 K0 y' h/ Z% a4 e( c
{
1 W' h3 C/ V8 n: q% Z .active_low = 0,. U1 a# ]( V6 r G8 F( [( O
.gpio = DA850_USER_LED0,0 c: c9 P- J3 j# ^
.name = "user_led0",
1 ~ H/ @. P, t P- H3 j .default_trigger = "default-on",
1 x' R) O9 l7 S( p },
R! Z! p6 c8 [2 g1 s {4 \! o9 t% Z1 f; K
.active_low = 0,+ {) C: d' T9 I$ ^" g# |( |" A9 v
.gpio = DA850_USER_LED1,- F' S; r% o+ H, _+ h
.name = "user_led1",0 M' m4 V/ o0 G- b0 K) H0 D
.default_trigger = "default-on",
1 j- a4 E; M, ~+ v9 R },
. F1 P. ~& k2 ]2 R: F {
5 P# R, ^9 V3 d4 }4 k .active_low = 0,0 c' f) D& s( v3 ~8 k( N
.gpio = DA850_USER_LED2,# z8 S4 t" e6 G+ V
.name = "user_led2",
0 J1 ~3 I3 o6 Z U# H .default_trigger = "default-on",
7 Q- u" `5 e1 ^2 g },
3 ^/ [- o- z8 ]0 t! M8 s8 z# \7 D; B {
( _3 ^1 H2 p& r* x5 c- i .active_low = 0,/ D: \9 Z+ l! [$ e
.gpio = DA850_USER_LED3,
$ s3 X+ a4 F) \( T, b .name = "user_led3",
" V: O3 G. U. ?# y; B9 } .default_trigger = "default-on",
$ L9 l3 _2 d5 P1 z, s0 H: s },: Y3 t4 ^9 T0 t! g* t
};
8 j7 z$ p' \4 T! y$ ~
+ N, s: f- S! fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ s; l9 T; Q$ d- `) N W
.leds = da850_evm_tl_leds,
; ~/ x# i4 _% s) h2 s8 c .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 f x+ r; q$ N- K& p2 y};& S; p" S7 `$ i$ m" X; l
6 f; ?/ g/ W) y+ l% Xstatic void led_dev_release(struct device *dev)
( p" {. u( H) v6 B2 \+ J: b# x{
4 D- S- T' u2 s. v2 j1 R; k: ?, R};& B3 g* k. U0 s6 u' a/ b
& a( e% h+ B% U, a/ W7 Y7 x. Ostatic struct platform_device da850_evm_tl_leds_device = {
3 d5 |2 B H* d9 P! F0 z .name = "leds-gpio",
1 t( N9 s! J7 i( s8 ? .id = 1,
9 q) T1 | h4 ~ .dev = {
( e; W% g3 A* a& ]; P' U .platform_data = &da850_evm_tl_leds_pdata,& N" G7 R5 }: ~* Q3 C
.release = led_dev_release,9 w3 l- q2 J1 Z) y. T" t% ?% @/ b
}
+ E4 t0 m( l) c! | Y9 Z};
) J! u r l; ^- U2 y/ u) P" D1 c5 R6 B1 Y- S) d
static int __init led_platform_init(void)
1 Y8 n: M' D( H7 k4 n0 [6 s{* x$ K3 J. s- u% D/ r9 q) S; M. r2 W1 i
int ret;
3 H9 ^3 O' U# T/ h: v5 F1 q#if 0. T r$ z! p* @4 j3 K
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 o# n Y; L% J9 s1 `
if (ret)% S3 |" p6 l* v" @" C% W& x
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' ^( F! g" S' z0 g
"%d\n", ret);8 P& `6 C2 V- ^/ m
#endif
- @. S* ]& S& x/ c, N, ] ret = platform_device_register(&da850_evm_tl_leds_device);- K& {$ I) }$ v- m
if (ret): T l3 D0 H2 k9 s7 y6 ^8 b' n
pr_warning("Could not register som GPIO expander LEDS");1 g2 Q% L: y& R# N6 S' a* _9 _" t
else4 l5 o% S- C6 |3 x4 C
printk(KERN_INFO "LED register sucessful!\n");
2 n0 y( H0 V9 {% N# C- g0 b4 w1 ?; K' r+ c8 t1 O
return ret;
: Z! P& o U$ f) E5 J} n2 k% ]' E( b; q
) q1 _2 S7 R! F" l
static void __exit led_platform_exit(void)6 M+ L$ r# T5 B" W: |. ^8 h
{
9 z- C2 R0 X; T4 W! H8 C& @ platform_device_unregister(&da850_evm_tl_leds_device);
9 M! }9 @$ m* j0 `4 T& c- t, q3 `
3 w8 E% Q% W6 D |& X printk(KERN_INFO "LED unregister!\n");
~8 p' Q6 S( b$ B7 z. `}
+ ^5 b1 a0 h J& ~0 f% `# n7 f6 w) C* K6 g) S& Y2 r
module_init(led_platform_init);6 X+ z* Z7 D# z9 t3 Y1 s$ N2 R
module_exit(led_platform_exit);
: u( b: @6 ~: j
6 ]( c, ?- n) e& X7 o1 I8 `0 PMODULE_DESCRIPTION("Led platform driver");0 ~/ ]; n! s, @+ W. L+ R* k% v
MODULE_AUTHOR("Tronlong");
9 t( B) g$ i. `) k7 O9 |MODULE_LICENSE("GPL");
( V- H9 u4 K, A( S6 Y2 y7 ]$ _
y" o) X# l# r% B% J2 h' A |
|