|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( {/ h" R5 z# a! v3 r7 I, Y9 O z/ }#include <linux/init.h>: r7 h/ s4 V7 `3 Q
#include <linux/module.h>6 b M9 a D% j9 {% O: M4 P0 ~& C4 \
#include <linux/kernel.h>
- z J0 U0 X* Q/ d# E! v#include <linux/types.h>
* Z$ Y. ^1 n( R+ [# B$ f#include <linux/gpio.h>
+ A9 A3 V" d; B. G* `#include <linux/leds.h>1 _# d" j/ H: r. w7 v7 s' Y
#include <linux/platform_device.h>! h( y9 k8 M; f) Z0 v' n8 {
9 B" l' P9 z5 N& h- k; }- x% M& M#include <asm/mach-types.h>
8 q0 L7 @. D$ l- B/ k% ^1 c( l* M#include <asm/mach/arch.h>
0 W4 ^/ w1 }( a+ }5 g \#include <mach/da8xx.h>& q2 M: v; Y, U4 R- K$ k
#include <mach/mux.h>3 {& \5 Q! K7 B8 V3 Q
* r9 n7 y2 ?+ {* b( D2 `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 F" @, y5 A$ e% w4 Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 ^# q8 C" \! H#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' m# m9 p3 e7 H, N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 J7 P' U2 k% ]4 Z% k
8 X7 C9 w1 F8 D. a$ `, b1 N/* assign the tl som board LED-GPIOs*/
* c7 {" n" c% s% D- Tstatic const short da850_evm_tl_user_led_pins[] = {9 U( W# k8 @+ A6 ?& Z
/* These pins are definition at <mach/mux.h> file */
" _& X$ V. e, s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- Y% x! }1 n1 h6 l D0 {. ]1 F$ { -1
2 ~, m+ X* U o# _, s};
. Y* e0 K- Y% I. D7 T3 m0 E0 M0 \9 A. W
static struct gpio_led da850_evm_tl_leds[] = {
; N$ R/ K: Q( \ Q. r2 ?# ], w$ Q {: l: B0 j: G. [2 ]
.active_low = 0,
" q8 u- Y9 T& H .gpio = DA850_USER_LED0,! P6 a; s* m$ @0 `( u( M7 _5 ]3 N
.name = "user_led0",
0 `6 E, [+ e. B& N# m .default_trigger = "default-on",, w8 d& j6 ~' ]# _; y
},0 H+ _* u* r9 |/ Y$ F
{
2 ]4 N" k7 h- u) v0 }: w .active_low = 0,' q5 i% V+ \2 b" _# f. O' e: t
.gpio = DA850_USER_LED1,# F+ t& ~0 u( M! C" B% z
.name = "user_led1",
0 t' f# ~, c+ ~' J .default_trigger = "default-on",
& N. M, e* s0 R8 d6 m },
) t# A5 ?& j* X& Y+ E8 H) k {
5 S% f( y( X# n3 K. o .active_low = 0,
' O$ l8 u, K% \, l( b+ ~7 }; } .gpio = DA850_USER_LED2,) U1 n9 P W# v' A8 r8 }
.name = "user_led2",
6 z+ n% Z8 N! ?# C+ i( X .default_trigger = "default-on",
: P; i( r5 r' l },
% \ H. t/ Z* }( D, } I+ H {
. P% W% h% I, g6 a .active_low = 0,4 w2 i: K+ L" k1 e% _$ `4 n
.gpio = DA850_USER_LED3,
5 {% H( w$ b O) \ .name = "user_led3",% f0 {2 n9 l! ^) ?3 b. Z: x+ ^
.default_trigger = "default-on"," W0 L/ v8 P2 f2 D# R! m: C
},
: ^" M- L$ `! q l* b8 V+ A, n};
- M3 R( R$ o% d7 Q4 V5 P
& I. E& H; `8 K* nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' E) e( k7 N$ C. v .leds = da850_evm_tl_leds,
. Q. @, R( r% I4 ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& q- y! W V* c o' T
};# U: w. e* H4 H" ]( A. j6 N
3 h$ B/ G2 x& R2 e# \( Q' }static void led_dev_release(struct device *dev)! d6 G6 v) i, k) C; P8 W' k) n" P
{
0 h7 J5 v3 h# v+ a' H3 i};" I6 x$ G# V5 P) Y( A Z
/ y- ^' _7 t! u) t. @
static struct platform_device da850_evm_tl_leds_device = {
: w7 a) }* g+ M, [- C .name = "leds-gpio",3 i# e: d& O8 j, }3 q4 b5 U4 @9 c
.id = 1,; i" U9 y/ T3 e" k! T
.dev = {
( E6 n! u! v' c% y% ^8 g .platform_data = &da850_evm_tl_leds_pdata,: g' \) E1 ]$ A( U7 H% C
.release = led_dev_release,
7 x& C3 V# C& x" `( l6 f( f. @( B }
3 ^5 v' [& r, [7 G1 ^3 s. s};0 J7 E/ P4 _' x6 T
9 U! r3 [! [ P( n% Xstatic int __init led_platform_init(void)! G) Y4 j1 _2 x
{
0 ]$ g9 L; r9 Z3 w int ret;
! R5 g: ~. f. ~% U, \#if 0
5 W, u: V" Y8 F) q" {3 W4 }, Y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); [/ r* N& }9 B) G
if (ret); G7 m6 h, W, e$ r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ n; ]5 _6 ~- U+ O0 V; r. ^1 C0 J "%d\n", ret);
' R* B+ `% D* i#endif
! `6 k6 n+ v# Y, w, n5 j# P& L: P# w ret = platform_device_register(&da850_evm_tl_leds_device);
" i6 e G0 L* ?9 v# f if (ret)4 j4 S% l% M3 h, H, I
pr_warning("Could not register som GPIO expander LEDS");
0 e8 W- ?# d& A; ?: h else% `" _- \5 Q3 r! Q+ K
printk(KERN_INFO "LED register sucessful!\n");
3 l- U( h2 b& {* |' t1 ~% r6 }$ M$ f# \4 p. \# j
return ret;
2 }) `4 ^2 j+ B# Z+ o, l- C}
* R& j/ j$ ^( [ ~1 d8 e% V( @8 s* H* @ ^# z* n
static void __exit led_platform_exit(void)( {) x0 w6 z5 x' W) [. M# m
{
' Q7 l: p# J3 Y! p( M$ k" |4 B platform_device_unregister(&da850_evm_tl_leds_device);
; J$ v* h' [& n* F2 f X6 T6 n( a7 @! e! ]
printk(KERN_INFO "LED unregister!\n");
2 U# m( m3 D$ M}2 Z9 [* q- d1 h* E/ W% ~
; ^+ V$ H: d8 F+ I" {1 Nmodule_init(led_platform_init);
; x* v$ }4 f; u% r5 x( [module_exit(led_platform_exit);
9 ?; b* O5 h$ v& A% |0 s
; }" [7 T' R# ?% o! f# bMODULE_DESCRIPTION("Led platform driver");
1 E" [% t; \0 h! H" c+ CMODULE_AUTHOR("Tronlong");) Y6 u" m) y+ D
MODULE_LICENSE("GPL");
8 D! s1 E" d7 A# d* }3 H# j7 N6 Z. b( N4 z
|
|