|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! [$ R" n* |: Z) I$ g- q. I0 Y7 n; l0 Q
#include <linux/init.h>
; l/ R k% @; E% @! u5 R* _#include <linux/module.h>
5 x$ s4 @' h' u3 f#include <linux/kernel.h>
& L1 }- ]+ r0 R9 l- h# `2 m#include <linux/types.h>
' Y# I( {. S6 P: V; b#include <linux/gpio.h>
/ `4 [+ u$ L* P. G) R' @4 V2 r#include <linux/leds.h>
. j1 I; ^) ~5 @& s5 \) _4 D#include <linux/platform_device.h>
- _; z' Y5 J7 H8 B! K* A+ F- s* B' Z- F0 n! w8 B1 q
#include <asm/mach-types.h>
1 D* D5 [7 ^: g& Z! ?4 N#include <asm/mach/arch.h>. _$ z4 P8 L+ ]- H5 ?' O1 E: J
#include <mach/da8xx.h>0 h& |3 L3 V8 S* H. j( U
#include <mach/mux.h>
- G5 {$ q1 e2 t
R5 w% E! U* b2 r: M Q$ S2 k#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ @( y4 _* o- [, x1 k' X/ Y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 o- o" b) v+ f9 e0 }; y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 W* k7 t$ G8 {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% [# C2 D3 ^5 W5 `( w! d# B! U
2 X. f9 f- p! h X
/* assign the tl som board LED-GPIOs*/
[% n) V6 N& K+ ~% H8 L* I* O) nstatic const short da850_evm_tl_user_led_pins[] = {0 G; O o) D f) {
/* These pins are definition at <mach/mux.h> file */( P: i. ?6 P7 M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( y' o7 y3 u9 }6 X# O$ r, }3 ]" V -1' V" f* T; h* x; p3 H
};% J! H' `4 Y9 Q4 f# W3 G
; B) @+ d9 \. {: [! x4 F1 ?$ zstatic struct gpio_led da850_evm_tl_leds[] = {
, q3 u3 g1 I( I8 g' X {; j! @' P6 w$ ~" F5 S/ M
.active_low = 0,5 [1 R% E6 ], R
.gpio = DA850_USER_LED0,
( m: Q$ B$ D' u: V; r5 I- |5 Y .name = "user_led0",
$ `7 ^+ T6 v9 I" D .default_trigger = "default-on",
1 |- z3 H# F; I4 |. Z& r7 {0 f ? },
$ M9 P. t7 Z t {% {) Y' r4 ]- _7 t
.active_low = 0,2 Z' \# O' D# X$ d" m4 {' ]
.gpio = DA850_USER_LED1,
5 ~+ l+ K$ W4 s( Z; g* Z3 ] .name = "user_led1",
- m. [; i# w" u. u6 G .default_trigger = "default-on",
6 \5 F x7 g' n0 ]$ x },1 h" y3 R+ ], K- v$ c2 K
{
9 @" f& ^' A- x1 X! s .active_low = 0,3 ^, ]0 r+ ]7 ^ @. ]- U/ Y. v% B* s
.gpio = DA850_USER_LED2,
( u# I8 U0 O: z' e .name = "user_led2",
! E9 ~. D/ H6 N4 l+ ]3 O .default_trigger = "default-on",) I o' n- F- Z% Z! ]* I
},1 A& x& o" S2 M% ], h9 u3 l+ Q# D
{
# w6 A) E* P6 t& l# ` .active_low = 0,; u/ B5 L, A6 |+ _" N( U+ X
.gpio = DA850_USER_LED3,
: I4 e9 m9 c) J' ~ .name = "user_led3",6 a! i. U8 `2 y, @% I
.default_trigger = "default-on",3 o% ^2 X8 y3 U: ^; u+ _" n
},
' D' E/ q/ J5 I/ ]" c' u g* c};
& ?0 G) P2 m2 o# ?- f% g% `- p7 q
2 e0 E" _3 y" d- b; x& H. O/ t5 t# r# ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 P y+ ?0 S& ]( t5 I+ S( g4 d .leds = da850_evm_tl_leds,) @4 w4 L/ X. o8 {7 ~: d
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," T5 ^0 \4 `3 m/ }5 s( D1 w) _
};) \/ K5 p! F5 w2 V- P" C3 `0 s! l
/ Z' @) [4 t& ?2 q5 e r
static void led_dev_release(struct device *dev)# Q7 N" @- w8 o" e8 [
{: G: t/ s5 u" i" ~
};
% m: T' h' S& Z4 ~+ y& h$ a r5 C$ d9 k
static struct platform_device da850_evm_tl_leds_device = {
; Z5 c* W3 o8 a$ N .name = "leds-gpio",* ~9 N" o. [( x4 a( a8 ~" ~! n
.id = 1,4 x; I7 F% m% a9 u1 \. ?' z4 R. A
.dev = {4 ?$ o1 `1 K* r8 j7 T Z
.platform_data = &da850_evm_tl_leds_pdata,
. d0 P/ S1 p. P3 N1 h- Y" ` p .release = led_dev_release,! Z( J5 @) U( l
}
n9 ] J: g9 Q8 {};! m9 z. \$ B, K: ]6 S1 @
% r. d9 S% L9 G2 h2 M1 M! q3 k
static int __init led_platform_init(void): n7 x* |7 C2 n, f& i9 R: Q
{
: z( x0 C$ s3 P$ G; S int ret;
& `6 x4 k1 ^% I0 D/ o#if 0
% }7 G; @/ ^7 n* k8 W* d! m2 k5 k) U ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) o: M3 i$ ]* Y0 o: T- \ if (ret)
0 Z" E# `3 p6 ]' x7 a% e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ m4 T8 K$ f; q# R0 \ "%d\n", ret);
" B! L5 g2 o8 K H#endif U# K" W% Z& `$ p& P1 N# b, M( m
ret = platform_device_register(&da850_evm_tl_leds_device);
( h- Z! l9 K+ }2 H: ^+ ] if (ret). ]0 y6 z6 ~ \
pr_warning("Could not register som GPIO expander LEDS");7 D1 N. X: e% ^, l0 b% ~: s
else3 n; }- ~5 ^/ \ k$ G, G
printk(KERN_INFO "LED register sucessful!\n");
! T0 \. I$ R8 \2 B7 E# O6 j/ H" I2 N8 Y) D
return ret;0 _9 N; C6 _( ~2 N9 L& D3 y* W! A
}
; }" s/ @, ]7 l! W4 y& w# A7 A8 s" i& _; u7 `
static void __exit led_platform_exit(void)! t0 |6 c' V' R! S! z* j. Z
{
$ M V" v9 H2 M+ j3 R5 _ platform_device_unregister(&da850_evm_tl_leds_device);6 b0 V. f: z0 z; ^! [
& Q6 P1 w5 ~0 |, h
printk(KERN_INFO "LED unregister!\n");( A1 p( q1 w0 }' h; O
}
+ M3 w( F- K* W5 Z
" r& j" C, H1 x4 ~3 jmodule_init(led_platform_init);
5 U; i& R- R/ ]% ?5 t% {module_exit(led_platform_exit);
+ R1 m8 k! K/ j6 @3 Z4 u
( Z: @4 @0 l5 ~- wMODULE_DESCRIPTION("Led platform driver");- B4 S$ O/ w) O/ I0 N, J3 p
MODULE_AUTHOR("Tronlong");
4 ?/ ~+ p1 o% JMODULE_LICENSE("GPL");) J$ g ?, D3 F! K. I. I$ N+ Q/ R1 p
% u3 S: M% S8 o8 n# K* E7 a |
|