|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ _% Z1 Z, U% Q5 D5 Y, ?#include <linux/init.h>' }" b5 o6 ?8 I
#include <linux/module.h>( B, k; } b! @7 _ O
#include <linux/kernel.h>9 [' e7 } ^6 Q( b; ?; j
#include <linux/types.h>4 p$ {+ u, O$ d! N
#include <linux/gpio.h>' X I Z, b8 t, G( V) ?
#include <linux/leds.h>$ r4 \: c4 ~5 _7 o# r9 S3 p
#include <linux/platform_device.h>8 b( y4 v2 L& d. I7 H$ w) S# w0 ?
+ i$ m; j) \- e% c
#include <asm/mach-types.h>
* ?3 w% ^+ `4 N#include <asm/mach/arch.h>
8 ]+ G0 U8 J! H6 }: N#include <mach/da8xx.h>
' C9 ]: n/ P: ~! P, r# K#include <mach/mux.h>
+ l. X2 r9 D- J8 b# H: S/ A+ r8 ^+ \1 H b4 j
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* V" n# ]" r( s" t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! a. i; U# ]) H0 y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: H) y2 b' ^: u4 m7 d5 @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" t; t1 v# Y/ M' R! W4 Y
3 \3 U) K( g& I/* assign the tl som board LED-GPIOs*/
3 d# r7 |& @$ J r; p. t4 ^- {& {) B4 sstatic const short da850_evm_tl_user_led_pins[] = {
$ c/ G3 N/ Z( p /* These pins are definition at <mach/mux.h> file */
; R( @/ ^ Q8 ]2 [4 v- @ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 j8 u) V% l/ V C -1
( o9 A" ] X1 f- l, j5 W};& E" e$ m0 H" n( o+ U& r. E8 a! f
; G+ a8 \0 o, p8 }4 B$ N6 Qstatic struct gpio_led da850_evm_tl_leds[] = {
/ t7 b7 ?7 v# a/ o: {, | {# X" ]: b+ w7 t4 d
.active_low = 0,8 {/ f- E/ l" E) e( i& K
.gpio = DA850_USER_LED0,
% I& u7 K- G3 E# _ .name = "user_led0",
9 D; w: K8 t8 U( s j .default_trigger = "default-on",
# K" z+ k! S0 Y: K* A& N5 C6 k" ^ },
/ K5 G* o7 W6 A f0 {4 h {! X( ^: j2 P9 ^! o y
.active_low = 0,
' }: X' t7 ^# g2 @9 d .gpio = DA850_USER_LED1,/ N+ {! t' H/ j& G) q# j- I
.name = "user_led1",
) C; x0 w# R0 B% `& ~ .default_trigger = "default-on",
$ o$ O0 h9 q6 d, Z; F2 w },
! Z2 S- O' q C2 q {
' }- o- L8 n: J& g) I& N .active_low = 0,
! I) L2 X/ M" q+ R .gpio = DA850_USER_LED2,
; X4 ?, m8 O6 w .name = "user_led2",
9 z$ ~. F+ z. C- N4 H( A; ] .default_trigger = "default-on",, p5 {' G9 |1 v1 o
},
4 F. D7 {, _$ n3 z( v {7 I: h! {: d! t
.active_low = 0,+ n0 l$ j" N# P7 w; {
.gpio = DA850_USER_LED3,. g3 V5 h' b! k7 z
.name = "user_led3",
' I' |. E4 r1 w/ [% U .default_trigger = "default-on",; M7 }7 B" u/ {: y
},9 ]+ }+ P7 U. o+ D3 h
};: B! o& f8 a. ]3 O. \
& R& f! N B \4 {$ y0 N7 pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
J t1 C8 `. i& M G/ w# A- c6 w' U .leds = da850_evm_tl_leds,
8 t* e: k. K7 x9 e( o" A7 N, s .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: ?, c8 J9 E) _
};- r; d& j2 Z1 \+ C* I7 h
2 h, v9 z; S% f+ {* e% z6 ?static void led_dev_release(struct device *dev)6 u9 `6 _: r1 ^. M4 |' G/ D
{: j+ F7 N! h' g- s9 I1 c: A
}; n h* @0 T4 t5 W
3 _8 v# r" Y3 b9 ^' Hstatic struct platform_device da850_evm_tl_leds_device = {( M3 @6 l, x6 n: i0 ]9 \
.name = "leds-gpio",( G6 e! y' t, W: X: r7 t7 Y( |, `
.id = 1,
' v5 e- x( D3 f5 ] .dev = {1 ^3 D& S% o4 ^1 e
.platform_data = &da850_evm_tl_leds_pdata,& d$ R: E3 T+ f+ A" p- O, \
.release = led_dev_release,
3 {' m; S8 t* u' ^ }
/ W5 k9 x) s I D};
& v- b/ L( l. h. ]1 L9 G6 J6 P% E5 C# ~
/ J, Y; e& Y: o$ E( ~+ q# Dstatic int __init led_platform_init(void)! t( L$ y; J8 h; n# Y! _9 S
{
5 s. z5 l+ m W; c# O int ret;
" z! x4 c$ x+ E2 X2 [2 z#if 0' B) d3 A! S3 r; @+ e/ L; g W+ ?! r$ d
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 c7 U* g2 W$ ~2 N* J if (ret)! e4 z/ t/ _2 J$ v
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 u' V& n, f9 Z! ^; a' i "%d\n", ret);
( K# [6 R, W* W2 Y1 I#endif
. `0 l& j2 c2 w: O5 J ret = platform_device_register(&da850_evm_tl_leds_device);
, s9 T- d/ P* w o if (ret)
$ v( {" V3 ]+ V( o pr_warning("Could not register som GPIO expander LEDS");' U, `' p# K* l; t: Y
else
" M: T3 Z/ @9 R7 ^ printk(KERN_INFO "LED register sucessful!\n");' I7 \/ G) T; J0 d# k; M& I1 O, k
+ c+ `" k4 j _# k! ?+ i return ret;( D, L( {4 X- z
}
! {5 S1 J. |. O) f P' ~3 s2 b4 M0 y* W" ]
static void __exit led_platform_exit(void)& i0 k0 J5 B( _' o( T, d
{
" A. h* Y& t$ |( c/ b0 t) C platform_device_unregister(&da850_evm_tl_leds_device);# V4 l. @1 `7 Y* ^
) \" E5 R/ O$ K printk(KERN_INFO "LED unregister!\n");
& |0 ~, g8 C) a7 t9 y) j}
4 ?- T C1 U% q$ f/ B
$ Q/ Q5 [0 K* @: B l; m. C- ymodule_init(led_platform_init);
" l0 w; m# Z: s# i) y6 b) Lmodule_exit(led_platform_exit);
6 r, V6 h6 u, u
! t( L* V! @$ D5 b4 z. Y' u5 rMODULE_DESCRIPTION("Led platform driver");
! \5 v4 u U2 N; h2 n) WMODULE_AUTHOR("Tronlong");
# B0 h; J! e& v( JMODULE_LICENSE("GPL");4 L5 G- A, a) [5 q; w, K5 W
; K; Q- [" D$ |
|
|