|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
y+ U( a) T4 f1 b, j! V$ L#include <linux/init.h>
4 y; r& S5 k& Y5 t; |6 e; ]#include <linux/module.h>
# T% _# `" Q- D, R" M#include <linux/kernel.h>
! C; j$ i/ Q( n#include <linux/types.h>
/ J; T; ^6 z: u1 n#include <linux/gpio.h>
4 } `( q1 G+ ]+ t2 o#include <linux/leds.h>
/ A' `$ q8 i; B# C#include <linux/platform_device.h>
# \$ g1 C* ?. ^0 J4 v& e. Z
0 m$ |' V, r( S7 I/ {#include <asm/mach-types.h>
# V3 {1 S: f3 R) i% | {#include <asm/mach/arch.h>
" W+ ]" V6 e8 p) U! `) e#include <mach/da8xx.h>! u a( ~8 k: n! N- F
#include <mach/mux.h>9 K$ F5 ?( F8 p
1 l* X) q+ Q& U) d; r& \5 u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( C% V6 c6 j% |( T
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 J0 ~& w0 x3 g. v0 m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( R) G% P& N& d; m; F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( h8 z8 f& O8 v# c2 g
2 m; K) A( e/ p. _" Z: y+ e
/* assign the tl som board LED-GPIOs*/$ I# t8 j$ `. C. P0 `
static const short da850_evm_tl_user_led_pins[] = {3 V1 Q; b$ w* F& p# ]) l' Y
/* These pins are definition at <mach/mux.h> file */
8 t! l* c# T0 P: K& Z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& W3 ?$ U2 O, w( G -1
+ n' z g7 m9 u" W( @2 L k9 b};, H" e9 E/ i1 }
3 @# W1 I0 V, A# Tstatic struct gpio_led da850_evm_tl_leds[] = {6 ]5 w' b; u% R
{% F5 \9 f0 ~+ ?1 v/ l6 u# d: ]& h
.active_low = 0,
4 g0 @6 Y& b+ X8 n- p2 |6 ` .gpio = DA850_USER_LED0,+ _5 r0 e [9 i
.name = "user_led0",8 d5 M4 D2 q! o4 o# G9 w7 [: z
.default_trigger = "default-on",+ p7 ?6 s0 h/ r, J: r
},+ U+ j7 C# `* S( U
{
! k1 e+ _( A! V; C5 u! |0 Q0 D .active_low = 0,
/ E/ z J n) ?9 ^; E7 P .gpio = DA850_USER_LED1,
( \5 L, v* y5 }; w, \) \ .name = "user_led1",
7 W' z; J+ X5 W# B2 ` L0 @ .default_trigger = "default-on",
- `0 {0 D+ l. K },
& D, j2 |" }% e6 Q/ r {: C6 `( Y" T) z3 A( }
.active_low = 0,
; A3 b/ \- u/ P2 \3 f .gpio = DA850_USER_LED2," k* e; J. I7 z( Y5 @+ w
.name = "user_led2",, N! x9 N4 Z" l' Q
.default_trigger = "default-on",
' b( I) g& u" q) D; ]9 u' C' N },0 ]6 P& G& Z+ K9 ?
{
& g4 [! P9 {6 x; g& V .active_low = 0,
2 H0 f' Q* Z7 i5 ?# ^; E: t .gpio = DA850_USER_LED3,
7 d) O, Y9 n* ]/ _ .name = "user_led3",
0 u: X! m+ E1 o3 j4 v( _/ ^ .default_trigger = "default-on",
0 N- t# t8 @5 M9 `5 x; t- r/ D' ] },
. M" V }( t/ }/ J};! b& v' ^; S1 g# n t4 E
, V [0 K1 S( ?/ U
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' [9 b$ n- Z! Z' q# I
.leds = da850_evm_tl_leds,) v. [7 X( ^! q' k0 ~( `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* i$ X; i# \/ C! \ J: m' V
};
( ~$ a& `7 S: F% g
9 X5 V- m( h' Ustatic void led_dev_release(struct device *dev)- |: I* d k' F7 l2 h( Z
{
% B) Z+ D" H, j- ~! k};5 J D5 Q: {% D
; R* j0 n( U, j* V4 B ostatic struct platform_device da850_evm_tl_leds_device = {! j% p" l* o# i( `& G# v* d8 v
.name = "leds-gpio",. \' |3 w& B0 s0 o
.id = 1,
* A. K. }4 }! h" { .dev = {/ @6 M8 v% S. E4 \4 ]2 t
.platform_data = &da850_evm_tl_leds_pdata,8 b5 ^- | k& X: F) X
.release = led_dev_release,! T. v0 `5 W% \1 Y2 }
} A! P. O, j( i: S) F
};
3 `2 {+ F, c* f; w. _* a2 n e! i# W+ i
static int __init led_platform_init(void)6 u# g, v1 |7 S; A" \# @( W
{+ ^( E0 L d4 D( ]+ a) J% N
int ret;
0 a1 g% M3 h. X" {0 W" _* f#if 0, r2 V$ H/ i- D: M
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( \2 {. h& ~% b# }& ~ if (ret)# x' c# i- j6 _( o& U/ e( D% P) L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& a( \& W( P- ]( x8 K! h6 c# T6 @
"%d\n", ret);
6 e" E" }/ |/ {0 v#endif" k1 Q! u' R ^: J; _2 Z
ret = platform_device_register(&da850_evm_tl_leds_device);5 \/ { B% L; B% G, D- J3 t1 P7 d
if (ret)
" H9 F% }& z5 N0 l! R+ Z- z pr_warning("Could not register som GPIO expander LEDS");, P8 ^* g/ U4 d
else
, z! E; N& j5 }3 |. U* p printk(KERN_INFO "LED register sucessful!\n");( B" _5 Q9 @, r, N" t1 B
3 o" [4 I3 P7 c* ? return ret;
4 I% r8 d3 ]3 [ \}+ e, h# B( P; A* K$ x
' ~: P- g' u) m7 \static void __exit led_platform_exit(void)
# k+ ~6 z* I1 i$ F- z{
8 f8 ~" ?7 M* X/ n, H platform_device_unregister(&da850_evm_tl_leds_device);4 I9 g4 M' z- d/ c8 E, ]4 f2 r) `
( v6 ^/ Z& D6 k/ |
printk(KERN_INFO "LED unregister!\n");
8 h1 @% _) M \- P* I; J}
7 o" L& U- C3 J& F
% d3 f( M8 C g5 ?& A! y+ f! mmodule_init(led_platform_init);
& z# S) i. C7 m! z r" }module_exit(led_platform_exit);! ]6 X1 K+ G1 p, L" L2 s3 k
$ v) q6 Z8 e) B8 l5 z! c4 xMODULE_DESCRIPTION("Led platform driver");
& m# V9 a7 R4 {' l. Z0 @3 A; w$ rMODULE_AUTHOR("Tronlong");
7 Z5 e: V! c$ {2 i tMODULE_LICENSE("GPL");6 F' `, o( R: O, K1 ]
! {& g) S4 K$ ^
|
|