|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; E% u3 B8 d: J$ S/ Y7 m' z
#include <linux/init.h>
4 g$ J2 T; G$ z. O$ N#include <linux/module.h>! p. b3 B, |8 ~* q$ h
#include <linux/kernel.h>
/ j9 c G/ J) d* l: c; W#include <linux/types.h>' V1 S1 r) ^7 x J* z5 R
#include <linux/gpio.h>) e# |8 o+ k& D
#include <linux/leds.h>5 _9 i7 f6 _$ ?( [
#include <linux/platform_device.h>
3 ]( A7 ]& S0 V4 u- u0 C. n% q! y
]% L: f( M7 g6 ^$ ~#include <asm/mach-types.h>
8 V' @( W2 E0 k( l4 a& O#include <asm/mach/arch.h>2 A- z' {" u! B
#include <mach/da8xx.h>: E. Z- _5 E& B" v7 w
#include <mach/mux.h>
! J$ l3 u' Q0 K! p$ M3 j# u K% @) j* y: T& L$ p$ Q* d. m9 P0 G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ |, B: R: r: \. U1 i+ J" p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; l2 }: {$ K5 D% G+ w) O#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). r9 d+ v: O6 H, V7 T% s% `
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 a3 d7 ^2 [/ w. R: ~, S" ?! Q' g9 Q3 | C) {5 e
/* assign the tl som board LED-GPIOs*/
- ^. [: L4 R( u. Ostatic const short da850_evm_tl_user_led_pins[] = {
/ G/ |9 g0 C, _3 i, J0 | /* These pins are definition at <mach/mux.h> file */
2 u: p) D- ~) t2 O+ \9 I DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- V8 @ e. B; ~2 T# c1 y -1
. ~! N, {3 F1 z6 E7 e% B};
& S7 R; ]# e) Y }
7 F5 [( w/ |/ s) [1 mstatic struct gpio_led da850_evm_tl_leds[] = {
: w( H" E- q: V J) i {9 ?, I4 I2 ~; D1 e# w# \6 s. Q
.active_low = 0,
/ P. b) G& J) ~5 h% ` .gpio = DA850_USER_LED0,7 a; B- L: E5 G7 r# r% N# R, @0 d
.name = "user_led0",
/ z1 N. @& J& b0 t3 L .default_trigger = "default-on",
( p! o2 t* f Q% r7 g },
3 a( Z( c/ [! B; R# P5 X {
% j& z% B4 _3 n- X" J( F9 ] .active_low = 0,
8 g; W& H; `$ F( Z1 e .gpio = DA850_USER_LED1,# o( y6 L4 i- [( a' T* O2 H, O5 ^
.name = "user_led1",9 N; N; V4 D* O
.default_trigger = "default-on",
# e$ B: c( F2 s2 s },) I+ S$ {3 W: f
{+ s7 K. i3 K( u2 K% Q* b6 D. r
.active_low = 0,
* F* _# C& h5 @' A# y .gpio = DA850_USER_LED2,+ d5 Y' m# H8 e4 P- X
.name = "user_led2",; H$ n' d& U# h" R; }. l
.default_trigger = "default-on",, }8 G. ^8 Z5 L0 ^
},% n+ R% s4 N% X1 d, ^
{4 G( U5 `6 m* ]! J: `3 ~
.active_low = 0,8 Q/ @0 Z! m$ J2 z& l7 W3 `% l
.gpio = DA850_USER_LED3,
' n9 M- S3 C: X# q' j% m .name = "user_led3",
4 G% R. ?! r2 K1 o .default_trigger = "default-on",
, `1 w5 K6 d0 q& Z m* N0 M },; X7 d2 P/ N8 _$ d- ~, \* {$ J
};) ]/ N9 S7 F, _' G4 h
: }% n; K# u G# K0 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 o( f' L! `3 R7 W
.leds = da850_evm_tl_leds,
; k5 u& o2 }$ L- o; g# L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 |5 s5 ^9 f0 O4 D$ V};6 z- x; M/ o$ J( R
' k N6 y w+ c X8 x
static void led_dev_release(struct device *dev)* Y# E2 w0 m- f5 e
{$ m( d, f( R# N' v. }; ~0 h
};
X5 }3 x B& j H
& Q: i# \4 c/ p. c6 vstatic struct platform_device da850_evm_tl_leds_device = {
" W0 J# J- U: s$ _# x/ h) v .name = "leds-gpio",
7 L$ l' F( e! X7 k. N .id = 1,
3 y- r7 [6 F. E. } .dev = {1 B2 j% T# d9 V' S
.platform_data = &da850_evm_tl_leds_pdata,
5 @( v4 ]; z1 [8 O# ] .release = led_dev_release,/ N; `/ D; Z: j+ m5 Z
}
0 ?5 T- s' Z9 A. L. B};
/ f- F2 f' G) y- m; o6 W6 w3 O, m' O
' v ~6 G+ p2 E3 `' f0 W! J+ tstatic int __init led_platform_init(void)' a! _* m/ O$ c
{9 B$ @( n5 V4 ~9 G+ g- Z* J
int ret;" y6 @/ [! |; p7 c ?( W
#if 0! {1 i c# I8 J1 }/ ?, G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* b% K2 ~. W1 ^6 n9 F
if (ret). p0 _# V: `* Z. b
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! i9 x9 b: Q8 x5 X8 C "%d\n", ret);4 f- ?' s" ^0 H7 P: B9 o5 F+ H
#endif
3 V5 n9 g `6 ]- \( v& s, l ret = platform_device_register(&da850_evm_tl_leds_device);
: H0 s3 R8 Y6 }0 m$ w7 K @! ^ if (ret)! A H4 w8 F& L
pr_warning("Could not register som GPIO expander LEDS");3 t) z% V# ~0 F. P
else, M+ N; T7 ~# s/ P
printk(KERN_INFO "LED register sucessful!\n");
* l0 N9 n0 J" |$ c4 J( O5 N
' @( b( M& ~7 t return ret;
8 u# b! |% ?3 c6 W: C% t: m}5 y& a7 b$ \$ }" [- q9 W
: f* E, h# q' R6 m( z- B5 u1 ?static void __exit led_platform_exit(void)
- Z/ N+ W; f% i$ k{) t" ^4 \ k0 y
platform_device_unregister(&da850_evm_tl_leds_device);# s' q2 S' D6 b4 D3 D1 @
) ~) L/ g3 C3 j/ X
printk(KERN_INFO "LED unregister!\n");6 w4 R+ h8 u( q! s+ R8 J3 J
}3 ]$ X: ^5 K* J" s
U+ O' `6 \! C. Bmodule_init(led_platform_init);
+ D$ ~4 Z. y& S! \0 A/ z5 Zmodule_exit(led_platform_exit);
8 |0 n. n* B, F: e$ A
R/ ]" r* f" @" `MODULE_DESCRIPTION("Led platform driver");. {* f2 K$ V# _" I: V& [# ~: S# K
MODULE_AUTHOR("Tronlong");; L: ?( l; M- D4 I
MODULE_LICENSE("GPL");
8 g: Y2 z3 @6 `" X$ F5 b# ]
" g5 @) ]! Z; ]. j+ g( p! a- Y1 a |
|