|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 q) S& D8 v& |! U! Z/ Z& ]4 @
#include <linux/init.h>
" A4 p3 }3 H$ l3 C3 e0 ^% O' \#include <linux/module.h># _: I. P1 U5 `
#include <linux/kernel.h>, i0 O: L1 r; r1 f c
#include <linux/types.h>
8 t$ ~. H" k% F- d#include <linux/gpio.h>
" \" z% j1 x* d! t! s) y+ t#include <linux/leds.h>0 u) H0 p7 K9 u7 f# w2 m/ Z
#include <linux/platform_device.h>6 w; z8 i+ @6 h
- H' D3 u: D5 n; d- H) O3 r% E' |#include <asm/mach-types.h>
6 z2 _. ]) S" X" W9 j* J, }#include <asm/mach/arch.h>
6 n7 K- R) y; _- S#include <mach/da8xx.h>
6 W3 n3 A1 e5 y3 u! {: d/ ~$ h, C7 k#include <mach/mux.h>
" R+ a& ]- I, j+ F1 V2 E; k4 m! J3 p o0 J8 K/ h, w
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& E% v/ T- e* _: I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ q0 m% E) p/ @8 E# K% V) \2 R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ k* ]) A5 m( }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 ] L2 i2 W# K) S7 C* L+ |: a* Q
5 ?0 K6 N" ~% d
/* assign the tl som board LED-GPIOs*/
) T- u* B, H# A& sstatic const short da850_evm_tl_user_led_pins[] = {# P* h7 R4 _- {$ ]
/* These pins are definition at <mach/mux.h> file */
6 u5 b$ p6 Q, c/ C$ Z( ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ [) X! z w- k
-17 G" q+ }! V4 L( _! ?6 [
};9 \8 h" z% w% z- [: X" `
2 y' L/ d @# X) j' ~
static struct gpio_led da850_evm_tl_leds[] = {, ^, `/ R& e" ?; @8 y% x. b# X
{- i# [4 s. K9 p9 X) G0 ]0 Y8 r- C% @
.active_low = 0,) c6 S5 \/ I9 `8 D( {# g
.gpio = DA850_USER_LED0,- a1 c- \ o V" G) a
.name = "user_led0",, c' ]; l; e6 e, b
.default_trigger = "default-on",+ o( T* `4 ]" y) w! ~, O0 p2 }
}," D- l5 c) Y* j; F
{# P: V+ c( { c H" b$ I! m
.active_low = 0,
3 b$ G$ Z- y: A$ m .gpio = DA850_USER_LED1,
1 O: F0 } u- o) v1 v7 u .name = "user_led1",
* @0 G. ?- R( j, i .default_trigger = "default-on",( I# z* B1 F, o- d3 i, W
},
2 e3 W7 N& K! F$ c G6 N {3 N, _" p: [" |, H4 b8 X
.active_low = 0,. y! J o0 Y! `1 E4 x4 d" B. |
.gpio = DA850_USER_LED2,
* {8 W! h; g9 R .name = "user_led2",
6 _5 a0 m& {: Z6 H; j5 w .default_trigger = "default-on",
5 K- k1 Y9 W9 k) M },
$ `' o3 k" L7 h" ^ {
9 C! a) }9 h& Z: m) l: S .active_low = 0,7 h3 f3 Q/ `1 r
.gpio = DA850_USER_LED3,2 d3 _) N5 `5 W" W- G
.name = "user_led3",5 o) D6 B% }" @( u2 |# I- h
.default_trigger = "default-on",
1 V8 _! a0 j M( a/ s },
3 D( t' U4 d0 k/ r# w( F" F};# X$ O! G- @/ d& |" ^) C2 N }
4 j* X/ o( o9 A5 \7 ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; {3 I2 m2 @$ E: T# j8 d
.leds = da850_evm_tl_leds,
; B$ g# x- E; v8 Q; N .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, y1 Q b. A2 i7 I
};
4 }. J! F; ?% C! o, Y
) N1 R! H# ?, L/ V- bstatic void led_dev_release(struct device *dev)" s/ ^# |1 W- q
{
8 }0 F5 A9 T5 w# U, C# n4 s};3 r; c m: A) J2 l2 x/ [% i3 s
+ Y( A0 y0 T( G! Sstatic struct platform_device da850_evm_tl_leds_device = {
O4 M$ u' S3 J. `$ g: K .name = "leds-gpio",
N& Z2 F! I# N; c$ u3 m+ V .id = 1,9 ~* w" ^6 U4 p' @- j" d( C( p
.dev = {
+ J( a/ Y- D) H0 o! H+ I5 } .platform_data = &da850_evm_tl_leds_pdata,
4 z) E2 I* r5 d .release = led_dev_release,
# l5 L( x" C; e1 |- T }
" H- k: N8 f- Y' K/ m: c};
/ ~) `/ R3 `, s, y u: @( w0 I$ q, w O* r
static int __init led_platform_init(void)- q! m( z& M8 |3 F' W9 T
{
- U' W5 w/ }9 w5 U" [; x3 U int ret;3 I- A) n, L8 }& u, A* n
#if 0
% `2 B& T) N) |+ s9 s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 O1 h% ~; h: k' m: N) @ if (ret)& ]3 b: [+ C7 B% V. x8 e1 k! E
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 I# f# Q, y! ~6 S, k9 z
"%d\n", ret);
; q9 M, R5 s$ t#endif
" C7 Q- k# H" M ret = platform_device_register(&da850_evm_tl_leds_device);
8 }( T9 G" Y, e+ R3 J! N if (ret), y( r- Z8 v4 L7 S5 R, N* g
pr_warning("Could not register som GPIO expander LEDS"); D5 ~# L0 U; |6 }8 l
else i/ o3 c# f' n. u7 \
printk(KERN_INFO "LED register sucessful!\n");/ O! X9 N# i* a5 m3 i- t7 b
/ { f3 H" c# @2 E7 E+ e* r
return ret;1 v n2 c6 G8 P8 V! D
}
6 }. S# y( S, Z# G; H9 [0 E5 C
. s$ o/ C/ p" C- J1 c4 ]1 zstatic void __exit led_platform_exit(void)6 h, M# j+ e& a) [" k4 b8 `0 k* V& O
{* |" J" W G j
platform_device_unregister(&da850_evm_tl_leds_device);8 ?9 k6 Z* y. Z! p. Z- {
, V3 `- D* G' |/ M% X9 E1 G' q) |
printk(KERN_INFO "LED unregister!\n");4 O# @+ D! L" p) \3 \8 N- k9 J8 x
}
# V% l& h3 ^1 G8 _& ?6 [6 s& f3 m0 S5 @5 f
module_init(led_platform_init);6 V- }: k% s) x* {
module_exit(led_platform_exit);8 U$ H% O% K, x, z. _5 S
% m2 H* m0 q9 k& l& l+ N
MODULE_DESCRIPTION("Led platform driver");
1 s; y3 }9 i. S2 J1 x: CMODULE_AUTHOR("Tronlong");
- W, K4 Y5 Q: l& E' e$ s" uMODULE_LICENSE("GPL");
7 w# x3 j- `7 g: W+ X; j+ Q7 ], h: d+ m( Q X' U5 M) k
|
|