|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 P7 E- ?, \, n2 ~
#include <linux/init.h>
; _2 _5 Q0 I- r, X8 J#include <linux/module.h>
5 y' m/ f! \8 O4 Q, A3 S#include <linux/kernel.h>$ @7 }3 D, a9 Q( D
#include <linux/types.h>9 o& \2 M6 s5 b$ U4 R) n/ T
#include <linux/gpio.h>
0 Z) A B! x: [2 q- `! _#include <linux/leds.h>
; b) z: ?) `! h! z$ L3 C#include <linux/platform_device.h>
6 x6 Q8 ~7 F! q7 h; `5 j1 C
7 {- j8 I0 D7 M5 A2 I#include <asm/mach-types.h>
- K( D* o/ Q5 @( g: O/ s#include <asm/mach/arch.h>
: e. y0 Z2 D8 T4 x#include <mach/da8xx.h>
0 l0 k( j/ }- Z8 Q* H- d7 N2 L& z#include <mach/mux.h>! {0 [( f8 u u' ~
- [( Y. p- R6 f$ n. b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 v4 _. v( B1 \" w, _# ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% }9 M6 k0 u- G% H' j#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& V ?6 F* |( q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
B, ~6 `* ~6 H$ t9 k
Y0 u0 Y# v' }. ~ |* \0 v: q1 x! u2 g/* assign the tl som board LED-GPIOs*/7 {3 Q" g0 w& N7 m
static const short da850_evm_tl_user_led_pins[] = {, Q x$ K. F7 r
/* These pins are definition at <mach/mux.h> file */
: w* o- N; h8 _) S" y4 Z9 ~0 | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ Q8 G" a$ A* w# \2 v -1
+ t8 l, K" L, x0 Y};, ?! {- d2 `* R$ V2 z+ c
$ K# q P: b8 rstatic struct gpio_led da850_evm_tl_leds[] = {
& X8 Q9 F6 s7 [; V5 M {2 v5 |6 f2 h+ h6 M" s
.active_low = 0,
) ^+ j# _5 b8 v5 l .gpio = DA850_USER_LED0,. B! \. F1 H, R/ e6 w
.name = "user_led0",
" B) Q' {+ g( X0 I .default_trigger = "default-on",
( F2 x2 A a# e( S },- \5 ~# [- Z& Z: o6 F l
{/ w" O. N6 B2 J! y$ C4 u' C9 F
.active_low = 0,
% Z9 C1 R+ {9 \9 d .gpio = DA850_USER_LED1,
4 o: Q" F( d0 I, V4 z+ V% P2 U9 y .name = "user_led1",9 H2 E r: k( B# v J
.default_trigger = "default-on",
0 K- A; j1 w+ V8 g" C },
9 x2 G3 p) w; f, |. i {0 t% w6 v4 y/ ~
.active_low = 0,
& O( f( e' ^/ [$ }# D .gpio = DA850_USER_LED2,
l4 J% o& K8 P: \% J8 p+ x! B .name = "user_led2",% G0 z- p, f, a" \! R
.default_trigger = "default-on",
3 H5 x' B- y8 U/ P' w, ?5 |. w5 m1 E' q },. m% D+ U1 H" P0 |: j2 ?
{4 B4 Y0 F: {9 {' ~- D% N+ @
.active_low = 0,
# O* D: V! ~/ w8 `! W# b .gpio = DA850_USER_LED3,
# e& ?% B6 _. q0 U& m .name = "user_led3",% C- D/ ?$ h- r* T' q; P
.default_trigger = "default-on",
, o. V \" S% v4 S },
' ~3 h4 ^. ?- Y. f$ Q) a/ C3 [};
. Z, [; s) J+ r! ~+ ]% ^! d. F v
" x4 q- ?0 n) T5 x$ c2 K+ Zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 n: {" z. I( w# i# \
.leds = da850_evm_tl_leds,
# m7 f8 ~/ F. X) h .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; ~( {( s" P/ J" D7 a};2 O! a4 b6 N x( @' `) \
% X& d8 z, ~# u1 q3 V! p1 A. hstatic void led_dev_release(struct device *dev)9 L' h/ u% V. `" ]0 V
{9 R& a( j; d. u+ H$ n
};
1 e# c8 A- d$ I. \4 e
4 U* a0 Z+ r. O( g5 ^# Estatic struct platform_device da850_evm_tl_leds_device = {
, r+ } v# D' q7 i- W .name = "leds-gpio",) Q; ?9 F: V6 Z* q3 J% @
.id = 1,
" x0 Z/ [. l& f; ]+ j9 p' e .dev = {
+ Z. i* j% J( q' U: D' K .platform_data = &da850_evm_tl_leds_pdata,% A& l7 n6 E* c' Y. J1 \9 y
.release = led_dev_release,* i3 u3 X5 Y( q4 s# Q
}
6 L& v2 W+ v& Z$ Z9 @7 ?+ o4 ?};
- o: V+ ^' K. `
& N* E+ C/ W6 j& z& q( Bstatic int __init led_platform_init(void)" W3 j% g+ `! r- k7 v( g
{
0 L8 X, d! _2 K, ? int ret;
8 [/ q8 }5 U5 D, a5 }, x8 w#if 0
2 S3 Q4 [4 p5 y# ]% j% [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: Z' y; N- ^$ D8 R if (ret)3 W& L: @# i. Z. B- ]4 z* [. n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; G& N" ]4 f# ^. Q
"%d\n", ret);
/ l" q2 z- o3 N" ~9 Q5 q7 n% Z#endif
1 W+ |4 A) B' M P ret = platform_device_register(&da850_evm_tl_leds_device);
2 d' c! ~8 G; |* Q1 A7 O% I if (ret)- J- L# k b0 ?* \ L% E' p! E5 e2 |
pr_warning("Could not register som GPIO expander LEDS");0 U# b3 ]$ ~) n
else, F0 @' F3 n8 o/ j9 C
printk(KERN_INFO "LED register sucessful!\n");" X% E* l; L! U% V
. D1 J0 d6 ? c
return ret;5 p o" |) y3 {0 X
}
% g# ~7 i3 u2 k2 @$ m. ?* Y) w X3 b' `% z' [8 q
static void __exit led_platform_exit(void)1 k" G5 i/ P0 P4 c: X
{7 O# d( X1 A: E
platform_device_unregister(&da850_evm_tl_leds_device);
0 f2 u/ N- }( i1 Q9 j
) \& X a/ w& g2 h printk(KERN_INFO "LED unregister!\n");' `& h4 P( U$ o/ N: L- [6 f
}
2 J# P4 [, s* r: g! D( i
$ z3 m4 F0 U, e* B( f2 w, Gmodule_init(led_platform_init);
0 q2 j. E( S L N5 n% G* _module_exit(led_platform_exit);/ w( T' z/ @( d" J
( s7 R# Y3 q) C, }
MODULE_DESCRIPTION("Led platform driver");
2 w; {: `* Z% f9 k" T3 T5 g& FMODULE_AUTHOR("Tronlong");
, O3 I% \+ `, v' M9 _MODULE_LICENSE("GPL");6 b& ^* a& ~4 v
9 w# k- [! d- B f1 g! y3 c
|
|