|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) s) V/ J* c, h" H6 K
#include <linux/init.h>
2 n& L- f$ f% Z" y9 {3 K* W#include <linux/module.h>& _" H- W# m- ^' m- S+ w
#include <linux/kernel.h>8 z. o* ?* G0 }! Z5 {
#include <linux/types.h>7 D, i. c2 @- F* z
#include <linux/gpio.h>
! p' l% g# P; b7 h#include <linux/leds.h>8 W6 ?5 C6 Y q( I# W; i* S4 a" V
#include <linux/platform_device.h>
/ J6 Q4 t. Z1 h C1 b2 X `) V
, A& [4 I& Z4 v( C#include <asm/mach-types.h>; h9 z; j# f, y" Y' d. o1 K# Q
#include <asm/mach/arch.h>
6 X% Y$ K( q9 W1 k' t0 B9 o5 d1 O) Y#include <mach/da8xx.h>
: P( C# k, q& C1 y7 z#include <mach/mux.h>
, ?! b: H( R& M6 ]- {- H' Y' ^8 W5 d9 b1 e( x
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% E# d" }. T, N; [3 ^
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. D* R: H- F* f# \6 q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% g; G/ W3 ^! d: f* z* U" y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( d' \1 f4 M2 C- ]* F2 F# y
3 W! M$ u( P& ]- o* }
/* assign the tl som board LED-GPIOs*/* E# ~1 q- L; w: | {' @( l
static const short da850_evm_tl_user_led_pins[] = {
( H2 S/ C5 {( e" K- X. R0 x. I /* These pins are definition at <mach/mux.h> file */ k3 r/ j) q' f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% O# d9 Y8 @! M# } -1' A T S4 w: r3 ]' e% l3 C8 }3 i* b
};, ^, Z. t; @6 l; O) P
% t- [ F8 _8 `static struct gpio_led da850_evm_tl_leds[] = {
; b. {1 S& O; Z2 q2 T* p {1 Q% q+ j$ b1 Y6 u P
.active_low = 0,8 z; \7 ~9 Q- i* U: k
.gpio = DA850_USER_LED0,' v* @# p5 N2 [$ i @* E; t
.name = "user_led0",: m+ ~8 [# i$ m; W) w' Q8 Z3 U# K# ]
.default_trigger = "default-on",) O$ a7 y& V6 n) E+ n9 w
},
* N# I9 h- i2 b; b n$ U' J4 S {
+ S4 {; [0 ?7 H2 r .active_low = 0,
2 Y3 y$ g$ S( t$ K8 s1 E- h .gpio = DA850_USER_LED1,
' b* a4 z8 _) q; d .name = "user_led1",
. f# Q$ S/ y1 {, O: G# s) F .default_trigger = "default-on",6 S! _: M9 d5 ?1 f" m- o6 k! W- ]8 y
},
: ?& L o. M1 g. t {+ F1 p {
! [) x1 a8 U1 P .active_low = 0," X' n" `4 E; S
.gpio = DA850_USER_LED2,/ g( W. n: I! ~* p# a Y# Y
.name = "user_led2",! e' A6 u3 m1 i/ U
.default_trigger = "default-on",
1 G& o! C9 ]# z },
" z/ N& A+ ~. R+ s u0 T9 Z0 _ {' S& h/ p/ F% _
.active_low = 0,7 F: n7 ], ^* y- W- J3 _" s& N2 U
.gpio = DA850_USER_LED3,
# ] D3 Y; [ Y: ^ .name = "user_led3",
; ~$ H: w2 b8 _' y# f .default_trigger = "default-on",
( R( ^4 M; C: W& n4 X },9 ]& T) E; A. x" c, W9 O1 |6 r) c
};
9 E% l. G$ @1 K# H9 ?+ r& D
0 s$ ~; ]/ K6 ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, o( g% B, C& K* L; o
.leds = da850_evm_tl_leds,3 k' m' F( `1 Y5 @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. v5 h7 N$ [1 S; _( K};
1 f+ U x3 x4 V- E u: c3 _* \5 q) O! }6 h$ n
static void led_dev_release(struct device *dev)
4 A6 b8 S7 {6 {8 q5 Q% ]4 m: E6 V{& t. Q( S$ u6 H3 I
};5 d8 B+ e- C' c( x( X* d" }
5 A) J7 O' J$ T* E0 \: e6 {
static struct platform_device da850_evm_tl_leds_device = {4 R% v: t. r" x; t5 L
.name = "leds-gpio",8 U6 `% v" N3 s5 W! Y$ U4 A7 g
.id = 1,
" M, R+ ^; n' H& H, K1 }% z .dev = {
4 n& q: {$ O- \! g .platform_data = &da850_evm_tl_leds_pdata,' j* n8 F v* t7 F8 Y
.release = led_dev_release,
8 y8 L- p/ \. d8 |3 e' d, \# G5 m* i }: a8 ^& m$ R# l4 e# V
};
/ h, \# U% D" b7 S% n7 e: R+ V
6 x. h6 _1 R. k9 w& Sstatic int __init led_platform_init(void)
* V3 a: P9 P4 Q: d{
* U3 x1 |9 ?4 O6 O% _ int ret;
' G- D3 X- a8 U: Z, {. H#if 0
3 ]: G0 K" E3 Q& J1 P) s) c$ u ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ A: ]9 v; E1 N9 N V; n2 i
if (ret)2 }8 z+ u: h9 U( c" F% i, l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( y- `4 _- r1 ~/ [! A "%d\n", ret);$ U, ^" N0 s. w; L& M0 L; F- j
#endif
% X; T# v: I9 R2 x3 I u m ret = platform_device_register(&da850_evm_tl_leds_device);
4 ~8 q6 z8 r H if (ret)
7 s8 r/ U7 c! w$ Y pr_warning("Could not register som GPIO expander LEDS");4 `$ w; W1 m# q: A# |# {
else
9 D* e, y9 A7 B0 f" ^) J printk(KERN_INFO "LED register sucessful!\n");! O0 i8 W2 N: t( J
; ~4 O; ~; ]+ O1 x. W' \ d" h
return ret;
4 X, J7 u, \ I}
* s3 o* x2 ?) t3 G9 A. P+ X6 n- |( M; Y$ O# H" L
static void __exit led_platform_exit(void)5 Q% q5 J% o9 \! ^( O& M/ U8 S
{ u) a/ f' S2 F
platform_device_unregister(&da850_evm_tl_leds_device);
- B5 q5 D4 z: q k7 o1 y3 W7 b# f2 r6 z {6 \5 `4 Y" f. h4 k! P) d
printk(KERN_INFO "LED unregister!\n");1 C1 v& p2 C5 b* t' g; d: A# L
}
7 c+ L* q. p1 I, a' g: j" y* Y1 Q, \3 U2 I$ c# J U/ @' _
module_init(led_platform_init);0 I7 @ x; d+ n' h2 C1 W |
module_exit(led_platform_exit);4 s- W+ f5 p; S; I
0 d5 }% X6 t- @0 C+ g5 m
MODULE_DESCRIPTION("Led platform driver");
, W! k3 N/ J& n+ ]. y1 \1 Z. ^MODULE_AUTHOR("Tronlong");$ i; L- U9 U9 R$ r6 M
MODULE_LICENSE("GPL");' p7 f2 j2 \6 a; [* l9 h
6 p7 z7 G1 W2 O( n9 c3 A
|
|