|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 @1 b* I( b: A2 g0 g7 f
#include <linux/init.h>
: J+ E6 z4 y2 A3 J' ]# r' b& X( c+ r#include <linux/module.h>6 Q; w+ }6 W; z" a5 ]
#include <linux/kernel.h>
& C& z% X1 d# y# A! r/ s" D#include <linux/types.h>' C' d# w; _3 J
#include <linux/gpio.h>
9 S) Z9 l4 o% g#include <linux/leds.h>
|" E+ n- P& Z* r" Q#include <linux/platform_device.h>
+ U6 M2 e* v* S: s# X5 F; T& ?, u* M( c: K3 w1 c+ |* H
#include <asm/mach-types.h>
$ c+ D6 B4 d5 L. G( G: B) e* a#include <asm/mach/arch.h>
5 a M+ N4 K! m. r& N#include <mach/da8xx.h>0 Y" g. n/ o0 g
#include <mach/mux.h>
4 B: C7 `7 @/ h# e6 n0 m/ I) c: Y1 K5 T. F& g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ x- R( f2 K9 _/ D0 N$ x. P( X) S#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 d. {4 H F' X6 A* A. V* L
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 K Q6 }7 O7 Y: k
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 }. z0 E& l& }2 T Q' f* a1 X6 V' s% E3 _0 \& o' n% u
/* assign the tl som board LED-GPIOs*/& W* s& E+ p& v* g. }
static const short da850_evm_tl_user_led_pins[] = {
- P& t0 N+ y$ l /* These pins are definition at <mach/mux.h> file */
2 G% _' o# k7 b4 s9 Z v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," g' l; U( h# l% e: U4 E
-1
+ k8 y {9 |/ H/ m4 _/ I};2 U$ k7 J3 j0 W6 J/ Q5 H
! v3 B6 V$ I& w4 \4 `4 P1 Y& Sstatic struct gpio_led da850_evm_tl_leds[] = {
5 U* n9 g6 a' q6 s* b {# ]$ h, h! o, C5 G" T
.active_low = 0, P) c% u+ N5 V0 b* C$ }' G6 X' l
.gpio = DA850_USER_LED0,
) T( R% K& D$ T( G; z$ e0 j .name = "user_led0",- r. k5 @. V$ P% X X! a- ?; F
.default_trigger = "default-on",# G9 X! K1 }. W
},) b* ?. Q4 |1 L* y: \- A) ?3 h- e
{
! M* Y& P4 {' d& D) f5 A( z .active_low = 0,
i$ `6 I8 C- F .gpio = DA850_USER_LED1,
8 m# c) I* A+ L- l9 v .name = "user_led1",
6 \- P& i" }" E/ ^2 H5 g .default_trigger = "default-on",
) G5 V% B& B! f/ v1 l },: d5 R9 M5 M$ A' c# `
{
' y8 v2 }; ~, o4 v& _ .active_low = 0,
3 F" ?) i/ N6 Q' N4 | .gpio = DA850_USER_LED2,( k/ `* e z8 K; }$ `
.name = "user_led2",- v2 _% g2 V/ [8 l I
.default_trigger = "default-on",, G5 {# j$ W$ m1 ^& }
},& D- A' n X3 K! W% H" Z6 B! y
{
4 m4 F) h! ?) R* p* P .active_low = 0,2 n- P4 G6 X" ?; O+ T* Q' X! f
.gpio = DA850_USER_LED3,
2 K6 ]# p3 e% f" o; q! G( Z .name = "user_led3",
" i. h {2 m$ H |" @* L .default_trigger = "default-on",
+ M+ O" M! S# ~+ F },8 Q4 W3 ^2 M0 r. R/ _8 u
};
" a5 M4 E) P& }/ W/ ^! @+ u
3 B; @/ ?2 e* R6 Y' S. Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 d1 }+ \ ^; h6 i .leds = da850_evm_tl_leds,& J& @0 v5 P; n- [
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' [/ S' d4 b% C" j8 I. R
};
/ M6 S+ m! c) u4 ~2 t: n! M5 k2 \. P% Z9 h: k; P' O
static void led_dev_release(struct device *dev)
+ y. }9 l+ U H7 ?8 X# K3 e8 s. q, s! Q{5 ]" \( X A f1 w. s* i
};
$ n$ Q" m; \' m* u- A2 _1 S+ ^( D- C0 L* d5 f7 N9 f4 s7 |! Q
static struct platform_device da850_evm_tl_leds_device = {
: ~1 N$ i' x8 D! F& j5 c2 Z b/ a .name = "leds-gpio",5 f4 Y; x1 v# u! {; [
.id = 1,
3 g/ V" [8 K7 q C9 I/ ^+ R6 A1 C .dev = {
0 }) w" a* V$ ^; r/ O4 c! G" O! T, W .platform_data = &da850_evm_tl_leds_pdata,
% w9 r% M# K- Y- ?7 Z" r8 Z .release = led_dev_release,- A, P; T9 N0 E( t8 a3 @
}
4 N- K: V8 e# W$ @5 K# i& M6 m};6 D& I" Y' e' W- v
% ^" L4 X* U% a R9 Bstatic int __init led_platform_init(void)# N7 c$ O$ Q' B& Z6 h$ X9 y
{7 g7 r) \# P$ I9 _: V
int ret;
$ l+ o) p& m4 K#if 00 v7 o% {( J; l& G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; {) B. m$ ] a/ t/ [ if (ret) y5 r% S% h! S! v8 q; D
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% l( l! w& w8 @& D) @1 F* G
"%d\n", ret);
: m/ x& n7 g! f( w- T d/ ^! b#endif2 T( B( H) U- r+ S( ^; S
ret = platform_device_register(&da850_evm_tl_leds_device);
" |0 w( U- Y: I( G if (ret)7 i7 e% G# \1 `# j
pr_warning("Could not register som GPIO expander LEDS");' c! j* X& I& H5 |2 ~
else5 k+ V W9 u9 c# s% ~1 H
printk(KERN_INFO "LED register sucessful!\n");' {$ {. W/ j3 l
1 c; g/ Z2 S% \3 j4 ]+ i
return ret;
) X( ?+ ~- X1 P( z7 `}
: X' J. V& s) A+ m6 v( _) ^- J' V/ s- I( [% b/ p6 V8 h! ]
static void __exit led_platform_exit(void)3 V @- z8 [- p8 e
{8 E- h& Q7 x" J3 p; E% m
platform_device_unregister(&da850_evm_tl_leds_device);
* y& L) i1 _9 r. b: Z8 }; A4 @& q F# m
/ D* Q' q0 }2 v2 L! X$ ~ printk(KERN_INFO "LED unregister!\n");4 z$ q# o, A" V6 r" r
}
# f/ L3 j, U# w4 Q% H9 Y8 t( X1 p4 ?5 c( g1 a8 I
module_init(led_platform_init);
: a; w1 O l7 A7 V6 mmodule_exit(led_platform_exit);
9 z# G% i8 T' n* ?/ I
7 Z1 u( c7 `! N' p1 IMODULE_DESCRIPTION("Led platform driver");3 Z& ]& x) U# \/ l3 U
MODULE_AUTHOR("Tronlong");
1 J* M: T: [$ V& W: f# hMODULE_LICENSE("GPL");
$ T2 s* c; U0 `5 R% n. c" o7 q: m) |- u7 b8 T
|
|