|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 y! E# V4 G2 C6 F0 A8 s- l#include <linux/init.h>
: |$ E4 d% N& Q2 {) q4 @. a. y#include <linux/module.h>3 y/ t, q6 f! l! u3 N" i' i% B% t
#include <linux/kernel.h>
7 y* z2 M( O0 Q#include <linux/types.h>
- j6 c4 |* x! O- @#include <linux/gpio.h>) f" P( p6 v9 e
#include <linux/leds.h>3 Z; I! R! A8 _2 a+ E8 @+ W: o
#include <linux/platform_device.h>' a8 w$ e) d0 o2 T
6 } p) @6 \0 H. G7 x( s#include <asm/mach-types.h>
# P( y* H, \3 L#include <asm/mach/arch.h>8 a6 m' }3 E$ b5 t
#include <mach/da8xx.h>
1 }/ G- v5 B5 ?7 ~( J L7 a/ z#include <mach/mux.h>8 Y1 w( H( a* u. D5 j* |
5 R3 t5 O1 h( V v) O0 A* W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), }- l8 m z+ k/ ^. o
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) p6 M+ l" ], q) E6 A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ b8 m: B2 V( k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). b8 p( f% I$ t% @* ?7 G4 X8 M
5 |% [: o! Y" r6 F/ B/ x/* assign the tl som board LED-GPIOs*/0 ~ \8 [$ D" H. s! f# d( O* E2 _
static const short da850_evm_tl_user_led_pins[] = {9 E W# R7 e7 R9 I
/* These pins are definition at <mach/mux.h> file */2 c7 M) h5 ?/ e: z1 X4 E( g$ u2 J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) y& T9 v8 m4 r' Q. E# y9 O: k. t0 J
-1$ ~2 s9 n; e. _ M _" p% ^
};+ h: O/ m v0 O) S
0 o3 g- e3 U$ n' g' z
static struct gpio_led da850_evm_tl_leds[] = {8 s, z T* a' @' T: k8 g
{+ a' ?( f: W2 h8 j) _: N
.active_low = 0,' N$ d+ }3 p+ J3 o9 O5 b8 g* m
.gpio = DA850_USER_LED0,4 }+ c5 q' v% \6 R
.name = "user_led0",
9 U" I# P. [- }; D( P .default_trigger = "default-on",- \ z2 f' z% ] J
},
8 L- C) N7 t6 j1 N2 n) ^ {) o6 i+ {! i; \( P6 D# i9 k+ y
.active_low = 0,
7 s) e0 F' g$ L6 R .gpio = DA850_USER_LED1,) u* v9 g8 X3 z) g; x( t
.name = "user_led1",
7 c7 S9 g$ |! \( v2 Z! H .default_trigger = "default-on",5 K& Q. g/ `! }
},! ~% I! s, s" }4 |: m P
{$ W, ?) I. X& a4 H
.active_low = 0,2 L5 P U9 {+ f% K( K$ q0 J' u0 ]
.gpio = DA850_USER_LED2,( g0 r! k2 ^# l1 G& C+ V
.name = "user_led2",
" D8 P: O! ?! `& N8 U' n6 _ .default_trigger = "default-on",
" _ G4 o/ e! t7 Z% U! l! P; } },0 ?- m/ b7 c7 V4 S: m( J9 W |
{
4 @; N) I1 p+ q+ R- U; e. p: D .active_low = 0,
) k- H$ P! I" H- h! L* P .gpio = DA850_USER_LED3,+ Z' H+ c) {& A, h0 ]6 l$ q
.name = "user_led3",
& `, j- K7 T0 p, J% D .default_trigger = "default-on",
: x) |6 k* z! f },3 O" z- Z; q8 Z( B6 L
};
5 E" T) @0 _% R3 j" i* r+ U3 _- }9 l8 g) A5 z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ U( u, D8 v0 r: q0 w .leds = da850_evm_tl_leds,, P1 i- W& M% {0 ~4 P1 [! n" S
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
I& [7 \8 {- G};# |0 K0 p# z" V4 g7 l* q. k
6 S* K8 `3 U& p% |static void led_dev_release(struct device *dev)) ?9 f$ S! |; P- l0 |6 o
{; j {- v+ ^! _$ W$ H- x
};
. v/ {6 q% U8 x1 q" I
m1 G3 T, S) @+ M. L7 C3 X8 S. xstatic struct platform_device da850_evm_tl_leds_device = {, H. |1 x( _" V) h4 V
.name = "leds-gpio",
; [# g; ~ ?- O3 A/ E, `/ K0 B9 d6 g .id = 1,
. Y/ F1 G- q# P" i) t. Q# t) T .dev = {( `7 H. \+ | V
.platform_data = &da850_evm_tl_leds_pdata,: X K6 ]$ L* K7 z3 @2 C3 S9 ?/ j
.release = led_dev_release,& x/ G' h; s m
}
- T B) c3 K9 D! p' ~+ K, }};
9 [- C+ a: D; { q5 c' |( a6 n8 p( Y1 g" U' D: H
static int __init led_platform_init(void)
, C$ |( `% M" g' q{
& A$ p2 O4 z2 A6 p int ret;
$ p/ R+ q3 Y' t7 Y& \) q( k#if 0) F* V1 _, X+ c* n: T, G* Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 X9 M8 @8 m. N% H3 r
if (ret)
' N. K; c4 V* N pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 T l1 A1 _8 a) @$ F
"%d\n", ret);: v& {0 ~' K2 p7 M( j
#endif& i6 j# k$ S7 ^7 n7 |) j2 H5 V; b+ Z
ret = platform_device_register(&da850_evm_tl_leds_device);7 x; @1 Q/ q, t9 e# }1 S* f2 k
if (ret)
$ c% i: ?6 e7 x9 \ M pr_warning("Could not register som GPIO expander LEDS");
4 U8 t ? s, ]* g" L5 A else( X1 `9 R; ?" ?4 E' a6 t
printk(KERN_INFO "LED register sucessful!\n");
3 |) R9 W- h' r" o& q1 ^% p) y) w9 H' G
return ret;
: f( p V% X% x' Z) Y( C}, X6 S3 ?, v4 r) z7 w( @
1 f% y; ^) e! Y# V Zstatic void __exit led_platform_exit(void): y6 [- B' H6 {: Q
{# ^, r6 T0 T4 C- F: Q
platform_device_unregister(&da850_evm_tl_leds_device);
2 f, F! c/ }2 {, E+ k4 L: W6 U& [& f+ ~7 ?& j
printk(KERN_INFO "LED unregister!\n");
5 R$ m- l* _( D+ k ~" b0 P; I}
$ A. M1 s4 R% Z4 i6 w! |& W, S6 n ]# U) V3 E8 ^3 o
module_init(led_platform_init);
" h4 r8 z- K/ N+ `2 ] T; e- o( J/ Vmodule_exit(led_platform_exit);
# Z) [; b( l; {
5 j- t. l, M- ^2 VMODULE_DESCRIPTION("Led platform driver");
( e; v0 V8 f$ Y7 s1 vMODULE_AUTHOR("Tronlong");
9 x" Z( o$ ^" `9 d o" uMODULE_LICENSE("GPL");
, \ B3 g7 x9 q* G0 r" |
$ K. V8 v: X, n, g# o |
|