|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- `; X3 a6 D% {) D) Y* r5 f1 i#include <linux/init.h>- q: h% h" A2 ~1 i
#include <linux/module.h>
$ E7 B" m5 x/ e* W& p# w#include <linux/kernel.h>
1 \' B3 c/ w/ L$ U#include <linux/types.h>( s4 O8 [& P( K: T1 ?. Z
#include <linux/gpio.h>
' g+ s; D8 B2 r3 t#include <linux/leds.h>
5 A* ]: ~ S; P' j" y#include <linux/platform_device.h>* G% S; r" l6 D0 c" p" B
: w- T' G4 K4 T#include <asm/mach-types.h>
5 v8 j1 S3 D1 O#include <asm/mach/arch.h>
# y. {9 P1 d5 ^" Z& b0 ]8 m$ a#include <mach/da8xx.h>
7 _0 L, ~& D2 O3 q#include <mach/mux.h>
8 F# y/ I6 p9 F2 B+ d6 C5 z1 n3 d2 Q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 J5 \, s$ F d( c9 Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! ^8 r, K/ d( f* G. @#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 B! H8 j( I: E' e) M* r' R#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" X. f2 T3 T1 O- ^7 S
1 c- b/ a/ F3 z+ A- [$ t
/* assign the tl som board LED-GPIOs*/
4 R$ }0 n- X3 D, tstatic const short da850_evm_tl_user_led_pins[] = {
- L1 U4 ^4 f1 D( r" q /* These pins are definition at <mach/mux.h> file */
! F& M: L6 i. `3 _ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 K, u/ W& f, n8 t
-1
: v2 o& k. D2 o8 s, C$ _};( g, t1 @, I1 f5 r* H L
" g' z8 f3 S( H5 g( U) x
static struct gpio_led da850_evm_tl_leds[] = {
1 ~' Z( R# O% I+ W {; j; P% C( `! ~6 d- K
.active_low = 0,
6 [3 ^. X2 O; p+ C9 h9 x .gpio = DA850_USER_LED0,
0 a$ ?9 j9 }; |% D' v .name = "user_led0",
. o1 c+ ^5 i7 @( E+ z- o .default_trigger = "default-on",: v& N1 G" C% k) @, R. c8 Q
},! h, U1 f( I V: g' }2 \; O
{
; ^* i% s, @8 @ .active_low = 0,$ c& u8 H2 R& M, F5 `. N/ [
.gpio = DA850_USER_LED1,; ]% n: n% U; \$ E
.name = "user_led1",$ _3 [4 n$ e3 K9 s& v* k
.default_trigger = "default-on",
6 C: g# `; j& g: ^ },: N: ^: P9 ~; _9 O- W K; x! p
{( V6 p2 j+ t- }
.active_low = 0,3 B6 n: m8 }& N1 M9 ?: M5 r) k
.gpio = DA850_USER_LED2,
/ y8 p) H. D: [/ H8 ^ F2 I% d .name = "user_led2",# R# J7 @# i2 X$ j8 {7 I' H+ r$ Z
.default_trigger = "default-on",
- N# K* y) i* S. m/ I4 d/ V, B4 @ },
% Y( _+ L- y/ W; k- { {% f) y3 ?) ]) c; X4 M. Y2 \
.active_low = 0,& u* |3 o( }6 l; |6 O; |
.gpio = DA850_USER_LED3,
& `1 U0 U, K' A' Z' D; m9 m' I( _$ | .name = "user_led3",; x4 p5 \6 U: ]( v0 w1 Y. I
.default_trigger = "default-on",
9 q* O0 C6 m! V" x6 z) k' t },1 \/ y: M7 }" m8 ~, L, i( P
};: l# y3 U, P- `, Q
2 \- `5 \: ~/ \/ B, |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 Q! c Z; b1 j2 y% ]; F
.leds = da850_evm_tl_leds,
; }) h: e, c. a: v: l% ` P .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% e3 R0 b1 F; M+ V0 ~# E& c" Y( W};% m; X! ?8 o9 j2 P! O
- b- o% ]( U* v* x( jstatic void led_dev_release(struct device *dev), Y2 a8 d, u1 Y: }; I% L' r
{- T0 | }- Q3 L F7 U4 @( b! f. O1 X
};' Y2 a% J5 Z/ J( D& y8 d8 J4 ~1 r3 }3 w
! v& O2 \" O7 w+ ?static struct platform_device da850_evm_tl_leds_device = {0 R7 K$ ~% H2 W* Z/ u+ R4 P& s
.name = "leds-gpio",
, E! |# q5 Q& D) X$ o .id = 1,
b" x* J6 s( H! c .dev = {
; P/ M! x( E5 I C; E3 f, D .platform_data = &da850_evm_tl_leds_pdata,8 |5 F6 t5 F* m7 e0 o9 {
.release = led_dev_release,0 C! B, C2 o! ~8 U8 D
}, u! Y1 _3 i+ ~, O( s3 p+ h
};2 q( A. J% c' x: X& r; Q, c
& V7 k) ]9 i% h# }
static int __init led_platform_init(void)& p. {$ L' J3 X/ `/ \7 L2 {
{
) e$ E: G# g1 x/ J int ret;/ @/ c. `% n/ O
#if 04 {, j# x3 |1 ]) a3 W( {
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 A8 i( d3 P+ M8 {4 r
if (ret)
5 R0 v& L6 y7 X0 k3 d pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 S) N9 g y! }. E8 f+ @% }
"%d\n", ret);: a a* _) c- F/ N( U' D
#endif
8 y1 a; ]* M5 [+ u6 N ? ret = platform_device_register(&da850_evm_tl_leds_device);; ^0 M2 M4 p7 C1 S% Z7 W' d w
if (ret)
3 X, Q" \4 t7 ~9 l; y( [ ?8 M1 z' w pr_warning("Could not register som GPIO expander LEDS");) P3 y6 J" n! {( H. K
else5 _9 m' }& U, u2 }6 K$ L
printk(KERN_INFO "LED register sucessful!\n");
9 Y7 {2 K- W3 U5 v2 {$ Y0 u
' q- [- z% P, x6 e' r& ^0 C return ret;
) W6 [% J' H( |" h2 h}
. H& b7 i( L: a7 W" A; G+ t6 M$ J9 _
static void __exit led_platform_exit(void)
" I G! K, X$ X( _6 |) A! T9 _2 L{
% D# c# M: F5 T# Z2 s) b platform_device_unregister(&da850_evm_tl_leds_device);: l- e) C1 R/ j+ t1 v
1 y* G O3 i1 v! ~0 ]( x! S
printk(KERN_INFO "LED unregister!\n");5 ~: ^3 W# S: y; e% z" U0 g' G
}
1 X8 C+ L5 Q1 X3 l% @* I: [
5 w5 O% s' ~' J+ R2 Xmodule_init(led_platform_init);
! ~+ I. p6 c- g& ]$ C. kmodule_exit(led_platform_exit);+ i. V" P1 e' J0 F
' x: @8 a# p$ z$ D9 \3 |
MODULE_DESCRIPTION("Led platform driver");
$ I5 v6 M7 ^2 u2 F! ?, rMODULE_AUTHOR("Tronlong");! i, y2 D0 n% K1 D' E+ \
MODULE_LICENSE("GPL");' @, M4 R9 }- B7 s, m# [
! q7 Q& Y; I/ ]. D) ~% I4 @ |
|