|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ @- |; V- A; T7 X) r |
#include <linux/init.h>
% {/ Z5 Y- @: P' n' [#include <linux/module.h>
1 w- s/ y+ q7 A! I$ h: G, V#include <linux/kernel.h> ^( D6 u$ V, ?. b+ o- Q
#include <linux/types.h>
! S' e! E" x" q#include <linux/gpio.h>
V2 U& H% d9 S' m8 e9 R7 e( G: c#include <linux/leds.h># j; V f' P( F6 M5 A( {3 `; B
#include <linux/platform_device.h>" M; l. C, U8 Z& A) B( Q
. v5 u% Z5 h/ ]" r; n5 s! f* P! s#include <asm/mach-types.h># T1 W l( j7 _& W5 X. Y
#include <asm/mach/arch.h>
. y- K5 n6 d9 G5 V5 e#include <mach/da8xx.h>3 |. r. H' ~+ F" c1 Y F
#include <mach/mux.h>
' Q1 L" {! g* m5 f( J3 L0 A
) l* \( I$ u1 g F# O) t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! {4 H+ R3 k" C4 @! w
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 w; b! z, s& ~8 \1 ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! T* T7 p: G# H. \
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ z* B* m( W4 R# S% [/ l* I6 E9 v/ n$ K3 w# q
/* assign the tl som board LED-GPIOs*/9 l: s! W" O, |" H: K) b: i+ ?
static const short da850_evm_tl_user_led_pins[] = {
! s. \# F) X, o. o6 | /* These pins are definition at <mach/mux.h> file */
/ [- T& C3 i/ Y9 X DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 U2 L8 n) E; t1 o5 ?+ `
-1- O% d% b) n" X
};7 a# C6 y% I. D$ {8 M
8 @5 L: c" \; b
static struct gpio_led da850_evm_tl_leds[] = {
3 T* [" c' l4 U+ N% {, w/ z {
& A( `6 V3 u1 C. }; R G0 F .active_low = 0,+ I2 `6 T% a; D$ b
.gpio = DA850_USER_LED0,
! o5 f E$ h$ t$ ^ .name = "user_led0",# W& I7 Q$ S! }5 ?% \9 D
.default_trigger = "default-on",
) g0 A- C D f7 Y },
1 L! h4 ^+ k. X; p& q2 Q {
0 B4 S& z: L e. D/ Q+ M .active_low = 0,
2 [" Q) I; M( Z; j% r' }0 u8 | .gpio = DA850_USER_LED1,) l3 F' n+ L! M$ c
.name = "user_led1",0 g, X2 d& E8 N
.default_trigger = "default-on",
+ e+ e I8 }3 n8 p+ G$ U8 ^1 \- L },
8 q( w3 }' g9 S {$ B1 {' \8 p5 d+ d% @( O
.active_low = 0,
; b' u2 D5 }. u' j .gpio = DA850_USER_LED2,
! x) a. D+ l7 v: _/ L3 `) p( | .name = "user_led2",5 N0 M t9 c6 Z% p
.default_trigger = "default-on",6 O& f3 R! j! c
},
. {3 E4 f1 e4 e9 ~- K1 x% Y1 U {- z% J7 }. e6 _' g" l
.active_low = 0,7 P2 d. V8 a& L+ U, h( {
.gpio = DA850_USER_LED3,
$ I. [: I& M+ g! J- I! {$ _6 d$ f .name = "user_led3",
; G; w o# C/ s, L& @7 U .default_trigger = "default-on",% D& _0 ~( {; ]8 s4 D. I# C
},
) `- k6 w" v& |0 Z8 `, |};. w- g1 {9 b* j+ \$ j. p9 V
" Q1 M5 x2 F, w- e* |static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. P i) m6 n" |" M! l .leds = da850_evm_tl_leds,, C3 g6 ~) z/ g1 _, |# t; g
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: ^ J' c6 Z# n4 f* h/ N! c
};, W4 n3 @$ E& f- }
- q3 c7 d, f7 B9 D2 t: t: Zstatic void led_dev_release(struct device *dev); @% E$ Q p) @& h) N9 T
{
3 t: Q5 {3 {$ y# L};
9 y+ y( f1 w: Z
4 _0 h; s- [6 v: Y# m: d. H- ]0 Gstatic struct platform_device da850_evm_tl_leds_device = {) @- a- d0 G& o+ d/ D. N
.name = "leds-gpio",8 ]8 P3 K! f! o( L3 ^# @
.id = 1,
- l; X$ v q( E$ L1 w; e .dev = {5 S! V; Q. I- \+ L( p2 E5 P3 x
.platform_data = &da850_evm_tl_leds_pdata,: n7 {8 }6 d' |" K
.release = led_dev_release,
) ?# `8 ~/ |0 p$ N) q5 O8 w7 v }
$ s7 y& j8 `5 T/ J" i" W7 b};
$ Y8 ?2 A7 A! Y8 _% S/ C. N2 w' [1 J- }; S" Y
static int __init led_platform_init(void)( K8 W4 E2 [3 R, h! S8 k
{
! E4 [- ?# ^8 o) E5 o- p. W# E* b int ret;
$ L( v7 ]. ]# [- l+ f0 ~. k7 }#if 0+ F% h! M# A6 T) U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ q1 V, o$ ?/ `
if (ret)4 r r& @; ?! L4 _) D I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; L# K+ i9 o, ^0 j: G "%d\n", ret);" V% o2 M5 [% D: Q6 n
#endif7 t5 J% V# _! ^1 z3 J7 |
ret = platform_device_register(&da850_evm_tl_leds_device);
U8 w& u9 V# P" \ if (ret)
$ `$ Y, V1 E' H2 t% j3 d/ R pr_warning("Could not register som GPIO expander LEDS");; c2 ?1 T! u3 F& h) a l! Z* g9 Q
else
. x( {# z. e$ b& i, D6 @* O& I printk(KERN_INFO "LED register sucessful!\n");
. l' d4 ^3 u0 C0 u. N' k: E: N& V) T2 \/ T y
return ret;
9 ?! |; g1 D% J}2 c3 l! M7 P7 n- A
- k$ g6 P* H/ @( [
static void __exit led_platform_exit(void)
4 L p2 {+ [" A7 s5 I{
% ~) H. O* b, k# Z" y7 p/ _; h platform_device_unregister(&da850_evm_tl_leds_device);; z( l, t, n) B7 T
& F2 |; c% c* q+ F& ]! f% u printk(KERN_INFO "LED unregister!\n");" l' E5 T- E0 R/ Q6 R. t% I
}9 Z N0 h8 j3 K+ L2 S0 Y0 P: i% M
( h7 k3 j/ M# x2 @; v0 B7 y
module_init(led_platform_init);, l! e. D0 }) e2 b2 d) e0 x) R
module_exit(led_platform_exit);
; l. Z* ]7 S+ O1 K( o
$ G7 h6 B) O* Y% L4 i7 U. YMODULE_DESCRIPTION("Led platform driver");
' ~( b; @/ L: O! W3 gMODULE_AUTHOR("Tronlong");
, k) E; A( S+ L8 hMODULE_LICENSE("GPL");( ^6 | l3 S" o5 \" r- g
+ H( L6 }. C6 t
|
|