|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 K w2 `" |, s
#include <linux/init.h>
! M2 h! H! F! Z1 o [#include <linux/module.h>
. l1 U" B; X c5 n5 E2 F _# o#include <linux/kernel.h>4 N1 R/ d) h* f! \; e$ u' @
#include <linux/types.h>
/ o1 h- e) Q2 B) ~, _7 C#include <linux/gpio.h>
' a* Z4 r/ B# B" ]' R5 K#include <linux/leds.h>
2 k$ Y% R7 [5 V: A$ x( B- \0 d+ o! z, K#include <linux/platform_device.h>
" _; c, i }' q% H! ]- v. o0 `, P9 x, o
#include <asm/mach-types.h>
. W: R/ y9 g, W; }#include <asm/mach/arch.h>
8 C. E/ a6 n! b+ Y#include <mach/da8xx.h>/ j% h2 B( @7 D" Z
#include <mach/mux.h>' n7 m8 w( a% g9 L- w
3 d) _3 I7 c+ a7 x#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), f y% K8 b( @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 I& b! f% @: @* D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# x- a* L; g2 B. k5 a0 t% ~#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 G+ P2 J: Z3 @3 j
6 L% @% j; `, I/* assign the tl som board LED-GPIOs*/
6 M+ l" R6 |2 @' fstatic const short da850_evm_tl_user_led_pins[] = {' L. h7 w1 I. q9 W) a- S6 O
/* These pins are definition at <mach/mux.h> file */( D8 v# l7 [% x& I
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 A0 a0 a) |7 k; G, M -1
* u7 D! f4 P& M};; W! r% o* A! ^, h3 {0 k) \
B5 R8 p R2 R- B) ]6 _9 _
static struct gpio_led da850_evm_tl_leds[] = {3 M6 ?& d7 ~7 X
{
; S n6 { S# \' h1 [ .active_low = 0,3 z; t" j2 D4 t
.gpio = DA850_USER_LED0,
, P& L; a7 S! r. ^9 W .name = "user_led0",
: t3 n- L1 U& S; H .default_trigger = "default-on",
* I4 e8 k" U1 ?7 {6 W },
% ?/ m) m& @% K \; t {' `/ r0 Y, ~7 f3 w' `# }! I4 u
.active_low = 0,9 J1 `# D \; s
.gpio = DA850_USER_LED1,
% n; J7 p1 R4 f7 h$ m# a% V2 } .name = "user_led1",
8 P. f) i1 k( w" q7 C$ y' F- S3 Q .default_trigger = "default-on",
: b( J8 K' r7 A. Q },
1 o3 I5 v3 `# ]- I$ S1 }1 ^: w" ~ {# C% W. F- w+ w- p! u
.active_low = 0,# i9 J$ q I. D* T8 G- F$ C
.gpio = DA850_USER_LED2, ]( `6 E7 P! ~& ]+ a( t- M
.name = "user_led2",: c. Z3 \. }$ R5 @
.default_trigger = "default-on",1 m6 ~8 e4 n- {
},
( x5 `7 m) F0 d, { {0 c' J% k( T) t, ^- M' G
.active_low = 0,
% o4 Z9 A3 x5 x( i* C; z ] .gpio = DA850_USER_LED3,0 V- n9 L7 e( p7 V; @
.name = "user_led3",: N- E* J: W c' }0 h, P
.default_trigger = "default-on",0 Z3 i" j( F6 L4 k
},* L( |" q! f4 I- _! `2 U
};
/ Z ~: H/ Q3 j( a
- `* Y' q+ G, ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 }" O1 v, F* y .leds = da850_evm_tl_leds,* p! j% u) w- D; b
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" ]; t8 @' M0 V$ I};+ S9 S1 V$ ]3 R' P) n# |/ `
( }; c3 |" D- ]& F* w4 M
static void led_dev_release(struct device *dev)+ n$ O( d8 m# m# @
{- ?1 ^- g! k i5 A% _* L
};
4 z: A) k8 U% z1 H2 R2 Q4 B' r
! L Y- D- z" Wstatic struct platform_device da850_evm_tl_leds_device = {7 W* r5 b* ]! t# m; [
.name = "leds-gpio"," o. w& k# w5 a# t
.id = 1,; g# X9 X' {- Q# T4 M- ^
.dev = {1 t1 `0 i {! W$ N
.platform_data = &da850_evm_tl_leds_pdata,
. W. {# `- z+ ^: ^1 b( C( U .release = led_dev_release,
7 L( g* x" y% A: b }# Q* W8 o- a5 s* X
};
2 S2 ?! d- Y% }* {. g+ m+ }9 [ i0 y% g
static int __init led_platform_init(void)* }( V! U' r) Y6 x& W" a) b2 ?
{
9 F+ `( s/ E5 o int ret;
* v, v1 m* t# J7 Y9 J4 Y% A5 S2 u#if 0" `" i0 u @3 u# q' k; \
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) y, `$ W* S- h2 U& u, B$ c; E6 b
if (ret)+ [1 S$ K. f) E0 Z. T- f
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", \9 ~9 G7 O+ N
"%d\n", ret);
! s* E# o! K1 k#endif
) q+ ~7 V, C+ i/ z" r) x ret = platform_device_register(&da850_evm_tl_leds_device);- _+ @- i% H" t- B* Z
if (ret)
# j# E: E$ u2 }3 |' a9 K9 Q5 Q pr_warning("Could not register som GPIO expander LEDS");5 ~" s3 J! ~* d( a
else% O+ Q+ B# q" o, v. M
printk(KERN_INFO "LED register sucessful!\n");: `' B) {$ o2 O
+ {5 J, s0 j# q/ i* j
return ret;
9 H- V! I, a5 U6 ~5 |8 i/ _' A}
) \/ A, _/ _* R5 }& T, g u8 K! t/ E
$ Q; i+ @# D$ W3 a" w; Nstatic void __exit led_platform_exit(void)
0 L) p( X" W) ]9 |7 o{+ u" a. s# L2 i( m
platform_device_unregister(&da850_evm_tl_leds_device);- d1 O0 I( u- f1 n8 [
6 i' T% g5 P/ k printk(KERN_INFO "LED unregister!\n");! `2 M/ U+ H% x8 F7 M1 c
}
1 T0 e% A( z* g l* ^! w; D, [2 h% ~9 W
module_init(led_platform_init);
M4 z, V' V8 ?! E6 U- c4 Zmodule_exit(led_platform_exit);& ?% V) X$ u$ y* H+ P" D
k: e# d9 u. l- |
MODULE_DESCRIPTION("Led platform driver");
8 _+ {( x* T* PMODULE_AUTHOR("Tronlong");
- m% Z: S4 p7 r$ e) n7 hMODULE_LICENSE("GPL");
4 S7 y! |6 H. D3 R/ d8 s* `- [8 [; r, U( n f
|
|