|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 Y* P. G3 Z! ]" V# ^
#include <linux/init.h>. _1 H, j7 z6 z$ `- U
#include <linux/module.h>8 W9 C% \" c6 t: S0 ~5 B
#include <linux/kernel.h>
# Y) X# H8 P; X, f) n#include <linux/types.h>9 U2 }& q2 {8 G: b
#include <linux/gpio.h>
6 h% L4 w. k) r1 P# M o& v#include <linux/leds.h>$ \" k2 y, A o9 h+ u7 t
#include <linux/platform_device.h>
6 C4 S6 U+ I6 r$ E1 D
0 s4 ^4 ~# K! A) w#include <asm/mach-types.h>1 [! D) y( z: ]/ O7 ]
#include <asm/mach/arch.h>
. T1 z J# \) A" b- o: r! Y7 i+ ^#include <mach/da8xx.h># W/ r" c* w# X- K( u, |4 J: p
#include <mach/mux.h>
, N$ f$ R' [' A( T6 `" Z; D
% Y, K I/ c2 q$ j; {' K O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 O* i: N$ u) e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* x, s# B/ A. w5 }' n
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ I5 N" r# g. [4 V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 s# Q4 m3 ]' z) X. Y# V* A7 ]+ Q Q1 i1 C
/* assign the tl som board LED-GPIOs*/
# v" j5 L' ]: R, @5 x( p& ~- O" pstatic const short da850_evm_tl_user_led_pins[] = {' n# N! i$ Z1 i z# I9 ?
/* These pins are definition at <mach/mux.h> file */
2 R/ V8 k. N! T6 _ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: v0 ?! h: }) O7 q ^
-1
4 T ?* }0 [2 W4 K( {" J};
& L' Q) L% l) r! N; A
2 Y) h" F/ ~2 {* Sstatic struct gpio_led da850_evm_tl_leds[] = {
6 k& ]6 j0 d- b5 ]8 b7 y {. l9 e5 n6 R: Y3 ]$ U* s4 P" O
.active_low = 0,% m4 }1 }3 \8 {
.gpio = DA850_USER_LED0,+ A7 p7 }( g* k& Y( M2 l. `
.name = "user_led0",
/ l" J1 w6 E+ Z/ G( t) A .default_trigger = "default-on",8 p6 J# q# Y0 D) N
},* o7 |: i* P; o
{
7 I" i# @- k( o {1 j5 s .active_low = 0,9 R4 X3 m; i& H0 q; J7 i
.gpio = DA850_USER_LED1,$ P. [ J$ _* I3 W
.name = "user_led1",
2 G! W" H5 H+ e* O) A0 O7 F .default_trigger = "default-on",/ A y8 ?# N8 S
},
( }4 p& Q: B X, z {( _. x, s8 B- ]
.active_low = 0,
# \/ U0 h2 s9 A .gpio = DA850_USER_LED2,; G2 S1 ~* a. @1 t6 I7 [8 i; f
.name = "user_led2",
/ \5 ~% P* I5 z .default_trigger = "default-on",
. D) E/ o& O4 y6 l. U4 q3 t },
5 y; j0 M& S" C M. t0 l, r {
3 G3 c5 g% v( R3 o) q5 D .active_low = 0,- V& ?, h$ {8 R& g' h% v! ?1 K
.gpio = DA850_USER_LED3,' ~1 y9 y% S' g2 C5 W( C
.name = "user_led3",2 N* ?3 X" b6 x* ?: {
.default_trigger = "default-on",+ s. A8 N c. Q2 I! M
},2 w( c2 `1 y- M7 Q
};
1 M+ I" P' B& `. M6 d {
5 x9 x" w5 S3 p% `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( f" [ N4 V; ]: F% {5 V5 k9 \- ? .leds = da850_evm_tl_leds,. N1 C& {3 R6 j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 I! i1 {7 w0 c5 {
};
& q" F1 p$ B+ n5 d" O1 U" z0 J& u3 a9 Q4 A1 d! y
static void led_dev_release(struct device *dev): h3 V9 |" G! V* v* v+ @
{
2 X* E1 H1 z( V" Z& ], s; r7 d};1 m3 t- O2 N% s6 D2 y |
5 P. g/ u) J) }( @4 Y; N2 }5 t. \& Q
static struct platform_device da850_evm_tl_leds_device = {+ m0 }1 L/ R7 ?8 K* P/ ?1 l
.name = "leds-gpio",
% n; k' a- ?% m- h .id = 1,. E! Q# l0 X* L4 Y+ H+ m" y
.dev = {
/ l( x1 w9 H, O) r .platform_data = &da850_evm_tl_leds_pdata,
) O% h# [+ o: ~5 v: @3 } .release = led_dev_release,) T) g5 S& C( x. S/ Z
}+ k3 [! f! i/ ~$ d; J7 I
};
8 S1 }+ l! L9 O/ r2 h# z5 o, q2 R( {& U
static int __init led_platform_init(void)
" {# J% K' [5 \5 ]3 b{
+ N% d$ q j/ ] int ret;) E$ V0 [( ]1 t4 k' A. T0 n b
#if 0( L& z# u, \$ M% \( p" O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, M7 W" q, |3 G6 q. l6 F# q
if (ret)% Q1 H6 W6 {8 x. Y5 Q* }
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 C) O$ V: q7 P$ u6 O( Q) O9 ]8 I "%d\n", ret);
$ x: p6 c$ Z7 _( X. Z#endif8 @$ Z( M9 S4 w/ I
ret = platform_device_register(&da850_evm_tl_leds_device);
! L( @% A3 l9 K0 [6 ]/ Q3 @ if (ret)3 g2 o9 H) D4 b7 h D* L
pr_warning("Could not register som GPIO expander LEDS");
& L8 p1 l4 d3 o" s& P D else( v% ^% g- f" n& G0 E
printk(KERN_INFO "LED register sucessful!\n");# Q0 A9 d) g; Z! _
2 {) E! k" Y6 C5 Q, g return ret;4 v% v& V5 P1 p- i4 F
}# `3 \8 {' U8 X q# J2 R- f
; k- p: G2 X% q5 x. }% Sstatic void __exit led_platform_exit(void)4 R; J. G/ ~7 C' A- Y9 x5 }8 F
{1 W; B- P- L: O: h2 V ? @% e2 f
platform_device_unregister(&da850_evm_tl_leds_device);* j. w& m0 D7 g9 T8 O
* w$ \3 L, ]# K5 E$ c1 Z
printk(KERN_INFO "LED unregister!\n");; Q6 s/ n% v+ O. ~7 h
}
. }. e( |8 p x# f! ^+ |8 E2 D& j9 D4 t; {: a$ b {# @6 Y, }: q v
module_init(led_platform_init);
8 t# X1 f0 }3 a, Bmodule_exit(led_platform_exit);* H# i1 i: A+ O8 F9 d$ {
7 K) _8 P$ p( P
MODULE_DESCRIPTION("Led platform driver");4 o( u8 ?' B% E1 N Z0 t3 m, V
MODULE_AUTHOR("Tronlong");% b6 |/ D1 `" @+ i% P+ h
MODULE_LICENSE("GPL");
8 o# w. [0 _6 A! X X* K9 ^# V& S) i# F T3 |5 K$ t
|
|