|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) C# F8 r) W+ ]#include <linux/init.h>( m: a. d& s$ C: S
#include <linux/module.h>( l9 P R+ X! U+ S0 y
#include <linux/kernel.h>2 u, s! E0 N" s" n" x/ h+ n% j
#include <linux/types.h>( G3 ]# z& ~8 C; G8 S3 x
#include <linux/gpio.h>- S7 X1 m1 m7 G5 j
#include <linux/leds.h>+ A: y: Q; ^" z0 k. h: _0 m
#include <linux/platform_device.h>
: n/ A; b( b9 q; D! b: w- Q
! `. ~& }, N! O) s0 a#include <asm/mach-types.h>( e: s, q. F1 Q+ N4 w
#include <asm/mach/arch.h>
; Q0 c; L0 n% A# z% f- f#include <mach/da8xx.h>+ X# d' {' w* s) z3 \
#include <mach/mux.h>* L* g$ \' p' _9 I6 z; k3 O
6 y5 k5 D; A7 w! f' T" }- h$ B
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ I" @) a# ^2 k7 e$ u8 }3 a5 q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" }/ ?& V: \8 |6 n
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' U* e) e" m, n+ h3 L
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% ^ m% S2 v6 ^4 ^. k6 Z8 u( N# {' O1 j' |. ?7 Z' R
/* assign the tl som board LED-GPIOs*/3 N1 c7 Y1 C P: s
static const short da850_evm_tl_user_led_pins[] = {- b8 {' `0 l& N; I; o2 ~$ c/ P
/* These pins are definition at <mach/mux.h> file */
' e u7 c7 F" z: O DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" L* E5 F5 [& w- ~* P -1
5 W9 n; E- \7 L3 e4 p; w2 K, N};2 s% s% B! e& \, @7 z% s
2 i, F K3 U( V6 j: Mstatic struct gpio_led da850_evm_tl_leds[] = {4 I( \$ u# D; e* I
{
. [' T8 W: t$ ^$ @2 t; s .active_low = 0,
9 k" k) {. F1 z- j: ` .gpio = DA850_USER_LED0,! J, ~" R4 p9 }( [
.name = "user_led0",5 ]4 M% ^# Y3 {, }$ J/ l- L
.default_trigger = "default-on",
) n! w) C1 N. A! Q },
9 v3 s! Y; X: U {2 ^0 i5 E6 u; Y( }9 M8 a
.active_low = 0,4 F/ n* q% N& F4 p3 Z, [
.gpio = DA850_USER_LED1,
! g& E% m2 {$ p5 ^ .name = "user_led1",! Y4 n2 U9 ]; j8 A5 e' G
.default_trigger = "default-on",
6 f# Y" ]7 ]: C: q },# @7 U( T' y9 c% N4 o" _3 e5 r+ k7 h
{1 _$ |3 c- F0 _+ V) p4 _/ K
.active_low = 0,
8 Z3 }: F' \/ ~+ d) ~6 _ G) k .gpio = DA850_USER_LED2,
/ X/ \$ f( _1 U3 E) H .name = "user_led2",
# ?( _% _( X) j; k, b .default_trigger = "default-on",
1 F# n5 E8 \9 {( g },0 i c, m- a% c. _' E
{- g" y' U# n4 J1 p, o7 J: h
.active_low = 0,0 ]6 W. {4 H7 r4 p' `& z! U q
.gpio = DA850_USER_LED3,
" P; V( E' j8 H+ Z5 T1 Q& u .name = "user_led3",
( {, v9 j! l. d: ^/ f2 b .default_trigger = "default-on",+ K- b% [( [2 ^$ r& Y
},
0 k' {9 c( A+ f};
" `2 g" u9 |7 U* o5 E' r6 d/ H9 Y# e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 D2 y4 W, r; P7 s
.leds = da850_evm_tl_leds,
7 ?: n2 ]; A9 S4 A- f6 J/ H0 Y4 t5 K9 y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! y' k. U; D1 }7 Y+ a};
) ~( Q2 Q+ \: g) D$ W/ T/ ]8 b2 x2 }$ H) j$ d* R+ p2 S
static void led_dev_release(struct device *dev)
g! d4 V" R% `8 n5 |{
' k9 y0 g# c2 Y1 b, O0 o};/ P$ ]: r9 y" B- I# ^
/ T$ A0 H* ]; Z6 `5 j: V* B2 c/ F! Rstatic struct platform_device da850_evm_tl_leds_device = {+ @; ]6 f, V) u8 b4 ?9 X
.name = "leds-gpio",6 v5 {; I7 J, q( C) C/ w2 `6 v
.id = 1,
6 J9 O4 `0 t e .dev = {7 y: @# d. }: d" B. E
.platform_data = &da850_evm_tl_leds_pdata,% N$ t9 K6 {2 i: Q* E$ U
.release = led_dev_release,
3 D( S7 h3 D0 _2 D: P6 o }
4 h3 \: g$ W1 m: _4 S5 c# D; A};
2 P6 R" i. R! l3 U, ^3 T$ E8 _, }( I9 Y. G$ p; V* _ i' z$ g; }
static int __init led_platform_init(void)+ V6 x5 E! s4 c1 {: u6 f& v
{
7 b8 S( H* j0 ?+ d1 v int ret;
6 o! V6 I9 G4 p# o#if 0
- c2 O9 S8 L6 {2 o" l! S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# H' w" ]# o1 y* J if (ret)
! w& L/ A x# o2 {5 B+ n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ n8 ?. w" d. a* ]+ @
"%d\n", ret);, ?: [1 i6 m! x2 Q
#endif7 g5 i' x e) ^) q8 W# a5 U
ret = platform_device_register(&da850_evm_tl_leds_device);4 E5 J! i1 c3 G, \9 u6 T/ J
if (ret)- Z7 S2 z2 \; Y+ c7 K
pr_warning("Could not register som GPIO expander LEDS"); i0 n' i, z7 U" \9 _
else% A g# l( C. q6 P
printk(KERN_INFO "LED register sucessful!\n");+ D) O* C2 M, U/ B2 F6 F- J
+ l: \4 w& S8 f; P& v2 D return ret;
- h% y7 Y8 u5 @}
- w$ v- m& z1 i' Y& e3 F* F5 A+ P9 S0 I7 c( z
static void __exit led_platform_exit(void)
R" U% q5 M) J0 L{
9 d# ]3 ?. p1 }" p; v! _( f$ Q platform_device_unregister(&da850_evm_tl_leds_device);0 f; a; t& A3 _
5 G2 y' ?& x4 X; \7 X5 |, D- A printk(KERN_INFO "LED unregister!\n");4 N/ n* e) O* Z7 {% D7 ? V. E. u- d
}
6 ?+ I) |, E8 ~
2 W9 Q- n5 r! I/ t* Y$ ^; f% amodule_init(led_platform_init);
0 _0 t4 s$ ^# V/ K4 x7 H0 W' Rmodule_exit(led_platform_exit);
! H0 e+ j% b' I+ z& }
/ a4 S( E- F/ r3 b! A0 _% M( ]MODULE_DESCRIPTION("Led platform driver");
) { c g) W2 e% f$ PMODULE_AUTHOR("Tronlong");
( t, N: h7 R& B8 f% y+ h3 `0 EMODULE_LICENSE("GPL");
& G# C' I5 G. t
0 l. S! {4 C. T, a% D |
|