|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# P) r1 ]" V2 p#include <linux/init.h>
% K2 N- R6 ^* D5 u, x8 N3 k#include <linux/module.h>
7 a7 ^$ j, o0 l% M) W8 C#include <linux/kernel.h>1 e6 v/ Z+ i, a- _+ Y3 t
#include <linux/types.h>
9 H$ d7 _- |* i- F5 X8 x#include <linux/gpio.h>
/ |6 G* |. b9 H#include <linux/leds.h>
6 }, v2 h. S5 ?; o$ }#include <linux/platform_device.h>) _9 g9 r1 W; r' a3 w. D" f) c
) O2 b9 v/ H) i: H6 g#include <asm/mach-types.h>; J- n. X1 Y& b; y! k4 F1 m
#include <asm/mach/arch.h>
* z* `4 U' C' ~2 o" J. d#include <mach/da8xx.h>
: Z! a& |( G; {6 P: k7 {#include <mach/mux.h>
4 [0 ^5 ~. u- H, {3 a% N$ h' Z, S' d. ~
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- ]( o0 ^: B) i4 e7 S# C#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. G4 Z3 g W3 i. R' {3 ]6 |' S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) _$ ^+ D4 e0 w: t% e' P
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 D' N% T8 T! _6 O" p4 g9 d
) @# g6 Z0 ~. _. R0 {4 a* H/* assign the tl som board LED-GPIOs*/
! I) \/ p) {- C1 Y ]5 Gstatic const short da850_evm_tl_user_led_pins[] = {3 j, j4 E# g0 b0 X; O8 Y
/* These pins are definition at <mach/mux.h> file */, s. Y- @' y: W7 T7 `3 s# {; }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' {/ @# y5 h" L O0 h+ ~
-1
5 f4 y: h: X/ r: q};
! }& _: ^/ v' A+ e
# Q0 I$ E7 ?. V$ Lstatic struct gpio_led da850_evm_tl_leds[] = {
- G" K( V4 f7 r5 p& ]- k7 ] {& x: P/ G! V" U+ {
.active_low = 0,$ s; ~5 z" z+ c6 d0 m7 f( `1 R
.gpio = DA850_USER_LED0,
$ C3 x5 U7 L4 A) {0 v .name = "user_led0",
% i9 ]+ ?, o) A# m# Y" j3 Y* Q .default_trigger = "default-on",1 f- d: ^' |) _# R2 G
},! P" @2 g/ ?" ^7 T/ w3 a, {3 o; q
{
; g& B# a/ ~$ P .active_low = 0,- J; s3 C% F5 b4 ~- f: Z1 h: i N3 Z
.gpio = DA850_USER_LED1,
$ N0 Y& g3 v+ t3 W( L9 ], m5 `0 a .name = "user_led1",
* c* X2 M6 U: Q- A; r .default_trigger = "default-on",
" ?& I3 y; w; I$ ^- l* E },
: R; H$ h& q$ r# w- N5 U. Q, { {
# r" n u- h% ^3 Q, } .active_low = 0,- [4 l" q$ _* I |- H
.gpio = DA850_USER_LED2,
" Z" O0 Z+ Z4 W% ?7 S .name = "user_led2",
- Y r7 P, e% D! n$ Q4 Y% C& Q8 Z .default_trigger = "default-on",
8 y* |4 Z5 j; Z; M6 A7 T/ Z5 s },
" c `/ N' J2 Y/ }$ H8 {" o {* ]* r. o% J" J$ B- O$ s
.active_low = 0,/ T" P! ~( h c4 a! X4 H4 E. C0 Q
.gpio = DA850_USER_LED3,5 A0 k% C8 f" v9 |
.name = "user_led3",# N. K$ s7 h& ^" b5 ^
.default_trigger = "default-on",, j9 k. l# w4 w8 L/ _+ j
},- r% v7 f- s; o/ a/ o8 t
};# u4 t$ p1 W e& @8 X
) }" t x$ R; g. W' l2 z3 Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* n* A( w ~! d* F+ Y1 n$ i! F .leds = da850_evm_tl_leds,
( C3 N# s- o3 L* K, j1 A: r .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. i& X/ }+ P! j5 j
};
9 M: ]: |- o6 c6 n2 y/ s: v8 O4 @" w* f# M
static void led_dev_release(struct device *dev)7 g8 p- C: x+ O+ O( U' H
{7 d, p9 Q3 Y/ {9 L/ K" u/ S' k
};
# m# j$ p8 H" l u/ a( V# z4 P3 {2 x5 y7 Z" m$ Q
static struct platform_device da850_evm_tl_leds_device = {# A8 u7 i$ S Q }9 O5 x U
.name = "leds-gpio",
' \6 ]+ r, [6 U/ M .id = 1,
" K9 d7 W1 z" N ^ .dev = {
3 A) r: a# d2 m( W7 ~ .platform_data = &da850_evm_tl_leds_pdata,
% \" H$ x o- | .release = led_dev_release,
# \: M) M8 h0 ^3 X5 }, S! i" e# D }) V# P, p4 V2 L8 G/ m6 n
};
6 ^" Q& \7 _! m5 u& |$ M' M/ R+ k% u* v
static int __init led_platform_init(void)
( M; x7 O3 n2 J3 Q# `{
3 B" U4 N0 W3 x3 e$ \ int ret;
# w- V+ ?* [9 E+ D# Z R#if 0" n; ^7 S7 q( i* a7 z- w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 C- V, M6 M; i' N, |8 F! O X if (ret)
' F3 g& Z2 B8 Q# {9 S+ B W6 ~& ` pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- t% F0 ], d" U c% l) g
"%d\n", ret);9 s* u$ ]$ B0 x7 D1 v \- y# v
#endif O5 N( c b, W2 [( c9 v# J
ret = platform_device_register(&da850_evm_tl_leds_device);' w' G5 H! M2 ~' g- q
if (ret)
/ w6 X1 Q$ @# M' Z5 `+ S' ^' i4 B: e pr_warning("Could not register som GPIO expander LEDS");
3 O% A$ W7 h% y \* ^ y s& U else) |: }3 s7 I( o
printk(KERN_INFO "LED register sucessful!\n");
. T0 M3 Z! n# S8 l1 f
$ h8 s/ v5 ?3 k/ n2 n" i return ret;
% _" H: ?6 ]7 h q- A- K}2 \0 a" m# l9 P5 {# F5 {, D
, D. S7 w1 m4 g2 t" Y' v9 P5 @; b8 E
static void __exit led_platform_exit(void) j8 l. b6 ^/ y9 I G
{
1 l3 ~" s% G! H4 B/ t. _ platform_device_unregister(&da850_evm_tl_leds_device);
: F7 z$ [9 l+ g& ^6 o0 ~
6 X& T8 z- T) Q& D printk(KERN_INFO "LED unregister!\n");
4 G& Y+ _9 N$ L$ {( @ o' |. p}' B( Z$ c( A# K/ T
' G5 J7 J6 n5 J( Nmodule_init(led_platform_init);
0 }2 z7 b4 a4 V4 C2 y- j# Emodule_exit(led_platform_exit);2 o% B$ M1 `0 V( \+ e, W. {: _( z8 l6 r
1 Z: V( @2 c9 _3 l' A0 { xMODULE_DESCRIPTION("Led platform driver");
* J8 W& Y& j A* x/ [MODULE_AUTHOR("Tronlong");
9 G! g9 V" ~! X* dMODULE_LICENSE("GPL");
8 c' \5 O1 \/ v
2 U7 G! C. s9 @ |
|