|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 s& b( F4 P3 r
#include <linux/init.h>! b1 |4 X6 t1 T8 j
#include <linux/module.h>
% w# T' B* H6 M! V( p#include <linux/kernel.h>" K; @7 s* g0 a% r) [" w/ t6 o) x+ ]( _
#include <linux/types.h>* p+ ~! d5 T8 }9 y, a j- X* Q$ Y
#include <linux/gpio.h>
t' Q0 D4 w# h; X# G$ \, u, h9 i#include <linux/leds.h>
5 j& [. F. L3 f#include <linux/platform_device.h>1 f! {/ M Y8 D0 v" H
2 y* f$ H5 G! C6 G0 T1 W4 d. M
#include <asm/mach-types.h>
: S5 S8 k+ g$ V, s! e9 W) N#include <asm/mach/arch.h>) R9 z0 ?/ F: {; I; r
#include <mach/da8xx.h>( n) c8 _2 z- w" ^
#include <mach/mux.h>" g6 v+ G: P& r
$ j1 y) X7 T* F( h; S7 D3 @
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 b; Y5 p8 S, q+ x1 [2 E' j
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 h0 U% z3 i2 ^3 x6 b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& C9 U) V# O6 n$ ^' h8 Q. `" y8 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ ?- y9 }4 k; F' [) Q; r1 g. K3 Q* W" ]
. e/ \8 J4 H" r# `! A$ v
/* assign the tl som board LED-GPIOs*/
8 W; K5 i7 D5 C) E7 X7 |: i$ n Gstatic const short da850_evm_tl_user_led_pins[] = {
7 A) m5 Z& P1 C% w; A' u8 d/ ^3 n /* These pins are definition at <mach/mux.h> file */
; |; w- U- B$ \0 C, o: } DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, j" d: ^6 _+ Q* i1 Y3 v6 w/ B
-1
; N- J e8 v* h$ _0 s};
6 ~% h) w' F; \" [, Q6 |3 X( T. k" {( f. f5 j/ ~
static struct gpio_led da850_evm_tl_leds[] = {0 N0 K! f* P$ i5 a4 F
{
, t9 q6 U; h* H6 o- _! T* w .active_low = 0, r( e o( ^/ H4 J3 G% u& b" b! w
.gpio = DA850_USER_LED0,
+ {+ D, l) ~+ ?& j4 D1 }4 [ .name = "user_led0",
# P) ^; C/ m% l2 ?, X3 E% @+ c .default_trigger = "default-on",0 _( ]8 l7 u7 g
},
* V# f+ Y) c+ h7 R" w; c7 k, t {( J: N: V- p& _4 Q5 F
.active_low = 0,) H! t& B7 z6 b1 w9 N) M8 x& G
.gpio = DA850_USER_LED1,/ X8 \. A& r+ D) T& p" A$ j, {7 `
.name = "user_led1",9 V4 A: o, F) @! j8 v3 ^
.default_trigger = "default-on",+ M9 s+ Y/ j2 p) d( |$ @4 z
},
8 j' e+ E T4 z$ r {/ C/ } t2 L7 s' V2 }
.active_low = 0,& @" F1 c) }5 J5 F$ B2 @4 _
.gpio = DA850_USER_LED2,
2 x) _* D' N' k* @ .name = "user_led2",
$ @+ Z$ F5 g- m8 d8 O& r7 C .default_trigger = "default-on",
) z/ m5 v* N( i },
! l7 p0 P) R$ n7 j {0 _' V) D8 N: B* W! ?
.active_low = 0,7 \8 D2 W n( ]1 s+ {6 X8 P
.gpio = DA850_USER_LED3,5 s+ o$ x/ [; ~: i( t
.name = "user_led3",
6 n( Z4 d3 u" z% Y. l .default_trigger = "default-on",5 a1 E. N2 |" O: g; j
},
+ U- Z1 T% P2 |$ M};( \; {( M* W ^; K
2 m, c1 h# X/ z: fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 b6 c1 D8 M$ w
.leds = da850_evm_tl_leds,
" [) N" \' S( T7 @ g8 M1 I .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) ]8 p0 R" d5 z+ X1 F
};
5 |* j: }' W& D. w+ E* {
( S* E* g/ [; Z* m5 [! Tstatic void led_dev_release(struct device *dev)
8 B# Q. Q( V& \4 g8 l1 n{
6 [' x0 r' t& @ H; T8 G};1 }& `; m- ]3 \! H/ s% M
; Q7 ~* v) I5 Ostatic struct platform_device da850_evm_tl_leds_device = {* v, y' Q' G6 s& i/ p
.name = "leds-gpio",, I9 @; u# y8 O# c/ K2 v1 ]: \. W8 h
.id = 1,
8 V+ ?% _, Z' R2 {, f .dev = {
4 c1 R; i8 T- h' K6 |& F& P2 c: O .platform_data = &da850_evm_tl_leds_pdata,
8 C8 l# ^. {% z; s+ o .release = led_dev_release,
1 z& b0 ?/ |( l, R8 ?) [0 | }. P: |, h, I7 w
};6 ?+ Q' i1 Y& K
' I- W! p- z+ A. Z7 r7 Y3 Kstatic int __init led_platform_init(void)9 V3 m+ ~* r! U' [- I; C
{
9 s1 H7 F& p6 f8 ^ c int ret;$ E' e# ^" @' E
#if 0/ S* d+ |2 h3 @$ H, `* ^/ |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 Y/ G1 B$ z: t4 M: d% t e
if (ret)# J$ z' @/ F! h
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* r/ _8 D) \$ k+ P5 z6 I
"%d\n", ret);
8 ^5 \1 ~) k& z#endif1 N" n" w) P, S. \9 X b
ret = platform_device_register(&da850_evm_tl_leds_device);
# b$ a. [ w9 | if (ret)
" W; C% I3 j+ J) y pr_warning("Could not register som GPIO expander LEDS");
$ c) G& n3 d" U+ l* n& Z else
3 d4 v2 \3 b1 |* S printk(KERN_INFO "LED register sucessful!\n");
( \" ?9 N7 ^, w$ o9 {$ G0 ? k( w( ?$ R
return ret;
# L" A8 m b" o% s3 @4 O: A}! W# v7 j: f9 K# h: R0 W; u/ I
: V M, m N; h1 M, bstatic void __exit led_platform_exit(void)
( ^" A/ C% v! ~7 y4 B/ \; F! C& P6 I{+ K) t6 \* B5 s
platform_device_unregister(&da850_evm_tl_leds_device);% E1 I( Z: d" X/ Q- {' l" u3 v" ~
: n8 t1 T3 T A8 w3 Z6 m
printk(KERN_INFO "LED unregister!\n");: s6 r' ]' |4 ~
}1 v2 ?- c9 @' H ^; k6 r8 ^
- q2 ]1 N3 S+ L3 J* l8 s& P: imodule_init(led_platform_init);
1 ]" S- G3 B( L! U1 Ymodule_exit(led_platform_exit);
7 ?. y# @1 i4 B: G4 a
; M, V5 b8 b) {- z1 {, dMODULE_DESCRIPTION("Led platform driver");# J+ i& r% a7 V% H. D# k0 O
MODULE_AUTHOR("Tronlong");' d, d7 l7 D- h7 Q7 R% C# K
MODULE_LICENSE("GPL");0 h: E& O! R! T/ [
0 V! S$ {# A, H8 I1 ` h, I
|
|