|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 Z4 \3 W/ [+ ]#include <linux/init.h># R! x1 \- \: [' i) G
#include <linux/module.h>
/ C& F8 r( F( w3 }#include <linux/kernel.h>8 A& u7 T9 C5 A0 Z
#include <linux/types.h>5 T3 A. I' E% H' G: B! K$ B
#include <linux/gpio.h>
8 U8 y! A3 q1 R7 y- T9 v1 A# M#include <linux/leds.h>
1 P/ e- n8 U5 b% n n8 H#include <linux/platform_device.h>
' w) u2 j8 W* v9 e, `* L
4 T4 }: {! m( i8 J) s! q#include <asm/mach-types.h>
0 S5 n: r4 I6 ^+ m! P( m' g- ?#include <asm/mach/arch.h>9 y% i# M) D% v; R! C4 ^# O
#include <mach/da8xx.h>
+ C3 T' Y7 g$ m#include <mach/mux.h>9 e. g* M) ?8 z# w
4 M; f! [/ s) l# |( X3 w- W' ~
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* Z: X6 I8 u" N; g$ c& F3 I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ H* ~" t, D/ I, U$ a& C2 ~, _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 M. ^6 p8 S2 q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. R0 D# i9 _" p2 p
! I9 ]& v+ ?1 u/* assign the tl som board LED-GPIOs*/
& ?7 \4 R% @9 }$ d# \+ \5 a. ]# {4 Astatic const short da850_evm_tl_user_led_pins[] = {
: {3 J' M/ s2 C. k+ i7 V( g! w /* These pins are definition at <mach/mux.h> file */% l# [- e4 P0 g& l i
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% v$ w& W; j9 G/ t -1
/ C* x5 I. I' M# t" D. Z};
: {# v7 t5 e1 c$ o% e
$ w/ I5 m ~' b5 N& @- Lstatic struct gpio_led da850_evm_tl_leds[] = {
, {6 ~3 u: D" d9 x {8 O8 j" G8 ?4 g6 v, C* w
.active_low = 0,
( Q) V- [1 l2 |! ]; h! ^: w .gpio = DA850_USER_LED0,5 ?. b! z# N$ u
.name = "user_led0",
9 K- t: p; Z2 R- E: k .default_trigger = "default-on",( A: Z' ~3 D; k# t5 e/ ^& H/ D% n
},
+ Y0 e A2 t9 W- V7 q {8 C$ `( ~: ]3 l- G
.active_low = 0,8 E2 q1 G+ y% ?2 z- \. ]
.gpio = DA850_USER_LED1,, p) ~) Q0 k! I
.name = "user_led1",% X k2 M/ n- s- Z
.default_trigger = "default-on",
- K) F$ y- i" W# ~4 E ]+ E% k3 T3 [) z },
, Z, p M# r& m" ^- f6 ] {! G2 i A& r3 |: ~. X8 H( s5 h
.active_low = 0,9 K6 t. a5 \; y& E2 J% ?1 P+ z" U* Q
.gpio = DA850_USER_LED2,
, z" f* n/ Q9 }9 Z0 P- O6 r+ g .name = "user_led2",
! U- y& ^0 @5 S$ h9 r" G7 y .default_trigger = "default-on",# x i; C0 N5 h0 o+ @# t9 V
},, K( O% s$ H8 l7 d- k5 E" c
{1 n, m1 { ^6 m* G, N/ X
.active_low = 0,7 M) S5 P5 {1 s% p
.gpio = DA850_USER_LED3,, U; v& h) O* ^8 p( t, x! }% `6 x
.name = "user_led3",# ~0 d- S" @/ ~6 Z7 l
.default_trigger = "default-on",
5 P; ]4 \% L/ ~ },
% I1 ?. D$ h6 c+ c. t};
, F6 H7 h+ i' X: Y1 `+ R. Q+ x
+ h5 _: l& v$ j G. @7 o3 lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ l$ V8 W+ }" t9 J
.leds = da850_evm_tl_leds,! N* a8 C: e9 j1 i4 l" H* j2 `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; Q f) {$ `, Q* B' @};) _, F$ J' I1 ~1 N. L4 K7 Z: p7 L
: S6 u# h, {, e
static void led_dev_release(struct device *dev)
" @9 N" E0 v+ K# e& v7 g1 N' ]" \{8 a r* u6 t9 [2 p$ V! f: C; B- R& \5 E
};1 Q( e" B0 }* K Q& H! M' m
7 D0 C1 F4 Y9 x. [5 \% m- istatic struct platform_device da850_evm_tl_leds_device = {
5 W! J) {7 u$ W, q: v: a .name = "leds-gpio",
% M1 l3 q' M) P$ _7 Q& a .id = 1,
6 U B- b* K1 u+ u .dev = {- Y/ C+ g$ M9 n
.platform_data = &da850_evm_tl_leds_pdata,
' Q, B0 P' c% g) E7 K+ E8 M .release = led_dev_release,# \7 l7 u! m. W. J! k6 G$ I0 F
}
# F8 h" [6 I. D: m' m};1 f' u# I7 L( P+ s
+ E1 W1 a8 y% H0 @" b9 b0 W
static int __init led_platform_init(void)
2 ~% Y3 G. o" T3 h* C" ?{8 g" |( P# w2 t, L- D
int ret;
% v# W. S* ]$ l; s$ |: P5 ]#if 0
, k8 u' w' p9 C0 h( M- X. k ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; o9 ~5 W! M, m4 S
if (ret)
5 G7 n! f; C5 |! w4 I0 P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 W7 z5 c" g& G- q
"%d\n", ret);7 L" O1 P0 r7 c* \* g
#endif3 ~8 n7 s3 D4 `: y3 U
ret = platform_device_register(&da850_evm_tl_leds_device);$ \. G' O8 W. H7 a7 e
if (ret)9 L: [( l0 y5 M* p$ r. v; V5 ]6 V
pr_warning("Could not register som GPIO expander LEDS");1 A8 x# M7 {* v# w! n) }( k2 V
else7 @) e" P5 v- I% b2 a) a
printk(KERN_INFO "LED register sucessful!\n");# a4 `- j, T4 b; C d6 f
% K( ]) B$ m. X3 z. I3 F" u
return ret;' l; N) p, x. Z) U: B N+ J g1 Q. {
}8 I* |$ W0 \. b t1 R8 O
* J1 N: P9 w8 x9 { q
static void __exit led_platform_exit(void), \3 V2 Q9 ]5 j+ ~6 ]- N$ [; ]
{! @+ o. n7 t2 [3 K; I) A
platform_device_unregister(&da850_evm_tl_leds_device);, t( u- k( y" L
3 P) b- |% d! a0 {0 q% \5 d
printk(KERN_INFO "LED unregister!\n");! B, m+ A7 p! ~0 M! W) y" d
}
; v0 q" s* S. g/ \( c8 U# M* j% @3 F8 }- I2 _& f* n1 i. k
module_init(led_platform_init);& n% P" C* X E3 p4 D" t$ S$ d
module_exit(led_platform_exit);) l# F) N% O7 E, Q) q) r0 K y
& \; k+ n; L/ i8 J( L: x1 NMODULE_DESCRIPTION("Led platform driver");. Q" Q$ K6 R; P8 K. Q
MODULE_AUTHOR("Tronlong");9 m5 |4 w( ^* b; S8 @& L0 t
MODULE_LICENSE("GPL");2 E& I3 A! I" g H. a/ d X# C
& F) Q, {' a4 F+ |) Z7 {% \
|
|